Skip to content

Commit 430327d

Browse files
authored
Merge pull request #9 from nathanwhit/update-changes
Sync with upstream
2 parents 60b12d7 + b3d426d commit 430327d

File tree

919 files changed

+11339
-30499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

919 files changed

+11339
-30499
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Strada to Corsa Port Expert
3+
description: A Go and TypeScript expert who can easily figure out how to port PRs from one language to another
4+
---
5+
6+
This repository is a port of `microsoft/TypeScript` from TypeScript to Go. Since the port began, the following pull request was applied to microsoft/TypeScript. An equivalent change now needs to be applied here. The user will give you a link to the PR and you will need to try to port it to this repo.
7+
8+
Instructions
9+
- Use `curl` to fetch e.g. `https://api.github.com/repos/microsoft/typescript/pulls/59767` to view the merge commit SHA
10+
- Then use `curl` to fetch e.g. `https://github.com/microsoft/TypeScript/commit/bd3d70058c30253209199cc9dfeb85e72330d79b.patch` to download the diff patch
11+
- Use Playwright MCP if you have other information from github you need, since you won't have MCP access to the TypeScript repo
12+
- Apply the edits made in that PR to this codebase, translating them from TypeScript to Go.
13+
- The change may or may not be applicable. It may have already been ported. Do not make any significant changes outside the scope of the diff. If the change cannot be applied without significant out-of-scope changes, explain why and stop working.
14+
- Tip: search for functions and identifiers from the diff to find the right location to apply edits. Some files in microsoft/TypeScript have been split into multiple.
15+
- Tip: some changes have already been ported, like changes to diagnostic message text. Tests do not need to be ported as they are imported from the submodule.
16+
- Check that the code builds by running npx hereby build in the terminal.
17+
- Run tests. It is expected that tests will fail due to baseline changes.
18+
- Run `npx hereby test` in a terminal. They should fail with messages about baseline changes.
19+
- Tip: to run a single baseline test from the submodule, run go test ./internal/testrunner -run '^TestSubmodule/NAME_OF_TEST_FILE'
20+
- Run npx hereby baseline-accept to adopt the baseline changes.
21+
- Run git diff 'testdata/**/*.diff'. If your change is correct, these diff files will be reduced or completely deleted.
22+
- Iterate until you are satisfied with your change. Commit everything, including the baseline changes in testdata, and open a PR.

.github/copilot-instructions.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ go test -run='TestLocal/<test name>' ./internal/testrunner # For new "local
2424

2525
Always make sure code is formatted, linted, and tested before sending a pull request.
2626

27+
<critical>
28+
YOU MUST RUN THESE COMMANDS AT THE END OF YOUR SESSION!
29+
IF THESE COMMANDS FAIL, CI WILL FAIL, AND YOUR PR WILL BE REJECTED OUT OF HAND.
30+
FIXING ERRORS FROM THESE COMMANDS IS YOUR HIGHEST PRIORITY.
31+
ENSURE YOU DO THE RIGHT THINGS TO MAKE THEM PASS.
32+
```sh
33+
npx hereby build # Build the project
34+
npx hereby test # Run tests
35+
npx hereby lint # Run linters
36+
npx hereby format # Format the code
37+
```
38+
</critical>
39+
2740
## Compiler Features, Fixes, and Tests
2841

2942
When fixing a bug or implementing a new feature, at least one minimal test case should always be added in advance to verify the fix.
@@ -96,4 +109,4 @@ The TypeScript submodule serves as the reference implementation for behavior and
96109
# Other Instructions
97110

98111
- Do not add or change existing dependencies unless asked to.
99-
112+
- Do not remove any debug assertions or panic calls. Existing assertions are never too strict or incorrect.

_extension/src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function updateUseTsgoSetting(enable: boolean): Promise<void> {
5050
useTsgo.globalValue !== undefined ? vscode.ConfigurationTarget.Global : undefined;
5151
}
5252
// Update the setting and restart the extension host (needed to change the state of the built-in TS extension)
53-
await tsConfig.update("experimental.useTsgo", enable, target);
53+
await tsConfig.update("experimental.useTsgo", enable, target ?? vscode.ConfigurationTarget.Global);
5454
await restartExtHostOnChangeIfNeeded();
5555
}
5656

_submodules/TypeScript

Submodule TypeScript updated 157 files

internal/ast/utilities.go

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ func IsBindableStaticElementAccessExpression(node *Node, excludeThisKeyword bool
13401340
return IsLiteralLikeElementAccess(node) &&
13411341
((!excludeThisKeyword && node.Expression().Kind == KindThisKeyword) ||
13421342
IsEntityNameExpression(node.Expression()) ||
1343-
IsBindableStaticAccessExpression(node.Expression() /*excludeThisKeyword*/, true))
1343+
IsBindableStaticAccessExpression(node.Expression(), true /*excludeThisKeyword*/))
13441344
}
13451345

