Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions .github/agents/strada-corsa-port.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Strada to Corsa Port Expert
description: A Go and TypeScript expert who can easily figure out how to port PRs from one language to another
---

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.

Instructions
- Use `curl` to fetch e.g. `https://api.github.com/repos/microsoft/typescript/pulls/59767` to view the merge commit SHA
- Then use `curl` to fetch e.g. `https://github.com/microsoft/TypeScript/commit/bd3d70058c30253209199cc9dfeb85e72330d79b.patch` to download the diff patch
- Use Playwright MCP if you have other information from github you need, since you won't have MCP access to the TypeScript repo
- Apply the edits made in that PR to this codebase, translating them from TypeScript to Go.
- 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.
- 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.
- 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.
- Check that the code builds by running npx hereby build in the terminal.
- Run tests. It is expected that tests will fail due to baseline changes.
- Run `npx hereby test` in a terminal. They should fail with messages about baseline changes.
- Tip: to run a single baseline test from the submodule, run go test ./internal/testrunner -run '^TestSubmodule/NAME_OF_TEST_FILE'
- Run npx hereby baseline-accept to adopt the baseline changes.
- Run git diff 'testdata/**/*.diff'. If your change is correct, these diff files will be reduced or completely deleted.
- Iterate until you are satisfied with your change. Commit everything, including the baseline changes in testdata, and open a PR.
15 changes: 14 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ go test -run='TestLocal/<test name>' ./internal/testrunner # For new "local

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

<critical>
YOU MUST RUN THESE COMMANDS AT THE END OF YOUR SESSION!
IF THESE COMMANDS FAIL, CI WILL FAIL, AND YOUR PR WILL BE REJECTED OUT OF HAND.
FIXING ERRORS FROM THESE COMMANDS IS YOUR HIGHEST PRIORITY.
ENSURE YOU DO THE RIGHT THINGS TO MAKE THEM PASS.
```sh
npx hereby build # Build the project
npx hereby test # Run tests
npx hereby lint # Run linters
npx hereby format # Format the code
```
</critical>

## Compiler Features, Fixes, and Tests

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.
Expand Down Expand Up @@ -96,4 +109,4 @@ The TypeScript submodule serves as the reference implementation for behavior and
# Other Instructions

- Do not add or change existing dependencies unless asked to.
- Do not remove any debug assertions or panic calls. Existing assertions are never too strict or incorrect.
2 changes: 1 addition & 1 deletion _extension/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function updateUseTsgoSetting(enable: boolean): Promise<void> {
useTsgo.globalValue !== undefined ? vscode.ConfigurationTarget.Global : undefined;
}
// Update the setting and restart the extension host (needed to change the state of the built-in TS extension)
await tsConfig.update("experimental.useTsgo", enable, target);
await tsConfig.update("experimental.useTsgo", enable, target ?? vscode.ConfigurationTarget.Global);
await restartExtHostOnChangeIfNeeded();
}

Expand Down
2 changes: 1 addition & 1 deletion _submodules/TypeScript
Submodule TypeScript updated 157 files
35 changes: 30 additions & 5 deletions internal/ast/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ func IsBindableStaticElementAccessExpression(node *Node, excludeThisKeyword bool
return IsLiteralLikeElementAccess(node) &&
((!excludeThisKeyword && node.Expression().Kind == KindThisKeyword) ||
IsEntityNameExpression(node.Expression()) ||
IsBindableStaticAccessExpression(node.Expression() /*excludeThisKeyword*/, true))
IsBindableStaticAccessExpression(node.Expression(), true /*excludeThisKeyword*/))
}

