vendor tsgo

This commit is contained in:
2026-07-09 16:50:43 -04:00
parent c06ea2e5a4
commit 98978e4930
5804 changed files with 1556156 additions and 101 deletions

View File

@@ -0,0 +1,48 @@
package fourslash_test
import (
"testing"
"github.com/microsoft/typescript-go/internal/fourslash"
"github.com/microsoft/typescript-go/internal/testutil"
)
func TestGoToSourceDefinitionEmptyJsFile(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
// When the resolved .js file is empty (0 statements), source definition
// navigates to the SourceFile node itself.
const content = `// @moduleResolution: bundler
// @Filename: /home/src/workspaces/project/node_modules/pkg/package.json
{ "name": "pkg", "main": "./index.js", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/pkg/index.d.ts
export declare function foo(): void;
// @Filename: /home/src/workspaces/project/node_modules/pkg/index.js
// @Filename: /home/src/workspaces/project/index.ts
import { foo } from /*specifier*/"pkg";
foo();`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineGoToSourceDefinition(t, "specifier")
}
func TestGoToSourceDefaultImportNoDefaultInJs(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
// When a default import resolves to a .js file that has no default export,
// source definition falls back to the first statement of the file.
const content = `// @moduleResolution: bundler
// @Filename: /home/src/workspaces/project/node_modules/pkg/package.json
{ "name": "pkg", "main": "./index.js", "types": "./index.d.ts" }
// @Filename: /home/src/workspaces/project/node_modules/pkg/index.d.ts
export default function create(): void;
// @Filename: /home/src/workspaces/project/node_modules/pkg/index.js
/*targetEntry*/function internalCreate() { return {}; }
module.exports = { create: internalCreate };
// @Filename: /home/src/workspaces/project/index.ts
import /*importDefault*/create from "pkg";
create();`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineGoToSourceDefinition(t, "importDefault")
}