13461346
func IsLiteralLikeElementAccess(node *Node) bool {
@@ -2822,10 +2822,6 @@ func IsModuleExportsAccessExpression(node *Node) bool {
28222822
return false
28232823
}
28242824

2825-
func isLiteralLikeElementAccess(node *Node) bool {
2826-
return node.Kind == KindElementAccessExpression && IsStringOrNumericLiteralLike(node.AsElementAccessExpression().ArgumentExpression)
2827-
}
2828-
28292825
func IsCheckJSEnabledForFile(sourceFile *SourceFile, compilerOptions *core.CompilerOptions) bool {
28302826
if sourceFile.CheckJsDirective != nil {
28312827
return sourceFile.CheckJsDirective.Enabled
@@ -3865,3 +3861,32 @@ func IsJSDocNameReferenceContext(node *Node) bool {
38653861
func IsImportOrImportEqualsDeclaration(node *Node) bool {
38663862
return IsImportDeclaration(node) || IsImportEqualsDeclaration(node)
38673863
}
3864+
3865+
func IsKeyword(token Kind) bool {
3866+
return KindFirstKeyword <= token && token <= KindLastKeyword
3867+
}
3868+
3869+
func IsNonContextualKeyword(token Kind) bool {
3870+
return IsKeyword(token) && !IsContextualKeyword(token)
3871+
}
3872+
3873+
func HasModifier(node *Node, flags ModifierFlags) bool {
3874+
return node.ModifierFlags()&flags != 0
3875+
}
3876+
3877+
func IsExpandoInitializer(initializer *Node) bool {
3878+
if initializer == nil {
3879+
return false
3880+
}
3881+
if IsFunctionExpressionOrArrowFunction(initializer) {
3882+
return true
3883+
}
3884+
if IsInJSFile(initializer) {
3885+
return IsClassExpression(initializer) || (IsObjectLiteralExpression(initializer) && len(initializer.AsObjectLiteralExpression().Properties.Nodes) == 0)
3886+
}
3887+
return false
3888+
}
3889+
3890+
func GetContainingFunction(node *Node) *Node {
3891+
return FindAncestor(node.Parent, IsFunctionLike)
3892+
}

internal/binder/binder.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,30 +1022,18 @@ func getInitializerSymbol(symbol *ast.Symbol) *ast.Symbol {
10221022
case ast.IsVariableDeclaration(declaration) &&
10231023
(declaration.Parent.Flags&ast.NodeFlagsConst != 0 || ast.IsInJSFile(declaration)):
10241024
initializer := declaration.Initializer()
1025-
if isExpandoInitializer(initializer) {
1025+
if ast.IsExpandoInitializer(initializer) {
10261026
return initializer.Symbol()
10271027
}
10281028
case ast.IsBinaryExpression(declaration) && ast.IsInJSFile(declaration):
10291029
initializer := declaration.AsBinaryExpression().Right
1030-
if isExpandoInitializer(initializer) {
1030+
if ast.IsExpandoInitializer(initializer) {
10311031
return initializer.Symbol()
10321032
}
10331033
}
10341034
return nil
10351035
}
10361036

1037-
func isExpandoInitializer(initializer *ast.Node) bool {
1038-
if initializer == nil {
1039-
return false
1040-
}
1041-
if ast.IsFunctionExpressionOrArrowFunction(initializer) {
1042-
return true
1043-
} else if ast.IsInJSFile(initializer) {
1044-
return ast.IsClassExpression(initializer) || (ast.IsObjectLiteralExpression(initializer) && len(initializer.AsObjectLiteralExpression().Properties.Nodes) == 0)
1045-
}
1046-
return false
1047-
}
1048-
10491037
func (b *Binder) bindThisPropertyAssignment(node *ast.Node) {
10501038
if !ast.IsInJSFile(node) {
10511039
return

internal/binder/referenceresolver.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type ReferenceResolver interface {
1111
GetReferencedImportDeclaration(node *ast.IdentifierNode) *ast.Declaration
1212
GetReferencedValueDeclaration(node *ast.IdentifierNode) *ast.Declaration
1313
GetReferencedValueDeclarations(node *ast.IdentifierNode) []*ast.Declaration
14+
GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string
1415
}
1516

1617
type ReferenceResolverHooks struct {
@@ -21,6 +22,7 @@ type ReferenceResolverHooks struct {
2122
GetSymbolOfDeclaration func(*ast.Declaration) *ast.Symbol
2223
GetTypeOnlyAliasDeclaration func(symbol *ast.Symbol, include ast.SymbolFlags) *ast.Declaration
2324
GetExportSymbolOfValueSymbolIfExported func(*ast.Symbol) *ast.Symbol
25+
GetElementAccessExpressionName func(*ast.ElementAccessExpression) (string, bool)
2426
}
2527

2628
var _ ReferenceResolver = &referenceResolver{}
@@ -236,3 +238,14 @@ func (r *referenceResolver) GetReferencedValueDeclarations(node *ast.IdentifierN
236238
}
237239
return declarations
238240
}
241+
242+
func (r *referenceResolver) GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string {
243+
if expression != nil {
244+
if r.hooks.GetElementAccessExpressionName != nil {
245+
if name, ok := r.hooks.GetElementAccessExpressionName(expression); ok {
246+
return name
247+
}
248+
}
249+
}
250+
return ""
251+
}

0 commit comments

Comments
 (0)