func IsLiteralLikeElementAccess(node *Node) bool {
Expand Down Expand Up @@ -2822,10 +2822,6 @@ func IsModuleExportsAccessExpression(node *Node) bool {
return false
}

func isLiteralLikeElementAccess(node *Node) bool {
return node.Kind == KindElementAccessExpression && IsStringOrNumericLiteralLike(node.AsElementAccessExpression().ArgumentExpression)
}

func IsCheckJSEnabledForFile(sourceFile *SourceFile, compilerOptions *core.CompilerOptions) bool {
if sourceFile.CheckJsDirective != nil {
return sourceFile.CheckJsDirective.Enabled
Expand Down Expand Up @@ -3865,3 +3861,32 @@ func IsJSDocNameReferenceContext(node *Node) bool {
func IsImportOrImportEqualsDeclaration(node *Node) bool {
return IsImportDeclaration(node) || IsImportEqualsDeclaration(node)
}

func IsKeyword(token Kind) bool {
return KindFirstKeyword <= token && token <= KindLastKeyword
}

func IsNonContextualKeyword(token Kind) bool {
return IsKeyword(token) && !IsContextualKeyword(token)
}

func HasModifier(node *Node, flags ModifierFlags) bool {
return node.ModifierFlags()&flags != 0
}

func IsExpandoInitializer(initializer *Node) bool {
if initializer == nil {
return false
}
if IsFunctionExpressionOrArrowFunction(initializer) {
return true
}
if IsInJSFile(initializer) {
return IsClassExpression(initializer) || (IsObjectLiteralExpression(initializer) && len(initializer.AsObjectLiteralExpression().Properties.Nodes) == 0)
}
return false
}

func GetContainingFunction(node *Node) *Node {
return FindAncestor(node.Parent, IsFunctionLike)
}
16 changes: 2 additions & 14 deletions internal/binder/binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1022,30 +1022,18 @@ func getInitializerSymbol(symbol *ast.Symbol) *ast.Symbol {
case ast.IsVariableDeclaration(declaration) &&
(declaration.Parent.Flags&ast.NodeFlagsConst != 0 || ast.IsInJSFile(declaration)):
initializer := declaration.Initializer()
if isExpandoInitializer(initializer) {
if ast.IsExpandoInitializer(initializer) {
return initializer.Symbol()
}
case ast.IsBinaryExpression(declaration) && ast.IsInJSFile(declaration):
initializer := declaration.AsBinaryExpression().Right
if isExpandoInitializer(initializer) {
if ast.IsExpandoInitializer(initializer) {
return initializer.Symbol()
}
}
return nil
}

func isExpandoInitializer(initializer *ast.Node) bool {
if initializer == nil {
return false
}
if ast.IsFunctionExpressionOrArrowFunction(initializer) {
return true
} else if ast.IsInJSFile(initializer) {
return ast.IsClassExpression(initializer) || (ast.IsObjectLiteralExpression(initializer) && len(initializer.AsObjectLiteralExpression().Properties.Nodes) == 0)
}
return false
}

func (b *Binder) bindThisPropertyAssignment(node *ast.Node) {
if !ast.IsInJSFile(node) {
return
Expand Down
13 changes: 13 additions & 0 deletions internal/binder/referenceresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type ReferenceResolver interface {
GetReferencedImportDeclaration(node *ast.IdentifierNode) *ast.Declaration
GetReferencedValueDeclaration(node *ast.IdentifierNode) *ast.Declaration
GetReferencedValueDeclarations(node *ast.IdentifierNode) []*ast.Declaration
GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string
}

type ReferenceResolverHooks struct {
Expand All @@ -21,6 +22,7 @@ type ReferenceResolverHooks struct {
GetSymbolOfDeclaration func(*ast.Declaration) *ast.Symbol
GetTypeOnlyAliasDeclaration func(symbol *ast.Symbol, include ast.SymbolFlags) *ast.Declaration
GetExportSymbolOfValueSymbolIfExported func(*ast.Symbol) *ast.Symbol
GetElementAccessExpressionName func(*ast.ElementAccessExpression) (string, bool)
}

var _ ReferenceResolver = &referenceResolver{}
Expand Down Expand Up @@ -236,3 +238,14 @@ func (r *referenceResolver) GetReferencedValueDeclarations(node *ast.IdentifierN
}
return declarations
}

func (r *referenceResolver) GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string {
if expression != nil {
if r.hooks.GetElementAccessExpressionName != nil {
if name, ok := r.hooks.GetElementAccessExpressionName(expression); ok {
return name
}
}
}
return ""
}
Loading