diff --git a/.github/ISSUE_TEMPLATE/03-vscode-editor-issue.yml b/.github/ISSUE_TEMPLATE/03-vscode-editor-issue.yml new file mode 100644 index 0000000000..ada6878520 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/03-vscode-editor-issue.yml @@ -0,0 +1,48 @@ +name: 'VS Code Editor Issue' +description: 'Issue using tsgo in VS Code' +labels: 'Domain: Editor' +assignees: [] +body: + - type: input + id: extension_version + attributes: + label: Extension Version + description: The version of the TypeScript (native preview) extension + placeholder: '0.20251016.x' + validations: + required: true + - type: input + id: vscode_version + attributes: + label: VS Code Version + description: The version of the VS Code you are using + placeholder: '1.105.x' + validations: + required: true + - type: input + id: os_version + attributes: + label: Operating system Version + description: Your operating system and version + validations: + required: true + - type: textarea + id: steps + attributes: + label: 'Steps to reproduce' + description: | + Information about how to reproduce the issue and expected behavior + value: | + 1. + 2. + 3. + validations: + required: true + - type: textarea + id: bug_info + attributes: + label: 'Issue' + description: | + Information about the bug, such as expected vs actual behavior + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/03-other.md b/.github/ISSUE_TEMPLATE/04-other.md similarity index 100% rename from .github/ISSUE_TEMPLATE/03-other.md rename to .github/ISSUE_TEMPLATE/04-other.md diff --git a/.github/ISSUE_TEMPLATE/04-copilot-pr-porting.md b/.github/ISSUE_TEMPLATE/05-copilot-pr-porting.md similarity index 100% rename from .github/ISSUE_TEMPLATE/04-copilot-pr-porting.md rename to .github/ISSUE_TEMPLATE/05-copilot-pr-porting.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9d2d707b9..b425ff8c4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go @@ -45,7 +45,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - run: npm ci @@ -105,7 +105,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: submodules: ${{ !matrix.config.no-submodules }} - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 with: node-version: 'lts/*' - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable @@ -192,7 +192,7 @@ jobs: steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go with: @@ -215,7 +215,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go @@ -229,7 +229,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: submodules: true - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 with: node-version: '>=22.16.0' - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable @@ -263,7 +263,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: submodules: true - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go @@ -299,7 +299,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: submodules: true - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 21ba9905a5..73fb120ba4 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -48,7 +48,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3.29.5 + uses: github/codeql-action/init@16140ae1a102900babc80a33c44059580f687047 # v4.30.9 with: config-file: ./.github/codeql/codeql-configuration.yml # Override language selection by uncommenting this and choosing your languages @@ -58,7 +58,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below). - name: Autobuild - uses: github/codeql-action/autobuild@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3.29.5 + uses: github/codeql-action/autobuild@16140ae1a102900babc80a33c44059580f687047 # v4.30.9 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -72,4 +72,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3.29.5 + uses: github/codeql-action/analyze@16140ae1a102900babc80a33c44059580f687047 # v4.30.9 diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index a7f408a406..61adbde600 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: submodules: true - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go with: diff --git a/.github/workflows/create-cache.yml b/.github/workflows/create-cache.yml index df7cf27b7d..c088571175 100644 --- a/.github/workflows/create-cache.yml +++ b/.github/workflows/create-cache.yml @@ -20,6 +20,8 @@ defaults: jobs: cache: + if: github.repository == 'microsoft/typescript-go' + strategy: fail-fast: false matrix: @@ -39,7 +41,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: submodules: true - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 - uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable - uses: ./.github/actions/setup-go diff --git a/.golangci.yml b/.golangci.yml index afb62f07e9..d08578a81b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,6 +22,7 @@ linters: - errname - errorlint - fatcontext + - forbidigo - gocheckcompilerdirectives - goprintffuncname - govet @@ -70,11 +71,30 @@ linters: - pkg: 'encoding/json$' desc: 'Use "github.com/go-json-experiment/json" instead.' + forbidigo: + analyze-types: true + forbid: + - pattern: '.*' + msg: tspath should likely be used instead + pkg: ^(path|path/filepath)$ + - pattern: '.*' + msg: a host implementation should likely be used instead + pkg: ^os(/|$) + - pattern: 'GOOS' + msg: a host implementation should likely be used instead + pkg: ^runtime$ + exclusions: rules: - path: internal/fourslash/tests/gen/ linters: - misspell + - path: 'internal/(repo|testutil|testrunner|vfs|pprof|execute/tsctests|bundled)|cmd/tsgo' + text: should likely be used instead + - path: '(.+)_test\.go$' + text: should likely be used instead + - path: '_tools' + text: should likely be used instead presets: - comments diff --git a/Herebyfile.mjs b/Herebyfile.mjs index 81109df321..b1b7e03b91 100644 --- a/Herebyfile.mjs +++ b/Herebyfile.mjs @@ -57,6 +57,7 @@ const { values: rawOptions } = parseArgs({ tests: { type: "string", short: "t" }, fix: { type: "boolean" }, debug: { type: "boolean" }, + dirty: { type: "boolean" }, insiders: { type: "boolean" }, @@ -325,6 +326,12 @@ function goTest(taskName) { async function runTests() { warnIfTypeScriptSubmoduleNotCloned(); + + if (!options.dirty) { + await rimraf(localBaseline); + await fs.promises.mkdir(localBaseline, { recursive: true }); + } + await $test`${gotestsum("tests")} ./... ${isCI ? ["--timeout=45m"] : []}`; } @@ -520,10 +527,13 @@ function baselineAcceptTask(localBaseline, refBaseline) { }; } +const localBaseline = "testdata/baselines/local/"; +const refBaseline = "testdata/baselines/reference/"; + export const baselineAccept = task({ name: "baseline-accept", description: "Makes the most recent test results the new baseline, overwriting the old baseline.", - run: baselineAcceptTask("testdata/baselines/local/", "testdata/baselines/reference/"), + run: baselineAcceptTask(localBaseline, refBaseline), }); /** @@ -1127,7 +1137,7 @@ export const buildNativePreviewPackages = task({ const readme = [ `# \`${npmPackageName}\``, "", - `This package provides ${nodeOs}-${nodeArch} support for [${packageJson.name}](https://www.npmjs.com/package/${packageJson.name}).`, + `This package provides ${nodeOs}-${nodeArch} support for [${mainNativePreviewPackage.npmPackageName}](https://www.npmjs.com/package/${mainNativePreviewPackage.npmPackageName}).`, ]; fs.promises.writeFile(path.join(npmDir, "README.md"), readme.join("\n") + "\n"); diff --git a/_extension/package.json b/_extension/package.json index 6fd7113d63..b218b3496a 100644 --- a/_extension/package.json +++ b/_extension/package.json @@ -85,6 +85,12 @@ "title": "Show LSP Trace", "enablement": "typescript.native-preview.serverRunning", "category": "TypeScript Native Preview" + }, + { + "command": "typescript.native-preview.reportIssue", + "title": "Report Issue", + "enablement": "typescript.native-preview.serverRunning", + "category": "TypeScript Native Preview" } ] }, diff --git a/_extension/src/commands.ts b/_extension/src/commands.ts index d60192ff8e..a2e0a58065 100644 --- a/_extension/src/commands.ts +++ b/_extension/src/commands.ts @@ -34,6 +34,12 @@ export function registerLanguageCommands(context: vscode.ExtensionContext, clien disposables.push(vscode.commands.registerCommand("typescript.native-preview.showMenu", showCommands)); + disposables.push(vscode.commands.registerCommand("typescript.native-preview.reportIssue", () => { + vscode.commands.executeCommand("workbench.action.openIssueReporter", { + extensionId: "TypeScriptTeam.native-preview", + }); + })); + return disposables; } @@ -50,7 +56,7 @@ async function updateUseTsgoSetting(enable: boolean): Promise { 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(); } @@ -74,6 +80,11 @@ async function showCommands(): Promise { description: "Show the LSP communication trace", command: "typescript.native-preview.lsp-trace.focus", }, + { + label: "$(report) Report Issue", + description: "Report an issue with TypeScript Native Preview", + command: "typescript.native-preview.reportIssue", + }, { label: "$(stop-circle) Disable TypeScript Native Preview", description: "Switch back to the built-in TypeScript extension", diff --git a/_submodules/TypeScript b/_submodules/TypeScript index 1ee9e0d9a2..050a6f8127 160000 --- a/_submodules/TypeScript +++ b/_submodules/TypeScript @@ -1 +1 @@ -Subproject commit 1ee9e0d9a24b629da3a8cae2748616af1dc8fc0c +Subproject commit 050a6f8127f54ce64c79ee992b9f0e27d0d712a2 diff --git a/cmd/tsgo/lsp.go b/cmd/tsgo/lsp.go index 35c973a3a0..0dd04c57fb 100644 --- a/cmd/tsgo/lsp.go +++ b/cmd/tsgo/lsp.go @@ -1,10 +1,14 @@ package main import ( + "context" "flag" "fmt" "os" + "os/exec" + "os/signal" "runtime" + "syscall" "github.com/microsoft/typescript-go/internal/bundled" "github.com/microsoft/typescript-go/internal/core" @@ -49,9 +53,17 @@ func runLSP(args []string) int { FS: fs, DefaultLibraryPath: defaultLibraryPath, TypingsLocation: typingsLocation, + NpmInstall: func(cwd string, args []string) ([]byte, error) { + cmd := exec.Command("npm", args...) + cmd.Dir = cwd + return cmd.Output() + }, }) - if err := s.Run(); err != nil { + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + if err := s.Run(ctx); err != nil { return 1 } return 0 diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 718bbda8b2..4c15abd4fe 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -8706,6 +8706,10 @@ func (node *TemplateHead) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewTemplateHead(node.Text, node.RawText, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } +func IsTemplateHead(node *Node) bool { + return node.Kind == KindTemplateHead +} + // TemplateMiddle type TemplateMiddle struct { @@ -8726,6 +8730,10 @@ func (node *TemplateMiddle) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewTemplateMiddle(node.Text, node.RawText, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } +func IsTemplateMiddle(node *Node) bool { + return node.Kind == KindTemplateMiddle +} + // TemplateTail type TemplateTail struct { @@ -8746,6 +8754,10 @@ func (node *TemplateTail) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewTemplateTail(node.Text, node.RawText, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } +func IsTemplateTail(node *Node) bool { + return node.Kind == KindTemplateTail +} + // TemplateLiteralTypeNode type TemplateLiteralTypeNode struct { @@ -9635,6 +9647,10 @@ func (node *JSDocTypeExpression) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewJSDocTypeExpression(node.Type), node.AsNode(), f.AsNodeFactory().hooks) } +func IsJSDocTypeExpression(node *Node) bool { + return node.Kind == KindJSDocTypeExpression +} + // JSDocNonNullableType type JSDocNonNullableType struct { @@ -10565,6 +10581,10 @@ func (node *JSDocTypeLiteral) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewJSDocTypeLiteral(node.JSDocPropertyTags, node.IsArrayType), node.AsNode(), f.AsNodeFactory().hooks) } +func IsJSDocTypeLiteral(node *Node) bool { + return node.Kind == KindJSDocTypeLiteral +} + // JSDocSignature type JSDocSignature struct { TypeNodeBase diff --git a/internal/ast/symbol.go b/internal/ast/symbol.go index 926d9bd53a..56cfb2ba1b 100644 --- a/internal/ast/symbol.go +++ b/internal/ast/symbol.go @@ -43,7 +43,6 @@ const ( InternalSymbolNameClass = InternalSymbolNamePrefix + "class" // Unnamed class expression InternalSymbolNameFunction = InternalSymbolNamePrefix + "function" // Unnamed function expression InternalSymbolNameComputed = InternalSymbolNamePrefix + "computed" // Computed property name declaration with dynamic name - InternalSymbolNameResolving = InternalSymbolNamePrefix + "resolving" // Indicator symbol used to mark partially resolved type aliases InternalSymbolNameInstantiationExpression = InternalSymbolNamePrefix + "instantiationExpression" // Instantiation expressions InternalSymbolNameImportAttributes = InternalSymbolNamePrefix + "importAttributes" InternalSymbolNameExportEquals = "export=" // Export assignment symbol diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index 4968528f9d..f491127d22 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -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 { @@ -2641,7 +2641,7 @@ func GetNodeAtPosition(file *SourceFile, position int, includeJSDoc bool) *Node } if child == nil { current.ForEachChild(func(node *Node) bool { - if nodeContainsPosition(node, position) { + if nodeContainsPosition(node, position) && node.Kind != KindJSExportAssignment && node.Kind != KindCommonJSExport { child = node return true } @@ -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 @@ -3866,6 +3862,31 @@ 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) } diff --git a/internal/astnav/tokens.go b/internal/astnav/tokens.go index a7b4750034..27ad1ebdf6 100644 --- a/internal/astnav/tokens.go +++ b/internal/astnav/tokens.go @@ -65,6 +65,10 @@ func getTokenAtPosition( // `left` tracks the lower boundary of the node/token that could be returned, // and is eventually the scanner's start position, if the scanner is used. left := 0 + // `allowReparsed` is set when we're navigating inside an AsExpression or + // SatisfiesExpression, which allows visiting their reparsed children to reach + // the actual identifier from JSDoc type assertions. + allowReparsed := false testNode := func(node *ast.Node) int { if node.Kind != ast.KindEndOfFile && node.End() == position && includePrecedingTokenAtEndPosition != nil { @@ -74,7 +78,8 @@ func getTokenAtPosition( if node.End() < position || node.Kind != ast.KindEndOfFile && node.End() == position { return -1 } - if getPosition(node, sourceFile, allowPositionInLeadingTrivia) > position { + nodePos := getPosition(node, sourceFile, allowPositionInLeadingTrivia) + if nodePos > position { return 1 } return 0 @@ -86,18 +91,29 @@ func getTokenAtPosition( visitNode := func(node *ast.Node, _ *ast.NodeVisitor) *ast.Node { // We can't abort visiting children, so once a match is found, we set `next` // and do nothing on subsequent visits. - if node != nil && node.Flags&ast.NodeFlagsReparsed == 0 && next == nil { - switch testNode(node) { - case -1: - if !ast.IsJSDocKind(node.Kind) { - // We can't move the left boundary into or beyond JSDoc, - // because we may end up returning the token after this JSDoc, - // constructing it with the scanner, and we need to include - // all its leading trivia in its position. - left = node.End() + if node != nil && next == nil { + // Skip reparsed nodes unless: + // 1. The node itself is AsExpression or SatisfiesExpression, OR + // 2. We're already inside an AsExpression or SatisfiesExpression (allowReparsed=true) + // These are special cases where reparsed nodes from JSDoc type assertions + // should still be navigable to reach identifiers. + isSpecialReparsed := node.Flags&ast.NodeFlagsReparsed != 0 && + (node.Kind == ast.KindAsExpression || node.Kind == ast.KindSatisfiesExpression) + + if node.Flags&ast.NodeFlagsReparsed == 0 || isSpecialReparsed || allowReparsed { + result := testNode(node) + switch result { + case -1: + if !ast.IsJSDocKind(node.Kind) { + // We can't move the left boundary into or beyond JSDoc, + // because we may end up returning the token after this JSDoc, + // constructing it with the scanner, and we need to include + // all its leading trivia in its position. + left = node.End() + } + case 0: + next = node } - case 0: - next = node } } return node @@ -194,6 +210,11 @@ func getTokenAtPosition( current = next left = current.Pos() next = nil + // When navigating into AsExpression or SatisfiesExpression, allow visiting + // their reparsed children to reach identifiers from JSDoc type assertions. + if current.Kind == ast.KindAsExpression || current.Kind == ast.KindSatisfiesExpression { + allowReparsed = true + } } } diff --git a/internal/astnav/tokens_test.go b/internal/astnav/tokens_test.go index b5eb7ba39f..0a0d180646 100644 --- a/internal/astnav/tokens_test.go +++ b/internal/astnav/tokens_test.go @@ -43,6 +43,52 @@ func TestGetTokenAtPosition(t *testing.T) { ) }) + t.Run("JSDoc type assertion", func(t *testing.T) { + t.Parallel() + fileText := `function foo(x) { + const s = /**@type {string}*/(x) +}` + file := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.js", + Path: "/test.js", + }, fileText, core.ScriptKindJS) + + // Position of 'x' inside the parenthesized expression (position 52) + position := 52 + + // This should not panic - it previously panicked with: + // "did not expect KindParenthesizedExpression to have KindIdentifier in its trivia" + token := astnav.GetTouchingPropertyName(file, position) + if token == nil { + t.Fatal("Expected to get a token, got nil") + } + + // The function may return either the identifier itself or the containing + // parenthesized expression, depending on how the AST is structured + if token.Kind != ast.KindIdentifier && token.Kind != ast.KindParenthesizedExpression { + t.Errorf("Expected identifier or parenthesized expression, got %s", token.Kind) + } + }) + + t.Run("JSDoc type assertion with comment", func(t *testing.T) { + t.Parallel() + // Exact code from the issue report + fileText := `function foo(x) { + const s = /**@type {string}*/(x) // Go-to-definition on x causes panic +}` + file := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.js", + Path: "/test.js", + }, fileText, core.ScriptKindJS) + + // Find position of 'x' in the type assertion + xPos := 52 // Position of 'x' in (x) + + // This should not panic + token := astnav.GetTouchingPropertyName(file, xPos) + assert.Assert(t, token != nil, "Expected to get a token") + }) + t.Run("pointer equality", func(t *testing.T) { t.Parallel() fileText := ` diff --git a/internal/binder/binder.go b/internal/binder/binder.go index e215ef7ad3..1824ffcac1 100644 --- a/internal/binder/binder.go +++ b/internal/binder/binder.go @@ -1018,30 +1018,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 diff --git a/internal/binder/referenceresolver.go b/internal/binder/referenceresolver.go index 8fbe5297e3..2e428044a7 100644 --- a/internal/binder/referenceresolver.go +++ b/internal/binder/referenceresolver.go @@ -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 { @@ -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{} @@ -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 "" +} diff --git a/internal/checker/checker.go b/internal/checker/checker.go index d2033c07d8..8c68eafb19 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -61,6 +61,7 @@ const ( TypeSystemPropertyNameResolvedBaseTypes TypeSystemPropertyNameWriteType TypeSystemPropertyNameInitializerIsUndefined + TypeSystemPropertyNameAliasTarget ) type TypeResolution struct { @@ -618,7 +619,6 @@ type Checker struct { argumentsSymbol *ast.Symbol requireSymbol *ast.Symbol unknownSymbol *ast.Symbol - resolvingSymbol *ast.Symbol unresolvedSymbols map[string]*ast.Symbol errorTypes map[string]*Type globalThisSymbol *ast.Symbol @@ -915,7 +915,6 @@ func NewChecker(program Program) *Checker { c.argumentsSymbol = c.newSymbol(ast.SymbolFlagsProperty, "arguments") c.requireSymbol = c.newSymbol(ast.SymbolFlagsProperty, "require") c.unknownSymbol = c.newSymbol(ast.SymbolFlagsProperty, "unknown") - c.resolvingSymbol = c.newSymbol(ast.SymbolFlagsNone, ast.InternalSymbolNameResolving) c.unresolvedSymbols = make(map[string]*ast.Symbol) c.errorTypes = make(map[string]*Type) c.globalThisSymbol = c.newSymbolEx(ast.SymbolFlagsModule, "globalThis", ast.CheckFlagsReadonly) @@ -1905,46 +1904,64 @@ func (c *Checker) isBlockScopedNameDeclaredBeforeUse(declaration *ast.Node, usag } func (c *Checker) isUsedInFunctionOrInstanceProperty(usage *ast.Node, declaration *ast.Node, declContainer *ast.Node) bool { - for current := usage; current != nil && current != declContainer; current = current.Parent { + return ast.FindAncestorOrQuit(usage, func(current *ast.Node) ast.FindAncestorResult { + if current == declContainer { + return ast.FindAncestorQuit + } if ast.IsFunctionLike(current) { - return ast.GetImmediatelyInvokedFunctionExpression(current) == nil + return ast.ToFindAncestorResult(ast.GetImmediatelyInvokedFunctionExpression(current) == nil) } if ast.IsClassStaticBlockDeclaration(current) { - return declaration.Pos() < usage.Pos() + return ast.ToFindAncestorResult(declaration.Pos() < usage.Pos()) } - if current.Parent != nil && ast.IsPropertyDeclaration(current.Parent) && current.Parent.Initializer() == current { - if ast.IsStatic(current.Parent) { - if ast.IsMethodDeclaration(declaration) { - return true - } - if ast.IsPropertyDeclaration(declaration) && ast.GetContainingClass(usage) == ast.GetContainingClass(declaration) { - propName := declaration.Name() - if ast.IsIdentifier(propName) || ast.IsPrivateIdentifier(propName) { - t := c.getTypeOfSymbol(c.getSymbolOfDeclaration(declaration)) - staticBlocks := core.Filter(declaration.Parent.Members(), ast.IsClassStaticBlockDeclaration) - if c.isPropertyInitializedInStaticBlocks(propName, t, staticBlocks, declaration.Parent.Pos(), current.Pos()) { - return true + + if current.Parent != nil && ast.IsPropertyDeclaration(current.Parent) { + propertyDeclaration := current.Parent + initializerOfProperty := propertyDeclaration.Initializer() == current + if initializerOfProperty { + if ast.IsStatic(current.Parent) { + if ast.IsMethodDeclaration(declaration) { + return ast.FindAncestorTrue + } + if ast.IsPropertyDeclaration(declaration) && ast.GetContainingClass(usage) == ast.GetContainingClass(declaration) { + propName := declaration.Name() + if ast.IsIdentifier(propName) || ast.IsPrivateIdentifier(propName) { + t := c.getTypeOfSymbol(c.getSymbolOfDeclaration(declaration)) + staticBlocks := core.Filter(declaration.Parent.Members(), ast.IsClassStaticBlockDeclaration) + if c.isPropertyInitializedInStaticBlocks(propName, t, staticBlocks, declaration.Parent.Pos(), current.Pos()) { + return ast.FindAncestorTrue + } } } - } - } else { - isDeclarationInstanceProperty := ast.IsPropertyDeclaration(declaration) && !ast.IsStatic(declaration) - if !isDeclarationInstanceProperty || ast.GetContainingClass(usage) != ast.GetContainingClass(declaration) { - return true + } else { + isDeclarationInstanceProperty := ast.IsPropertyDeclaration(declaration) && !ast.IsStatic(declaration) + if !isDeclarationInstanceProperty || ast.GetContainingClass(usage) != ast.GetContainingClass(declaration) { + return ast.FindAncestorTrue + } } } } - if current.Parent != nil && ast.IsDecorator(current.Parent) && current.Parent.AsDecorator().Expression == current { + + if current.Parent != nil && ast.IsDecorator(current.Parent) { decorator := current.Parent.AsDecorator() - if ast.IsParameter(decorator.Parent) { - return c.isUsedInFunctionOrInstanceProperty(decorator.Parent.Parent.Parent, declaration, declContainer) - } - if ast.IsMethodDeclaration(decorator.Parent) { - return c.isUsedInFunctionOrInstanceProperty(decorator.Parent.Parent, declaration, declContainer) + if decorator.Expression == current { + if ast.IsParameter(decorator.Parent) { + if c.isUsedInFunctionOrInstanceProperty(decorator.Parent.Parent.Parent, declaration, declContainer) { + return ast.FindAncestorTrue + } + return ast.FindAncestorQuit + } + if ast.IsMethodDeclaration(decorator.Parent) { + if c.isUsedInFunctionOrInstanceProperty(decorator.Parent.Parent, declaration, declContainer) { + return ast.FindAncestorTrue + } + return ast.FindAncestorQuit + } } } - } - return false + + return ast.FindAncestorFalse + }) != nil } func isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration *ast.Node, usage *ast.Node, declContainer *ast.Node) bool { @@ -4234,7 +4251,7 @@ func (c *Checker) checkBaseTypeAccessibility(t *Type, node *ast.Node) { signatures := c.getSignaturesOfType(t, SignatureKindConstruct) if len(signatures) != 0 { declaration := signatures[0].declaration - if declaration != nil && HasModifier(declaration, ast.ModifierFlagsPrivate) { + if declaration != nil && ast.HasModifier(declaration, ast.ModifierFlagsPrivate) { typeClassDeclaration := ast.GetClassLikeDeclarationOfSymbol(t.symbol) if !c.isNodeWithinClass(node, typeClassDeclaration) { c.error(node, diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, c.getFullyQualifiedName(t.symbol, nil)) @@ -6489,7 +6506,7 @@ func (c *Checker) checkAliasSymbol(node *ast.Node) { name := node.PropertyNameOrName().Text() c.addTypeOnlyDeclarationRelatedInfo(c.error(node, message, name), core.IfElse(isType, nil, typeOnlyAlias), name) } - if isType && node.Kind == ast.KindImportEqualsDeclaration && HasModifier(node, ast.ModifierFlagsExport) { + if isType && node.Kind == ast.KindImportEqualsDeclaration && ast.HasModifier(node, ast.ModifierFlagsExport) { c.error(node, diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_0_is_enabled, c.getIsolatedModulesLikeFlagName()) } case ast.KindExportSpecifier: @@ -6777,7 +6794,7 @@ func (c *Checker) checkUnusedClassMembers(node *ast.Node) { break // Already would have reported an error on the getter. } symbol := c.getSymbolOfDeclaration(member) - if !c.isReferenced(symbol) && (HasModifier(member, ast.ModifierFlagsPrivate) || member.Name() != nil && ast.IsPrivateIdentifier(member.Name())) && member.Flags&ast.NodeFlagsAmbient == 0 { + if !c.isReferenced(symbol) && (ast.HasModifier(member, ast.ModifierFlagsPrivate) || member.Name() != nil && ast.IsPrivateIdentifier(member.Name())) && member.Flags&ast.NodeFlagsAmbient == 0 { c.reportUnused(member, UnusedKindLocal, NewDiagnosticForNode(member.Name(), diagnostics.X_0_is_declared_but_its_value_is_never_read, c.symbolToString(symbol))) } case ast.KindConstructor: @@ -7029,7 +7046,9 @@ func (c *Checker) getQuickTypeOfExpression(node *ast.Node) *Type { if isCallChain(expr) { return c.getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) } - return c.getReturnTypeOfSingleNonGenericCallSignature(c.checkNonNullExpression(expr.Expression())) + return c.getReturnTypeOfSingleNonGenericSignature(c.checkNonNullExpression(expr.Expression()), SignatureKindCall) + case ast.IsNewExpression(expr): + return c.getReturnTypeOfSingleNonGenericSignature(c.checkNonNullExpression(expr.Expression()), SignatureKindConstruct) case ast.IsAssertionExpression(expr) && !ast.IsConstTypeReference(expr.Type()): return c.getTypeFromTypeNode(expr.Type()) case ast.IsLiteralExpression(node) || ast.IsBooleanLiteral(node): @@ -7038,8 +7057,8 @@ func (c *Checker) getQuickTypeOfExpression(node *ast.Node) *Type { return nil } -func (c *Checker) getReturnTypeOfSingleNonGenericCallSignature(funcType *Type) *Type { - signature := c.getSingleCallSignature(funcType) +func (c *Checker) getReturnTypeOfSingleNonGenericSignature(funcType *Type, kind SignatureKind) *Type { + signature := c.getSingleSignature(funcType, kind, true /*allowMembers*/) if signature != nil && len(signature.typeParameters) == 0 { return c.getReturnTypeOfSignature(signature) } @@ -7049,7 +7068,7 @@ func (c *Checker) getReturnTypeOfSingleNonGenericCallSignature(funcType *Type) * func (c *Checker) getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr *ast.Node) *Type { funcType := c.checkExpression(expr.Expression()) nonOptionalType := c.getOptionalExpressionType(funcType, expr.Expression()) - returnType := c.getReturnTypeOfSingleNonGenericCallSignature(funcType) + returnType := c.getReturnTypeOfSingleNonGenericSignature(funcType, SignatureKindCall) if returnType != nil { return c.propagateOptionalTypeMarker(returnType, expr, nonOptionalType != funcType) } @@ -8335,7 +8354,7 @@ func (c *Checker) resolveNewExpression(node *ast.Node, candidatesOutArray *[]*Si } if expressionType.symbol != nil { valueDecl := ast.GetClassLikeDeclarationOfSymbol(expressionType.symbol) - if valueDecl != nil && HasModifier(valueDecl, ast.ModifierFlagsAbstract) { + if valueDecl != nil && ast.HasModifier(valueDecl, ast.ModifierFlagsAbstract) { c.error(node, diagnostics.Cannot_create_an_instance_of_an_abstract_class) return c.resolveErrorCall(node) } @@ -9736,7 +9755,7 @@ func (c *Checker) invocationErrorRecovery(apparentType *Type, kind SignatureKind // Create a diagnostic on the originating import if possible onto which we can attach a quickfix // An import call expression cannot be rewritten into another form to correct the error - the only solution is to use `.default` at the use-site if importNode != nil && !ast.IsImportCall(importNode) { - sigs := c.getSignaturesOfType(c.getTypeOfSymbol(c.valueSymbolLinks.Get(apparentType.symbol).target), kind) + sigs := c.getSignaturesOfType(c.getTypeOfSymbol(c.exportTypeLinks.Get(apparentType.symbol).target), kind) if len(sigs) == 0 { return } @@ -11062,6 +11081,9 @@ func (c *Checker) checkPrivateIdentifierPropertyAccess(leftType *Type, right *as } func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType *Type) { + if ast.IsJSDocNameReferenceContext(propNode) { + return + } var diagnostic *ast.Diagnostic if !ast.IsPrivateIdentifier(propNode) && containingType.flags&TypeFlagsUnion != 0 && containingType.flags&TypeFlagsPrimitive == 0 { for _, subtype := range containingType.Types() { @@ -15632,29 +15654,25 @@ func (c *Checker) resolveAlias(symbol *ast.Symbol) *ast.Symbol { } links := c.aliasSymbolLinks.Get(symbol) if links.aliasTarget == nil { - links.aliasTarget = c.resolvingSymbol + if !c.pushTypeResolution(symbol, TypeSystemPropertyNameAliasTarget) { + return c.unknownSymbol + } node := c.getDeclarationOfAliasSymbol(symbol) if node == nil { panic("Unexpected nil in resolveAlias for symbol: " + c.symbolToString(symbol)) } - target := c.getTargetOfAliasDeclaration(node, false /*dontRecursivelyResolve*/) - if links.aliasTarget == c.resolvingSymbol { - if target == nil { - target = c.unknownSymbol - } - links.aliasTarget = target - } else { + links.aliasTarget = core.OrElse(c.getTargetOfAliasDeclaration(node, false /*dontRecursivelyResolve*/), c.unknownSymbol) + if !c.popTypeResolution() { c.error(node, diagnostics.Circular_definition_of_import_alias_0, c.symbolToString(symbol)) + links.aliasTarget = c.unknownSymbol } - } else if links.aliasTarget == c.resolvingSymbol { - links.aliasTarget = c.unknownSymbol } return links.aliasTarget } func (c *Checker) tryResolveAlias(symbol *ast.Symbol) *ast.Symbol { links := c.aliasSymbolLinks.Get(symbol) - if links.aliasTarget != c.resolvingSymbol { + if links.aliasTarget != nil || c.findResolutionCycleStartIndex(symbol, TypeSystemPropertyNameAliasTarget) < 0 { return c.resolveAlias(symbol) } return nil @@ -18077,6 +18095,8 @@ func (c *Checker) typeResolutionHasProperty(r *TypeResolution) bool { return c.nodeLinks.Get(r.target.(*ast.Node)).flags&NodeCheckFlagsInitializerIsUndefinedComputed != 0 case TypeSystemPropertyNameWriteType: return c.valueSymbolLinks.Get(r.target.(*ast.Symbol)).writeType != nil + case TypeSystemPropertyNameAliasTarget: + return c.aliasSymbolLinks.Get(r.target.(*ast.Symbol)).aliasTarget != nil } panic("Unhandled case in typeResolutionHasProperty") } @@ -18910,7 +18930,7 @@ func (c *Checker) getIndexInfosOfIndexSymbol(indexSymbol *ast.Symbol, siblingSym } forEachType(c.getTypeFromTypeNode(typeNode), func(keyType *Type) { if c.isValidIndexKeyType(keyType) && findIndexInfo(indexInfos, keyType) == nil { - indexInfo := c.newIndexInfo(keyType, valueType, HasModifier(declaration, ast.ModifierFlagsReadonly), declaration, nil) + indexInfo := c.newIndexInfo(keyType, valueType, ast.HasModifier(declaration, ast.ModifierFlagsReadonly), declaration, nil) indexInfos = append(indexInfos, indexInfo) } }) @@ -26821,7 +26841,7 @@ func (c *Checker) markPropertyAsReferenced(prop *ast.Symbol, nodeForCheckWriteOn if prop.Flags&ast.SymbolFlagsClassMember == 0 || prop.ValueDeclaration == nil { return } - hasPrivateModifier := HasModifier(prop.ValueDeclaration, ast.ModifierFlagsPrivate) + hasPrivateModifier := ast.HasModifier(prop.ValueDeclaration, ast.ModifierFlagsPrivate) hasPrivateIdentifier := prop.ValueDeclaration.Name() != nil && ast.IsPrivateIdentifier(prop.ValueDeclaration.Name()) if !hasPrivateModifier && !hasPrivateIdentifier { return diff --git a/internal/checker/checker_test.go b/internal/checker/checker_test.go index c5029ecbc9..c9041c6606 100644 --- a/internal/checker/checker_test.go +++ b/internal/checker/checker_test.go @@ -36,7 +36,7 @@ foo.bar;` fs = bundled.WrapFS(fs) cd := "/" - host := compiler.NewCompilerHost(cd, fs, bundled.LibPath(), nil, nil) + host := compiler.NewCompilerHost(cd, fs, bundled.LibPath(), nil, nil, nil) parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile("/tsconfig.json", &core.CompilerOptions{}, host, nil) assert.Equal(t, len(errors), 0, "Expected no errors in parsed command line") @@ -70,7 +70,7 @@ func TestCheckSrcCompiler(t *testing.T) { rootPath := tspath.CombinePaths(tspath.NormalizeSlashes(repo.TypeScriptSubmodulePath), "src", "compiler") - host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, nil) + host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, nil, nil) parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile(tspath.CombinePaths(rootPath, "tsconfig.json"), &core.CompilerOptions{}, host, nil) assert.Equal(t, len(errors), 0, "Expected no errors in parsed command line") p := compiler.NewProgram(compiler.ProgramOptions{ @@ -87,7 +87,7 @@ func BenchmarkNewChecker(b *testing.B) { rootPath := tspath.CombinePaths(tspath.NormalizeSlashes(repo.TypeScriptSubmodulePath), "src", "compiler") - host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, nil) + host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, nil, nil) parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile(tspath.CombinePaths(rootPath, "tsconfig.json"), &core.CompilerOptions{}, host, nil) assert.Equal(b, len(errors), 0, "Expected no errors in parsed command line") p := compiler.NewProgram(compiler.ProgramOptions{ diff --git a/internal/checker/emitresolver.go b/internal/checker/emitresolver.go index 1a28c3c21e..71c1a60955 100644 --- a/internal/checker/emitresolver.go +++ b/internal/checker/emitresolver.go @@ -825,6 +825,7 @@ func (r *emitResolver) getReferenceResolver() binder.ReferenceResolver { GetSymbolOfDeclaration: r.checker.getSymbolOfDeclaration, GetTypeOnlyAliasDeclaration: r.checker.getTypeOnlyAliasDeclarationEx, GetExportSymbolOfValueSymbolIfExported: r.checker.getExportSymbolOfValueSymbolIfExported, + GetElementAccessExpressionName: r.checker.tryGetElementAccessExpressionName, }) } return r.referenceResolver @@ -879,6 +880,17 @@ func (r *emitResolver) GetReferencedValueDeclarations(node *ast.IdentifierNode) return r.getReferenceResolver().GetReferencedValueDeclarations(node) } +func (r *emitResolver) GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string { + if !ast.IsParseTreeNode(expression.AsNode()) { + return "" + } + + r.checkerMu.Lock() + defer r.checkerMu.Unlock() + + return r.getReferenceResolver().GetElementAccessExpressionName(expression) +} + // TODO: the emit resolver being responsible for some amount of node construction is a very leaky abstraction, // and requires giving it access to a lot of context it's otherwise not required to have, which also further complicates the API // and likely reduces performance. There's probably some refactoring that could be done here to simplify this. diff --git a/internal/checker/nodebuilderimpl.go b/internal/checker/nodebuilderimpl.go index afdc9494d7..5ac9b95369 100644 --- a/internal/checker/nodebuilderimpl.go +++ b/internal/checker/nodebuilderimpl.go @@ -532,7 +532,7 @@ func (b *nodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFl specifier = b.getSpecifierForModuleSymbol(chain[0], core.ModuleKindESNext) attributes = b.f.NewImportAttributes( ast.KindWithKeyword, - b.f.NewNodeList([]*ast.Node{b.f.NewImportAttribute(b.f.NewStringLiteral("resolution-mode"), b.f.NewStringLiteral("import"))}), + b.f.NewNodeList([]*ast.Node{b.f.NewImportAttribute(b.newStringLiteral("resolution-mode"), b.newStringLiteral("import"))}), false, ) } @@ -561,7 +561,7 @@ func (b *nodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFl } attributes = b.f.NewImportAttributes( ast.KindWithKeyword, - b.f.NewNodeList([]*ast.Node{b.f.NewImportAttribute(b.f.NewStringLiteral("resolution-mode"), b.f.NewStringLiteral(modeStr))}), + b.f.NewNodeList([]*ast.Node{b.f.NewImportAttribute(b.newStringLiteral("resolution-mode"), b.newStringLiteral(modeStr))}), false, ) } @@ -575,7 +575,7 @@ func (b *nodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFl } } - lit := b.f.NewLiteralTypeNode(b.f.NewStringLiteral(specifier)) + lit := b.f.NewLiteralTypeNode(b.newStringLiteral(specifier)) b.ctx.approximateLength += len(specifier) + 10 // specifier + import("") if nonRootParts == nil || ast.IsEntityName(nonRootParts) { if nonRootParts != nil { @@ -692,12 +692,12 @@ func (b *nodeBuilderImpl) createAccessFromSymbolChain(chain []*ast.Symbol, index if ast.IsIndexedAccessTypeNode(lhs) { return b.f.NewIndexedAccessTypeNode( lhs, - b.f.NewLiteralTypeNode(b.f.NewStringLiteral(symbolName)), + b.f.NewLiteralTypeNode(b.newStringLiteral(symbolName)), ) } return b.f.NewIndexedAccessTypeNode( b.f.NewTypeReferenceNode(lhs, typeParameterNodes), - b.f.NewLiteralTypeNode(b.f.NewStringLiteral(symbolName)), + b.f.NewLiteralTypeNode(b.newStringLiteral(symbolName)), ) } @@ -736,7 +736,7 @@ func (b *nodeBuilderImpl) createExpressionFromSymbolChain(chain []*ast.Symbol, i } if startsWithSingleOrDoubleQuote(symbolName) && core.Some(symbol.Declarations, hasNonGlobalAugmentationExternalModuleSymbol) { - return b.f.NewStringLiteral(b.getSpecifierForModuleSymbol(symbol, core.ResolutionModeNone)) + return b.newStringLiteral(b.getSpecifierForModuleSymbol(symbol, core.ResolutionModeNone)) } if index == 0 || canUsePropertyAccess(symbolName) { @@ -757,7 +757,7 @@ func (b *nodeBuilderImpl) createExpressionFromSymbolChain(chain []*ast.Symbol, i var expression *ast.Expression if startsWithSingleOrDoubleQuote(symbolName) && symbol.Flags&ast.SymbolFlagsEnumMember == 0 { - expression = b.f.NewStringLiteral(stringutil.UnquoteString(symbolName)) + expression = b.newStringLiteral(stringutil.UnquoteString(symbolName)) } else if jsnum.FromString(symbolName).String() == symbolName { // TODO: the follwing in strada would assert if the number is negative, but no such assertion exists here // Moreover, what's even guaranteeing the name *isn't* -1 here anyway? Needs double-checking. @@ -2089,7 +2089,7 @@ func (b *nodeBuilderImpl) trackComputedName(accessExpression *ast.Node, enclosin } } -func (b *nodeBuilderImpl) createPropertyNameNodeForIdentifierOrLiteral(name string, _singleQuote bool, stringNamed bool, isMethod bool) *ast.Node { +func (b *nodeBuilderImpl) createPropertyNameNodeForIdentifierOrLiteral(name string, singleQuote bool, stringNamed bool, isMethod bool) *ast.Node { isMethodNamedNew := isMethod && name == "new" if !isMethodNamedNew && scanner.IsIdentifierText(name, core.LanguageVariantStandard) { return b.f.NewIdentifier(name) @@ -2098,7 +2098,9 @@ func (b *nodeBuilderImpl) createPropertyNameNodeForIdentifierOrLiteral(name stri return b.f.NewNumericLiteral(name) } result := b.f.NewStringLiteral(name) - // !!! TODO: set singleQuote + if singleQuote { + result.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + } return result } @@ -2119,10 +2121,8 @@ func (b *nodeBuilderImpl) isStringNamed(d *ast.Declaration) bool { } func (b *nodeBuilderImpl) isSingleQuotedStringNamed(d *ast.Declaration) bool { - return false // !!! - // TODO: actually support single-quote-style-maintenance - // name := ast.GetNameOfDeclaration(d) - // return name != nil && ast.IsStringLiteral(name) && (name.AsStringLiteral().SingleQuote || !nodeIsSynthesized(name) && startsWith(getTextOfNode(name, false /*includeTrivia*/), "'")) + name := ast.GetNameOfDeclaration(d) + return name != nil && ast.IsStringLiteral(name) && name.AsStringLiteral().TokenFlags&ast.TokenFlagsSingleQuote != 0 } func (b *nodeBuilderImpl) getPropertyNameNodeForSymbol(symbol *ast.Symbol) *ast.Node { @@ -2164,8 +2164,11 @@ func (b *nodeBuilderImpl) getPropertyNameNodeForSymbolFromNameType(symbol *ast.S name = nameType.AsLiteralType().value.(string) } if !scanner.IsIdentifierText(name, core.LanguageVariantStandard) && (stringNamed || !isNumericLiteralName(name)) { - // !!! TODO: set singleQuote - return b.f.NewStringLiteral(name) + node := b.f.NewStringLiteral(name) + if singleQuote { + node.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + } + return node } if isNumericLiteralName(name) && name[0] == '-' { return b.f.NewComputedPropertyName(b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(name[1:]))) @@ -2881,9 +2884,9 @@ func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { if ast.IsImportTypeNode(parentName) { parentName.AsImportTypeNode().IsTypeOf = true // mutably update, node is freshly manufactured anyhow - return b.f.NewIndexedAccessTypeNode(parentName, b.f.NewLiteralTypeNode(b.f.NewStringLiteral(memberName))) + return b.f.NewIndexedAccessTypeNode(parentName, b.f.NewLiteralTypeNode(b.newStringLiteral(memberName))) } else if ast.IsTypeReferenceNode(parentName) { - return b.f.NewIndexedAccessTypeNode(b.f.NewTypeQueryNode(parentName.AsTypeReferenceNode().TypeName, nil), b.f.NewLiteralTypeNode(b.f.NewStringLiteral(memberName))) + return b.f.NewIndexedAccessTypeNode(b.f.NewTypeQueryNode(parentName.AsTypeReferenceNode().TypeName, nil), b.f.NewLiteralTypeNode(b.newStringLiteral(memberName))) } else { panic("Unhandled type node kind returned from `symbolToTypeNode`.") } @@ -2892,7 +2895,7 @@ func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { } if t.flags&TypeFlagsStringLiteral != 0 { b.ctx.approximateLength += len(t.AsLiteralType().value.(string)) + 2 - lit := b.f.NewStringLiteral(t.AsLiteralType().value.(string) /*, b.flags&nodebuilder.FlagsUseSingleQuotesForStringLiteralType != 0*/) + lit := b.newStringLiteral(t.AsLiteralType().value.(string)) b.e.AddEmitFlags(lit, printer.EFNoAsciiEscaping) return b.f.NewLiteralTypeNode(lit) } @@ -3105,6 +3108,14 @@ func (b *nodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { panic("Should be unreachable.") } +func (b *nodeBuilderImpl) newStringLiteral(text string) *ast.Node { + node := b.f.NewStringLiteral(text) + if b.ctx.flags&nodebuilder.FlagsUseSingleQuotesForStringLiteralType != 0 { + node.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + } + return node +} + // Direct serialization core functions for types, type aliases, and symbols func (t *TypeAlias) ToTypeReferenceNode(b *nodeBuilderImpl) *ast.Node { diff --git a/internal/checker/utilities.go b/internal/checker/utilities.go index 3637b8d421..bd026c259c 100644 --- a/internal/checker/utilities.go +++ b/internal/checker/utilities.go @@ -76,12 +76,8 @@ func getSelectedModifierFlags(node *ast.Node, flags ast.ModifierFlags) ast.Modif return node.ModifierFlags() & flags } -func HasModifier(node *ast.Node, flags ast.ModifierFlags) bool { - return node.ModifierFlags()&flags != 0 -} - func hasReadonlyModifier(node *ast.Node) bool { - return HasModifier(node, ast.ModifierFlagsReadonly) + return ast.HasModifier(node, ast.ModifierFlagsReadonly) } func isStaticPrivateIdentifierProperty(s *ast.Symbol) bool { @@ -405,7 +401,7 @@ func declarationBelongsToPrivateAmbientMember(declaration *ast.Node) bool { } func isPrivateWithinAmbient(node *ast.Node) bool { - return (HasModifier(node, ast.ModifierFlagsPrivate) || ast.IsPrivateIdentifierClassElementDeclaration(node)) && node.Flags&ast.NodeFlagsAmbient != 0 + return (ast.HasModifier(node, ast.ModifierFlagsPrivate) || ast.IsPrivateIdentifierClassElementDeclaration(node)) && node.Flags&ast.NodeFlagsAmbient != 0 } func isTypeAssertion(node *ast.Node) bool { diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 9fbbc49057..328529e09b 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -104,7 +104,7 @@ func processAllProgramFiles( includeProcessor: &includeProcessor{}, } loader.addProjectReferenceTasks(singleThreaded) - loader.resolver = module.NewResolver(loader.projectReferenceFileMapper.host, compilerOptions, opts.TypingsLocation, opts.ProjectName) + loader.resolver = module.NewResolver(loader.projectReferenceFileMapper.host, compilerOptions, opts.TypingsLocation, opts.ProjectName, opts.Host.GetPNPResolutionConfig()) for index, rootFile := range rootFiles { loader.addRootTask(rootFile, nil, &fileIncludeReason{kind: fileIncludeKindRootFile, data: index}) } diff --git a/internal/compiler/host.go b/internal/compiler/host.go index 68f3cf620a..c25aa388b6 100644 --- a/internal/compiler/host.go +++ b/internal/compiler/host.go @@ -3,6 +3,7 @@ package compiler import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/module/pnp" "github.com/microsoft/typescript-go/internal/parser" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" @@ -17,6 +18,7 @@ type CompilerHost interface { Trace(msg string) GetSourceFile(opts ast.SourceFileParseOptions) *ast.SourceFile GetResolvedProjectReference(fileName string, path tspath.Path) *tsoptions.ParsedCommandLine + GetPNPResolutionConfig() *pnp.ResolutionConfig } var _ CompilerHost = (*compilerHost)(nil) @@ -27,6 +29,7 @@ type compilerHost struct { defaultLibraryPath string extendedConfigCache tsoptions.ExtendedConfigCache trace func(msg string) + pnpResolutionConfig *pnp.ResolutionConfig } func NewCachedFSCompilerHost( @@ -35,8 +38,9 @@ func NewCachedFSCompilerHost( defaultLibraryPath string, extendedConfigCache tsoptions.ExtendedConfigCache, trace func(msg string), + pnpResolutionConfig *pnp.ResolutionConfig, ) CompilerHost { - return NewCompilerHost(currentDirectory, cachedvfs.From(fs), defaultLibraryPath, extendedConfigCache, trace) + return NewCompilerHost(currentDirectory, cachedvfs.From(fs), defaultLibraryPath, extendedConfigCache, trace, pnpResolutionConfig) } func NewCompilerHost( @@ -45,16 +49,19 @@ func NewCompilerHost( defaultLibraryPath string, extendedConfigCache tsoptions.ExtendedConfigCache, trace func(msg string), + pnpResolutionConfig *pnp.ResolutionConfig, ) CompilerHost { if trace == nil { trace = func(msg string) {} } + return &compilerHost{ currentDirectory: currentDirectory, fs: fs, defaultLibraryPath: defaultLibraryPath, extendedConfigCache: extendedConfigCache, trace: trace, + pnpResolutionConfig: pnpResolutionConfig, } } @@ -86,3 +93,7 @@ func (h *compilerHost) GetResolvedProjectReference(fileName string, path tspath. commandLine, _ := tsoptions.GetParsedCommandLineOfConfigFilePath(fileName, path, nil, h, h.extendedConfigCache) return commandLine } + +func (h *compilerHost) GetPNPResolutionConfig() *pnp.ResolutionConfig { + return h.pnpResolutionConfig +} diff --git a/internal/compiler/pnp.go b/internal/compiler/pnp.go new file mode 100644 index 0000000000..df4db482dc --- /dev/null +++ b/internal/compiler/pnp.go @@ -0,0 +1,21 @@ +package compiler + +import ( + "github.com/microsoft/typescript-go/internal/module/pnp" + "github.com/microsoft/typescript-go/internal/vfs" +) + +func TryGetPnpResolutionConfig(path string, fs vfs.FS) *pnp.ResolutionConfig { + pnpManifest, err := pnp.FindPNPManifest(path, fs) + if err != nil { + return nil + } + + return &pnp.ResolutionConfig{ + Host: pnp.PNPResolutionHost{ + FindPNPManifest: func(_ string) (*pnp.Manifest, error) { + return pnpManifest, nil + }, + }, + } +} diff --git a/internal/compiler/program.go b/internal/compiler/program.go index b70a00197f..7238991f97 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -1056,6 +1056,12 @@ func (p *Program) getSemanticDiagnosticsForFileNotFilter(ctx context.Context, so }) } + isJS := sourceFile.ScriptKind == core.ScriptKindJS || sourceFile.ScriptKind == core.ScriptKindJSX + isCheckJS := isJS && ast.IsCheckJSEnabledForFile(sourceFile, compilerOptions) + if isCheckJS { + diags = append(diags, sourceFile.JSDocDiagnostics()...) + } + filtered, directivesByLine := p.getDiagnosticsWithPrecedingDirectives(sourceFile, diags) for _, directive := range directivesByLine { // Above we changed all used directive kinds to @ts-ignore, so any @ts-expect-error directives that diff --git a/internal/compiler/program_test.go b/internal/compiler/program_test.go index ae3a967b30..7d9a6f604b 100644 --- a/internal/compiler/program_test.go +++ b/internal/compiler/program_test.go @@ -243,7 +243,7 @@ func TestProgram(t *testing.T) { CompilerOptions: &opts, }, }, - Host: compiler.NewCompilerHost("c:/dev/src", fs, bundled.LibPath(), nil, nil), + Host: compiler.NewCompilerHost("c:/dev/src", fs, bundled.LibPath(), nil, nil, nil), }) actualFiles := []string{} @@ -280,7 +280,7 @@ func BenchmarkNewProgram(b *testing.B) { CompilerOptions: &opts, }, }, - Host: compiler.NewCompilerHost("c:/dev/src", fs, bundled.LibPath(), nil, nil), + Host: compiler.NewCompilerHost("c:/dev/src", fs, bundled.LibPath(), nil, nil, nil), } for b.Loop() { @@ -297,7 +297,7 @@ func BenchmarkNewProgram(b *testing.B) { fs := osvfs.FS() fs = bundled.WrapFS(fs) - host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, nil) + host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, nil, nil) parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile(tspath.CombinePaths(rootPath, "tsconfig.json"), nil, host, nil) assert.Equal(b, len(errors), 0, "Expected no errors in parsed command line") diff --git a/internal/core/core.go b/internal/core/core.go index f284826eda..7b7efc6a89 100644 --- a/internal/core/core.go +++ b/internal/core/core.go @@ -7,6 +7,7 @@ import ( "slices" "sort" "strings" + "sync" "unicode" "unicode/utf8" @@ -476,6 +477,8 @@ func GetSpellingSuggestion[T any](name string, candidates []T, getName func(T) s maximumLengthDifference := max(2, int(float64(len(name))*0.34)) bestDistance := math.Floor(float64(len(name))*0.4) + 1 // If the best result is worse than this, don't bother. runeName := []rune(name) + buffers := levenshteinBuffersPool.Get().(*levenshteinBuffers) + defer levenshteinBuffersPool.Put(buffers) var bestCandidate T for _, candidate := range candidates { candidateName := getName(candidate) @@ -490,7 +493,7 @@ func GetSpellingSuggestion[T any](name string, candidates []T, getName func(T) s if len(candidateName) < 3 && !strings.EqualFold(candidateName, name) { continue } - distance := levenshteinWithMax(runeName, []rune(candidateName), bestDistance-0.1) + distance := levenshteinWithMax(buffers, runeName, []rune(candidateName), bestDistance-0.1) if distance < 0 { continue } @@ -502,9 +505,25 @@ func GetSpellingSuggestion[T any](name string, candidates []T, getName func(T) s return bestCandidate } -func levenshteinWithMax(s1 []rune, s2 []rune, maxValue float64) float64 { - previous := make([]float64, len(s2)+1) - current := make([]float64, len(s2)+1) +type levenshteinBuffers struct { + previous []float64 + current []float64 +} + +var levenshteinBuffersPool = sync.Pool{ + New: func() any { + return &levenshteinBuffers{} + }, +} + +func levenshteinWithMax(buffers *levenshteinBuffers, s1 []rune, s2 []rune, maxValue float64) float64 { + bufferSize := len(s2) + 1 + buffers.previous = slices.Grow(buffers.previous[:0], bufferSize)[:bufferSize] + buffers.current = slices.Grow(buffers.current[:0], bufferSize)[:bufferSize] + + previous := buffers.previous + current := buffers.current + big := maxValue + 0.01 for i := range previous { previous[i] = float64(i) diff --git a/internal/diagnostics/diagnostics_generated.go b/internal/diagnostics/diagnostics_generated.go index 5c32430d2b..4d7899b46d 100644 --- a/internal/diagnostics/diagnostics_generated.go +++ b/internal/diagnostics/diagnostics_generated.go @@ -2326,7 +2326,7 @@ var Compiler_option_0_may_only_be_used_with_build = &Message{code: 5093, categor var Compiler_option_0_may_not_be_used_with_build = &Message{code: 5094, category: CategoryError, key: "Compiler_option_0_may_not_be_used_with_build_5094", text: "Compiler option '--{0}' may not be used with '--build'."} -var Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later = &Message{code: 5095, category: CategoryError, key: "Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later_5095", text: "Option '{0}' can only be used when 'module' is set to 'preserve' or to 'es2015' or later."} +var Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later = &Message{code: 5095, category: CategoryError, key: "Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later_5095", text: "Option '{0}' can only be used when 'module' is set to 'preserve', 'commonjs', or 'es2015' or later."} var Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set = &Message{code: 5096, category: CategoryError, key: "Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set_5096", text: "Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set."} @@ -4253,3 +4253,33 @@ var Do_not_print_diagnostics = &Message{code: 100000, category: CategoryMessage, var Run_in_single_threaded_mode = &Message{code: 100001, category: CategoryMessage, key: "Run_in_single_threaded_mode_100001", text: "Run in single threaded mode."} var Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory = &Message{code: 100002, category: CategoryMessage, key: "Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory_100002", text: "Generate pprof CPU/memory profiles to the given directory."} + +var Invalid_specifier = &Message{code: 100010, category: CategoryError, key: "Invalid_specifier_100010", text: "Invalid specifier"} + +var X_assertion_failed_Colon_should_have_a_top_level_name_key = &Message{code: 100011, category: CategoryError, key: "assertion_failed_Colon_should_have_a_top_level_name_key_100011", text: "assertion failed: should have a top-level name key"} + +var X_assertion_failed_Colon_should_have_a_top_level_range_key = &Message{code: 100012, category: CategoryError, key: "assertion_failed_Colon_should_have_a_top_level_range_key_100012", text: "assertion failed: should have a top-level range key"} + +var We_failed_to_read_the_content_of_the_manifest_Colon_0 = &Message{code: 100013, category: CategoryError, key: "We_failed_to_read_the_content_of_the_manifest_Colon_0_100013", text: "We failed to read the content of the manifest: {0}"} + +var We_failed_to_locate_the_PnP_data_payload_inside_its_manifest_file_Did_you_manually_edit_the_file = &Message{code: 100014, category: CategoryError, key: "We_failed_to_locate_the_PnP_data_payload_inside_its_manifest_file_Did_you_manually_edit_the_file_100014", text: "We failed to locate the PnP data payload inside its manifest file. Did you manually edit the file?"} + +var We_failed_to_parse_the_PnP_data_payload_as_proper_JSON_Did_you_manually_edit_the_file_Colon_0 = &Message{code: 100015, category: CategoryError, key: "We_failed_to_parse_the_PnP_data_payload_as_proper_JSON_Did_you_manually_edit_the_file_Colon_0_100015", text: "We failed to parse the PnP data payload as proper JSON; Did you manually edit the file?: {0}"} + +var We_failed_to_init_the_PnP_manifest_Colon_0 = &Message{code: 100016, category: CategoryError, key: "We_failed_to_init_the_PnP_manifest_Colon_0_100016", text: "We failed to init the PnP manifest: {0}"} + +var X_should_have_an_entry_in_the_package_registry_for_0 = &Message{code: 100017, category: CategoryError, key: "should_have_an_entry_in_the_package_registry_for_0_100017", text: "should have an entry in the package registry for {0}"} + +var X_via_0 = &Message{code: 100018, category: CategoryError, key: "via_0_100018", text: " (via \"{0}\")"} + +var Your_application_tried_to_access_0_While_this_module_is_usually_interpreted_as_a_Node_builtin_your_resolver_is_running_inside_a_non_Node_resolution_context_where_such_builtins_are_ignored_Since_0_isn_t_otherwise_declared_in_your_dependencies_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_0_1_Required_by_Colon_2 = &Message{code: 100019, category: CategoryError, key: "Your_application_tried_to_access_0_While_this_module_is_usually_interpreted_as_a_Node_builtin_your_r_100019", text: "Your application tried to access {0}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since {0} isn't otherwise declared in your dependencies, this makes the require call ambiguous and unsound.\n\nRequired package: {0}{1}\nRequired by: {2}"} + +var X_0_tried_to_access_1_While_this_module_is_usually_interpreted_as_a_Node_builtin_your_resolver_is_running_inside_a_non_Node_resolution_context_where_such_builtins_are_ignored_Since_1_isn_t_otherwise_declared_in_0_s_dependencies_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_1_2_Required_by_Colon_3 = &Message{code: 100020, category: CategoryError, key: "_0_tried_to_access_1_While_this_module_is_usually_interpreted_as_a_Node_builtin_your_resolver_is_run_100020", text: "{0} tried to access {1}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since {1} isn't otherwise declared in {0}'s dependencies, this makes the require call ambiguous and unsound.\n\nRequired package: {1}{2}\nRequired by: {3}"} + +var Your_application_tried_to_access_0_but_it_isn_t_declared_in_your_dependencies_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_0_1_Required_by_Colon_2 = &Message{code: 100021, category: CategoryError, key: "Your_application_tried_to_access_0_but_it_isn_t_declared_in_your_dependencies_this_makes_the_require_100021", text: "Your application tried to access {0}, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.\n\nRequired package: {0}{1}\nRequired by: {2}"} + +var X_0_tried_to_access_1_a_peer_dependency_but_it_isn_t_provided_by_your_application_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_1_2_Required_by_Colon_0_3_via_4 = &Message{code: 100022, category: CategoryError, key: "_0_tried_to_access_1_a_peer_dependency_but_it_isn_t_provided_by_your_application_this_makes_the_requ_100022", text: "{0} tried to access {1} (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.\n\nRequired package: {1}{2}\nRequired by: {0}@{3} (via {4})"} + +var X_0_tried_to_access_1_a_peer_dependency_but_it_isn_t_provided_by_its_ancestors_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_1_2_Required_by_Colon_0_3_via_4 = &Message{code: 100023, category: CategoryError, key: "_0_tried_to_access_1_a_peer_dependency_but_it_isn_t_provided_by_its_ancestors_this_makes_the_require_100023", text: "{0} tried to access {1} (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.\n\nRequired package: {1}{2}\nRequired by: {0}@{3} (via {4})"} + +var X_no_host_configured = &Message{code: 100024, category: CategoryError, key: "no_host_configured_100024", text: "no host configured"} diff --git a/internal/diagnostics/extraDiagnosticMessages.json b/internal/diagnostics/extraDiagnosticMessages.json index b735a67695..007266e63c 100644 --- a/internal/diagnostics/extraDiagnosticMessages.json +++ b/internal/diagnostics/extraDiagnosticMessages.json @@ -38,5 +38,65 @@ "Project '{0}' is out of date because it has errors.": { "category": "Message", "code": 6423 + }, + "Invalid specifier": { + "category": "Error", + "code": 100010 + }, + "assertion failed: should have a top-level name key": { + "category": "Error", + "code": 100011 + }, + "assertion failed: should have a top-level range key": { + "category": "Error", + "code": 100012 + }, + "We failed to read the content of the manifest: {0}": { + "category": "Error", + "code": 100013 + }, + "We failed to locate the PnP data payload inside its manifest file. Did you manually edit the file?": { + "category": "Error", + "code": 100014 + }, + "We failed to parse the PnP data payload as proper JSON; Did you manually edit the file?: {0}": { + "category": "Error", + "code": 100015 + }, + "We failed to init the PnP manifest: {0}": { + "category": "Error", + "code": 100016 + }, + "should have an entry in the package registry for {0}": { + "category": "Error", + "code": 100017 + }, + " (via \"{0}\")": { + "category": "Error", + "code": 100018 + }, + "Your application tried to access {0}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since {0} isn't otherwise declared in your dependencies, this makes the require call ambiguous and unsound.\n\nRequired package: {0}{1}\nRequired by: {2}": { + "category": "Error", + "code": 100019 + }, + "{0} tried to access {1}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since {1} isn't otherwise declared in {0}'s dependencies, this makes the require call ambiguous and unsound.\n\nRequired package: {1}{2}\nRequired by: {3}": { + "category": "Error", + "code": 100020 + }, + "Your application tried to access {0}, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.\n\nRequired package: {0}{1}\nRequired by: {2}": { + "category": "Error", + "code": 100021 + }, + "{0} tried to access {1} (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.\n\nRequired package: {1}{2}\nRequired by: {0}@{3} (via {4})": { + "category": "Error", + "code": 100022 + }, + "{0} tried to access {1} (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.\n\nRequired package: {1}{2}\nRequired by: {0}@{3} (via {4})": { + "category": "Error", + "code": 100023 + }, + "no host configured": { + "category": "Error", + "code": 100024 } } diff --git a/internal/execute/build/compilerHost.go b/internal/execute/build/compilerHost.go index f11f06b9fc..e21454f35f 100644 --- a/internal/execute/build/compilerHost.go +++ b/internal/execute/build/compilerHost.go @@ -3,6 +3,7 @@ package build import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/module/pnp" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" "github.com/microsoft/typescript-go/internal/vfs" @@ -38,3 +39,7 @@ func (h *compilerHost) GetSourceFile(opts ast.SourceFileParseOptions) *ast.Sourc func (h *compilerHost) GetResolvedProjectReference(fileName string, path tspath.Path) *tsoptions.ParsedCommandLine { return h.host.GetResolvedProjectReference(fileName, path) } + +func (h *compilerHost) GetPNPResolutionConfig() *pnp.ResolutionConfig { + return h.host.GetPNPResolutionConfig() +} diff --git a/internal/execute/build/host.go b/internal/execute/build/host.go index 91f50aa59c..c5a0b6dc05 100644 --- a/internal/execute/build/host.go +++ b/internal/execute/build/host.go @@ -8,6 +8,7 @@ import ( "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/execute/incremental" "github.com/microsoft/typescript-go/internal/execute/tsc" + "github.com/microsoft/typescript-go/internal/module/pnp" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" "github.com/microsoft/typescript-go/internal/vfs" @@ -23,8 +24,9 @@ type host struct { configTimes collections.SyncMap[tspath.Path, time.Duration] // caches that stay as long as they are needed - resolvedReferences parseCache[tspath.Path, *tsoptions.ParsedCommandLine] - mTimes *collections.SyncMap[tspath.Path, time.Time] + resolvedReferences parseCache[tspath.Path, *tsoptions.ParsedCommandLine] + mTimes *collections.SyncMap[tspath.Path, time.Time] + pnpResolutionConfig *pnp.ResolutionConfig } var ( @@ -111,3 +113,7 @@ func (h *host) storeMTimeFromOldCache(file string, oldCache *collections.SyncMap h.mTimes.Store(path, mTime) } } + +func (h *host) GetPNPResolutionConfig() *pnp.ResolutionConfig { + return h.pnpResolutionConfig +} diff --git a/internal/execute/build/orchestrator.go b/internal/execute/build/orchestrator.go index d521031780..1629079110 100644 --- a/internal/execute/build/orchestrator.go +++ b/internal/execute/build/orchestrator.go @@ -15,6 +15,7 @@ import ( "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" "github.com/microsoft/typescript-go/internal/vfs/cachedvfs" + "github.com/microsoft/typescript-go/internal/vfs/zipvfs" ) type Options struct { @@ -380,14 +381,20 @@ func NewOrchestrator(opts Options) *Orchestrator { }, tasks: &collections.SyncMap[tspath.Path, *buildTask]{}, } + pnpResolutionConfig := compiler.TryGetPnpResolutionConfig(orchestrator.opts.Sys.GetCurrentDirectory(), orchestrator.opts.Sys.FS()) + fs := orchestrator.opts.Sys.FS() + if pnpResolutionConfig != nil { + fs = zipvfs.From(fs) + } orchestrator.host = &host{ orchestrator: orchestrator, host: compiler.NewCachedFSCompilerHost( orchestrator.opts.Sys.GetCurrentDirectory(), - orchestrator.opts.Sys.FS(), + fs, orchestrator.opts.Sys.DefaultLibraryPath(), nil, nil, + pnpResolutionConfig, ), mTimes: &collections.SyncMap[tspath.Path, time.Time]{}, } diff --git a/internal/execute/tsc.go b/internal/execute/tsc.go index 65bf8d43bb..1808d73693 100644 --- a/internal/execute/tsc.go +++ b/internal/execute/tsc.go @@ -18,6 +18,7 @@ import ( "github.com/microsoft/typescript-go/internal/pprof" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" + "github.com/microsoft/typescript-go/internal/vfs/zipvfs" ) func CommandLine(sys tsc.System, commandLineArgs []string, testing tsc.CommandLineTesting) tsc.CommandLineResult { @@ -245,7 +246,12 @@ func performIncrementalCompilation( compileTimes *tsc.CompileTimes, testing tsc.CommandLineTesting, ) tsc.CommandLineResult { - host := compiler.NewCachedFSCompilerHost(sys.GetCurrentDirectory(), sys.FS(), sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(sys, testing)) + pnpResolutionConfig := compiler.TryGetPnpResolutionConfig(sys.GetCurrentDirectory(), sys.FS()) + fs := sys.FS() + if pnpResolutionConfig != nil { + fs = zipvfs.From(fs) + } + host := compiler.NewCachedFSCompilerHost(sys.GetCurrentDirectory(), fs, sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(sys, testing), pnpResolutionConfig) buildInfoReadStart := sys.Now() oldProgram := incremental.ReadBuildInfoProgram(config, incremental.NewBuildInfoReader(host), host) compileTimes.BuildInfoReadTime = sys.Now().Sub(buildInfoReadStart) @@ -288,7 +294,12 @@ func performCompilation( compileTimes *tsc.CompileTimes, testing tsc.CommandLineTesting, ) tsc.CommandLineResult { - host := compiler.NewCachedFSCompilerHost(sys.GetCurrentDirectory(), sys.FS(), sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(sys, testing)) + pnpResolutionConfig := compiler.TryGetPnpResolutionConfig(sys.GetCurrentDirectory(), sys.FS()) + fs := sys.FS() + if pnpResolutionConfig != nil { + fs = zipvfs.From(fs) + } + host := compiler.NewCachedFSCompilerHost(sys.GetCurrentDirectory(), fs, sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(sys, testing), pnpResolutionConfig) // todo: cache, statistics, tracing parseStart := sys.Now() program := compiler.NewProgram(compiler.ProgramOptions{ diff --git a/internal/execute/tsc/help.go b/internal/execute/tsc/help.go index f3467a6b6d..a10eac843e 100644 --- a/internal/execute/tsc/help.go +++ b/internal/execute/tsc/help.go @@ -19,7 +19,7 @@ func PrintHelp(sys System, commandLine *tsoptions.ParsedCommandLine) { if commandLine.CompilerOptions().All.IsFalseOrUnknown() { printEasyHelp(sys, getOptionsForHelp(commandLine)) } else { - // !!! printAllHelp(sys, getOptionsForHelp(commandLine)) + printAllHelp(sys, getOptionsForHelp(commandLine)) } } @@ -107,6 +107,31 @@ func printEasyHelp(sys System, simpleOptions []*tsoptions.CommandLineOption) { } } +func printAllHelp(sys System, options []*tsoptions.CommandLineOption) { + var output []string + msg := diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Format() + " - " + diagnostics.Version_0.Format(core.Version()) + output = append(output, getHeader(sys, msg)...) + + // ALL COMPILER OPTIONS section + afterCompilerOptions := diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0.Format("https://aka.ms/tsc") + output = append(output, generateSectionOptionsOutput(sys, diagnostics.ALL_COMPILER_OPTIONS.Format(), options, true, nil, &afterCompilerOptions)...) + + // WATCH OPTIONS section + beforeWatchOptions := diagnostics.Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon.Format() + output = append(output, generateSectionOptionsOutput(sys, diagnostics.WATCH_OPTIONS.Format(), tsoptions.OptionsForWatch, false, &beforeWatchOptions, nil)...) + + // BUILD OPTIONS section + beforeBuildOptions := diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0.Format("https://aka.ms/tsc-composite-builds") + buildOptions := core.Filter(tsoptions.OptionsForBuild, func(option *tsoptions.CommandLineOption) bool { + return option != &tsoptions.TscBuildOption + }) + output = append(output, generateSectionOptionsOutput(sys, diagnostics.BUILD_OPTIONS.Format(), buildOptions, false, &beforeBuildOptions, nil)...) + + for _, chunk := range output { + fmt.Fprint(sys.Writer(), chunk) + } +} + func PrintBuildHelp(sys System, buildOptions []*tsoptions.CommandLineOption) { var output []string output = append(output, getHeader(sys, diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Format()+" - "+diagnostics.Version_0.Format(core.Version()))...) @@ -142,14 +167,19 @@ func generateSectionOptionsOutput( return output } categoryMap := make(map[string][]*tsoptions.CommandLineOption) + var categoryOrder []string for _, option := range options { if option.Category == nil { continue } curCategory := option.Category.Format() + if _, exists := categoryMap[curCategory]; !exists { + categoryOrder = append(categoryOrder, curCategory) + } categoryMap[curCategory] = append(categoryMap[curCategory], option) } - for key, value := range categoryMap { + for _, key := range categoryOrder { + value := categoryMap[key] output = append(output, "### ", key, "\n", "\n") output = append(output, generateGroupOptionOutput(sys, value)...) } diff --git a/internal/execute/watcher.go b/internal/execute/watcher.go index 1c1a97b238..85f9636de9 100644 --- a/internal/execute/watcher.go +++ b/internal/execute/watcher.go @@ -11,6 +11,7 @@ import ( "github.com/microsoft/typescript-go/internal/execute/incremental" "github.com/microsoft/typescript-go/internal/execute/tsc" "github.com/microsoft/typescript-go/internal/tsoptions" + "github.com/microsoft/typescript-go/internal/vfs/zipvfs" ) type Watcher struct { @@ -45,7 +46,12 @@ func createWatcher(sys tsc.System, configParseResult *tsoptions.ParsedCommandLin } func (w *Watcher) start() { - w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), nil, getTraceFromSys(w.sys, w.testing)) + pnpResolutionConfig := compiler.TryGetPnpResolutionConfig(w.sys.GetCurrentDirectory(), w.sys.FS()) + fs := w.sys.FS() + if pnpResolutionConfig != nil { + fs = zipvfs.From(fs) + } + w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), fs, w.sys.DefaultLibraryPath(), nil, getTraceFromSys(w.sys, w.testing), pnpResolutionConfig) w.program = incremental.ReadBuildInfoProgram(w.config, incremental.NewBuildInfoReader(w.host), w.host) if w.testing == nil { @@ -122,7 +128,12 @@ func (w *Watcher) hasErrorsInTsConfig() bool { } w.config = configParseResult } - w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(w.sys, w.testing)) + pnpResolutionConfig := compiler.TryGetPnpResolutionConfig(w.sys.GetCurrentDirectory(), w.sys.FS()) + fs := w.sys.FS() + if pnpResolutionConfig != nil { + fs = zipvfs.From(fs) + } + w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), fs, w.sys.DefaultLibraryPath(), extendedConfigCache, getTraceFromSys(w.sys, w.testing), pnpResolutionConfig) return false } diff --git a/internal/format/comment_test.go b/internal/format/comment_test.go index b7063bfe5d..f94799d82d 100644 --- a/internal/format/comment_test.go +++ b/internal/format/comment_test.go @@ -47,9 +47,9 @@ func TestCommentFormatting(t *testing.T) { firstFormatted := applyBulkEdits(originalText, edits) // Check that the asterisk is not corrupted - assert.Check(t, !contains(firstFormatted, "*/\n /"), "should not corrupt */ to /") - assert.Check(t, contains(firstFormatted, "*/"), "should preserve */ token") - assert.Check(t, contains(firstFormatted, "async"), "should preserve async keyword") + assert.Check(t, !strings.Contains(firstFormatted, "*/\n /"), "should not corrupt */ to /") + assert.Check(t, strings.Contains(firstFormatted, "*/"), "should preserve */ token") + assert.Check(t, strings.Contains(firstFormatted, "async"), "should preserve async keyword") // Apply formatting a second time to test stability sourceFile2 := parser.ParseSourceFile(ast.SourceFileParseOptions{ @@ -61,11 +61,183 @@ func TestCommentFormatting(t *testing.T) { secondFormatted := applyBulkEdits(firstFormatted, edits2) // Check that second formatting doesn't introduce corruption - assert.Check(t, !contains(secondFormatted, " sync x()"), "should not corrupt async to sync") - assert.Check(t, contains(secondFormatted, "async"), "should preserve async keyword on second pass") + assert.Check(t, !strings.Contains(secondFormatted, " sync x()"), "should not corrupt async to sync") + assert.Check(t, strings.Contains(secondFormatted, "async"), "should preserve async keyword on second pass") + }) + + t.Run("format JSDoc with tab indentation", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: false, // Use tabs + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // Original code with tab indentation (tabs represented as \t) + originalText := "class Foo {\n\t/**\n\t * @param {string} argument - This is a param description.\n\t */\n\texample(argument) {\nconsole.log(argument);\n\t}\n}" + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // Apply formatting + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // Check that tabs come before spaces (not spaces before tabs) + // The comment lines should have format: tab followed by space and asterisk + // NOT: space followed by tab and asterisk + assert.Check(t, !strings.Contains(formatted, " \t*"), "should not have space before tab before asterisk") + assert.Check(t, strings.Contains(formatted, "\t *"), "should have tab before space before asterisk") + + // Verify console.log is properly indented with tabs + assert.Check(t, strings.Contains(formatted, "\t\tconsole.log"), "console.log should be indented with two tabs") + }) + + t.Run("format comment inside multi-line argument list", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: false, // Use tabs + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // Original code with proper indentation + originalText := "console.log(\n\t\"a\",\n\t// the second arg\n\t\"b\"\n);" + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // Apply formatting + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // The comment should remain indented with a tab + assert.Check(t, strings.Contains(formatted, "\t// the second arg"), "comment should be indented with tab") + // The comment should not lose its indentation + assert.Check(t, !strings.Contains(formatted, "\n// the second arg"), "comment should not lose indentation") + }) + + t.Run("format comment in chained method calls", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: false, // Use tabs + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // Original code with proper indentation + originalText := "foo\n\t.bar()\n\t// A second call\n\t.baz();" + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // Apply formatting + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // The comment should remain indented + assert.Check(t, strings.Contains(formatted, "\t// A second call") || strings.Contains(formatted, " // A second call"), "comment should be indented") + // The comment should not lose its indentation + assert.Check(t, !strings.Contains(formatted, "\n// A second call"), "comment should not lose indentation") + }) + + // Regression test for issue #1928 - panic when formatting chained method call with comment + t.Run("format chained method call with comment (issue #1928)", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 0, + NewLineCharacter: "\n", + ConvertTabsToSpaces: false, // Use tabs + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // This code previously caused a panic with "strings: negative Repeat count" + // because tokenIndentation was -1 and was being used directly for indentation + originalText := "foo\n\t.bar()\n\t// A second call\n\t.baz();" + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // Apply formatting - should not panic + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // Verify the comment maintains proper indentation and doesn't lose it + assert.Check(t, strings.Contains(formatted, "\t// A second call") || strings.Contains(formatted, " // A second call"), "comment should be indented") + assert.Check(t, !strings.Contains(formatted, "\n// A second call"), "comment should not be at column 0") }) } -func contains(s, substr string) bool { - return len(substr) > 0 && strings.Contains(s, substr) +func TestSliceBoundsPanic(t *testing.T) { + t.Parallel() + + t.Run("format code with trailing semicolon should not panic", func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 4, + NewLineCharacter: "\n", + ConvertTabsToSpaces: true, + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + InsertSpaceBeforeTypeAnnotation: core.TSTrue, + }, "\n") + + // Code from the issue that causes slice bounds panic + originalText := `const _enableDisposeWithListenerWarning = false + // || Boolean("TRUE") // causes a linter warning so that it cannot be pushed + ; +` + + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, originalText, core.ScriptKindTS) + + // This should not panic + edits := format.FormatDocument(ctx, sourceFile) + formatted := applyBulkEdits(originalText, edits) + + // Basic sanity checks + assert.Check(t, len(formatted) > 0, "formatted text should not be empty") + assert.Check(t, strings.Contains(formatted, "_enableDisposeWithListenerWarning"), "should preserve variable name") + }) } diff --git a/internal/format/format_test.go b/internal/format/format_test.go new file mode 100644 index 0000000000..1bf7945076 --- /dev/null +++ b/internal/format/format_test.go @@ -0,0 +1,60 @@ +package format_test + +import ( + "strings" + "testing" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/parser" + "gotest.tools/v3/assert" +) + +func TestFormatNoTrailingNewline(t *testing.T) { + t.Parallel() + // Issue: Formatter adds extra space at end of line + // When formatting a file that has content "1;" with no trailing newline, + // an extra space should NOT be added at the end of the line + + testCases := []struct { + name string + text string + }{ + {"simple statement without trailing newline", "1;"}, + {"function call without trailing newline", "console.log('hello');"}, + {"variable declaration without trailing newline", "const x = 1;"}, + {"multiple statements without trailing newline", "const x = 1;\nconst y = 2;"}, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + ctx := format.WithFormatCodeSettings(t.Context(), &format.FormatCodeSettings{ + EditorSettings: format.EditorSettings{ + TabSize: 4, + IndentSize: 4, + BaseIndentSize: 4, + NewLineCharacter: "\n", + ConvertTabsToSpaces: true, + IndentStyle: format.IndentStyleSmart, + TrimTrailingWhitespace: true, + }, + }, "\n") + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, tc.text, core.ScriptKindTS) + edits := format.FormatDocument(ctx, sourceFile) + newText := applyBulkEdits(tc.text, edits) + + // The formatted text should not add extra space at the end + // It may add proper spacing within the code, but not after the last character + assert.Assert(t, !strings.HasSuffix(newText, " "), "Formatter should not add trailing space") + // Also check that no space was added at EOF position if text didn't end with newline + if !strings.HasSuffix(tc.text, "\n") { + assert.Assert(t, !strings.HasSuffix(newText, " "), "Formatter should not add space before EOF") + } + }) + } +} diff --git a/internal/format/indent.go b/internal/format/indent.go index ee8649fe7a..2565666d2f 100644 --- a/internal/format/indent.go +++ b/internal/format/indent.go @@ -127,7 +127,7 @@ func getActualIndentationForNode(current *ast.Node, parent *ast.Node, cuurentLin } func isArgumentAndStartLineOverlapsExpressionBeingCalled(parent *ast.Node, child *ast.Node, childStartLine int, sourceFile *ast.SourceFile) bool { - if !(ast.IsCallExpression(child) && slices.Contains(parent.AsCallExpression().Arguments.Nodes, child)) { + if !(ast.IsCallExpression(parent) && slices.Contains(parent.AsCallExpression().Arguments.Nodes, child)) { return false } expressionOfCallExpressionEnd := parent.Expression().End() diff --git a/internal/format/rules.go b/internal/format/rules.go index c8b31a247e..07af86ef99 100644 --- a/internal/format/rules.go +++ b/internal/format/rules.go @@ -9,7 +9,9 @@ import ( func getAllRules() []ruleSpec { allTokens := make([]ast.Kind, 0, ast.KindLastToken-ast.KindFirstToken+1) for token := ast.KindFirstToken; token <= ast.KindLastToken; token++ { - allTokens = append(allTokens, token) + if token != ast.KindEndOfFile { + allTokens = append(allTokens, token) + } } anyTokenExcept := func(tokens ...ast.Kind) tokenRange { diff --git a/internal/format/span.go b/internal/format/span.go index 4657949f7e..3a1ea475cd 100644 --- a/internal/format/span.go +++ b/internal/format/span.go @@ -975,7 +975,7 @@ func getIndentationString(indentation int, options *FormatCodeSettings) string { spaces := indentation - (tabs * options.TabSize) res := strings.Repeat("\t", tabs) if spaces > 0 { - res = strings.Repeat(" ", spaces) + res + res = res + strings.Repeat(" ", spaces) } return res @@ -1093,6 +1093,9 @@ func (i *dynamicIndenter) getIndentationForComment(kind ast.Kind, tokenIndentati case ast.KindCloseBraceToken, ast.KindCloseBracketToken, ast.KindCloseParenToken: return i.indentation + i.getDelta(container) } + if tokenIndentation != -1 { + return tokenIndentation + } return i.indentation } diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 0b461efff6..5d47f7a836 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -151,14 +151,17 @@ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { } const namespace = callExpression.expression.expression; const func = callExpression.expression.name; - if (!(ts.isIdentifier(namespace) || namespace.getText() === "verify.not") || !ts.isIdentifier(func)) { - console.error(`Expected identifiers for namespace and function, got ${namespace.getText()} and ${func.getText()}`); - return undefined; - } if (!ts.isIdentifier(namespace)) { switch (func.text) { case "quickInfoExists": return parseQuickInfoArgs("notQuickInfoExists", callExpression.arguments); + case "andApplyCodeAction": + // verify.completions({ ... }).andApplyCodeAction(...) + if (!(ts.isCallExpression(namespace) && namespace.expression.getText() === "verify.completions")) { + console.error(`Unrecognized fourslash statement: ${statement.getText()}`); + return undefined; + } + return parseVerifyCompletionsArgs(namespace.arguments, callExpression.arguments); } console.error(`Unrecognized fourslash statement: ${statement.getText()}`); return undefined; @@ -169,6 +172,9 @@ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { case "completions": // `verify.completions(...)` return parseVerifyCompletionsArgs(callExpression.arguments); + case "applyCodeActionFromCompletion": + // `verify.applyCodeActionFromCompletion(...)` + return parseVerifyApplyCodeActionFromCompletionArgs(callExpression.arguments); case "quickInfoAt": case "quickInfoExists": case "quickInfoIs": @@ -184,13 +190,18 @@ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { return parseBaselineQuickInfo(callExpression.arguments); case "baselineSignatureHelp": return [parseBaselineSignatureHelp(callExpression.arguments)]; + case "baselineSmartSelection": + return [parseBaselineSmartSelection(callExpression.arguments)]; case "baselineGoToDefinition": case "baselineGetDefinitionAtPosition": - // Both of these take the same arguments, but differ in that... + case "baselineGoToType": + // Both `baselineGoToDefinition` and `baselineGetDefinitionAtPosition` take the same + // arguments, but differ in that... // - `verify.baselineGoToDefinition(...)` called getDefinitionAndBoundSpan // - `verify.baselineGetDefinitionAtPosition(...)` called getDefinitionAtPosition - // LSP doesn't have two separate commands though. It's unclear how we would model bound spans though. - return parseBaselineGoToDefinitionArgs(callExpression.arguments); + // LSP doesn't have two separate commands though. + // It's unclear how we would model bound spans though. + return parseBaselineGoToDefinitionArgs(func.text, callExpression.arguments); case "baselineRename": case "baselineRenameAtRangesWithText": // `verify.baselineRename...(...)` @@ -268,6 +279,13 @@ function parseEditStatement(funcName: string, args: readonly ts.Expression[]): E } } +function getGoMultiLineStringLiteral(text: string): string { + if (!text.includes("`") && !text.includes("\\")) { + return "`" + text + "`"; + } + return getGoStringLiteral(text); +} + function getGoStringLiteral(text: string): string { return `${JSON.stringify(text)}`; } @@ -359,18 +377,170 @@ function parseGoToArgs(args: readonly ts.Expression[], funcName: string): GoToCm } } -function parseVerifyCompletionsArgs(args: readonly ts.Expression[]): VerifyCompletionsCmd[] | undefined { +function parseVerifyCompletionsArgs(args: readonly ts.Expression[], codeActionArgs?: readonly ts.Expression[]): VerifyCompletionsCmd[] | undefined { const cmds = []; + const codeAction = codeActionArgs?.[0] && parseAndApplyCodeActionArg(codeActionArgs[0]); for (const arg of args) { - const result = parseVerifyCompletionArg(arg); + const result = parseVerifyCompletionArg(arg, codeAction); if (!result) { return undefined; } + if (codeActionArgs?.length) { + result.andApplyCodeActionArgs = parseAndApplyCodeActionArg(codeActionArgs[0]); + } cmds.push(result); } return cmds; } +function parseVerifyApplyCodeActionFromCompletionArgs(args: readonly ts.Expression[]): VerifyApplyCodeActionFromCompletionCmd[] | undefined { + const cmds: VerifyApplyCodeActionFromCompletionCmd[] = []; + if (args.length !== 2) { + console.error(`Expected two arguments in verify.applyCodeActionFromCompletion, got ${args.map(arg => arg.getText()).join(", ")}`); + return undefined; + } + if (!ts.isStringLiteralLike(args[0]) && args[0].getText() !== "undefined") { + console.error(`Expected string literal or "undefined" in verify.applyCodeActionFromCompletion, got ${args[0].getText()}`); + return undefined; + } + const markerName = getStringLiteralLike(args[0])?.text; + const marker = markerName === undefined ? "nil" : `PtrTo(${getGoStringLiteral(markerName)})`; + const options = parseVerifyApplyCodeActionArgs(args[1]); + if (options === undefined) { + return undefined; + } + + cmds.push({ kind: "verifyApplyCodeActionFromCompletion", marker, options }); + return cmds; +} + +function parseVerifyApplyCodeActionArgs(arg: ts.Expression): string | undefined { + const obj = getObjectLiteralExpression(arg); + if (!obj) { + console.error(`Expected object literal for verify.applyCodeActionFromCompletion options, got ${arg.getText()}`); + return undefined; + } + let nameInit, sourceInit, descInit, dataInit; + const props: string[] = []; + for (const prop of obj.properties) { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + if (ts.isShorthandPropertyAssignment(prop) && prop.name.text === "preferences") { + continue; // !!! parse once preferences are supported in fourslash + } + console.error(`Expected property assignment with identifier name in verify.applyCodeActionFromCompletion options, got ${prop.getText()}`); + return undefined; + } + const propName = prop.name.text; + const init = prop.initializer; + switch (propName) { + case "name": + nameInit = getStringLiteralLike(init); + if (!nameInit) { + console.error(`Expected string literal for name in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`Name: ${getGoStringLiteral(nameInit.text)},`); + break; + case "source": + sourceInit = getStringLiteralLike(init); + if (!sourceInit) { + console.error(`Expected string literal for source in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`Source: ${getGoStringLiteral(sourceInit.text)},`); + break; + case "data": + dataInit = getObjectLiteralExpression(init); + if (!dataInit) { + console.error(`Expected object literal for data in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + const dataProps: string[] = []; + for (const dataProp of dataInit.properties) { + if (!ts.isPropertyAssignment(dataProp) || !ts.isIdentifier(dataProp.name)) { + console.error(`Expected property assignment with identifier name in verify.applyCodeActionFromCompletion data, got ${dataProp.getText()}`); + return undefined; + } + const dataPropName = dataProp.name.text; + switch (dataPropName) { + case "moduleSpecifier": + const moduleSpecifierInit = getStringLiteralLike(dataProp.initializer); + if (!moduleSpecifierInit) { + console.error(`Expected string literal for moduleSpecifier in verify.applyCodeActionFromCompletion data, got ${dataProp.initializer.getText()}`); + return undefined; + } + dataProps.push(`ModuleSpecifier: ${getGoStringLiteral(moduleSpecifierInit.text)},`); + break; + case "exportName": + const exportNameInit = getStringLiteralLike(dataProp.initializer); + if (!exportNameInit) { + console.error(`Expected string literal for exportName in verify.applyCodeActionFromCompletion data, got ${dataProp.initializer.getText()}`); + return undefined; + } + dataProps.push(`ExportName: ${getGoStringLiteral(exportNameInit.text)},`); + break; + case "fileName": + const fileNameInit = getStringLiteralLike(dataProp.initializer); + if (!fileNameInit) { + console.error(`Expected string literal for fileName in verify.applyCodeActionFromCompletion data, got ${dataProp.initializer.getText()}`); + return undefined; + } + dataProps.push(`FileName: ${getGoStringLiteral(fileNameInit.text)},`); + break; + default: + console.error(`Unrecognized property in verify.applyCodeActionFromCompletion data: ${dataProp.getText()}`); + return undefined; + } + } + props.push(`AutoImportData: &ls.AutoImportData{\n${dataProps.join("\n")}\n},`); + break; + case "description": + descInit = getStringLiteralLike(init); + if (!descInit) { + console.error(`Expected string literal for description in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`Description: ${getGoStringLiteral(descInit.text)},`); + break; + case "newFileContent": + const newFileContentInit = getStringLiteralLike(init); + if (!newFileContentInit) { + console.error(`Expected string literal for newFileContent in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`NewFileContent: PtrTo(${getGoMultiLineStringLiteral(newFileContentInit.text)}),`); + break; + case "newRangeContent": + const newRangeContentInit = getStringLiteralLike(init); + if (!newRangeContentInit) { + console.error(`Expected string literal for newRangeContent in verify.applyCodeActionFromCompletion options, got ${init.getText()}`); + return undefined; + } + props.push(`NewRangeContent: PtrTo(${getGoMultiLineStringLiteral(newRangeContentInit.text)}),`); + break; + case "preferences": + // Few if any tests use non-default preferences + break; + default: + console.error(`Unrecognized property in verify.applyCodeActionFromCompletion options: ${prop.getText()}`); + return undefined; + } + } + if (!nameInit) { + console.error(`Expected name property in verify.applyCodeActionFromCompletion options`); + return undefined; + } + if (!sourceInit && !dataInit) { + console.error(`Expected source property in verify.applyCodeActionFromCompletion options`); + return undefined; + } + if (!descInit) { + console.error(`Expected description property in verify.applyCodeActionFromCompletion options`); + return undefined; + } + return `&fourslash.ApplyCodeActionFromCompletionOptions{\n${props.join("\n")}\n}`; +} + const completionConstants = new Map([ ["completion.globals", "CompletionGlobals"], ["completion.globalTypes", "CompletionGlobalTypes"], @@ -394,7 +564,7 @@ const completionPlus = new Map([ ["completion.typeKeywordsPlus", "CompletionTypeKeywordsPlus"], ]); -function parseVerifyCompletionArg(arg: ts.Expression): VerifyCompletionsCmd | undefined { +function parseVerifyCompletionArg(arg: ts.Expression, codeActionArgs?: VerifyApplyCodeActionArgs): VerifyCompletionsCmd | undefined { let marker: string | undefined; let goArgs: VerifyCompletionsArgs | undefined; const obj = getObjectLiteralExpression(arg); @@ -405,6 +575,9 @@ function parseVerifyCompletionArg(arg: ts.Expression): VerifyCompletionsCmd | un let isNewIdentifierLocation: true | undefined; for (const prop of obj.properties) { if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + if (ts.isShorthandPropertyAssignment(prop) && prop.name.text === "preferences") { + continue; // !!! parse once preferences are supported in fourslash + } console.error(`Expected property assignment with identifier name, got ${prop.getText()}`); return undefined; } @@ -475,7 +648,7 @@ function parseVerifyCompletionArg(arg: ts.Expression): VerifyCompletionsCmd | un } expected = `${funcName}(\n[]fourslash.CompletionsExpectedItem{`; for (const elem of items.elements) { - const result = parseExpectedCompletionItem(elem); + const result = parseExpectedCompletionItem(elem, codeActionArgs); if (!result) { return undefined; } @@ -586,7 +759,7 @@ function parseVerifyCompletionArg(arg: ts.Expression): VerifyCompletionsCmd | un }; } -function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { +function parseExpectedCompletionItem(expr: ts.Expression, codeActionArgs?: VerifyApplyCodeActionArgs): string | undefined { if (completionConstants.has(expr.getText())) { return completionConstants.get(expr.getText())!; } @@ -597,6 +770,7 @@ function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { if (strExpr = getObjectLiteralExpression(expr)) { let isDeprecated = false; // !!! let isOptional = false; + let sourceInit: ts.StringLiteralLike | undefined; let extensions: string[] = []; // !!! let itemProps: string[] = []; let name: string | undefined; @@ -705,6 +879,33 @@ function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { } case "isFromUncheckedFile": break; // Ignored + case "hasAction": + itemProps.push("AdditionalTextEdits: fourslash.AnyTextEdits,"); + break; + case "source": + case "sourceDisplay": + if (sourceInit !== undefined) { + break; + } + if (sourceInit = getStringLiteralLike(init)) { + if (propName === "source" && sourceInit.text.endsWith("/")) { + // source: "ClassMemberSnippet/" + itemProps.push(`Data: PtrTo(any(&ls.CompletionItemData{ + Source: ${getGoStringLiteral(sourceInit.text)}, + })),`); + break; + } + itemProps.push(`Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: ${getGoStringLiteral(sourceInit.text)}, + }, + })),`); + } + else { + console.error(`Expected string literal for source/sourceDisplay, got ${init.getText()}`); + return undefined; + } + break; case "commitCharacters": // !!! support these later break; @@ -729,6 +930,11 @@ function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { if (!name) { return undefined; // Shouldn't happen } + if (codeActionArgs && codeActionArgs.name === name && codeActionArgs.source === sourceInit?.text) { + itemProps.push(`LabelDetails: &lsproto.CompletionItemLabelDetails{ + Description: PtrTo(${getGoStringLiteral(codeActionArgs.source)}), + },`); + } if (replacementSpanIdx) { itemProps.push(`TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ TextEdit: &lsproto.TextEdit{ @@ -751,6 +957,60 @@ function parseExpectedCompletionItem(expr: ts.Expression): string | undefined { return undefined; // Unsupported expression type } +function parseAndApplyCodeActionArg(arg: ts.Expression): VerifyApplyCodeActionArgs | undefined { + const obj = getObjectLiteralExpression(arg); + if (!obj) { + console.error(`Expected object literal for code action argument, got ${arg.getText()}`); + return undefined; + } + const nameProperty = obj.properties.find(prop => + ts.isPropertyAssignment(prop) && + ts.isIdentifier(prop.name) && + prop.name.text === "name" && + ts.isStringLiteralLike(prop.initializer) + ) as ts.PropertyAssignment | undefined; + if (!nameProperty) { + console.error(`Expected name property in code action argument, got ${obj.getText()}`); + return undefined; + } + const sourceProperty = obj.properties.find(prop => + ts.isPropertyAssignment(prop) && + ts.isIdentifier(prop.name) && + prop.name.text === "source" && + ts.isStringLiteralLike(prop.initializer) + ) as ts.PropertyAssignment | undefined; + if (!sourceProperty) { + console.error(`Expected source property in code action argument, got ${obj.getText()}`); + return undefined; + } + const descriptionProperty = obj.properties.find(prop => + ts.isPropertyAssignment(prop) && + ts.isIdentifier(prop.name) && + prop.name.text === "description" && + ts.isStringLiteralLike(prop.initializer) + ) as ts.PropertyAssignment | undefined; + if (!descriptionProperty) { + console.error(`Expected description property in code action argument, got ${obj.getText()}`); + return undefined; + } + const newFileContentProperty = obj.properties.find(prop => + ts.isPropertyAssignment(prop) && + ts.isIdentifier(prop.name) && + prop.name.text === "newFileContent" && + ts.isStringLiteralLike(prop.initializer) + ) as ts.PropertyAssignment | undefined; + if (!newFileContentProperty) { + console.error(`Expected newFileContent property in code action argument, got ${obj.getText()}`); + return undefined; + } + return { + name: (nameProperty.initializer as ts.StringLiteralLike).text, + source: (sourceProperty.initializer as ts.StringLiteralLike).text, + description: (descriptionProperty.initializer as ts.StringLiteralLike).text, + newFileContent: (newFileContentProperty.initializer as ts.StringLiteralLike).text, + }; +} + function parseBaselineFindAllReferencesArgs(args: readonly ts.Expression[]): [VerifyBaselineFindAllReferencesCmd] | undefined { const newArgs = []; for (const arg of args) { @@ -817,7 +1077,20 @@ function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [V }]; } -function parseBaselineGoToDefinitionArgs(args: readonly ts.Expression[]): [VerifyBaselineGoToDefinitionCmd] | undefined { +function parseBaselineGoToDefinitionArgs( + funcName: "baselineGoToDefinition" | "baselineGoToType" | "baselineGetDefinitionAtPosition", + args: readonly ts.Expression[], +): [VerifyBaselineGoToDefinitionCmd] | undefined { + let kind: "verifyBaselineGoToDefinition" | "verifyBaselineGoToType"; + switch (funcName) { + case "baselineGoToDefinition": + case "baselineGetDefinitionAtPosition": + kind = "verifyBaselineGoToDefinition"; + break; + case "baselineGoToType": + kind = "verifyBaselineGoToType"; + break; + } const newArgs = []; for (const arg of args) { let strArg; @@ -829,19 +1102,19 @@ function parseBaselineGoToDefinitionArgs(args: readonly ts.Expression[]): [Verif } else if (arg.getText() === "...test.ranges()") { return [{ - kind: "verifyBaselineGoToDefinition", + kind, markers: [], ranges: true, }]; } else { - console.error(`Unrecognized argument in verify.baselineGoToDefinition: ${arg.getText()}`); + console.error(`Unrecognized argument in verify.${funcName}: ${arg.getText()}`); return undefined; } } return [{ - kind: "verifyBaselineGoToDefinition", + kind, markers: newArgs, }]; } @@ -1151,6 +1424,16 @@ function parseBaselineSignatureHelp(args: ts.NodeArray): Cmd { }; } +function parseBaselineSmartSelection(args: ts.NodeArray): Cmd { + if (args.length !== 0) { + // All calls are currently empty! + throw new Error("Expected no arguments in verify.baselineSmartSelection"); + } + return { + kind: "verifyBaselineSmartSelection", + }; +} + function parseKind(expr: ts.Expression): string | undefined { if (!ts.isStringLiteral(expr)) { console.error(`Expected string literal for kind, got ${expr.getText()}`); @@ -1271,6 +1554,7 @@ interface VerifyCompletionsCmd { marker: string; isNewIdentifierLocation?: true; args?: VerifyCompletionsArgs | "nil"; + andApplyCodeActionArgs?: VerifyApplyCodeActionArgs; } interface VerifyCompletionsArgs { @@ -1280,6 +1564,19 @@ interface VerifyCompletionsArgs { unsorted?: string; } +interface VerifyApplyCodeActionArgs { + name: string; + source: string; + description: string; + newFileContent: string; +} + +interface VerifyApplyCodeActionFromCompletionCmd { + kind: "verifyApplyCodeActionFromCompletion"; + marker: string; + options: string; +} + interface VerifyBaselineFindAllReferencesCmd { kind: "verifyBaselineFindAllReferences"; markers: string[]; @@ -1293,7 +1590,7 @@ interface VerifyBaselineFindAllReferencesCmd { } interface VerifyBaselineGoToDefinitionCmd { - kind: "verifyBaselineGoToDefinition"; + kind: "verifyBaselineGoToDefinition" | "verifyBaselineGoToType"; markers: string[]; ranges?: boolean; } @@ -1306,6 +1603,10 @@ interface VerifyBaselineSignatureHelpCmd { kind: "verifyBaselineSignatureHelp"; } +interface VerifyBaselineSmartSelection { + kind: "verifyBaselineSmartSelection"; +} + interface VerifyBaselineRenameCmd { kind: "verifyBaselineRename" | "verifyBaselineRenameAtRangesWithText"; args: string[]; @@ -1344,18 +1645,20 @@ interface VerifyRenameInfoCmd { type Cmd = | VerifyCompletionsCmd + | VerifyApplyCodeActionFromCompletionCmd | VerifyBaselineFindAllReferencesCmd | VerifyBaselineDocumentHighlightsCmd | VerifyBaselineGoToDefinitionCmd | VerifyBaselineQuickInfoCmd | VerifyBaselineSignatureHelpCmd + | VerifyBaselineSmartSelection | GoToCmd | EditCmd | VerifyQuickInfoCmd | VerifyBaselineRenameCmd | VerifyRenameInfoCmd; -function generateVerifyCompletions({ marker, args, isNewIdentifierLocation }: VerifyCompletionsCmd): string { +function generateVerifyCompletions({ marker, args, isNewIdentifierLocation, andApplyCodeActionArgs }: VerifyCompletionsCmd): string { let expectedList: string; if (args === "nil") { expectedList = "nil"; @@ -1379,7 +1682,21 @@ function generateVerifyCompletions({ marker, args, isNewIdentifierLocation }: Ve }, }`; } - return `f.VerifyCompletions(t, ${marker}, ${expectedList})`; + + const call = `f.VerifyCompletions(t, ${marker}, ${expectedList})`; + if (andApplyCodeActionArgs) { + return `${call}.AndApplyCodeAction(t, &fourslash.CompletionsExpectedCodeAction{ + Name: ${getGoStringLiteral(andApplyCodeActionArgs.name)}, + Source: ${getGoStringLiteral(andApplyCodeActionArgs.source)}, + Description: ${getGoStringLiteral(andApplyCodeActionArgs.description)}, + NewFileContent: ${getGoMultiLineStringLiteral(andApplyCodeActionArgs.newFileContent)}, + })`; + } + return call; +} + +function generateVerifyApplyCodeActionFromCompletion({ marker, options }: VerifyApplyCodeActionFromCompletionCmd): string { + return `f.VerifyApplyCodeActionFromCompletion(t, ${marker}, ${options})`; } function generateBaselineFindAllReferences({ markers, ranges }: VerifyBaselineFindAllReferencesCmd): string { @@ -1393,11 +1710,20 @@ function generateBaselineDocumentHighlights({ args, preferences }: VerifyBaselin return `f.VerifyBaselineDocumentHighlights(t, ${preferences}, ${args.join(", ")})`; } -function generateBaselineGoToDefinition({ markers, ranges }: VerifyBaselineGoToDefinitionCmd): string { +function generateBaselineGoToDefinition({ markers, ranges, kind }: VerifyBaselineGoToDefinitionCmd): string { + let goFunc; + switch (kind) { + case "verifyBaselineGoToDefinition": + goFunc = "VerifyBaselineGoToDefinition"; + break; + case "verifyBaselineGoToType": + goFunc = "VerifyBaselineGoToTypeDefinition"; + break; + } if (ranges || markers.length === 0) { - return `f.VerifyBaselineGoToDefinition(t)`; + return `f.${goFunc}(t)`; } - return `f.VerifyBaselineGoToDefinition(t, ${markers.join(", ")})`; + return `f.${goFunc}(t, ${markers.join(", ")})`; } function generateGoToCommand({ funcName, args }: GoToCmd): string { @@ -1431,17 +1757,22 @@ function generateCmd(cmd: Cmd): string { switch (cmd.kind) { case "verifyCompletions": return generateVerifyCompletions(cmd); + case "verifyApplyCodeActionFromCompletion": + return generateVerifyApplyCodeActionFromCompletion(cmd); case "verifyBaselineFindAllReferences": return generateBaselineFindAllReferences(cmd); case "verifyBaselineDocumentHighlights": return generateBaselineDocumentHighlights(cmd); case "verifyBaselineGoToDefinition": + case "verifyBaselineGoToType": return generateBaselineGoToDefinition(cmd); case "verifyBaselineQuickInfo": // Quick Info -> Hover return `f.VerifyBaselineHover(t)`; case "verifyBaselineSignatureHelp": return `f.VerifyBaselineSignatureHelp(t)`; + case "verifyBaselineSmartSelection": + return `f.VerifyBaselineSelectionRanges(t)`; case "goTo": return generateGoToCommand(cmd); case "edit": @@ -1471,7 +1802,7 @@ interface GoTest { } function generateGoTest(failingTests: Set, test: GoTest): string { - const testName = (test.name[0].toUpperCase() + test.name.substring(1)).replaceAll("-", "_"); + const testName = (test.name[0].toUpperCase() + test.name.substring(1)).replaceAll("-", "_").replaceAll(/[^a-zA-Z0-9_]/g, ""); const content = test.content; const commands = test.commands.map(cmd => generateCmd(cmd)).join("\n"); const imports = [`"github.com/microsoft/typescript-go/internal/fourslash"`]; diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index a3851e759e..3596e01173 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -3,6 +3,29 @@ TestAmbientShorthandGotoDefinition TestArgumentsAreAvailableAfterEditsAtEndOfFunction TestAugmentedTypesClass1 TestAugmentedTypesClass3Fourslash +TestAutoImportCompletionAmbientMergedModule1 +TestAutoImportCompletionExportEqualsWithDefault1 +TestAutoImportCompletionExportListAugmentation1 +TestAutoImportCompletionExportListAugmentation2 +TestAutoImportCompletionExportListAugmentation3 +TestAutoImportCompletionExportListAugmentation4 +TestAutoImportFileExcludePatterns3 +TestAutoImportPathsAliasesAndBarrels +TestAutoImportProvider_exportMap1 +TestAutoImportProvider_exportMap2 +TestAutoImportProvider_exportMap3 +TestAutoImportProvider_exportMap4 +TestAutoImportProvider_exportMap5 +TestAutoImportProvider_exportMap6 +TestAutoImportProvider_exportMap7 +TestAutoImportProvider_exportMap8 +TestAutoImportProvider_exportMap9 +TestAutoImportProvider_globalTypingsCache +TestAutoImportProvider_namespaceSameNameAsIntrinsic +TestAutoImportProvider_wildcardExports1 +TestAutoImportProvider_wildcardExports2 +TestAutoImportProvider_wildcardExports3 +TestAutoImportVerbatimTypeOnly1 TestBestCommonTypeObjectLiterals TestBestCommonTypeObjectLiterals1 TestCodeCompletionEscaping @@ -16,11 +39,11 @@ TestCompletionEntryClassMembersWithInferredFunctionReturnType1 TestCompletionEntryForArgumentConstrainedToString TestCompletionEntryForArrayElementConstrainedToString TestCompletionEntryForArrayElementConstrainedToString2 -TestCompletionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved TestCompletionEntryForUnionProperty TestCompletionEntryForUnionProperty2 TestCompletionForComputedStringProperties TestCompletionForMetaProperty +TestCompletionForObjectProperty TestCompletionForStringLiteral TestCompletionForStringLiteral4 TestCompletionForStringLiteralExport @@ -66,7 +89,6 @@ TestCompletionImportModuleSpecifierEndingUnsupportedExtension TestCompletionInChecks1 TestCompletionInFunctionLikeBody_includesPrimitiveTypes TestCompletionInJsDoc -TestCompletionInNamedImportLocation TestCompletionInUncheckedJSFile TestCompletionListBuilderLocations_VariableDeclarations TestCompletionListForDerivedType1 @@ -116,13 +138,51 @@ TestCompletionOfAwaitPromise6 TestCompletionOfAwaitPromise7 TestCompletionOfInterfaceAndVar TestCompletionPreferredSuggestions1 +TestCompletionPropertyShorthandForObjectLiteral5 TestCompletionWithConditionalOperatorMissingColon TestCompletionsAfterJSDoc TestCompletionsBeforeRestArg1 +TestCompletionsClassMemberImportTypeNodeParameter1 +TestCompletionsClassMemberImportTypeNodeParameter2 +TestCompletionsClassMemberImportTypeNodeParameter3 +TestCompletionsClassMemberImportTypeNodeParameter4 TestCompletionsElementAccessNumeric TestCompletionsExportImport TestCompletionsGenericTypeWithMultipleBases1 +TestCompletionsImportBaseUrl TestCompletionsImportOrExportSpecifier +TestCompletionsImport_default_alreadyExistedWithRename +TestCompletionsImport_default_anonymous +TestCompletionsImport_default_didNotExistBefore +TestCompletionsImport_default_exportDefaultIdentifier +TestCompletionsImport_details_withMisspelledName +TestCompletionsImport_exportEquals_anonymous +TestCompletionsImport_exportEquals_global +TestCompletionsImport_filteredByInvalidPackageJson_direct +TestCompletionsImport_filteredByPackageJson_direct +TestCompletionsImport_filteredByPackageJson_nested +TestCompletionsImport_filteredByPackageJson_peerDependencies +TestCompletionsImport_filteredByPackageJson_typesImplicit +TestCompletionsImport_filteredByPackageJson_typesOnly +TestCompletionsImport_importType +TestCompletionsImport_jsxOpeningTagImportDefault +TestCompletionsImport_mergedReExport +TestCompletionsImport_multipleWithSameName +TestCompletionsImport_named_didNotExistBefore +TestCompletionsImport_named_exportEqualsNamespace +TestCompletionsImport_named_namespaceImportExists +TestCompletionsImport_noSemicolons +TestCompletionsImport_ofAlias_preferShortPath +TestCompletionsImport_packageJsonImportsPreference +TestCompletionsImport_quoteStyle +TestCompletionsImport_reExportDefault +TestCompletionsImport_reExportDefault2 +TestCompletionsImport_reExport_wrongName +TestCompletionsImport_require_addToExisting +TestCompletionsImport_typeOnly +TestCompletionsImport_umdDefaultNoCrash1 +TestCompletionsImport_uriStyleNodeCoreModules2 +TestCompletionsImport_windowsPathsProjectRelative TestCompletionsInExport TestCompletionsInExport_moduleBlock TestCompletionsInRequire @@ -154,6 +214,7 @@ TestCompletionsPaths_kinds TestCompletionsPaths_pathMapping TestCompletionsPaths_pathMapping_nonTrailingWildcard1 TestCompletionsPaths_pathMapping_parentDirectory +TestCompletionsRecommended_namespace TestCompletionsRecommended_union TestCompletionsRedeclareModuleAsGlobal TestCompletionsStringsWithTriggerCharacter @@ -161,6 +222,8 @@ TestCompletionsSymbolMembers TestCompletionsTriggerCharacter TestCompletionsTuple TestCompletionsUniqueSymbol1 +TestCompletionsUniqueSymbol_import +TestCompletionsWithDeprecatedTag10 TestConstEnumQuickInfoAndCompletionList TestConstQuickInfoAndCompletionList TestContextuallyTypedFunctionExpressionGeneric1 @@ -168,7 +231,6 @@ TestDoubleUnderscoreCompletions TestEditJsdocType TestExportDefaultClass TestExportDefaultFunction -TestFindAllRefsForDefaultExport03 TestFindAllRefsForModule TestFindAllRefsModuleDotExports TestFindReferencesBindingPatternInJsdocNoCrash1 @@ -217,6 +279,16 @@ TestImportCompletions_importsMap2 TestImportCompletions_importsMap3 TestImportCompletions_importsMap4 TestImportCompletions_importsMap5 +TestImportNameCodeFixExportAsDefault +TestImportSuggestionsCache_exportUndefined +TestImportTypeCompletions1 +TestImportTypeCompletions3 +TestImportTypeCompletions4 +TestImportTypeCompletions5 +TestImportTypeCompletions6 +TestImportTypeCompletions7 +TestImportTypeCompletions8 +TestImportTypeCompletions9 TestIndexerReturnTypes1 TestIndirectClassInstantiation TestInstanceTypesForGenericType1 @@ -245,7 +317,9 @@ TestJsDocPropertyDescription6 TestJsDocPropertyDescription7 TestJsDocPropertyDescription8 TestJsDocPropertyDescription9 +TestJsDocServices TestJsDocTagsWithHyphen +TestJsFileImportNoTypes2 TestJsQuickInfoGenerallyAcceptableSize TestJsRequireQuickInfo TestJsdocCallbackTag @@ -387,7 +461,6 @@ TestQuickInfoOnGenericWithConstraints1 TestQuickInfoOnInternalAliases TestQuickInfoOnJsxNamespacedNameWithDoc1 TestQuickInfoOnMethodOfImportEquals -TestQuickInfoOnNarrowedType TestQuickInfoOnNarrowedTypeInModule TestQuickInfoOnNewKeyword01 TestQuickInfoOnObjectLiteralWithAccessors diff --git a/internal/fourslash/baselineutil.go b/internal/fourslash/baselineutil.go index 83e683b1d4..1a659331d9 100644 --- a/internal/fourslash/baselineutil.go +++ b/internal/fourslash/baselineutil.go @@ -47,7 +47,7 @@ func getBaselineFileName(t *testing.T, command string) string { func getBaselineExtension(command string) string { switch command { - case "QuickInfo", "SignatureHelp": + case "QuickInfo", "SignatureHelp", "Smart Selection": return "baseline" case "Auto Imports": return "baseline.md" @@ -61,6 +61,11 @@ func getBaselineExtension(command string) string { func getBaselineOptions(command string) baseline.Options { subfolder := "fourslash/" + normalizeCommandName(command) switch command { + case "Smart Selection": + return baseline.Options{ + Subfolder: subfolder, + IsSubmodule: true, + } case "findRenameLocations": return baseline.Options{ Subfolder: subfolder, diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index a488f7d2c5..93f61817ab 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -1,6 +1,7 @@ package fourslash import ( + "context" "fmt" "io" "maps" @@ -42,6 +43,7 @@ type FourslashTest struct { scriptInfos map[string]*scriptInfo converters *ls.Converters + userPreferences *ls.UserPreferences currentCaretPosition lsproto.Position lastKnownMarkerName *string activeFilename string @@ -164,7 +166,7 @@ func NewFourslash(t *testing.T, capabilities *lsproto.ClientCapabilities, conten defer func() { outputWriter.Close() }() - err := server.Run() + err := server.Run(context.TODO()) if err != nil { t.Error("server error:", err) } @@ -179,14 +181,15 @@ func NewFourslash(t *testing.T, capabilities *lsproto.ClientCapabilities, conten }) f := &FourslashTest{ - server: server, - in: inputWriter, - out: outputReader, - testData: &testData, - vfs: fs, - scriptInfos: scriptInfos, - converters: converters, - baselines: make(map[string]*strings.Builder), + server: server, + in: inputWriter, + out: outputReader, + testData: &testData, + userPreferences: ls.NewDefaultUserPreferences(), // !!! parse default preferences for fourslash case? + vfs: fs, + scriptInfos: scriptInfos, + converters: converters, + baselines: make(map[string]*strings.Builder), } // !!! temporary; remove when we have `handleDidChangeConfiguration`/implicit project config support @@ -256,6 +259,12 @@ func getCapabilitiesWithDefaults(capabilities *lsproto.ClientCapabilities) *lspr if capabilitiesWithDefaults.TextDocument.Completion == nil { capabilitiesWithDefaults.TextDocument.Completion = defaultCompletionCapabilities } + if capabilitiesWithDefaults.Workspace == nil { + capabilitiesWithDefaults.Workspace = &lsproto.WorkspaceClientCapabilities{} + } + if capabilitiesWithDefaults.Workspace.Configuration == nil { + capabilitiesWithDefaults.Workspace.Configuration = ptrTrue + } return &capabilitiesWithDefaults } @@ -268,6 +277,29 @@ func sendRequest[Params, Resp any](t *testing.T, f *FourslashTest, info lsproto. ) f.writeMsg(t, req.Message()) resp := f.readMsg(t) + if resp == nil { + return nil, *new(Resp), false + } + + // currently, the only request that may be sent by the server during a client request is one `config` request + // !!! remove if `config` is handled in initialization and there are no other server-initiated requests + if resp.Kind == lsproto.MessageKindRequest { + req := resp.AsRequest() + switch req.Method { + case lsproto.MethodWorkspaceConfiguration: + req := lsproto.ResponseMessage{ + ID: req.ID, + JSONRPC: req.JSONRPC, + Result: []any{f.userPreferences}, + } + f.writeMsg(t, req.Message()) + resp = f.readMsg(t) + default: + // other types of requests not yet used in fourslash; implement them if needed + t.Fatalf("Unexpected request received: %s", req.Method) + } + } + if resp == nil { return nil, *new(Resp), false } @@ -300,6 +332,21 @@ func (f *FourslashTest) readMsg(t *testing.T) *lsproto.Message { return msg } +func (f *FourslashTest) Configure(t *testing.T, config *ls.UserPreferences) { + f.userPreferences = config + sendNotification(t, f, lsproto.WorkspaceDidChangeConfigurationInfo, &lsproto.DidChangeConfigurationParams{ + Settings: config, + }) +} + +func (f *FourslashTest) ConfigureWithReset(t *testing.T, config *ls.UserPreferences) (reset func()) { + originalConfig := f.userPreferences.Copy() + f.Configure(t, config) + return func() { + f.Configure(t, originalConfig) + } +} + func (f *FourslashTest) GoToMarkerOrRange(t *testing.T, markerOrRange MarkerOrRange) { f.goToMarker(t, markerOrRange) } @@ -502,19 +549,31 @@ type CompletionsExpectedItems struct { Unsorted []CompletionsExpectedItem } +type CompletionsExpectedCodeAction struct { + Name string + Source string + Description string + NewFileContent string +} + +type VerifyCompletionsResult struct { + AndApplyCodeAction func(t *testing.T, expectedAction *CompletionsExpectedCodeAction) +} + // string | *Marker | []string | []*Marker type MarkerInput = any // !!! user preferences param // !!! completion context param -func (f *FourslashTest) VerifyCompletions(t *testing.T, markerInput MarkerInput, expected *CompletionsExpectedList) { +func (f *FourslashTest) VerifyCompletions(t *testing.T, markerInput MarkerInput, expected *CompletionsExpectedList) VerifyCompletionsResult { + var list *lsproto.CompletionList switch marker := markerInput.(type) { case string: f.GoToMarker(t, marker) - f.verifyCompletionsWorker(t, expected) + list = f.verifyCompletionsWorker(t, expected) case *Marker: f.goToMarker(t, marker) - f.verifyCompletionsWorker(t, expected) + list = f.verifyCompletionsWorker(t, expected) case []string: for _, markerName := range marker { f.GoToMarker(t, markerName) @@ -526,13 +585,45 @@ func (f *FourslashTest) VerifyCompletions(t *testing.T, markerInput MarkerInput, f.verifyCompletionsWorker(t, expected) } case nil: - f.verifyCompletionsWorker(t, expected) + list = f.verifyCompletionsWorker(t, expected) default: t.Fatalf("Invalid marker input type: %T. Expected string, *Marker, []string, or []*Marker.", markerInput) } + + return VerifyCompletionsResult{ + AndApplyCodeAction: func(t *testing.T, expectedAction *CompletionsExpectedCodeAction) { + item := core.Find(list.Items, func(item *lsproto.CompletionItem) bool { + if item.Label != expectedAction.Name || item.Data == nil { + return false + } + data, ok := (*item.Data).(*ls.CompletionItemData) + if !ok || data.AutoImport == nil { + return false + } + return data.AutoImport.ModuleSpecifier == expectedAction.Source + }) + if item == nil { + t.Fatalf("Code action '%s' from source '%s' not found in completions.", expectedAction.Name, expectedAction.Source) + } + assert.Check(t, strings.Contains(*item.Detail, expectedAction.Description), "Completion item detail does not contain expected description.") + f.applyTextEdits(t, *item.AdditionalTextEdits) + assert.Equal(t, f.getScriptInfo(f.activeFilename).content, expectedAction.NewFileContent, fmt.Sprintf("File content after applying code action '%s' did not match expected content.", expectedAction.Name)) + }, + } +} + +func (f *FourslashTest) verifyCompletionsWorker(t *testing.T, expected *CompletionsExpectedList) *lsproto.CompletionList { + prefix := f.getCurrentPositionPrefix() + var userPreferences *ls.UserPreferences + if expected != nil { + userPreferences = expected.UserPreferences + } + list := f.getCompletions(t, userPreferences) + f.verifyCompletionsResult(t, list, expected, prefix) + return list } -func (f *FourslashTest) verifyCompletionsWorker(t *testing.T, expected *CompletionsExpectedList) { +func (f *FourslashTest) getCompletions(t *testing.T, userPreferences *ls.UserPreferences) *lsproto.CompletionList { prefix := f.getCurrentPositionPrefix() params := &lsproto.CompletionParams{ TextDocument: lsproto.TextDocumentIdentifier{ @@ -541,6 +632,10 @@ func (f *FourslashTest) verifyCompletionsWorker(t *testing.T, expected *Completi Position: f.currentCaretPosition, Context: &lsproto.CompletionContext{}, } + if userPreferences != nil { + reset := f.ConfigureWithReset(t, userPreferences) + defer reset() + } resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentCompletionInfo, params) if resMsg == nil { t.Fatalf(prefix+"Nil response received for completion request", f.lastKnownMarkerName) @@ -548,7 +643,7 @@ func (f *FourslashTest) verifyCompletionsWorker(t *testing.T, expected *Completi if !resultOk { t.Fatalf(prefix+"Unexpected response type for completion request: %T", resMsg.AsResponse().Result) } - f.verifyCompletionsResult(t, result.List, expected, prefix) + return result.List } func (f *FourslashTest) verifyCompletionsResult( @@ -632,9 +727,9 @@ func (f *FourslashTest) verifyCompletionsItems(t *testing.T, prefix string, actu } return } - nameToActualItem := make(map[string]*lsproto.CompletionItem) + nameToActualItems := make(map[string][]*lsproto.CompletionItem) for _, item := range actual { - nameToActualItem[item.Label] = item + nameToActualItems[item.Label] = append(nameToActualItems[item.Label], item) } if expected.Unsorted != nil { if expected.Includes != nil { @@ -646,24 +741,30 @@ func (f *FourslashTest) verifyCompletionsItems(t *testing.T, prefix string, actu for _, item := range expected.Unsorted { switch item := item.(type) { case string: - _, ok := nameToActualItem[item] + _, ok := nameToActualItems[item] if !ok { t.Fatalf("%sLabel '%s' not found in actual items. Actual items: %s", prefix, item, cmp.Diff(actual, nil)) } - delete(nameToActualItem, item) + delete(nameToActualItems, item) case *lsproto.CompletionItem: - actualItem, ok := nameToActualItem[item.Label] + actualItems, ok := nameToActualItems[item.Label] if !ok { t.Fatalf("%sLabel '%s' not found in actual items. Actual items: %s", prefix, item.Label, cmp.Diff(actual, nil)) } - delete(nameToActualItem, item.Label) + actualItem := actualItems[0] + actualItems = actualItems[1:] + if len(actualItems) == 0 { + delete(nameToActualItems, item.Label) + } else { + nameToActualItems[item.Label] = actualItems + } f.verifyCompletionItem(t, prefix+"Includes completion item mismatch for label "+item.Label+": ", actualItem, item) default: t.Fatalf("%sExpected completion item to be a string or *lsproto.CompletionItem, got %T", prefix, item) } } if len(expected.Unsorted) != len(actual) { - unmatched := slices.Collect(maps.Keys(nameToActualItem)) + unmatched := slices.Collect(maps.Keys(nameToActualItems)) t.Fatalf("%sAdditional completions found but not included in 'unsorted': %s", prefix, strings.Join(unmatched, "\n")) } return @@ -672,15 +773,22 @@ func (f *FourslashTest) verifyCompletionsItems(t *testing.T, prefix string, actu for _, item := range expected.Includes { switch item := item.(type) { case string: - _, ok := nameToActualItem[item] + _, ok := nameToActualItems[item] if !ok { t.Fatalf("%sLabel '%s' not found in actual items. Actual items: %s", prefix, item, cmp.Diff(actual, nil)) } case *lsproto.CompletionItem: - actualItem, ok := nameToActualItem[item.Label] + actualItems, ok := nameToActualItems[item.Label] if !ok { t.Fatalf("%sLabel '%s' not found in actual items. Actual items: %s", prefix, item.Label, cmp.Diff(actual, nil)) } + actualItem := actualItems[0] + actualItems = actualItems[1:] + if len(actualItems) == 0 { + delete(nameToActualItems, item.Label) + } else { + nameToActualItems[item.Label] = actualItems + } f.verifyCompletionItem(t, prefix+"Includes completion item mismatch for label "+item.Label+": ", actualItem, item) default: t.Fatalf("%sExpected completion item to be a string or *lsproto.CompletionItem, got %T", prefix, item) @@ -688,7 +796,7 @@ func (f *FourslashTest) verifyCompletionsItems(t *testing.T, prefix string, actu } } for _, exclude := range expected.Excludes { - if _, ok := nameToActualItem[exclude]; ok { + if _, ok := nameToActualItems[exclude]; ok { t.Fatalf("%sLabel '%s' should not be in actual items but was found. Actual items: %s", prefix, exclude, cmp.Diff(actual, nil)) } } @@ -711,36 +819,80 @@ func (f *FourslashTest) verifyCompletionsAreExactly(t *testing.T, prefix string, } } -var completionIgnoreOpts = cmp.FilterPath( - func(p cmp.Path) bool { - switch p.Last().String() { - case ".Kind", ".SortText", ".Data": - return true - default: +func ignorePaths(paths ...string) cmp.Option { + return cmp.FilterPath( + func(p cmp.Path) bool { + for _, path := range paths { + if p.Last().String() == path { + return true + } + } return false - } - }, - cmp.Ignore(), + }, + cmp.Ignore(), + ) +} + +var ( + completionIgnoreOpts = ignorePaths(".Kind", ".SortText", ".FilterText", ".Data") + autoImportIgnoreOpts = ignorePaths(".Kind", ".SortText", ".FilterText", ".Data", ".LabelDetails", ".Detail", ".AdditionalTextEdits") ) func (f *FourslashTest) verifyCompletionItem(t *testing.T, prefix string, actual *lsproto.CompletionItem, expected *lsproto.CompletionItem) { - if expected.Detail != nil || expected.Documentation != nil { - resMsg, result, resultOk := sendRequest(t, f, lsproto.CompletionItemResolveInfo, actual) - if resMsg == nil { - t.Fatal(prefix + "Expected non-nil response for completion item resolve, got nil") + var actualAutoImportData, expectedAutoImportData *ls.AutoImportData + if actual.Data != nil { + if data, ok := (*actual.Data).(*ls.CompletionItemData); ok { + actualAutoImportData = data.AutoImport } - if !resultOk { - t.Fatalf(prefix+"Unexpected response type for completion item resolve: %T", resMsg.AsResponse().Result) + } + if expected.Data != nil { + if data, ok := (*expected.Data).(*ls.CompletionItemData); ok { + expectedAutoImportData = data.AutoImport + } + } + if (actualAutoImportData == nil) != (expectedAutoImportData == nil) { + t.Fatal(prefix + "Mismatch in auto-import data presence") + } + + if expected.Detail != nil || expected.Documentation != nil || actualAutoImportData != nil { + actual = f.resolveCompletionItem(t, actual) + } + + if actualAutoImportData != nil { + assertDeepEqual(t, actual, expected, prefix, autoImportIgnoreOpts) + if expected.AdditionalTextEdits == AnyTextEdits { + assert.Check(t, actual.AdditionalTextEdits != nil && len(*actual.AdditionalTextEdits) > 0, prefix+" Expected non-nil AdditionalTextEdits for auto-import completion item") } - actual = result + if expected.LabelDetails != nil { + assertDeepEqual(t, actual.LabelDetails, expected.LabelDetails, prefix+" LabelDetails mismatch") + } + + assert.Equal(t, actualAutoImportData.ModuleSpecifier, expectedAutoImportData.ModuleSpecifier, prefix+" ModuleSpecifier mismatch") + } else { + assertDeepEqual(t, actual, expected, prefix, completionIgnoreOpts) + } + + if expected.FilterText != nil { + assertDeepEqual(t, actual.FilterText, expected.FilterText, prefix+" FilterText mismatch") } - assertDeepEqual(t, actual, expected, prefix, completionIgnoreOpts) if expected.Kind != nil { assertDeepEqual(t, actual.Kind, expected.Kind, prefix+" Kind mismatch") } assertDeepEqual(t, actual.SortText, core.OrElse(expected.SortText, ptrTo(string(ls.SortTextLocationPriority))), prefix+" SortText mismatch") } +func (f *FourslashTest) resolveCompletionItem(t *testing.T, item *lsproto.CompletionItem) *lsproto.CompletionItem { + prefix := f.getCurrentPositionPrefix() + resMsg, result, resultOk := sendRequest(t, f, lsproto.CompletionItemResolveInfo, item) + if resMsg == nil { + t.Fatal(prefix + "Expected non-nil response for completion item resolve, got nil") + } + if !resultOk { + t.Fatalf(prefix+"Unexpected response type for completion item resolve: %T, Error: %v", resMsg.AsResponse().Result, resMsg.AsResponse().Error) + } + return result +} + func getExpectedLabel(t *testing.T, item CompletionsExpectedItem) string { switch item := item.(type) { case string: @@ -762,6 +914,68 @@ func assertDeepEqual(t *testing.T, actual any, expected any, prefix string, opts } } +type ApplyCodeActionFromCompletionOptions struct { + Name string + Source string + AutoImportData *ls.AutoImportData + Description string + NewFileContent *string + NewRangeContent *string + UserPreferences *ls.UserPreferences +} + +func (f *FourslashTest) VerifyApplyCodeActionFromCompletion(t *testing.T, markerName *string, options *ApplyCodeActionFromCompletionOptions) { + f.GoToMarker(t, *markerName) + var userPreferences *ls.UserPreferences + if options != nil && options.UserPreferences != nil { + userPreferences = options.UserPreferences + } else { + // Default preferences: enables auto-imports + userPreferences = ls.NewDefaultUserPreferences() + } + + reset := f.ConfigureWithReset(t, userPreferences) + defer reset() + completionsList := f.getCompletions(t, nil) // Already configured, so we do not need to pass it in again + item := core.Find(completionsList.Items, func(item *lsproto.CompletionItem) bool { + if item.Label != options.Name || item.Data == nil { + return false + } + data, ok := (*item.Data).(*ls.CompletionItemData) + if !ok { + return false + } + if options.AutoImportData != nil { + return data.AutoImport != nil && ((data.AutoImport.FileName == options.AutoImportData.FileName) && + (options.AutoImportData.ModuleSpecifier == "" || data.AutoImport.ModuleSpecifier == options.AutoImportData.ModuleSpecifier) && + (options.AutoImportData.ExportName == "" || data.AutoImport.ExportName == options.AutoImportData.ExportName) && + (options.AutoImportData.AmbientModuleName == nil || data.AutoImport.AmbientModuleName == options.AutoImportData.AmbientModuleName) && + (options.AutoImportData.IsPackageJsonImport == core.TSUnknown || data.AutoImport.IsPackageJsonImport == options.AutoImportData.IsPackageJsonImport)) + } + if data.AutoImport == nil && data.Source != "" && data.Source == options.Source { + return true + } + if data.AutoImport != nil && data.AutoImport.ModuleSpecifier == options.Source { + return true + } + return false + }) + if item == nil { + t.Fatalf("Code action '%s' from source '%s' not found in completions.", options.Name, options.Source) + } + item = f.resolveCompletionItem(t, item) + assert.Check(t, strings.Contains(*item.Detail, options.Description), "Completion item detail does not contain expected description.") + if item.AdditionalTextEdits == nil { + t.Fatalf("Expected non-nil AdditionalTextEdits for code action completion item.") + } + f.applyTextEdits(t, *item.AdditionalTextEdits) + if options.NewFileContent != nil { + assert.Equal(t, f.getScriptInfo(f.activeFilename).content, *options.NewFileContent, "File content after applying code action did not match expected content.") + } else if options.NewRangeContent != nil { + t.Fatal("!!! TODO") + } +} + func (f *FourslashTest) VerifyBaselineFindAllReferences( t *testing.T, markers ...string, @@ -852,6 +1066,55 @@ func (f *FourslashTest) VerifyBaselineGoToDefinition( } } +func (f *FourslashTest) VerifyBaselineGoToTypeDefinition( + t *testing.T, + markers ...string, +) { + referenceLocations := f.lookupMarkersOrGetRanges(t, markers) + + for _, markerOrRange := range referenceLocations { + // worker in `baselineEachMarkerOrRange` + f.GoToMarkerOrRange(t, markerOrRange) + + params := &lsproto.TypeDefinitionParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: ls.FileNameToDocumentURI(f.activeFilename), + }, + Position: f.currentCaretPosition, + } + + resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentTypeDefinitionInfo, params) + if resMsg == nil { + if f.lastKnownMarkerName == nil { + t.Fatalf("Nil response received for type definition request at pos %v", f.currentCaretPosition) + } else { + t.Fatalf("Nil response received for type definition request at marker '%s'", *f.lastKnownMarkerName) + } + } + if !resultOk { + if f.lastKnownMarkerName == nil { + t.Fatalf("Unexpected type definition response type at pos %v: %T", f.currentCaretPosition, resMsg.AsResponse().Result) + } else { + t.Fatalf("Unexpected type definition response type at marker '%s': %T", *f.lastKnownMarkerName, resMsg.AsResponse().Result) + } + } + + var resultAsLocations []lsproto.Location + if result.Locations != nil { + resultAsLocations = *result.Locations + } else if result.Location != nil { + resultAsLocations = []lsproto.Location{*result.Location} + } else if result.DefinitionLinks != nil { + t.Fatalf("Unexpected type definition response type at marker '%s': %T", *f.lastKnownMarkerName, result.DefinitionLinks) + } + + f.addResultToBaseline(t, "goToType", f.getBaselineForLocationsWithFileContents(resultAsLocations, baselineFourslashLocationsOptions{ + marker: markerOrRange, + markerName: "/*GOTO TYPE*/", + })) + } +} + func (f *FourslashTest) VerifyBaselineHover(t *testing.T) { markersAndItems := core.MapFiltered(f.Markers(), func(marker *Marker) (markerAndItem[*lsproto.Hover], bool) { if marker.Name == nil { @@ -1031,6 +1294,149 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { } } +func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { + markers := f.Markers() + var result strings.Builder + newLine := "\n" + + for i, marker := range markers { + if i > 0 { + result.WriteString(newLine + strings.Repeat("=", 80) + newLine + newLine) + } + + script := f.getScriptInfo(marker.FileName()) + fileContent := script.content + + // Add the marker position indicator + markerPos := marker.Position + baselineContent := fileContent[:markerPos] + "/**/" + fileContent[markerPos:] + newLine + result.WriteString(baselineContent) + + // Get selection ranges at this marker + params := &lsproto.SelectionRangeParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: ls.FileNameToDocumentURI(marker.FileName()), + }, + Positions: []lsproto.Position{marker.LSPosition}, + } + + resMsg, selectionRangeResult, resultOk := sendRequest(t, f, lsproto.TextDocumentSelectionRangeInfo, params) + markerNameStr := *core.OrElse(marker.Name, ptrTo("(unnamed)")) + if resMsg == nil { + t.Fatalf("Nil response received for selection range request at marker '%s'", markerNameStr) + } + if !resultOk { + if resMsg.AsResponse().Error != nil { + t.Fatalf("Error response for selection range request at marker '%s': %v", markerNameStr, resMsg.AsResponse().Error) + } + t.Fatalf("Unexpected selection range response type at marker '%s': %T", markerNameStr, resMsg.AsResponse().Result) + } + + if selectionRangeResult.SelectionRanges == nil || len(*selectionRangeResult.SelectionRanges) == 0 { + result.WriteString("No selection ranges available\n") + continue + } + + selectionRange := (*selectionRangeResult.SelectionRanges)[0] + + // Add blank line after source code section + result.WriteString(newLine) + + // Walk through the selection range chain + for selectionRange != nil { + start := int(f.converters.LineAndCharacterToPosition(script, selectionRange.Range.Start)) + end := int(f.converters.LineAndCharacterToPosition(script, selectionRange.Range.End)) + + // Create a masked version of the file showing only this range + runes := []rune(fileContent) + masked := make([]rune, len(runes)) + for i, ch := range runes { + if i >= start && i < end { + // Keep characters in the selection range + if ch == ' ' { + masked[i] = 'â€ĸ' + } else if ch == '\n' || ch == '\r' { + masked[i] = ch // Keep line breaks as-is, will add arrow later + } else { + masked[i] = ch + } + } else { + // Replace characters outside the range + if ch == '\n' || ch == '\r' { + masked[i] = ch + } else { + masked[i] = ' ' + } + } + } + + maskedStr := string(masked) + + // Add line break arrows + maskedStr = strings.ReplaceAll(maskedStr, "\n", "↲\n") + maskedStr = strings.ReplaceAll(maskedStr, "\r", "↲\r") + + // Remove blank lines + lines := strings.Split(maskedStr, "\n") + var nonBlankLines []string + for _, line := range lines { + trimmed := strings.TrimSpace(line) + if trimmed != "" && trimmed != "↲" { + nonBlankLines = append(nonBlankLines, line) + } + } + maskedStr = strings.Join(nonBlankLines, "\n") + + // Find leading and trailing width of non-whitespace characters + maskedRunes := []rune(maskedStr) + isRealCharacter := func(ch rune) bool { + return ch != 'â€ĸ' && ch != '↲' && !stringutil.IsWhiteSpaceLike(ch) + } + + leadingWidth := -1 + for i, ch := range maskedRunes { + if isRealCharacter(ch) { + leadingWidth = i + break + } + } + + trailingWidth := -1 + for j := len(maskedRunes) - 1; j >= 0; j-- { + if isRealCharacter(maskedRunes[j]) { + trailingWidth = j + break + } + } + + if leadingWidth != -1 && trailingWidth != -1 && leadingWidth <= trailingWidth { + // Clean up middle section + prefix := string(maskedRunes[:leadingWidth]) + middle := string(maskedRunes[leadingWidth : trailingWidth+1]) + suffix := string(maskedRunes[trailingWidth+1:]) + + middle = strings.ReplaceAll(middle, "â€ĸ", " ") + middle = strings.ReplaceAll(middle, "↲", "") + + maskedStr = prefix + middle + suffix + } + + // Add blank line before multi-line ranges + if strings.Contains(maskedStr, "\n") { + result.WriteString(newLine) + } + + result.WriteString(maskedStr) + if !strings.HasSuffix(maskedStr, "\n") { + result.WriteString(newLine) + } + + selectionRange = selectionRange.Parent + } + } + f.addResultToBaseline(t, "Smart Selection", strings.TrimSuffix(result.String(), "\n")) +} + func (f *FourslashTest) VerifyBaselineDocumentHighlights( t *testing.T, preferences *ls.UserPreferences, @@ -1197,6 +1603,22 @@ func (f *FourslashTest) getSelection() core.TextRange { ) } +func (f *FourslashTest) applyTextEdits(t *testing.T, edits []*lsproto.TextEdit) { + script := f.getScriptInfo(f.activeFilename) + slices.SortFunc(edits, func(a, b *lsproto.TextEdit) int { + aStart := f.converters.LineAndCharacterToPosition(script, a.Range.Start) + bStart := f.converters.LineAndCharacterToPosition(script, b.Range.Start) + return int(aStart) - int(bStart) + }) + // Apply edits in reverse order to avoid affecting the positions of earlier edits. + for i := len(edits) - 1; i >= 0; i-- { + edit := edits[i] + start := int(f.converters.LineAndCharacterToPosition(script, edit.Range.Start)) + end := int(f.converters.LineAndCharacterToPosition(script, edit.Range.End)) + f.editScriptAndUpdateMarkers(t, f.activeFilename, start, end, edit.NewText) + } +} + func (f *FourslashTest) Replace(t *testing.T, start int, length int, text string) { f.editScriptAndUpdateMarkers(t, f.activeFilename, start, start+length, text) // f.checkPostEditInvariants() // !!! do we need this? @@ -1449,6 +1871,12 @@ func (f *FourslashTest) getCurrentPositionPrefix() string { } func (f *FourslashTest) BaselineAutoImportsCompletions(t *testing.T, markerNames []string) { + reset := f.ConfigureWithReset(t, &ls.UserPreferences{ + IncludeCompletionsForModuleExports: core.TSTrue, + IncludeCompletionsForImportStatements: core.TSTrue, + }) + defer reset() + for _, markerName := range markerNames { f.GoToMarker(t, markerName) params := &lsproto.CompletionParams{ @@ -1508,7 +1936,7 @@ func (f *FourslashTest) BaselineAutoImportsCompletions(t *testing.T, markerNames t.Fatalf(prefix+"Nil response received for resolve completion", f.lastKnownMarkerName) } if !resultOk { - t.Fatalf(prefix+"Unexpected response type for resolve completion: %T", resMsg.AsResponse().Result) + t.Fatalf(prefix+"Unexpected response type for resolve completion: %T, Error: %v", resMsg.AsResponse().Result, resMsg.AsResponse().Error) } if details == nil || details.AdditionalTextEdits == nil || len(*details.AdditionalTextEdits) == 0 { t.Fatalf(prefix+"Entry %s from %s returned no code changes from completion details request", item.Label, item.Detail) @@ -1742,3 +2170,7 @@ func (f *FourslashTest) verifyBaselines(t *testing.T) { baseline.Run(t, getBaselineFileName(t, command), content.String(), getBaselineOptions(command)) } } + +type anyTextEdits *[]*lsproto.TextEdit + +var AnyTextEdits = anyTextEdits(nil) diff --git a/internal/fourslash/tests/autoImportCompletion_test.go b/internal/fourslash/tests/autoImportCompletion_test.go index 7c5aeaf356..078eeac2c8 100644 --- a/internal/fourslash/tests/autoImportCompletion_test.go +++ b/internal/fourslash/tests/autoImportCompletion_test.go @@ -40,6 +40,21 @@ a/**/ }, }) f.BaselineAutoImportsCompletions(t, []string{""}) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + UserPreferences: &ls.UserPreferences{ + // completion autoimport preferences off; this tests if fourslash server communication correctly registers changes in user preferences + IncludeCompletionsForModuleExports: core.TSUnknown, + IncludeCompletionsForImportStatements: core.TSUnknown, + }, + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Excludes: []string{"anotherVar"}, + }, + }) } func TestAutoImportCompletion2(t *testing.T) { diff --git a/internal/fourslash/tests/autoImportQuoteDetection_test.go b/internal/fourslash/tests/autoImportQuoteDetection_test.go new file mode 100644 index 0000000000..a9a6ade067 --- /dev/null +++ b/internal/fourslash/tests/autoImportQuoteDetection_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportQuoteDetection(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +export const foo = 0; +// @Filename: /b.ts +import {} from 'node:path'; + +fo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import {} from 'node:path'; +import { foo } from './a'; + +fo`), + }) +} diff --git a/internal/fourslash/tests/basicQuickInfo_test.go b/internal/fourslash/tests/basicQuickInfo_test.go index 44e80c9a6f..f207771e24 100644 --- a/internal/fourslash/tests/basicQuickInfo_test.go +++ b/internal/fourslash/tests/basicQuickInfo_test.go @@ -28,5 +28,5 @@ class Foo/*3*/ { ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyQuickInfoAt(t, "1", "var someVar: number", "Some var") - f.VerifyQuickInfoAt(t, "2", "var otherVar: number", "Other var\nSee `someVar`") + f.VerifyQuickInfoAt(t, "2", "var otherVar: number", "Other var\nSee [someVar](file:///basicQuickInfo.ts#4,5-4,12)") } diff --git a/internal/fourslash/tests/gen/autoImportCompletionAmbientMergedModule1_test.go b/internal/fourslash/tests/gen/autoImportCompletionAmbientMergedModule1_test.go new file mode 100644 index 0000000000..273f99b13e --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionAmbientMergedModule1_test.go @@ -0,0 +1,78 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionAmbientMergedModule1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +// @module: commonjs +// @filename: /node_modules/@types/vscode/index.d.ts +declare module "vscode" { + export class Position { + readonly line: number; + readonly character: number; + } +} +// @filename: src/motion.ts +import { Position } from "vscode"; + +export abstract class MoveQuoteMatch { + public override async execActionWithCount( + position: Position, + ): Promise {} +} + +declare module "vscode" { + interface Position { + toString(): string; + } +} +// @filename: src/smartQuotes.ts +import { MoveQuoteMatch } from "./motion"; + +export class MoveInsideNextQuote extends MoveQuoteMatch {/*1*/ + keys = ["i", "n", "q"]; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "execActionWithCount", + InsertText: PtrTo("public execActionWithCount(position: Position): Promise {\n}"), + FilterText: PtrTo("execActionWithCount"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + Source: "ClassMemberSnippet/", + })), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "execActionWithCount", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'execActionWithCount'", + NewFileContent: PtrTo(`import { Position } from "vscode"; +import { MoveQuoteMatch } from "./motion"; + +export class MoveInsideNextQuote extends MoveQuoteMatch { + keys = ["i", "n", "q"]; +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportEqualsWithDefault1_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportEqualsWithDefault1_test.go new file mode 100644 index 0000000000..e5036d3293 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportEqualsWithDefault1_test.go @@ -0,0 +1,104 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportEqualsWithDefault1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @filename: node.ts +import Container from "./container.js"; +import Document from "./document.js"; + +declare namespace Node { + class Node extends Node_ {} + + export { Node as default }; +} + +declare abstract class Node_ { + parent: Container | Document | undefined; +} + +declare class Node extends Node_ {} + +export = Node; +// @filename: document.ts +import Container from "./container.js"; + +declare namespace Document { + export { Document_ as default }; +} + +declare class Document_ extends Container {} + +declare class Document extends Document_ {} + +export = Document; +// @filename: container.ts +import Node from "./node.js"; + +declare namespace Container { + export { Container_ as default }; +} + +declare abstract class Container_ extends Node { + p/*1*/ +} + +declare class Container extends Container_ {} + +export = Container;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "parent", + InsertText: PtrTo("parent: Container_ | Document_ | undefined;"), + FilterText: PtrTo("parent"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + Source: "ClassMemberSnippet/", + })), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "parent", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'parent'", + NewFileContent: PtrTo(`import Document_ from "./document.js"; +import Node from "./node.js"; + +declare namespace Container { + export { Container_ as default }; +} + +declare abstract class Container_ extends Node { + p +} + +declare class Container extends Container_ {} + +export = Container;`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation1_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation1_test.go new file mode 100644 index 0000000000..725856e637 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation1_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportListAugmentation1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /node_modules/@sapphire/pieces/index.d.ts +interface Container { + stores: unknown; +} + +declare class Piece { + container: Container; +} + +export { Piece, type Container }; +// @FileName: /augmentation.ts +declare module "@sapphire/pieces" { + interface Container { + client: unknown; + } + export { Container }; +} +// @Filename: /index.ts +import { Piece } from "@sapphire/pieces"; +class FullPiece extends Piece { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "container", + InsertText: PtrTo("container: Container;"), + FilterText: PtrTo("container"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + Source: "ClassMemberSnippet/", + })), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "container", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'container'", + NewFileContent: PtrTo(`import { Container, Piece } from "@sapphire/pieces"; +class FullPiece extends Piece { + +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation2_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation2_test.go new file mode 100644 index 0000000000..34b6d1c7eb --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation2_test.go @@ -0,0 +1,80 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportListAugmentation2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /node_modules/@sapphire/pieces/index.d.ts +interface Container { + stores: unknown; +} + +declare class Piece { + get container(): Container; +} + +declare class AliasPiece extends Piece {} + +export { AliasPiece, type Container }; +// @Filename: /node_modules/@sapphire/framework/index.d.ts +import { AliasPiece } from "@sapphire/pieces"; + +declare class Command extends AliasPiece {} + +declare module "@sapphire/pieces" { + interface Container { + client: unknown; + } +} + +export { Command }; +// @Filename: /index.ts +import "@sapphire/pieces"; +import { Command } from "@sapphire/framework"; +class PingCommand extends Command { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "container", + InsertText: PtrTo("get container(): Container {\n}"), + FilterText: PtrTo("container"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + Source: "ClassMemberSnippet/", + })), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "container", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'container'", + NewFileContent: PtrTo(`import "@sapphire/pieces"; +import { Command } from "@sapphire/framework"; +import { Container } from "@sapphire/pieces"; +class PingCommand extends Command { + +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation3_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation3_test.go new file mode 100644 index 0000000000..1877ab0244 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation3_test.go @@ -0,0 +1,69 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportListAugmentation3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /node_modules/@sapphire/pieces/index.d.ts +export interface Container { + stores: unknown; +} + +declare class Piece { + container: Container; +} + +export { Piece }; +// @FileName: /augmentation.ts +declare module "@sapphire/pieces" { + interface Container { + client: unknown; + } +} +// @Filename: /index.ts +import { Piece } from "@sapphire/pieces"; +class FullPiece extends Piece { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "container", + InsertText: PtrTo("container: Container;"), + FilterText: PtrTo("container"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + Source: "ClassMemberSnippet/", + })), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "container", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'container'", + NewFileContent: PtrTo(`import { Container, Piece } from "@sapphire/pieces"; +class FullPiece extends Piece { + +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation4_test.go b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation4_test.go new file mode 100644 index 0000000000..b64b116e1b --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportCompletionExportListAugmentation4_test.go @@ -0,0 +1,78 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportCompletionExportListAugmentation4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /node_modules/@sapphire/pieces/index.d.ts +interface Container { + stores: unknown; +} + +declare class Piece { + get container(): Container; +} + +export { Piece as Alias, type Container }; +// @Filename: /node_modules/@sapphire/framework/index.d.ts +import { Alias } from "@sapphire/pieces"; + +declare class Command extends Alias {} + +declare module "@sapphire/pieces" { + interface Container { + client: unknown; + } +} + +export { Command as CommandAlias }; +// @Filename: /index.ts +import "@sapphire/pieces"; +import { CommandAlias } from "@sapphire/framework"; +class PingCommand extends CommandAlias { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "container", + InsertText: PtrTo("get container(): Container {\n}"), + FilterText: PtrTo("container"), + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + Source: "ClassMemberSnippet/", + })), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "container", + Source: "ClassMemberSnippet/", + Description: "Includes imports of types referenced by 'container'", + NewFileContent: PtrTo(`import "@sapphire/pieces"; +import { CommandAlias } from "@sapphire/framework"; +import { Container } from "@sapphire/pieces"; +class PingCommand extends CommandAlias { + +}`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportFileExcludePatterns3_test.go b/internal/fourslash/tests/gen/autoImportFileExcludePatterns3_test.go new file mode 100644 index 0000000000..e693dda53e --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportFileExcludePatterns3_test.go @@ -0,0 +1,71 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportFileExcludePatterns3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: /ambient1.d.ts +declare module "foo" { + export const x = 1; +} +// @Filename: /ambient2.d.ts +declare module "foo" { + export const y = 2; +} +// @Filename: /index.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "foo", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "y", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "foo", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobals, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportPathsAliasesAndBarrels_test.go b/internal/fourslash/tests/gen/autoImportPathsAliasesAndBarrels_test.go new file mode 100644 index 0000000000..3848049ba1 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportPathsAliasesAndBarrels_test.go @@ -0,0 +1,83 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportPathsAliasesAndBarrels(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json + { + "compilerOptions": { + "module": "commonjs", + "paths": { + "~/*": ["src/*"] + } + } +} +// @Filename: /src/dirA/index.ts + export * from "./thing1A"; + export * from "./thing2A"; +// @Filename: /src/dirA/thing1A.ts + export class Thing1A {} + Thing/**/ +// @Filename: /src/dirA/thing2A.ts + export class Thing2A {} +// @Filename: /src/dirB/index.ts + export * from "./thing1B"; + export * from "./thing2B"; +// @Filename: /src/dirB/thing1B.ts + export class Thing1B {} +// @Filename: /src/dirB/thing2B.ts + export class Thing2B {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Thing2A", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./thing2A", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "Thing1B", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "~/dirB", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "Thing2B", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "~/dirB", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider6_test.go b/internal/fourslash/tests/gen/autoImportProvider6_test.go new file mode 100644 index 0000000000..eeb92339c0 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider6_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ "compilerOptions": { "module": "commonjs", "lib": ["es2019"] } } +// @Filename: /home/src/workspaces/project/package.json +{ "dependencies": { "antd": "*", "react": "*" } } +// @Filename: /home/src/workspaces/project/node_modules/@types/react/index.d.ts +export declare function Component(): void; +// @Filename: /home/src/workspaces/project/node_modules/antd/index.d.ts +import "react"; +// @Filename: /home/src/workspaces/project/index.ts +Component/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Component", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap1_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap1_test.go new file mode 100644 index 0000000000..82b994d822 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap1_test.go @@ -0,0 +1,83 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + ".": { + "types": "./lib/index.d.ts" + }, + "./lol": { + "types": "./lib/lol.d.ts" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap2_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap2_test.go new file mode 100644 index 0000000000..57eb4b8e9a --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap2_test.go @@ -0,0 +1,76 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs" + "moduleResolution": "node10", + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "types": "./lib/index.d.ts", + "exports": { + ".": { + "types": "./lib/index.d.ts" + }, + "./lol": { + "types": "./lib/lol.d.ts" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap3_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap3_test.go new file mode 100644 index 0000000000..8f44b395be --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap3_test.go @@ -0,0 +1,69 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "name": "dependency", + "version": "1.0.0", + "main": "./lib/index.js", + "exports": "./lib/lol.d.ts" +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromIndex", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap4_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap4_test.go new file mode 100644 index 0000000000..9df1a5a2fd --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap4_test.go @@ -0,0 +1,72 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + "types": "./lib/index.d.ts", + "require": "./lib/lol.js" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromLol", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap5_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap5_test.go new file mode 100644 index 0000000000..7e92a21a2b --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap5_test.go @@ -0,0 +1,94 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap5(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @types package lookup +// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + ".": "./lib/index.js", + "./lol": "./lib/lol.js" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.js +export function fooFromIndex() {} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.js +export function fooFromLol() {} +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/package.json +{ + "type": "module", + "name": "@types/dependency", + "version": "1.0.0", + "exports": { + ".": "./lib/index.d.ts", + "./lol": "./lib/lol.d.ts" + } +} +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/index.d.ts +export declare function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/lol.d.ts +export declare function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap6_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap6_test.go new file mode 100644 index 0000000000..47d78b34d8 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap6_test.go @@ -0,0 +1,101 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap6(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @types package should be ignored because implementation package has types +// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + }, + "devDependencies": { + "@types/dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + ".": "./lib/index.js", + "./lol": "./lib/lol.js" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.js +export function fooFromIndex() {} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export declare function fooFromIndex(): void +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.js +export function fooFromLol() {} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export declare function fooFromLol(): void +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/package.json +{ + "type": "module", + "name": "@types/dependency", + "version": "1.0.0", + "exports": { + ".": "./lib/index.d.ts", + "./lol": "./lib/lol.d.ts" + } +} +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/index.d.ts +export declare function fooFromAtTypesIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/@types/dependency/lib/lol.d.ts +export declare function fooFromAtTypesLol(): void; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap7_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap7_test.go new file mode 100644 index 0000000000..7088378a8e --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap7_test.go @@ -0,0 +1,85 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap7(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + ".": { + "types": "./lib/index.d.ts" + }, + "./lol": { + "types": "./lib/lol.d.ts" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/bar.ts +import { fooFromIndex } from "dependency"; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap8_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap8_test.go new file mode 100644 index 0000000000..c31f19f053 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap8_test.go @@ -0,0 +1,103 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap8(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + "./lol": { + "import": "./lib/index.js", + "require": "./lib/lol.js" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/bar.ts +import { fooFromIndex } from "dependency"; +// @Filename: /home/src/workspaces/project/src/foo.cts +fooFrom/*cts*/ +// @Filename: /home/src/workspaces/project/src/foo.mts +fooFrom/*mts*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "cts") + f.VerifyCompletions(t, "cts", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromLol", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromIndex", + }, + }, + }) + f.GoToMarker(t, "mts") + f.VerifyCompletions(t, "mts", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromLol", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_exportMap9_test.go b/internal/fourslash/tests/gen/autoImportProvider_exportMap9_test.go new file mode 100644 index 0000000000..dd90f2c0fa --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_exportMap9_test.go @@ -0,0 +1,73 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_exportMap9(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "dependency": "^1.0.0" + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/package.json +{ + "type": "module", + "name": "dependency", + "version": "1.0.0", + "exports": { + "./lol": ["./lib/index.js", "./lib/lol.js"] + } +} +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/index.d.ts +export function fooFromIndex(): void; +// @Filename: /home/src/workspaces/project/node_modules/dependency/lib/lol.d.ts +export function fooFromLol(): void; +// @Filename: /home/src/workspaces/project/src/bar.ts +import { fooFromIndex } from "dependency"; +// @Filename: /home/src/workspaces/project/src/foo.ts +fooFrom/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooFromIndex", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dependency/lol", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + Excludes: []string{ + "fooFromLol", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_globalTypingsCache_test.go b/internal/fourslash/tests/gen/autoImportProvider_globalTypingsCache_test.go new file mode 100644 index 0000000000..e4c20f6b8c --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_globalTypingsCache_test.go @@ -0,0 +1,57 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_globalTypingsCache(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/Library/Caches/typescript/node_modules/@types/react-router-dom/package.json + { "name": "@types/react-router-dom", "version": "16.8.4", "types": "index.d.ts" } +// @Filename: /home/src/Library/Caches/typescript/node_modules/@types/react-router-dom/index.d.ts + export class BrowserRouterFromDts {} +// @Filename: /home/src/workspaces/project/package.json + { "dependencies": { "react-router-dom": "*" } } +// @Filename: /home/src/workspaces/project/tsconfig.json + { "compilerOptions": { "module": "commonjs", "allowJs": true, "checkJs": true, "maxNodeModuleJsDepth": 2 }, "typeAcquisition": { "enable": true } } +// @Filename: /home/src/workspaces/project/node_modules/react-router-dom/package.json + { "name": "react-router-dom", "version": "16.8.4", "main": "index.js" } +// @Filename: /home/src/workspaces/project/node_modules/react-router-dom/index.js + import "./BrowserRouter"; + export {}; +// @Filename: /home/src/workspaces/project/node_modules/react-router-dom/BrowserRouter.js + export const BrowserRouterFromJs = () => null; +// @Filename: /home/src/workspaces/project/index.js +BrowserRouter/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsInJSPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "BrowserRouterFromDts", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react-router-dom", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_namespaceSameNameAsIntrinsic_test.go b/internal/fourslash/tests/gen/autoImportProvider_namespaceSameNameAsIntrinsic_test.go new file mode 100644 index 0000000000..958cb934c0 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_namespaceSameNameAsIntrinsic_test.go @@ -0,0 +1,57 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_namespaceSameNameAsIntrinsic(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/node_modules/fp-ts/package.json +{ "name": "fp-ts", "version": "0.10.4" } +// @Filename: /home/src/workspaces/project/node_modules/fp-ts/index.d.ts +export * as string from "./lib/string"; +// @Filename: /home/src/workspaces/project/node_modules/fp-ts/lib/string.d.ts +export declare const fromString: (s: string) => string; +export type SafeString = string; +// @Filename: /home/src/workspaces/project/package.json +{ "dependencies": { "fp-ts": "^0.10.4" } } +// @Filename: /home/src/workspaces/project/tsconfig.json +{ "compilerOptions": { "module": "commonjs" } } +// @Filename: /home/src/workspaces/project/index.ts +type A = { name: string/**/ }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "string", + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + &lsproto.CompletionItem{ + Label: "string", + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "fp-ts", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_wildcardExports1_test.go b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports1_test.go new file mode 100644 index 0000000000..4a12fc1dde --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports1_test.go @@ -0,0 +1,122 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_wildcardExports1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/node_modules/pkg/package.json +{ + "name": "pkg", + "version": "1.0.0", + "exports": { + "./*": "./a/*.js", + "./b/*.js": "./b/*.js", + "./c/*": "./c/*", + "./d/*": { + "import": "./d/*.mjs" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/pkg/a/a1.d.ts +export const a1: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/b/b1.d.ts +export const b1: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/b/b2.d.mts +export const NOT_REACHABLE: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/c/c1.d.ts +export const c1: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/c/subfolder/c2.d.mts +export const c2: number; +// @Filename: /home/src/workspaces/project/node_modules/pkg/d/d1.d.mts +export const d1: number; +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "pkg": "1.0.0" + } +} +// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/main.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "a1", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "pkg/a1", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "b1", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "pkg/b/b1.js", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "c1", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "pkg/c/c1.js", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "c2", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "pkg/c/subfolder/c2.mjs", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "d1", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "pkg/d/d1", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "NOT_REACHABLE", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_wildcardExports2_test.go b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports2_test.go new file mode 100644 index 0000000000..efaa6244a9 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports2_test.go @@ -0,0 +1,67 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_wildcardExports2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/node_modules/pkg/package.json +{ + "name": "pkg", + "version": "1.0.0", + "exports": { + "./core/*": { + "types": "./lib/core/*.d.ts", + "default": "./lib/core/*.js" + } + } +} +// @Filename: /home/src/workspaces/project/node_modules/pkg/lib/core/test.d.ts +export function test(): void; +// @Filename: /home/src/workspaces/project/package.json +{ + "type": "module", + "dependencies": { + "pkg": "1.0.0" + } +} +// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "nodenext" + } +} +// @Filename: /home/src/workspaces/project/main.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "test", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "pkg/core/test", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportProvider_wildcardExports3_test.go b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports3_test.go new file mode 100644 index 0000000000..ac0430073b --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportProvider_wildcardExports3_test.go @@ -0,0 +1,71 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportProvider_wildcardExports3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/packages/ui/package.json +{ + "name": "@repo/ui", + "version": "1.0.0", + "exports": { + "./*": "./src/*.tsx" + } +} +// @Filename: /home/src/workspaces/project/packages/ui/src/Card.tsx +export const Card = () => null; +// @Filename: /home/src/workspaces/project/apps/web/package.json +{ + "name": "web", + "version": "1.0.0", + "dependencies": { + "@repo/ui": "workspace:*" + } +} +// @Filename: /home/src/workspaces/project/apps/web/tsconfig.json +{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "noEmit": true, + "jsx": "preserve" + }, + "include": ["app"] +} +// @Filename: /home/src/workspaces/project/apps/web/app/index.tsx +(); +// @link: /home/src/workspaces/project/packages/ui -> /home/src/workspaces/project/apps/web/node_modules/@repo/ui` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Card", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "@repo/ui/Card", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportReExportFromAmbientModule_test.go b/internal/fourslash/tests/gen/autoImportReExportFromAmbientModule_test.go new file mode 100644 index 0000000000..a685a1a371 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportReExportFromAmbientModule_test.go @@ -0,0 +1,76 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportReExportFromAmbientModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ + "compilerOptions": { + "module": "commonjs" + } +} +// @Filename: /home/src/workspaces/project/node_modules/@types/node/index.d.ts +declare module "fs" { + export function accessSync(path: string): void; +} +// @Filename: /home/src/workspaces/project/node_modules/@types/fs-extra/index.d.ts +export * from "fs"; +// @Filename: /home/src/workspaces/project/index.ts +access/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "accessSync", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "fs", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "accessSync", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "fs-extra", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "accessSync", + Source: "fs-extra", + Description: "Add import from \"fs-extra\"", + NewFileContent: PtrTo(`import { accessSync } from "fs-extra"; + +access`), + AutoImportData: &ls.AutoImportData{ + ExportName: "accessSync", + FileName: "/home/src/workspaces/project/node_modules/@types/fs-extra/index.d.ts", + ModuleSpecifier: "fs-extra", + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportSameNameDefaultExported_test.go b/internal/fourslash/tests/gen/autoImportSameNameDefaultExported_test.go new file mode 100644 index 0000000000..1c4e6a85be --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportSameNameDefaultExported_test.go @@ -0,0 +1,59 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportSameNameDefaultExported(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: /node_modules/antd/index.d.ts +declare function Table(): void; +export default Table; +// @Filename: /node_modules/rc-table/index.d.ts +declare function Table(): void; +export default Table; +// @Filename: /index.ts +Table/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Table", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "antd", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + &lsproto.CompletionItem{ + Label: "Table", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "rc-table", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportSortCaseSensitivity2_test.go b/internal/fourslash/tests/gen/autoImportSortCaseSensitivity2_test.go new file mode 100644 index 0000000000..ff585d978d --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportSortCaseSensitivity2_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportSortCaseSensitivity2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export interface HasBar { bar: number } +export function hasBar(x: unknown): x is HasBar { return x && typeof x.bar === "number" } +export function foo() {} +export type __String = string; +// @Filename: /b.ts +import { __String, HasBar, hasBar } from "./a"; +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import { __String, foo, HasBar, hasBar } from "./a"; +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/autoImportTypeOnlyPreferred1_test.go b/internal/fourslash/tests/gen/autoImportTypeOnlyPreferred1_test.go new file mode 100644 index 0000000000..3a89a0273c --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportTypeOnlyPreferred1_test.go @@ -0,0 +1,63 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportTypeOnlyPreferred1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @verbatimModuleSyntax: true +// @module: esnext +// @moduleResolution: bundler +// @Filename: /ts.d.ts +declare namespace ts { + interface SourceFile { + text: string; + } + function createSourceFile(): SourceFile; +} +export = ts; +// @Filename: /types.ts +export interface VFS { + getSourceFile(path: string): ts/**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "ts", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./ts", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }).AndApplyCodeAction(t, &fourslash.CompletionsExpectedCodeAction{ + Name: "ts", + Source: "./ts", + Description: "Add import from \"./ts\"", + NewFileContent: `import type ts from "./ts"; + +export interface VFS { + getSourceFile(path: string): ts +}`, + }) +} diff --git a/internal/fourslash/tests/gen/autoImportVerbatimTypeOnly1_test.go b/internal/fourslash/tests/gen/autoImportVerbatimTypeOnly1_test.go new file mode 100644 index 0000000000..6d8622d386 --- /dev/null +++ b/internal/fourslash/tests/gen/autoImportVerbatimTypeOnly1_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestAutoImportVerbatimTypeOnly1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @verbatimModuleSyntax: true +// @Filename: /mod.ts +export const value = 0; +export class C { constructor(v: any) {} } +export interface I {} +// @Filename: /a.mts +const x: /**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "I", + Source: "./mod", + Description: "Add import from \"./mod.js\"", + AutoImportData: &ls.AutoImportData{ + ExportName: "I", + FileName: "/mod.ts", + ModuleSpecifier: "./mod.js", + }, + NewFileContent: PtrTo(`import type { I } from "./mod.js"; + +const x: `), + }) + f.Insert(t, "I = new C") + f.VerifyApplyCodeActionFromCompletion(t, nil, &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "C", + Source: "./mod", + Description: "Update import from \"./mod.js\"", + AutoImportData: &ls.AutoImportData{ + ExportName: "C", + FileName: "/mod.ts", + ModuleSpecifier: "./mod.js", + }, + NewFileContent: PtrTo(`import { C, type I } from "./mod.js"; + +const x: I = new C`), + }) +} diff --git a/internal/fourslash/tests/gen/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved_test.go b/internal/fourslash/tests/gen/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved_test.go index 3f67b274df..3f78988212 100644 --- a/internal/fourslash/tests/gen/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved_test.go +++ b/internal/fourslash/tests/gen/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved_test.go @@ -10,25 +10,9 @@ import ( func TestCompletionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @Filename: /node_modules/@types/react/index.d.ts -export = React; -export as namespace React; -declare namespace React { - function createElement(): any; - interface Component

{ } - class Component { - static contextType?: any; - context: any; - constructor(props: Readonly

); - setState( - state: ((prevState: Readonly, props: Readonly

) => (Pick | S | null)) | (Pick | S | null), - callback?: () => void - ): void; - } -} -// @Filename: /a.ts + const content = `// @Filename: /a.ts import React from 'react' class Slider extends React.Component { static defau/**/ltProps = { diff --git a/internal/fourslash/tests/gen/completionForObjectProperty_test.go b/internal/fourslash/tests/gen/completionForObjectProperty_test.go new file mode 100644 index 0000000000..3ccb4b9527 --- /dev/null +++ b/internal/fourslash/tests/gen/completionForObjectProperty_test.go @@ -0,0 +1,189 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionForObjectProperty(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo = { bar: 'baz' }; +// @Filename: /b.ts +const test = foo/*1*/ +// @Filename: /c.ts +const test2 = {...foo/*2*/} +// @Filename: /d.ts +const test3 = [{...foo/*3*/}] +// @Filename: /e.ts +const test4 = { foo/*4*/ } +// @Filename: /f.ts +const test5 = { foo: /*5*/ } +// @Filename: /g.ts +const test6 = { unrelated: foo/*6*/ } +// @Filename: /i.ts +const test7: { foo/*7*/: "unrelated" } +// @Filename: /h.ts +const test8: { foo: string } = { foo/*8*/ }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "6", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "7", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Excludes: []string{ + "foo", + }, + }, + }) + f.VerifyCompletions(t, "8", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + SortText: PtrTo(string(ls.SortTextLocationPriority)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport16_test.go b/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport16_test.go index be55991de2..a269f1a909 100644 --- a/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport16_test.go +++ b/internal/fourslash/tests/gen/completionForStringLiteralNonrelativeImport16_test.go @@ -16,6 +16,7 @@ func TestCompletionForStringLiteralNonrelativeImport16(t *testing.T) { const content = `// @Filename: tsconfig.json { "compilerOptions": { + "resolveJsonModule": false, "baseUrl": "./", "paths": { "module1/path1": ["some/path/whatever.ts"], diff --git a/internal/fourslash/tests/gen/completionInNamedImportLocation_test.go b/internal/fourslash/tests/gen/completionInNamedImportLocation_test.go index 70e23f84fa..dd636cca8b 100644 --- a/internal/fourslash/tests/gen/completionInNamedImportLocation_test.go +++ b/internal/fourslash/tests/gen/completionInNamedImportLocation_test.go @@ -12,7 +12,7 @@ import ( func TestCompletionInNamedImportLocation(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: file.ts export var x = 10; diff --git a/internal/fourslash/tests/gen/completionPropertyShorthandForObjectLiteral5_test.go b/internal/fourslash/tests/gen/completionPropertyShorthandForObjectLiteral5_test.go new file mode 100644 index 0000000000..ed5e08c7ff --- /dev/null +++ b/internal/fourslash/tests/gen/completionPropertyShorthandForObjectLiteral5_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionPropertyShorthandForObjectLiteral5(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +export const exportedConstant = 0; +// @Filename: /b.ts +const foo = 'foo' +const obj = { exp/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "exportedConstant", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "/a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter1_test.go b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter1_test.go new file mode 100644 index 0000000000..1a537ea7ce --- /dev/null +++ b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter1_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsClassMemberImportTypeNodeParameter1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /generation.d.ts +export type GenerationConfigType = { max_length?: number }; +// @FileName: /index.d.ts +export declare class PreTrainedModel { + _get_generation_config( + param: import("./generation.js").GenerationConfigType, + ): import("./generation.js").GenerationConfigType; +} + +export declare class BlenderbotSmallPreTrainedModel extends PreTrainedModel { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "_get_generation_config", + InsertText: PtrTo("_get_generation_config(param: import(\"./generation.js\").GenerationConfigType): import(\"./generation.js\").GenerationConfigType;"), + FilterText: PtrTo("_get_generation_config"), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter2_test.go b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter2_test.go new file mode 100644 index 0000000000..291c5f4023 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter2_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsClassMemberImportTypeNodeParameter2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @FileName: /index.d.ts +export declare class Cls { + method( + param: import("./doesntexist.js").Foo, + ): import("./doesntexist.js").Foo; +} + +export declare class Derived extends Cls { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "method", + InsertText: PtrTo("method(param: import(\"./doesntexist.js\").Foo);"), + FilterText: PtrTo("method"), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter3_test.go b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter3_test.go new file mode 100644 index 0000000000..d3a0eb7fc7 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter3_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsClassMemberImportTypeNodeParameter3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @FileName: /other/foo.d.ts +export declare type Bar = { baz: string }; +// @FileName: /other/cls.d.ts +export declare class Cls { + method( + param: import("./foo.js").Bar, + ): import("./foo.js").Bar; +} +// @FileName: /index.d.ts +import { Cls } from "./other/cls.js"; + +export declare class Derived extends Cls { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "method", + InsertText: PtrTo("method(param: import(\"./other/foo.js\").Bar): import(\"./other/foo.js\").Bar;"), + FilterText: PtrTo("method"), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter4_test.go b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter4_test.go new file mode 100644 index 0000000000..52343b3055 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsClassMemberImportTypeNodeParameter4_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsClassMemberImportTypeNodeParameter4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @FileName: /other/cls.d.ts +export declare class Cls { + method( + param: import("./doesntexist.js").Foo, + ): import("./doesntexist.js").Foo; +} +// @FileName: /index.d.ts +import { Cls } from "./other/cls.js"; + +export declare class Derived extends Cls { + /*1*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "method", + InsertText: PtrTo("method(param: import(\"./doesntexist.js\").Foo);"), + FilterText: PtrTo("method"), + AdditionalTextEdits: fourslash.AnyTextEdits, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportBaseUrl_test.go b/internal/fourslash/tests/gen/completionsImportBaseUrl_test.go new file mode 100644 index 0000000000..e73fae4069 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportBaseUrl_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportBaseUrl(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "module": "esnext" + } +} +// @Filename: /src/a.ts +export const foo = 0; +// @Filename: /src/b.ts +fo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "/src/a", + }, + })), + Detail: PtrTo("const foo: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportDefaultExportCrash2_test.go b/internal/fourslash/tests/gen/completionsImportDefaultExportCrash2_test.go new file mode 100644 index 0000000000..f300628828 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportDefaultExportCrash2_test.go @@ -0,0 +1,77 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportDefaultExportCrash2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @allowJs: true +// @Filename: /node_modules/dom7/index.d.ts +export interface Dom7Array { + length: number; + prop(propName: string): any; +} + +export interface Dom7 { + (): Dom7Array; + fn: any; +} + +declare const Dom7: Dom7; + +export { + Dom7 as $, +}; +// @Filename: /dom7.js +import * as methods from 'dom7'; +Object.keys(methods).forEach((methodName) => { + if (methodName === '$') return; + methods.$.fn[methodName] = methods[methodName]; +}); + +export default methods.$; +// @Filename: /swipe-back.js +/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "$", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dom7", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "Dom7", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./dom7", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportFromJSXTag_test.go b/internal/fourslash/tests/gen/completionsImportFromJSXTag_test.go new file mode 100644 index 0000000000..c0488b300a --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportFromJSXTag_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportFromJSXTag(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: react +// @Filename: /types.d.ts +declare namespace JSX { + interface IntrinsicElements { a } +} +// @Filename: /Box.tsx +export function Box(props: any) { return null; } +// @Filename: /App.tsx +export function App() { + return ( +

+ + ) +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "Box", + Source: "./Box", + Description: "Add import from \"./Box\"", + NewFileContent: PtrTo(`import { Box } from "./Box"; + +export function App() { + return ( +
+ + ) +}`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportModuleAugmentationWithJS_test.go b/internal/fourslash/tests/gen/completionsImportModuleAugmentationWithJS_test.go new file mode 100644 index 0000000000..39ec087d07 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportModuleAugmentationWithJS_test.go @@ -0,0 +1,47 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportModuleAugmentationWithJS(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @noEmit: true +// @Filename: /test.js +class Abcde { + x +} + +module.exports = { + Abcde +}; +// @Filename: /index.ts +export {}; +declare module "./test" { + interface Abcde { b: string } +} + +Abcde/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "Abcde", + Source: "./test", + Description: "Add import from \"./test\"", + NewFileContent: PtrTo(`import { Abcde } from "./test"; + +export {}; +declare module "./test" { + interface Abcde { b: string } +} + +Abcde`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportPathsConflict_test.go b/internal/fourslash/tests/gen/completionsImportPathsConflict_test.go new file mode 100644 index 0000000000..da67a8a511 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportPathsConflict_test.go @@ -0,0 +1,68 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportPathsConflict(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /tsconfig.json +{ + "compilerOptions": { + "module": "esnext", + "paths": { + "@reduxjs/toolkit": ["src/index.ts"], + "@internal/*": ["src/*"] + } + } +} +// @Filename: /src/index.ts +export { configureStore } from "./configureStore"; +// @Filename: /src/configureStore.ts +export function configureStore() {} +// @Filename: /src/tests/createAsyncThunk.typetest.ts +import {} from "@reduxjs/toolkit"; +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "configureStore", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "@reduxjs/toolkit", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "configureStore", + Source: "@reduxjs/toolkit", + AutoImportData: &ls.AutoImportData{ + ExportName: "configureStore", + FileName: "/src/configureStore.ts", + ModuleSpecifier: "@reduxjs/toolkit", + }, + Description: "Update import from \"@reduxjs/toolkit\"", + NewFileContent: PtrTo(`import { configureStore } from "@reduxjs/toolkit"; +`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportTypeKeyword_test.go b/internal/fourslash/tests/gen/completionsImportTypeKeyword_test.go new file mode 100644 index 0000000000..42b83f978e --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportTypeKeyword_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportTypeKeyword(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +// @Filename: /os.d.ts +declare module "os" { + export function type(): string; +} +// @Filename: /index.ts +type/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "type", + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + &lsproto.CompletionItem{ + Label: "type", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "os", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImportYieldExpression_test.go b/internal/fourslash/tests/gen/completionsImportYieldExpression_test.go new file mode 100644 index 0000000000..f0c76cee39 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImportYieldExpression_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImportYieldExpression(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export function a() {} +// @Filename: /b.ts +function *f() { + yield a/**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "a", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { a } from "./a"; + +function *f() { + yield a +}`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_46332_test.go b/internal/fourslash/tests/gen/completionsImport_46332_test.go new file mode 100644 index 0000000000..bee727e2cc --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_46332_test.go @@ -0,0 +1,101 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_46332(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @moduleResolution: bundler +// @Filename: /node_modules/vue/package.json +{ + "name": "vue", + "types": "dist/vue.d.ts" +} +// @Filename: /node_modules/vue/dist/vue.d.ts +export * from "@vue/runtime-dom" +// @Filename: /node_modules/@vue/runtime-dom/package.json +{ + "name": "@vue/runtime-dom", + "types": "dist/runtime-dom.d.ts" +} +// @Filename: /node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +export * from "@vue/runtime-core"; +export {} +declare module '@vue/reactivity' { + export interface RefUnwrapBailTypes { + runtimeDOMBailTypes: any + } +} +// @Filename: /node_modules/@vue/runtime-core/package.json +{ + "name": "@vue/runtime-core", + "types": "dist/runtime-core.d.ts" +} +// @Filename: /node_modules/@vue/runtime-core/dist/runtime-core.d.ts +import { ref } from '@vue/reactivity'; +export { ref }; +declare module '@vue/reactivity' { + export interface RefUnwrapBailTypes { + runtimeCoreBailTypes: any + } +} +// @Filename: /node_modules/@vue/reactivity/package.json +{ + "name": "@vue/reactivity", + "types": "dist/reactivity.d.ts" +} +// @Filename: /node_modules/@vue/reactivity/dist/reactivity.d.ts +export declare function ref(): T; +// @Filename: /package.json +{ + "dependencies": { + "vue": "*" + } +} +// @Filename: /index.ts +import {} from "vue"; +ref/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "ref", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "vue", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "ref", + Source: "vue", + Description: "Update import from \"vue\"", + AutoImportData: &ls.AutoImportData{ + ExportName: "ref", + FileName: "/node_modules/vue/dist/vue.d.ts", + }, + NewFileContent: PtrTo(`import { ref } from "vue"; +ref`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_ambient_test.go b/internal/fourslash/tests/gen/completionsImport_ambient_test.go new file mode 100644 index 0000000000..611fdb9572 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_ambient_test.go @@ -0,0 +1,76 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_ambient(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: a.d.ts +declare namespace foo { class Bar {} } +declare module 'path1' { + import Bar = foo.Bar; + export default Bar; +} +declare module 'path2longer' { + import Bar = foo.Bar; + export {Bar}; +} + +// @Filename: b.ts +Ba/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + &lsproto.CompletionItem{ + Label: "Bar", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "path1", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "Bar", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "path2longer", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "Bar", + Source: "path2longer", + Description: "Add import from \"path2longer\"", + NewFileContent: PtrTo(`import { Bar } from "path2longer"; + +Ba`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_augmentation_test.go b/internal/fourslash/tests/gen/completionsImport_augmentation_test.go new file mode 100644 index 0000000000..2c7cdce25b --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_augmentation_test.go @@ -0,0 +1,60 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_augmentation(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const foo = 0; +// @Filename: /bar.ts +export {}; +declare module "./a" { + export const bar = 0; +} +// @Filename: /user.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Detail: PtrTo("const foo: 0"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "bar", + Detail: PtrTo("const bar: 0"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_compilerOptionsModule_test.go b/internal/fourslash/tests/gen/completionsImport_compilerOptionsModule_test.go new file mode 100644 index 0000000000..62a31af0ac --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_compilerOptionsModule_test.go @@ -0,0 +1,65 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_compilerOptionsModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @module: commonjs +// @Filename: /node_modules/a/index.d.ts +export const foo = 0; +// @Filename: /b.js +const a = require("./a"); +fo/*b*/ +// @Filename: /c.js +const x = 0;/*c*/ +// @Filename: /c1.js +// @ts-check +const x = 0;/*ccheck*/ +// @Filename: /c2.ts +const x = 0;/*cts*/ +// @Filename: /d.js +const a = import("./a"); // Does not make this an external module +fo/*d*/ +// @Filename: /d1.js +// @ts-check +const a = import("./a"); // Does not make this an external module +fo/*dcheck*/ +// @Filename: /d2.ts +const a = import("./a"); // Does not make this an external module +fo/*dts*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, []string{"b", "c", "ccheck", "cts", "d", "dcheck", "dts"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "a", + }, + })), + Detail: PtrTo("const foo: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_defaultAndNamedConflict_test.go b/internal/fourslash/tests/gen/completionsImport_defaultAndNamedConflict_test.go new file mode 100644 index 0000000000..f60bf9f376 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_defaultAndNamedConflict_test.go @@ -0,0 +1,72 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_defaultAndNamedConflict(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @Filename: /someModule.ts +export const someModule = 0; +export default 1; +// @Filename: /index.ts +someMo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "someModule", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./someModule", + }, + })), + Detail: PtrTo("(property) default: 1"), + Kind: PtrTo(lsproto.CompletionItemKindField), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "someModule", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./someModule", + }, + })), + Detail: PtrTo("const someModule: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, true), + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "someModule", + Source: "./someModule", + AutoImportData: &ls.AutoImportData{ + ExportName: "default", + FileName: "/someModule.ts", + }, + Description: "Add import from \"./someModule\"", + NewFileContent: PtrTo(`import someModule from "./someModule"; + +someMo`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_defaultFalsePositive_test.go b/internal/fourslash/tests/gen/completionsImport_defaultFalsePositive_test.go new file mode 100644 index 0000000000..38d4aef0f8 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_defaultFalsePositive_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_defaultFalsePositive(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /node_modules/foo/index.ts +export default function f(): void; +// @Filename: /node_modules/bar/concat.d.ts +export const concat = 0; +// @Filename: /a.ts +export {}; +conca/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/a.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "concat", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "bar/concat", + }, + })), + Detail: PtrTo("const concat: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "concat", + Source: "bar/concat", + Description: "Add import from \"bar/concat\"", + NewFileContent: PtrTo(`import { concat } from "bar/concat"; + +export {}; +conca`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_addToNamedImports_test.go b/internal/fourslash/tests/gen/completionsImport_default_addToNamedImports_test.go new file mode 100644 index 0000000000..d98caac868 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_addToNamedImports_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_addToNamedImports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export default function foo() {} +export const x = 0; +// @Filename: /b.ts +import { x } from "./a"; +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import foo, { x } from "./a"; +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_addToNamespaceImport_test.go b/internal/fourslash/tests/gen/completionsImport_default_addToNamespaceImport_test.go new file mode 100644 index 0000000000..23d8638a44 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_addToNamespaceImport_test.go @@ -0,0 +1,53 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_addToNamespaceImport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export default function foo() {} +// @Filename: /b.ts +import * as a from "./a"; +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import foo, * as a from "./a"; +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_alreadyExistedWithRename_test.go b/internal/fourslash/tests/gen/completionsImport_default_alreadyExistedWithRename_test.go new file mode 100644 index 0000000000..4ffdba061b --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_alreadyExistedWithRename_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_alreadyExistedWithRename(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export default function foo() {} +// @Filename: /b.ts +import f_o_o from "./a"; +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import foo from "./a"; +import f_o_o from "./a"; +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_anonymous_test.go b/internal/fourslash/tests/gen/completionsImport_default_anonymous_test.go new file mode 100644 index 0000000000..fce12a0932 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_anonymous_test.go @@ -0,0 +1,69 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_anonymous(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @noLib: true +// @Filename: /src/foo-bar.ts +export default 0; +// @Filename: /src/b.ts +def/*0*/ +fooB/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "0") + f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{}, true), + }, + }) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooBar", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "/src/foo-bar", + }, + })), + Detail: PtrTo("(property) default: 0"), + Kind: PtrTo(lsproto.CompletionItemKindField), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "fooBar", + Source: "/src/foo-bar", + Description: "Add import from \"./foo-bar\"", + NewFileContent: PtrTo(`import fooBar from "./foo-bar" + +def +fooB`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_didNotExistBefore_test.go b/internal/fourslash/tests/gen/completionsImport_default_didNotExistBefore_test.go new file mode 100644 index 0000000000..26576cab49 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_didNotExistBefore_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_didNotExistBefore(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +export default function foo() {} +// @Filename: /b.ts +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "/a", + }, + })), + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "/a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import foo from "./a"; + +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_exportDefaultIdentifier_test.go b/internal/fourslash/tests/gen/completionsImport_default_exportDefaultIdentifier_test.go new file mode 100644 index 0000000000..ae41e12f86 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_exportDefaultIdentifier_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_exportDefaultIdentifier(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +const foo = 0; +export default foo; +// @Filename: /b.ts +f/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "/a", + }, + })), + Detail: PtrTo("(alias) const foo: 0\nexport default foo"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "/a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import foo from "./a"; + +f;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_fromMergedDeclarations_test.go b/internal/fourslash/tests/gen/completionsImport_default_fromMergedDeclarations_test.go new file mode 100644 index 0000000000..5123c8e3cd --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_fromMergedDeclarations_test.go @@ -0,0 +1,60 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_fromMergedDeclarations(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +declare module "m" { + export default class M {} +} +// @Filename: /b.ts +declare module "m" { + export default interface M {} +} +// @Filename: /c.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "M", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "m", + }, + })), + Detail: PtrTo("class M"), + Kind: PtrTo(lsproto.CompletionItemKindClass), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "M", + Source: "m", + Description: "Add import from \"m\"", + NewFileContent: PtrTo(`import M from "m"; + +`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_reExport_test.go b/internal/fourslash/tests/gen/completionsImport_default_reExport_test.go new file mode 100644 index 0000000000..52e55cdecb --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_reExport_test.go @@ -0,0 +1,64 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_reExport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @allowJs: true +// @Filename: /file1.js +const a = 1; +export { + a as b +}; +export default a; +// @Filename: /file2.js +import * as foo from './file1'; +/**/ +export default foo.b;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsInJSPlus( + []fourslash.CompletionsExpectedItem{ + "foo", + &lsproto.CompletionItem{ + Label: "a", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./file1", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "b", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./file1", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_default_symbolName_test.go b/internal/fourslash/tests/gen/completionsImport_default_symbolName_test.go new file mode 100644 index 0000000000..bae20c6a6d --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_default_symbolName_test.go @@ -0,0 +1,62 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_default_symbolName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @Filename: /node_modules/@types/range-parser/index.d.ts +declare function RangeParser(): string; +declare namespace RangeParser { + interface Options { + combine?: boolean; + } +} +export = RangeParser; +// @Filename: /b.ts +R/*0*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "RangeParser", + Kind: PtrTo(lsproto.CompletionItemKindFunction), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "range-parser", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + Detail: PtrTo("namespace RangeParser\nfunction RangeParser(): string"), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("0"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "RangeParser", + Source: "range-parser", + Description: "Add import from \"range-parser\"", + NewFileContent: PtrTo(`import RangeParser = require("range-parser"); + +R`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_details_withMisspelledName_test.go b/internal/fourslash/tests/gen/completionsImport_details_withMisspelledName_test.go new file mode 100644 index 0000000000..f0201764ec --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_details_withMisspelledName_test.go @@ -0,0 +1,46 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_details_withMisspelledName(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const abc = 0; +// @Filename: /b.ts +acb/*1*/; +// @Filename: /c.ts +acb/*2*/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "abc", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { abc } from "./a"; + +acb;`), + }) + f.GoToMarker(t, "2") + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("2"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "abc", + Source: "./a", + AutoImportData: &ls.AutoImportData{ + ExportName: "abc", + FileName: "/a.ts", + ModuleSpecifier: "./a", + }, + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { abc } from "./a"; + +acb;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypesAndNotTypes_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypesAndNotTypes_test.go new file mode 100644 index 0000000000..650cff95f6 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypesAndNotTypes_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_scopedTypesAndNotTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@types/scope__react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/scope__react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@types/scope__react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/scope__react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@types/scope__react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/@scope/react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/@scope/react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "react-dom"; +import "react"; +// @Filename: /packages/a/foo.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "render", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "@scope/react-dom", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "useState", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "@scope/react", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypes_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypes_test.go new file mode 100644 index 0000000000..ef1bbfc4b9 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scopedTypes_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_scopedTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@types/scope__react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/scope__react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@types/scope__react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/scope__react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@types/scope__react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/@types/scope__react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/@types/scope__react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "@scope/react-dom"; +import "@scope/react"; +// @Filename: /packages/a/foo.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "render", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "@scope/react-dom", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "useState", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "@scope/react", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scoped_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scoped_test.go new file mode 100644 index 0000000000..7bdc35017a --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_scoped_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_scoped(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@scope/react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@scope/react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@scope/react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@scope/react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@scope/react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/@scope/react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/@scope/react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "@scope/react-dom"; +import "@scope/react"; +// @Filename: /packages/a/foo.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "render", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "@scope/react-dom", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "useState", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "@scope/react", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_typesAndNotTypes_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_typesAndNotTypes_test.go new file mode 100644 index 0000000000..380ddb701d --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_typesAndNotTypes_test.go @@ -0,0 +1,64 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_typesAndNotTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@types/react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@types/react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@types/react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "react-dom"; +import "react"; +// @Filename: /packages/a/foo.ts +useState/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "useState", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_duplicatePackages_types_test.go b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_types_test.go new file mode 100644 index 0000000000..6653f114ec --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_duplicatePackages_types_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_duplicatePackages_types(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: true +// @Filename: /node_modules/@types/react-dom/package.json +{ "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/react-dom/index.d.ts +import * as React from "react"; +export function render(): void; +// @Filename: /node_modules/@types/react/package.json +{ "name": "react", "version": "1.0.0", "types": "./index.d.ts" } +// @Filename: /node_modules/@types/react/index.d.ts +import "./other"; +export declare function useState(): void; +// @Filename: /node_modules/@types/react/other.d.ts +export declare function useRef(): void; +// @Filename: /packages/a/node_modules/@types/react/package.json +{ "name": "react", "version": "1.0.1", "types": "./index.d.ts" } +// @Filename: /packages/a/node_modules/@types/react/index.d.ts +export declare function useState(): void; +// @Filename: /packages/a/index.ts +import "react-dom"; +import "react"; +// @Filename: /packages/a/foo.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "render", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react-dom", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "useState", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_exportEqualsNamespace_noDuplicate_test.go b/internal/fourslash/tests/gen/completionsImport_exportEqualsNamespace_noDuplicate_test.go new file mode 100644 index 0000000000..df2677b55e --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_exportEqualsNamespace_noDuplicate_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_exportEqualsNamespace_noDuplicate(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /node_modules/a/index.d.ts +declare namespace core { + const foo: number; +} +declare module "a" { + export = core; +} +declare module "a/alias" { + export = core; +} +// @Filename: /user.ts +import * as a from "a"; +/**/foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_exportEquals_anonymous_test.go b/internal/fourslash/tests/gen/completionsImport_exportEquals_anonymous_test.go new file mode 100644 index 0000000000..f3b7805d04 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_exportEquals_anonymous_test.go @@ -0,0 +1,72 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_exportEquals_anonymous(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @Filename: /src/foo-bar.ts +export = 0; +// @Filename: /src/b.ts +exp/*0*/ +fooB/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "0") + f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{}, true), + }, + }) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "fooBar", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo-bar", + }, + })), + Detail: PtrTo("(property) export=: 0"), + Kind: PtrTo(lsproto.CompletionItemKindField), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, true), + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("0"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "fooBar", + Source: "./foo-bar", + Description: "Add import from \"./foo-bar\"", + NewFileContent: PtrTo(`import fooBar = require("./foo-bar") + +exp +fooB`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_exportEquals_global_test.go b/internal/fourslash/tests/gen/completionsImport_exportEquals_global_test.go new file mode 100644 index 0000000000..9f4f618159 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_exportEquals_global_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_exportEquals_global(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: es6 +// @Filename: /console.d.ts + interface Console {} + declare var console: Console; + declare module "console" { + export = console; + } +// @Filename: /react-native.d.ts + import 'console'; + declare global { + interface Console {} + var console: Console; + } +// @Filename: /a.ts +conso/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "console", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_exportEquals_test.go b/internal/fourslash/tests/gen/completionsImport_exportEquals_test.go new file mode 100644 index 0000000000..5a1ef9edd0 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_exportEquals_test.go @@ -0,0 +1,91 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_exportEquals(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @Filename: /a.d.ts +declare function a(): void; +declare namespace a { + export interface b {} +} +export = a; +// @Filename: /b.ts +a/*0*/; +let x: b/*1*/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "0", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "a", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "b", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "b", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { b } from "./a"; + +a; +let x: b;`), + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("0"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "a", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { b } from "./a"; +import a = require("./a"); + +a; +let x: b;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByInvalidPackageJson_direct_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByInvalidPackageJson_direct_test.go new file mode 100644 index 0000000000..7d7f135186 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByInvalidPackageJson_direct_test.go @@ -0,0 +1,73 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByInvalidPackageJson_direct(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "mod" + "dependencies": { + "react": "*" + } +} +//@Filename: /node_modules/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/react/package.json +{ + "name": "react", + "types": "./index.d.ts" +} +//@Filename: /node_modules/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/fake-react/package.json +{ + "name": "fake-react", + "types": "./index.d.ts" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "ReactFake", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "fake-react", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesImplicit_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesImplicit_test.go new file mode 100644 index 0000000000..bd53aa7be8 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesImplicit_test.go @@ -0,0 +1,63 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_typesImplicit(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "dependencies": { + "react": "*" + } +} +//@Filename: /node_modules/@types/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/@types/react/package.json +{ + "name": "@types/react" +} +//@Filename: /node_modules/@types/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/@types/fake-react/package.json +{ + "name": "@types/fake-react" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "ReactFake", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesOnly_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesOnly_test.go new file mode 100644 index 0000000000..27ccbf38d8 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_@typesOnly_test.go @@ -0,0 +1,63 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_typesOnly(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "devDependencies": { + "@types/react": "*" + } +} +//@Filename: /node_modules/@types/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/@types/react/package.json +{ + "name": "@types/react" +} +//@Filename: /node_modules/@types/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/@types/fake-react/package.json +{ + "name": "@types/fake-react" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "ReactFake", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_ambient_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_ambient_test.go new file mode 100644 index 0000000000..69fd73678f --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_ambient_test.go @@ -0,0 +1,153 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_ambient(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "dependencies": { + "react-syntax-highlighter": "*", + "declared-by-foo": "*" + } +} +//@Filename: /node_modules/@types/foo/index.d.ts +declare module "foo" { + export const foo: any; +} +declare module "declared-by-foo" { + export const declaredBySomethingNotInPackageJson: any; +} +//@Filename: /node_modules/@types/foo/package.json +{ + "name": "@types/node" +} +//@Filename: /node_modules/@types/react-syntax-highlighter/index.d.ts +declare module "react-syntax-highlighter/sub" { + const agate: any; + export default agate; +} +declare module "something-else" { + export const somethingElse: any; +} +//@Filename: /node_modules/@types/react-syntax-highlighter/package.json +{ + "name": "@types/react-syntax-highlighter" +} +//@Filename: /src/ambient.ts +declare module "local" { + export const local: any'; +} +//@Filename: /src/index.ts +fo/*1*/ +aga/*2*/ +somethi/*3*/ +declaredBy/*4*/ +loca/*5*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobals, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "agate", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react-syntax-highlighter/sub", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "somethingElse", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "something-else", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "declaredBySomethingNotInPackageJson", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "declared-by-foo", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "local", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "local", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_direct_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_direct_test.go new file mode 100644 index 0000000000..52dee82f49 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_direct_test.go @@ -0,0 +1,65 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_direct(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "dependencies": { + "react": "*" + } +} +//@Filename: /node_modules/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/react/package.json +{ + "name": "react", + "types": "./index.d.ts" +} +//@Filename: /node_modules/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/fake-react/package.json +{ + "name": "fake-react", + "types": "./index.d.ts" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "ReactFake", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_nested_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_nested_test.go new file mode 100644 index 0000000000..f2116414aa --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_nested_test.go @@ -0,0 +1,89 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_nested(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "dependencies": { + "react": "*" + } +} +//@Filename: /node_modules/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/react/package.json +{ + "name": "react", + "types": "./index.d.ts" +} +//@Filename: /dir/package.json +{ + "dependencies": { + "redux": "*" + } +} +//@Filename: /dir/node_modules/redux/package.json +{ + "name": "redux", + "types": "./index.d.ts" +} +//@Filename: /dir/node_modules/redux/index.d.ts +export declare var Redux: any; +//@Filename: /dir/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Redux", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "redux", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_peerDependencies_test.go b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_peerDependencies_test.go new file mode 100644 index 0000000000..8997b6e93a --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_filteredByPackageJson_peerDependencies_test.go @@ -0,0 +1,65 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_filteredByPackageJson_peerDependencies(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@noEmit: true +//@Filename: /package.json +{ + "peerDependencies": { + "react": "*" + } +} +//@Filename: /node_modules/react/index.d.ts +export declare var React: any; +//@Filename: /node_modules/react/package.json +{ + "name": "react", + "types": "./index.d.ts" +} +//@Filename: /node_modules/fake-react/index.d.ts +export declare var ReactFake: any; +//@Filename: /node_modules/fake-react/package.json +{ + "name": "fake-react", + "types": "./index.d.ts" +} +//@Filename: /src/index.ts +const x = Re/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "React", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "react", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "ReactFake", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_fromAmbientModule_test.go b/internal/fourslash/tests/gen/completionsImport_fromAmbientModule_test.go new file mode 100644 index 0000000000..e070b3e47f --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_fromAmbientModule_test.go @@ -0,0 +1,31 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_fromAmbientModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /a.ts +declare module "m" { + export const x: number; +} +// @Filename: /b.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "x", + Source: "m", + Description: "Add import from \"m\"", + NewFileContent: PtrTo(`import { x } from "m"; + +`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_importType_test.go b/internal/fourslash/tests/gen/completionsImport_importType_test.go new file mode 100644 index 0000000000..28c24d84d2 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_importType_test.go @@ -0,0 +1,83 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_importType(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +export const x = 0; +export class C {} +/** @typedef {number} T */ +// @Filename: /b.js +export const m = 0; +/** @type {/*0*/} */ +/** @type {/*1*/} */` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, []string{"0", "1"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "C", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("class C"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "T", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("type T = number"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "x", + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("0"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "C", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { C } from "./a"; + +export const m = 0; +/** @type {} */ +/** @type {} */`), + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("1"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "T", + Source: "./a", + Description: "Change 'T' to 'import(\"./a\").T'", + NewFileContent: PtrTo(`import { C } from "./a"; + +export const m = 0; +/** @type {} */ +/** @type {import("./a").} */`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_jsxOpeningTagImportDefault_test.go b/internal/fourslash/tests/gen/completionsImport_jsxOpeningTagImportDefault_test.go new file mode 100644 index 0000000000..1dc2706366 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_jsxOpeningTagImportDefault_test.go @@ -0,0 +1,61 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_jsxOpeningTagImportDefault(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @jsx: react +// @Filename: /component.tsx +export default function (props: any) {} +// @Filename: /index.tsx +export function Index() { + return void; +declare const namedExport: () => void; + +export default defaultExport; +export { namedExport }; +// @Filename: /node_modules/example/dist/index.d.ts +export { default, namedExport } from "./nested/module"; +// @Filename: /index.mjs +import { namedExport } from "example"; +defaultExp/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsInJSPlus( + []fourslash.CompletionsExpectedItem{ + "namedExport", + &lsproto.CompletionItem{ + Label: "defaultExport", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "example", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_reExportDefault_test.go b/internal/fourslash/tests/gen/completionsImport_reExportDefault_test.go new file mode 100644 index 0000000000..f6e4129652 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_reExportDefault_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_reExportDefault(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @moduleResolution: node10 +// @Filename: /a/b/impl.ts +export default function foo() {} +// @Filename: /a/index.ts +export { default as foo } from "./b/impl"; +// @Filename: /use.ts +fo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "/a/b/impl", + }, + })), + Detail: PtrTo("function foo(): void"), + Kind: PtrTo(lsproto.CompletionItemKindFunction), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "/a/b/impl", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { foo } from "./a"; + +fo`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_reExport_wrongName_test.go b/internal/fourslash/tests/gen/completionsImport_reExport_wrongName_test.go new file mode 100644 index 0000000000..4651f917c1 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_reExport_wrongName_test.go @@ -0,0 +1,76 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_reExport_wrongName(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @moduleResolution: bundler +// @Filename: /a.ts +export const x = 0; +// @Filename: /index.ts +export { x as y } from "./a"; +// @Filename: /c.ts +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("const x: 0"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "y", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: ".", + }, + })), + Detail: PtrTo("(alias) const y: 0\nexport y"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "x", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import { x } from "./a"; + +`), + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "y", + Source: ".", + Description: "Add import from \".\"", + NewFileContent: PtrTo(`import { y } from "."; +import { x } from "./a"; + +`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_reexportTransient_test.go b/internal/fourslash/tests/gen/completionsImport_reexportTransient_test.go new file mode 100644 index 0000000000..14e7c532c9 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_reexportTransient_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_reexportTransient(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @esModuleInterop: true +// @Filename: /transient.d.ts +declare const map: { [K in "one"]: number }; +export = map; +// @Filename: /r1.ts +export { one } from "./transient"; +// @Filename: /r2.ts +export { one } from "./r1"; +// @Filename: /index.ts +one/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "one", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./transient", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_require_addNew_test.go b/internal/fourslash/tests/gen/completionsImport_require_addNew_test.go new file mode 100644 index 0000000000..5f38f4b5b1 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_require_addNew_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_require_addNew(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +const x = 0; +module.exports = { x }; +// @Filename: /b.js +x/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("(alias) const x: 0\nimport x"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "x", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`const { x } = require("./a"); + +x`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_require_addToExisting_test.go b/internal/fourslash/tests/gen/completionsImport_require_addToExisting_test.go new file mode 100644 index 0000000000..e0ee34df82 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_require_addToExisting_test.go @@ -0,0 +1,57 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_require_addToExisting(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +const x = 0; +function f() {} +module.exports = { x, f }; +// @Filename: /b.js +const { f } = require("./a"); + +x/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("(alias) const x: 0\nimport x"), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "x", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`const { f, x } = require("./a"); + +x`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_require_test.go b/internal/fourslash/tests/gen/completionsImport_require_test.go new file mode 100644 index 0000000000..aab622f2ef --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_require_test.go @@ -0,0 +1,55 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_require(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.ts +export const foo = 0; +// @Filename: /b.js +import * as s from "something"; +fo/*b*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "b", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("const foo: 0"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo("b"), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import * as s from "something"; +import { foo } from "./a"; +fo`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_sortingModuleSpecifiers_test.go b/internal/fourslash/tests/gen/completionsImport_sortingModuleSpecifiers_test.go new file mode 100644 index 0000000000..625ab87cce --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_sortingModuleSpecifiers_test.go @@ -0,0 +1,74 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_sortingModuleSpecifiers(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: tsconfig.json +{ "compilerOptions": { "module": "commonjs" } } +// @Filename: path.d.ts +declare module "path/posix" { + export function normalize(p: string): string; +} +declare module "path/win32" { + export function normalize(p: string): string; +} +declare module "path" { + export function normalize(p: string): string; +} +// @Filename: main.ts +normalize/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "normalize", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "path", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "normalize", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "path/posix", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "normalize", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "path/win32", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_tsx_test.go b/internal/fourslash/tests/gen/completionsImport_tsx_test.go new file mode 100644 index 0000000000..4f8e7c38b5 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_tsx_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_tsx(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @jsx: preserve +// @Filename: /a.tsx +export type Bar = 0; +export default function Foo() {}; +// @Filename: /b.tsx +;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + Excludes: []string{ + "Bar", + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_typeOnly_test.go b/internal/fourslash/tests/gen/completionsImport_typeOnly_test.go new file mode 100644 index 0000000000..27d374d54e --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_typeOnly_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_typeOnly(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @moduleResolution: bundler +// @Filename: /a.ts +export class A {} +export class B {} +// @Filename: /b.ts +import type { A } from './a'; +const b: B/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/b.ts") + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "B", + Source: "./a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import type { A, B } from './a'; +const b: B`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash1_test.go b/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash1_test.go new file mode 100644 index 0000000000..f76355c039 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash1_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_umdDefaultNoCrash1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @moduleResolution: bundler +// @allowJs: true +// @checkJs: true +// @Filename: /node_modules/dottie/package.json +{ + "name": "dottie", + "main": "dottie.js" +} +// @Filename: /node_modules/dottie/dottie.js +(function (undefined) { + var root = this; + + var Dottie = function () {}; + + Dottie["default"] = function (object, path, value) {}; + + if (typeof module !== "undefined" && module.exports) { + exports = module.exports = Dottie; + } else { + root["Dottie"] = Dottie; + root["Dot"] = Dottie; + + if (typeof define === "function") { + define([], function () { + return Dottie; + }); + } + } +})(); +// @Filename: /src/index.js +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Dottie", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "dottie", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash2_test.go b/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash2_test.go index 57ecd5cb67..64dc8a4459 100644 --- a/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash2_test.go +++ b/internal/fourslash/tests/gen/completionsImport_umdDefaultNoCrash2_test.go @@ -13,7 +13,7 @@ func TestCompletionsImport_umdDefaultNoCrash2(t *testing.T) { t.Parallel() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @allowJs: true // @checkJs: true // @Filename: /node_modules/dottie/package.json diff --git a/internal/fourslash/tests/gen/completionsImport_umdModules1_globalAccess_test.go b/internal/fourslash/tests/gen/completionsImport_umdModules1_globalAccess_test.go new file mode 100644 index 0000000000..331af0b944 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_umdModules1_globalAccess_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_umdModules1_globalAccess(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /package.json +{ "dependencies": { "@types/classnames": "*" } } +// @filename: /tsconfig.json +{ "compilerOptions": { "allowUmdGlobalAccess": true } } +// @filename: /node_modules/@types/classnames/package.json +{ "name": "@types/classnames", "types": "index.d.ts" } +// @filename: /node_modules/@types/classnames/index.d.ts +declare const classNames: () => string; +export = classNames; +export as namespace classNames; +// @filename: /SomeReactComponent.tsx +import * as React from 'react'; + +const el1 =
foo
;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "classNames", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_umdModules2_moduleExports_test.go b/internal/fourslash/tests/gen/completionsImport_umdModules2_moduleExports_test.go new file mode 100644 index 0000000000..a1dfd2d6d8 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_umdModules2_moduleExports_test.go @@ -0,0 +1,54 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_umdModules2_moduleExports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /package.json +{ "dependencies": { "@types/classnames": "*" } } +// @filename: /tsconfig.json +{} +// @filename: /node_modules/@types/classnames/package.json +{ "name": "@types/classnames", "types": "index.d.ts" } +// @filename: /node_modules/@types/classnames/index.d.ts +declare const classNames: () => string; +export = classNames; +export as namespace classNames; +// @filename: /SomeReactComponent.tsx +import * as React from 'react'; + +const el1 =
foo
;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "classNames", + AdditionalTextEdits: fourslash.AnyTextEdits, + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "classnames", + }, + })), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_umdModules3_script_test.go b/internal/fourslash/tests/gen/completionsImport_umdModules3_script_test.go new file mode 100644 index 0000000000..f3781b3757 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_umdModules3_script_test.go @@ -0,0 +1,48 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_umdModules3_script(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /package.json +{ "dependencies": { "@types/classnames": "*" } } +// @filename: /tsconfig.json +{ "compilerOptions": { "module": "es2015" }} +// @filename: /node_modules/@types/classnames/package.json +{ "name": "@types/classnames", "types": "index.d.ts" } +// @filename: /node_modules/@types/classnames/index.d.ts +declare const classNames: () => string; +export = classNames; +export as namespace classNames; +// @filename: /SomeReactComponent.tsx + +const el1 =
foo
` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "classNames", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules1_test.go b/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules1_test.go new file mode 100644 index 0000000000..993593f4d2 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules1_test.go @@ -0,0 +1,78 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_uriStyleNodeCoreModules1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: /node_modules/@types/node/index.d.ts +declare module "fs" { function writeFile(): void } +declare module "fs/promises" { function writeFile(): Promise } +declare module "node:fs" { export * from "fs"; } +declare module "node:fs/promises" { export * from "fs/promises"; } +// @Filename: /index.ts +write/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "writeFile", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "fs", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "writeFile", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "node:fs", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "writeFile", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "fs/promises", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "writeFile", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "node:fs/promises", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules2_test.go b/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules2_test.go new file mode 100644 index 0000000000..5c295f65f2 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_uriStyleNodeCoreModules2_test.go @@ -0,0 +1,60 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_uriStyleNodeCoreModules2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @Filename: /node_modules/@types/node/index.d.ts +declare module "fs" { function writeFile(): void } +declare module "fs/promises" { function writeFile(): Promise } +declare module "node:fs" { export * from "fs"; } +declare module "node:fs/promises" { export * from "fs/promises"; } +// @Filename: /other.ts +import "node:fs/promises"; +// @Filename: /index.ts +write/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionGlobalsPlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "writeFile", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "node:fs", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "writeFile", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "node:fs/promises", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, false), + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_weirdDefaultSynthesis_test.go b/internal/fourslash/tests/gen/completionsImport_weirdDefaultSynthesis_test.go new file mode 100644 index 0000000000..5514308ba0 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_weirdDefaultSynthesis_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_weirdDefaultSynthesis(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: commonjs +// @esModuleInterop: false +// @allowSyntheticDefaultImports: false +// @Filename: /collection.ts +class Collection { + public static readonly default: typeof Collection = Collection; +} +export = Collection as typeof Collection & { default: typeof Collection }; +// @Filename: /index.ts +Colle/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "Collection", + Source: "./collection", + Description: "Add import from \"./collection\"", + NewFileContent: PtrTo(`import Collection = require("./collection"); + +Colle`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsImport_windowsPathsProjectRelative_test.go b/internal/fourslash/tests/gen/completionsImport_windowsPathsProjectRelative_test.go new file mode 100644 index 0000000000..8533cb5bea --- /dev/null +++ b/internal/fourslash/tests/gen/completionsImport_windowsPathsProjectRelative_test.go @@ -0,0 +1,131 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsImport_windowsPathsProjectRelative(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: c:/project/tsconfig.json +{ + "compilerOptions": { + "paths": { + "~/noIndex/*": ["./src/noIndex/*"], + "~/withIndex": ["./src/withIndex/index.ts"] + } + } +} +// @Filename: c:/project/package.json +{} +// @Filename: c:/project/src/noIndex/a.ts +export const myFunctionA = () => {}; +// @Filename: c:/project/src/withIndex/b.ts +export const myFunctionB = () => {}; +// @Filename: c:/project/src/withIndex/index.ts +export * from './b'; +// @Filename: c:/project/src/reproduction/1.ts +myFunction/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "myFunctionA", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "~/noIndex/a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "myFunctionB", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "~/withIndex", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "myFunctionA", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "../noIndex/a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "myFunctionB", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "../withIndex", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "myFunctionA", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "../noIndex/a", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + &lsproto.CompletionItem{ + Label: "myFunctionB", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "../withIndex", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsPathsJsonModuleWithoutResolveJsonModule_test.go b/internal/fourslash/tests/gen/completionsPathsJsonModuleWithoutResolveJsonModule_test.go index a66a4523b6..0da18ee5e1 100644 --- a/internal/fourslash/tests/gen/completionsPathsJsonModuleWithoutResolveJsonModule_test.go +++ b/internal/fourslash/tests/gen/completionsPathsJsonModuleWithoutResolveJsonModule_test.go @@ -12,7 +12,7 @@ func TestCompletionsPathsJsonModuleWithoutResolveJsonModule(t *testing.T) { t.Parallel() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @resolveJsonModule: false // @Filename: /project/test.json not read // @Filename: /project/index.ts diff --git a/internal/fourslash/tests/gen/completionsPathsJsonModule_test.go b/internal/fourslash/tests/gen/completionsPathsJsonModule_test.go index b713e79f35..bf86ca473b 100644 --- a/internal/fourslash/tests/gen/completionsPathsJsonModule_test.go +++ b/internal/fourslash/tests/gen/completionsPathsJsonModule_test.go @@ -13,7 +13,7 @@ func TestCompletionsPathsJsonModule(t *testing.T) { t.Parallel() t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @resolveJsonModule: true // @Filename: /project/node_modules/test.json not read diff --git a/internal/fourslash/tests/gen/completionsPathsRelativeJsonModule_test.go b/internal/fourslash/tests/gen/completionsPathsRelativeJsonModule_test.go index 98803f175d..48d174cad0 100644 --- a/internal/fourslash/tests/gen/completionsPathsRelativeJsonModule_test.go +++ b/internal/fourslash/tests/gen/completionsPathsRelativeJsonModule_test.go @@ -13,7 +13,7 @@ func TestCompletionsPathsRelativeJsonModule(t *testing.T) { t.Parallel() t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @resolveJsonModule: true // @Filename: /project/test.json not read diff --git a/internal/fourslash/tests/gen/completionsPaths_importType_test.go b/internal/fourslash/tests/gen/completionsPaths_importType_test.go index 3caae8585e..a0b677054e 100644 --- a/internal/fourslash/tests/gen/completionsPaths_importType_test.go +++ b/internal/fourslash/tests/gen/completionsPaths_importType_test.go @@ -14,7 +14,7 @@ func TestCompletionsPaths_importType(t *testing.T) { t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @allowJs: true -// @moduleResolution: node +// @moduleResolution: bundler // @Filename: /ns.ts file content not read // @Filename: /node_modules/package/index.ts diff --git a/internal/fourslash/tests/gen/completionsRecommended_namespace_test.go b/internal/fourslash/tests/gen/completionsRecommended_namespace_test.go new file mode 100644 index 0000000000..f81d6b2f98 --- /dev/null +++ b/internal/fourslash/tests/gen/completionsRecommended_namespace_test.go @@ -0,0 +1,92 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsRecommended_namespace(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @Filename: /a.ts +export namespace Name { + export class C {} +} +export function f(c: Name.C) {} +f(new N/*a0*/); +f(new /*a1*/); +// @Filename: /b.ts +import { f } from "./a"; +f(new N/*b0*/); +f(new /*b1*/); +// @Filename: /c.ts +import * as alpha from "./a"; +alpha.f(new a/*c0*/); +alpha.f(new /*c1*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, []string{"a0", "a1"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Name", + Detail: PtrTo("namespace Name"), + Kind: PtrTo(lsproto.CompletionItemKindModule), + Preselect: PtrTo(true), + }, + }, + }, + }) + f.VerifyCompletions(t, []string{"b0", "b1"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Name", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./a", + }, + })), + Detail: PtrTo("namespace Name"), + Kind: PtrTo(lsproto.CompletionItemKindModule), + AdditionalTextEdits: fourslash.AnyTextEdits, + Preselect: PtrTo(true), + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) + f.VerifyCompletions(t, []string{"c0", "c1"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "alpha", + Detail: PtrTo("import alpha"), + Kind: PtrTo(lsproto.CompletionItemKindVariable), + Preselect: PtrTo(true), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/completionsUniqueSymbol_import_test.go b/internal/fourslash/tests/gen/completionsUniqueSymbol_import_test.go new file mode 100644 index 0000000000..acdd1674ab --- /dev/null +++ b/internal/fourslash/tests/gen/completionsUniqueSymbol_import_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsUniqueSymbol_import(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @Filename: /globals.d.ts +declare const Symbol: () => symbol; +// @Filename: /a.ts +const privateSym = Symbol(); +export const publicSym = Symbol(); +export interface I { + [privateSym]: number; + [publicSym]: number; + [defaultPublicSym]: number; + n: number; +} +export const i: I; +// @Filename: /user.ts +import { i } from "./a"; +i[|./**/|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "n", + &lsproto.CompletionItem{ + Label: "publicSym", + InsertText: PtrTo("[publicSym]"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "/a", + }, + })), + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + AdditionalTextEdits: fourslash.AnyTextEdits, + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "publicSym", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "publicSym", + Source: "/a", + Description: "Update import from \"./a\"", + NewFileContent: PtrTo(`import { i, publicSym } from "./a"; +i.;`), + }) +} diff --git a/internal/fourslash/tests/gen/completionsWithDeprecatedTag9_test.go b/internal/fourslash/tests/gen/completionsWithDeprecatedTag10_test.go similarity index 56% rename from internal/fourslash/tests/gen/completionsWithDeprecatedTag9_test.go rename to internal/fourslash/tests/gen/completionsWithDeprecatedTag10_test.go index 3f86d91582..104b77761c 100644 --- a/internal/fourslash/tests/gen/completionsWithDeprecatedTag9_test.go +++ b/internal/fourslash/tests/gen/completionsWithDeprecatedTag10_test.go @@ -10,22 +10,15 @@ import ( "github.com/microsoft/typescript-go/internal/testutil" ) -func TestCompletionsWithDeprecatedTag9(t *testing.T) { +func TestCompletionsWithDeprecatedTag10(t *testing.T) { t.Parallel() - + t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @lib: dom -// @allowJs: true -// @Filename: globals.d.ts + const content = `// @Filename: /foo.ts /** @deprecated foo */ -declare var foo: string; -// @Filename: index.ts -class Foo { - foo: number; - m() { - foo/**/ - } -}` +export const foo = 0; +// @Filename: /index.ts +/**/` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ IsIncomplete: false, @@ -36,19 +29,17 @@ class Foo { Items: &fourslash.CompletionsExpectedItems{ Includes: []fourslash.CompletionsExpectedItem{ &lsproto.CompletionItem{ - Label: "foo", - Kind: PtrTo(lsproto.CompletionItemKindVariable), - SortText: PtrTo(string(ls.DeprecateSortText(ls.SortTextGlobalsOrKeywords))), + Label: "foo", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + Kind: PtrTo(lsproto.CompletionItemKindVariable), + SortText: PtrTo(string(ls.DeprecateSortText(ls.SortTextAutoImportSuggestions))), }, }, }, }) - f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ - IsIncomplete: false, - ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ - CommitCharacters: &DefaultCommitCharacters, - EditRange: Ignored, - }, - Items: &fourslash.CompletionsExpectedItems{}, - }) } diff --git a/internal/fourslash/tests/gen/exportEqualNamespaceClassESModuleInterop_test.go b/internal/fourslash/tests/gen/exportEqualNamespaceClassESModuleInterop_test.go index 32f1db0ff0..b610460f44 100644 --- a/internal/fourslash/tests/gen/exportEqualNamespaceClassESModuleInterop_test.go +++ b/internal/fourslash/tests/gen/exportEqualNamespaceClassESModuleInterop_test.go @@ -13,7 +13,7 @@ func TestExportEqualNamespaceClassESModuleInterop(t *testing.T) { defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @esModuleInterop: true -// @moduleResolution: node +// @moduleResolution: bundler // @target: es2015 // @module: esnext // @Filename: /node_modules/@bar/foo/index.d.ts diff --git a/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go b/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go index f41ebfe43a..85578f9b73 100644 --- a/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go +++ b/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllRefsForDefaultExport03(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `/*1*/function /*2*/f() { return 100; diff --git a/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash1_test.go b/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash1_test.go index b219b100e5..d12c4f724b 100644 --- a/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash1_test.go +++ b/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash1_test.go @@ -11,7 +11,7 @@ func TestFindReferencesBindingPatternInJsdocNoCrash1(t *testing.T) { t.Parallel() t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @Filename: node_modules/use-query/package.json { "name": "use-query", diff --git a/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash2_test.go b/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash2_test.go index 1fcafea499..94b4584713 100644 --- a/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash2_test.go +++ b/internal/fourslash/tests/gen/findReferencesBindingPatternInJsdocNoCrash2_test.go @@ -11,7 +11,7 @@ func TestFindReferencesBindingPatternInJsdocNoCrash2(t *testing.T) { t.Parallel() t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @moduleResolution: node + const content = `// @moduleResolution: bundler // @Filename: node_modules/use-query/package.json { "name": "use-query", diff --git a/internal/fourslash/tests/gen/goToTypeDefinition2_test.go b/internal/fourslash/tests/gen/goToTypeDefinition2_test.go new file mode 100644 index 0000000000..ebcbd8ab16 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition2_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: goToTypeDefinition2_Definition.ts +interface /*definition*/I1 { + p; +} +type propertyType = I1; +interface I2 { + property: propertyType; +} +// @Filename: goToTypeDefinition2_Consumption.ts +var i2: I2; +i2.prop/*reference*/erty;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition3_test.go b/internal/fourslash/tests/gen/goToTypeDefinition3_test.go new file mode 100644 index 0000000000..959731d36c --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition3_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type /*definition*/T = string; +const x: /*reference*/T;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition4_test.go b/internal/fourslash/tests/gen/goToTypeDefinition4_test.go new file mode 100644 index 0000000000..b37d04f884 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition4_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: foo.ts +export type /*def0*/T = string; +export const /*def1*/T = ""; +// @Filename: bar.ts +import { T } from "./foo"; +let x: [|/*reference*/T|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") + f.VerifyBaselineGoToDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition5_test.go b/internal/fourslash/tests/gen/goToTypeDefinition5_test.go new file mode 100644 index 0000000000..a6e495eddd --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition5_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: foo.ts +let Foo: /*definition*/unresolved; +type Foo = { x: string }; +/*reference*/Foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionAliases_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionAliases_test.go new file mode 100644 index 0000000000..cf70f8b7e6 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionAliases_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionAliases(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: goToTypeDefinitioAliases_module1.ts +interface /*definition*/I { + p; +} +export {I as I2}; +// @Filename: goToTypeDefinitioAliases_module2.ts +import {I2 as I3} from "./goToTypeDefinitioAliases_module1"; +var v1: I3; +export {v1 as v2}; +// @Filename: goToTypeDefinitioAliases_module3.ts +import {/*reference1*/v2 as v3} from "./goToTypeDefinitioAliases_module2"; +/*reference2*/v3;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference1", "reference2") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionEnumMembers_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionEnumMembers_test.go new file mode 100644 index 0000000000..6a248e3e46 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionEnumMembers_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionEnumMembers(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `enum E { + value1, + /*definition*/value2 +} +var x = E.value2; + +/*reference*/x;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionImportMeta_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionImportMeta_test.go new file mode 100644 index 0000000000..9cda20577e --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionImportMeta_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionImportMeta(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: foo.ts +/// +/// +import.me/*reference*/ta; +//@Filename: bar.d.ts +interface /*definition*/ImportMeta { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionModifiers_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionModifiers_test.go new file mode 100644 index 0000000000..957d3ff39e --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionModifiers_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionModifiers(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +/*export*/export class A/*A*/ { + + /*private*/private z/*z*/: string; + + /*private2*/private y/*y*/: A; + + /*readonly*/readonly x/*x*/: string; + + /*async*/async a/*a*/() { } + + /*override*/override b/*b*/() {} + + /*public1*/public/*public2*/ as/*multipleModifiers*/ync c/*c*/() { } +} + +exp/*exportFunction*/ort function foo/*foo*/() { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "export", "A", "private", "z", "private2", "y", "readonly", "x", "async", "a", "override", "b", "public1", "public2", "multipleModifiers", "c", "exportFunction", "foo") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionModule_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionModule_test.go new file mode 100644 index 0000000000..988f92ddd2 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionModule_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: module1.ts +module /*definition*/M { + export var p; +} +var m: typeof M; +// @Filename: module3.ts +/*reference1*/M; +/*reference2*/m;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference1", "reference2") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionPrimitives_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionPrimitives_test.go new file mode 100644 index 0000000000..18e9fe06ef --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionPrimitives_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionPrimitives(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: module1.ts +var w: {a: number}; +var x = "string"; +var y: number | string; +var z; // any +// @Filename: module2.ts +w./*reference1*/a; +/*reference2*/x; +/*reference3*/y; +/*reference4*/y;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference1", "reference2", "reference3", "reference4") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinitionUnionType_test.go b/internal/fourslash/tests/gen/goToTypeDefinitionUnionType_test.go new file mode 100644 index 0000000000..76e52a123e --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinitionUnionType_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinitionUnionType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class /*definition0*/C { + p; +} + +interface /*definition1*/I { + x; +} + +module M { + export interface /*definition2*/I { + y; + } +} + +var x: C | I | M.I; + +/*reference*/x;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_Pick_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_Pick_test.go new file mode 100644 index 0000000000..ed7dae6496 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_Pick_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_Pick(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type User = { id: number; name: string; }; +declare const user: Pick +/*reference*/user + +type PickedUser = Pick +declare const user2: PickedUser +/*reference2*/user2` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference", "reference2") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_arrayType_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_arrayType_test.go new file mode 100644 index 0000000000..8d3803c3bb --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_arrayType_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_arrayType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type User = { name: string }; +declare const users: User[] +/*reference*/users + +type UsersArr = Array +declare const users2: UsersArr +/*reference2*/users2 + +class CustomArray extends Array { immutableReverse() { return [...this].reverse() } } +declare const users3: CustomArray +/*reference3*/users3` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference", "reference2", "reference3") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_promiseType_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_promiseType_test.go new file mode 100644 index 0000000000..c13cbf198d --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_promiseType_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_promiseType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type User = { name: string }; +async function /*reference*/getUser() { return { name: "Bob" } satisfies User as User } + +const /*reference2*/promisedBob = getUser() + +export {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference", "reference2") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_returnType_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_returnType_test.go new file mode 100644 index 0000000000..930b658c60 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_returnType_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_returnType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface /*I*/I { x: number; } +interface /*J*/J { y: number; } + +function f0(): I { return { x: 0 }; } + +type T = /*T*/(i: I) => I; +const f1: T = i => ({ x: i.x + 1 }); + +const f2 = (i: I): I => ({ x: i.x + 1 }); + +const f3 = (i: I) => (/*f3Def*/{ x: i.x + 1 }); + +const f4 = (i: I) => i; + +const f5 = /*f5Def*/(i: I): I | J => ({ x: i.x + 1 }); + +const f6 = (i: I, j: J, b: boolean) => b ? i : j; + +const /*f7Def*/f7 = (i: I) => {}; + +function f8(i: I): I; +function f8(j: J): J; +function /*f8Def*/f8(ij: any): any { return ij; } + +/*f0*/f0(); +/*f1*/f1(); +/*f2*/f2(); +/*f3*/f3(); +/*f4*/f4(); +/*f5*/f5(); +/*f6*/f6(); +/*f7*/f7(); +/*f8*/f8();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_test.go new file mode 100644 index 0000000000..2b9a7ca2a1 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: goToTypeDefinition_Definition.ts +class /*definition*/C { + p; +} +var c: C; +// @Filename: goToTypeDefinition_Consumption.ts +/*reference*/c = undefined;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_typeReference_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_typeReference_test.go new file mode 100644 index 0000000000..e7e8ae6ee9 --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_typeReference_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_typeReference(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type User = { name: string }; +type Box = { value: T }; +declare const boxedUser: Box +/*reference*/boxedUser` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "reference") +} diff --git a/internal/fourslash/tests/gen/goToTypeDefinition_typedef_test.go b/internal/fourslash/tests/gen/goToTypeDefinition_typedef_test.go new file mode 100644 index 0000000000..8f8c1868cb --- /dev/null +++ b/internal/fourslash/tests/gen/goToTypeDefinition_typedef_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGoToTypeDefinition_typedef(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +/** + * /*def*/@typedef {object} I + * @property {number} x + */ + +/** @type {I} */ +const /*ref*/i = { x: 0 };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "ref") +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixDefaultExport6_test.go b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport6_test.go new file mode 100644 index 0000000000..43b6d1076a --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixDefaultExport6_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixDefaultExport6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export default Math.foo; +// @Filename: /index.ts +a/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "a", + Source: "./a", + Description: "Add import from \"./a\"", + NewFileContent: PtrTo(`import a from "./a"; + +a`), + }) +} diff --git a/internal/fourslash/tests/gen/importNameCodeFixExportAsDefault_test.go b/internal/fourslash/tests/gen/importNameCodeFixExportAsDefault_test.go new file mode 100644 index 0000000000..d5b712b078 --- /dev/null +++ b/internal/fourslash/tests/gen/importNameCodeFixExportAsDefault_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportNameCodeFixExportAsDefault(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /foo.ts +const foo = 'foo' +export { foo as default } +// @Filename: /index.ts + foo/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyApplyCodeActionFromCompletion(t, PtrTo(""), &fourslash.ApplyCodeActionFromCompletionOptions{ + Name: "foo", + Source: "./foo", + Description: "Add import from \"./foo\"", + NewFileContent: PtrTo(`import foo from "./foo"; + +foo`), + }) +} diff --git a/internal/fourslash/tests/gen/importSuggestionsCache_exportUndefined_test.go b/internal/fourslash/tests/gen/importSuggestionsCache_exportUndefined_test.go new file mode 100644 index 0000000000..33022ac27d --- /dev/null +++ b/internal/fourslash/tests/gen/importSuggestionsCache_exportUndefined_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportSuggestionsCache_exportUndefined(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/tsconfig.json +{ "compilerOptions": { "module": "esnext" } } +// @Filename: /home/src/workspaces/project/undefined.ts +export = undefined; +// @Filename: /home/src/workspaces/project/undefinedAlias.ts +const x = undefined; +export = x; +// @Filename: /home/src/workspaces/project/index.ts + /**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "/home/src/workspaces/project/undefinedAlias", + }, + })), + }, + }, + }, + }) + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "/home/src/workspaces/project/undefinedAlias", + }, + })), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importSuggestionsCache_invalidPackageJson_test.go b/internal/fourslash/tests/gen/importSuggestionsCache_invalidPackageJson_test.go new file mode 100644 index 0000000000..7ca5b026fc --- /dev/null +++ b/internal/fourslash/tests/gen/importSuggestionsCache_invalidPackageJson_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportSuggestionsCache_invalidPackageJson(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/jsconfig.json +{ + "compilerOptions": { + "module": "commonjs", + }, +} +// @Filename: /home/src/workspaces/project/node_modules/@types/node/index.d.ts +declare module 'fs' { + export function readFile(): void; +} +declare module 'util' { + export function promisify(): void; +} +// @Filename: /home/src/workspaces/project/package.json +{ "mod" } +// @Filename: /home/src/workspaces/project/a.js + +readF/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "readFile", + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "fs", + }, + })), + AdditionalTextEdits: fourslash.AnyTextEdits, + SortText: PtrTo(string(ls.SortTextAutoImportSuggestions)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions1_test.go b/internal/fourslash/tests/gen/importTypeCompletions1_test.go new file mode 100644 index 0000000000..3e586eb516 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions1_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @filename: /foo.ts +export interface Foo {} +// @filename: /bar.ts +[|import type F/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type { Foo } from \"./foo\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo", + }, + })), + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions3_test.go b/internal/fourslash/tests/gen/importTypeCompletions3_test.go new file mode 100644 index 0000000000..64d207be07 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions3_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions3(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @filename: /foo.ts +export interface Foo {} +// @filename: /bar.ts +[|import type { F/**/ }|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type { Foo } from \"./foo\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo", + }, + })), + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions4_test.go b/internal/fourslash/tests/gen/importTypeCompletions4_test.go new file mode 100644 index 0000000000..ba2465a5e1 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions4_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions4(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @esModuleInterop: true +// @Filename: /foo.ts +interface Foo { }; +export = Foo; +// @Filename: /bar.ts + [|import type f/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type Foo from \"./foo\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo", + }, + })), + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions5_test.go b/internal/fourslash/tests/gen/importTypeCompletions5_test.go new file mode 100644 index 0000000000..543d69aa3f --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions5_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions5(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowSyntheticDefaultImports: false +// @esModuleInterop: false +// @Filename: /foo.ts +interface Foo { }; +export = Foo; +// @Filename: /bar.ts + [|import type f/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type Foo = require(\"./foo\");"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo", + }, + })), + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions6_test.go b/internal/fourslash/tests/gen/importTypeCompletions6_test.go new file mode 100644 index 0000000000..49d825be38 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions6_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions6(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: esnext +// @Filename: /foo.ts +export const foo = { }; +export interface Foo { }; +// @Filename: /bar.ts + [|import type * as f/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import type { Foo } from \"./foo\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo", + }, + })), + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions7_test.go b/internal/fourslash/tests/gen/importTypeCompletions7_test.go new file mode 100644 index 0000000000..e927da63ff --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions7_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions7(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: es2020 +// @module: esnext +// @Filename: /foo.d.ts +declare namespace Foo {} +export = Foo; +// @Filename: /test.ts +[|import F/**/|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/test.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import * as Foo from \"./foo\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo", + }, + })), + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + &lsproto.CompletionItem{ + Label: "type", + SortText: PtrTo(string(ls.SortTextGlobalsOrKeywords)), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions8_test.go b/internal/fourslash/tests/gen/importTypeCompletions8_test.go new file mode 100644 index 0000000000..024b38ff05 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions8_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions8(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @filename: /foo.ts +export interface Foo {} +// @filename: /bar.ts +[|import { type F/**/ }|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import { type Foo } from \"./foo\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo", + }, + })), + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/importTypeCompletions9_test.go b/internal/fourslash/tests/gen/importTypeCompletions9_test.go new file mode 100644 index 0000000000..d6460a2e54 --- /dev/null +++ b/internal/fourslash/tests/gen/importTypeCompletions9_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestImportTypeCompletions9(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @target: esnext +// @filename: /foo.ts +export interface Foo {} +// @filename: /bar.ts +[|import { type /**/ }|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "/bar.ts") + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + InsertText: PtrTo("import { type Foo } from \"./foo\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./foo", + }, + })), + TextEdit: &lsproto.TextEditOrInsertReplaceEdit{ + TextEdit: &lsproto.TextEdit{ + NewText: "Foo", + Range: f.Ranges()[0].LSRange, + }, + }, + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsDocServices_test.go b/internal/fourslash/tests/gen/jsDocServices_test.go new file mode 100644 index 0000000000..e25cdc74ce --- /dev/null +++ b/internal/fourslash/tests/gen/jsDocServices_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsDocServices(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface /*I*/I {} + +/** + * @param /*use*/[|foo|] I pity the foo + */ +function f([|[|/*def*/{| "contextRangeIndex": 1 |}foo|]: I|]) { + return /*use2*/[|foo|]; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "use") + f.VerifyQuickInfoIs(t, "(parameter) foo: I", "I pity the foo") + f.VerifyBaselineFindAllReferences(t, "use", "def", "use2") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[0], f.Ranges()[2], f.Ranges()[3]) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[0], f.Ranges()[2], f.Ranges()[3]) + f.VerifyBaselineGoToTypeDefinition(t, "use") + f.VerifyBaselineGoToDefinition(t, "use") +} diff --git a/internal/fourslash/tests/gen/jsFileImportNoTypes2_test.go b/internal/fourslash/tests/gen/jsFileImportNoTypes2_test.go new file mode 100644 index 0000000000..84c2d97611 --- /dev/null +++ b/internal/fourslash/tests/gen/jsFileImportNoTypes2_test.go @@ -0,0 +1,84 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsFileImportNoTypes2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /default.ts +export default class TestDefaultClass {} +// @Filename: /defaultType.ts +export default interface TestDefaultInterface {} +// @Filename: /reExport/toReExport.ts +export class TestClassReExport {} +export interface TestInterfaceReExport {} +// @Filename: /reExport/index.ts +export { TestClassReExport, TestInterfaceReExport } from './toReExport'; +// @Filename: /exportList.ts +class TestClassExportList {}; +interface TestInterfaceExportList {}; +export { TestClassExportList, TestInterfaceExportList }; +// @Filename: /baseline.ts +export class TestClassBaseline {} +export interface TestInterfaceBaseline {} +// @Filename: /a.js +import /**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "TestClassBaseline", + InsertText: PtrTo("import { TestClassBaseline } from \"./baseline\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./baseline", + }, + })), + }, + &lsproto.CompletionItem{ + Label: "TestClassExportList", + InsertText: PtrTo("import { TestClassExportList } from \"./exportList\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./exportList", + }, + })), + }, + &lsproto.CompletionItem{ + Label: "TestClassReExport", + InsertText: PtrTo("import { TestClassReExport } from \"./reExport\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./reExport", + }, + })), + }, + &lsproto.CompletionItem{ + Label: "TestDefaultClass", + InsertText: PtrTo("import TestDefaultClass from \"./default\";"), + Data: PtrTo(any(&ls.CompletionItemData{ + AutoImport: &ls.AutoImportData{ + ModuleSpecifier: "./default", + }, + })), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsxTagNameCompletionClosed_test.go b/internal/fourslash/tests/gen/jsxTagNameCompletionClosed_test.go new file mode 100644 index 0000000000..9358ac1196 --- /dev/null +++ b/internal/fourslash/tests/gen/jsxTagNameCompletionClosed_test.go @@ -0,0 +1,145 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxTagNameCompletionClosed(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: file.tsx +interface NestedInterface { + Foo: NestedInterface; + (props: {}): any; +} + +declare const Foo: NestedInterface; + +function fn1() { + return + + +} +function fn2() { + return + + +} +function fn3() { + return + + +} +function fn4() { + return + + +} +function fn5() { + return + + +} +function fn6() { + return + + +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("const Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("const Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "6", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsxTagNameCompletionUnclosed_test.go b/internal/fourslash/tests/gen/jsxTagNameCompletionUnclosed_test.go new file mode 100644 index 0000000000..78ab4a048d --- /dev/null +++ b/internal/fourslash/tests/gen/jsxTagNameCompletionUnclosed_test.go @@ -0,0 +1,145 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxTagNameCompletionUnclosed(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: file.tsx +interface NestedInterface { + Foo: NestedInterface; + (props: {}): any; +} + +declare const Foo: NestedInterface; + +function fn1() { + return + +} +function fn2() { + return + +} +function fn3() { + return + +} +function fn4() { + return + +} +function fn5() { + return + +} +function fn6() { + return + +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("const Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("const Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) + f.VerifyCompletions(t, "6", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "Foo", + Detail: PtrTo("(property) NestedInterface.Foo: NestedInterface"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementClosed_test.go b/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementClosed_test.go new file mode 100644 index 0000000000..8e509858f3 --- /dev/null +++ b/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementClosed_test.go @@ -0,0 +1,84 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxTagNameCompletionUnderElementClosed(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: file.tsx +declare namespace JSX { + interface IntrinsicElements { + button: any; + div: any; + } +} +function fn() { + return <> + + ; +} +function fn2() { + return <> + preceding junk + ; +} +function fn3() { + return <> + + ; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementUnclosed_test.go b/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementUnclosed_test.go new file mode 100644 index 0000000000..568c195177 --- /dev/null +++ b/internal/fourslash/tests/gen/jsxTagNameCompletionUnderElementUnclosed_test.go @@ -0,0 +1,84 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsxTagNameCompletionUnderElementUnclosed(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: file.tsx +declare namespace JSX { + interface IntrinsicElements { + button: any; + div: any; + } +} +function fn() { + return <> + ; +} +function fn2() { + return <> + preceding junk ; +} +function fn3() { + return <> + ; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "button", + Detail: PtrTo("(property) JSX.IntrinsicElements.button: any"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard2_test.go b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard2_test.go index 558efd2c05..7f60525520 100644 --- a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard2_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard2_test.go @@ -13,6 +13,7 @@ func TestPathCompletionsTypesVersionsWildcard2(t *testing.T) { t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @module: commonjs +// @resolveJsonModule: false // @Filename: /node_modules/foo/package.json { "types": "index.d.ts", diff --git a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard3_test.go b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard3_test.go index 8d63214eea..d8f8688a88 100644 --- a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard3_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard3_test.go @@ -13,6 +13,7 @@ func TestPathCompletionsTypesVersionsWildcard3(t *testing.T) { t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @module: commonjs +// @resolveJsonModule: false // @Filename: /node_modules/foo/package.json { "types": "index.d.ts", diff --git a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard4_test.go b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard4_test.go index 320a68bfb2..d9f83bb7be 100644 --- a/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard4_test.go +++ b/internal/fourslash/tests/gen/pathCompletionsTypesVersionsWildcard4_test.go @@ -13,6 +13,7 @@ func TestPathCompletionsTypesVersionsWildcard4(t *testing.T) { t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @module: commonjs +// @resolveJsonModule: false // @Filename: /node_modules/foo/package.json { "types": "index.d.ts", diff --git a/internal/fourslash/tests/gen/quickInfoOnNarrowedType_test.go b/internal/fourslash/tests/gen/quickInfoOnNarrowedType_test.go index f917e01054..203d4dc986 100644 --- a/internal/fourslash/tests/gen/quickInfoOnNarrowedType_test.go +++ b/internal/fourslash/tests/gen/quickInfoOnNarrowedType_test.go @@ -11,7 +11,7 @@ import ( func TestQuickInfoOnNarrowedType(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @strictNullChecks: true function foo(strOrNum: string | number) { diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go new file mode 100644 index 0000000000..a323c1da47 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags10(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @template T + * @extends {/**/Set} + */ +class A extends B { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go new file mode 100644 index 0000000000..1eedc0f74c --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags11(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const x = 1; +type Foo = { + /** comment */ + /*2*/readonly /*1*/status: number; +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go new file mode 100644 index 0000000000..7ec86103a2 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags12(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type B = {}; +type A = { + a(/** Comment */ /*1*/p0: number, /** Comment */ /*2*/p1: number, /** Comment */ /*3*/p2: number): string; +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go new file mode 100644 index 0000000000..a3c4b2d4c6 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags13(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let a; +let b: { + /** Comment */ /*1*/p0: number + /** Comment */ /*2*/p1: number + /** Comment */ /*3*/p2: number +}; +let c;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go new file mode 100644 index 0000000000..fcc56e525a --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @returns {Array<{ value: /**/string }>} + */ +function foo() { return [] }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go new file mode 100644 index 0000000000..0db6205655 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @type {/**/string} + */ +const foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go new file mode 100644 index 0000000000..fb4b5ecdaf --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @param {/**/string} x + */ +function foo(x) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go new file mode 100644 index 0000000000..7d1d7bb0fc --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @typedef {object} Foo + * @property {string} a + * @property {number} b + * @property {/**/number} c + */ + +/** @type {Foo} */ +const foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go new file mode 100644 index 0000000000..c14320ca6a --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @callback Foo + * @param {string} data + * @param {/**/number} [index] - comment + * @return {boolean} + */ + +/** @type {Foo} */ +const foo = s => !(s.length % 2);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go new file mode 100644 index 0000000000..ac7904a3b6 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @template T + * @param {/**/T} x + * @return {T} + */ +function foo(x) { + return x; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go new file mode 100644 index 0000000000..fbfc577b24 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @constructor + * @param {/**/number} data + */ +function Foo(data) { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go new file mode 100644 index 0000000000..7a6dbfa501 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags8(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @this {/*1*/Foo} + * @param {/*2*/*} e + */ +function callback(e) { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go new file mode 100644 index 0000000000..cd4cfd9672 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags9(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** @enum {/**/number} */ +const Foo = { + x: 0, + y: 1, +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDoc_test.go b/internal/fourslash/tests/gen/smartSelection_JSDoc_test.go new file mode 100644 index 0000000000..df80bc98fc --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDoc_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDoc(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// Not a JSDoc comment +/** + * @param {number} x The number to square + */ +function /**/square(x) { + return x * x; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_behindCaret_test.go b/internal/fourslash/tests/gen/smartSelection_behindCaret_test.go new file mode 100644 index 0000000000..60616d9619 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_behindCaret_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_behindCaret(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let/**/ x: string` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go b/internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go new file mode 100644 index 0000000000..2af1ad8ece --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_bindingPatterns(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const { /*1*/x, y: /*2*/a, .../*3*/zs = {} } = {};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_comment1_test.go b/internal/fourslash/tests/gen/smartSelection_comment1_test.go new file mode 100644 index 0000000000..07ce0c89a1 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_comment1_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_comment1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 1; ///**/comment content` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_comment2_test.go b/internal/fourslash/tests/gen/smartSelection_comment2_test.go new file mode 100644 index 0000000000..5f85d31719 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_comment2_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_comment2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 1; //a b/**/c d` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_complex_test.go b/internal/fourslash/tests/gen/smartSelection_complex_test.go new file mode 100644 index 0000000000..f5e70e3505 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_complex_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_complex(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type X = IsExactlyAny

extends true ? T : ({ [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[/**/K] : P[K]; } & Pick>)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go b/internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go new file mode 100644 index 0000000000..bfe284f963 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_emptyRanges(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class HomePage { + componentDidMount(/*1*/) { + if (this.props.username/*2*/) { + return '/*3*/'; + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_function1_test.go b/internal/fourslash/tests/gen/smartSelection_function1_test.go new file mode 100644 index 0000000000..69f55b9433 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_function1_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_function1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const f1 = () => { + /**/ +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_function2_test.go b/internal/fourslash/tests/gen/smartSelection_function2_test.go new file mode 100644 index 0000000000..ae9342a804 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_function2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_function2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f2() { + /**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_function3_test.go b/internal/fourslash/tests/gen/smartSelection_function3_test.go new file mode 100644 index 0000000000..277f17a16e --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_function3_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_function3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const f3 = function () { + /**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_functionParams1_test.go b/internal/fourslash/tests/gen/smartSelection_functionParams1_test.go new file mode 100644 index 0000000000..9e72094748 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_functionParams1_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_functionParams1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(/*1*/p, /*2*/q?, /*3*/...r: any[] = []) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_functionParams2_test.go b/internal/fourslash/tests/gen/smartSelection_functionParams2_test.go new file mode 100644 index 0000000000..23742a790c --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_functionParams2_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_functionParams2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f( + a, + /**/b +) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_imports_test.go b/internal/fourslash/tests/gen/smartSelection_imports_test.go new file mode 100644 index 0000000000..fb6fdaf283 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_imports_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_imports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import { /**/x as y, z } from './z'; +import { b } from './'; + +console.log(1);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go b/internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go new file mode 100644 index 0000000000..707384913d --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_lastBlankLine(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C {} +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go b/internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go new file mode 100644 index 0000000000..da1f4af3a8 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_loneVariableDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const /**/x = 3;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go b/internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go new file mode 100644 index 0000000000..7467f4d8eb --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_mappedTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type M = { /*1*/-re/*2*/adonly /*3*/[K in ke/*4*/yof any]/*5*/-/*6*/?: any };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_objectTypes_test.go b/internal/fourslash/tests/gen/smartSelection_objectTypes_test.go new file mode 100644 index 0000000000..98fa38286b --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_objectTypes_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_objectTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type X = { + /*1*/foo?: string; + /*2*/readonly /*3*/bar: { x: num/*4*/ber }; + /*5*/meh +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go b/internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go new file mode 100644 index 0000000000..d63add6b39 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_punctuationPriority(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `console/**/.log();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_simple1_test.go b/internal/fourslash/tests/gen/smartSelection_simple1_test.go new file mode 100644 index 0000000000..e24d9bb2bb --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_simple1_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_simple1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + bar(a, b) { + if (/*1*/a === b) { + return tr/*2*/ue; + } + return false; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_simple2_test.go b/internal/fourslash/tests/gen/smartSelection_simple2_test.go new file mode 100644 index 0000000000..a2b31dfe05 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_simple2_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_simple2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export interface IService { + _serviceBrand: any; + + open(ho/*1*/st: number, data: any): Promise; + bar(): void/*2*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go b/internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go new file mode 100644 index 0000000000..789cac8a04 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_stringLiteral(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 'a'; +const b = /**/'b';` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go b/internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go new file mode 100644 index 0000000000..fa210cb690 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_templateStrings2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `` + "`" + `a ${b} /**/c` + "`" + `` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_templateStrings_test.go b/internal/fourslash/tests/gen/smartSelection_templateStrings_test.go new file mode 100644 index 0000000000..ef7a4d7fbb --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_templateStrings_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_templateStrings(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `` + "`" + `a /*1*/b ${ + '/*2*/c' +} d` + "`" + `` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/typedefinition01_test.go b/internal/fourslash/tests/gen/typedefinition01_test.go new file mode 100644 index 0000000000..dc025b79ad --- /dev/null +++ b/internal/fourslash/tests/gen/typedefinition01_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestTypedefinition01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: b.ts +import n = require('./a'); +var x/*1*/ = new n.Foo(); +// @Filename: a.ts +export class /*2*/Foo {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineGoToTypeDefinition(t, "1") +} diff --git a/internal/jsnum/jsnum.go b/internal/jsnum/jsnum.go index 14d8338a08..9e54baaf72 100644 --- a/internal/jsnum/jsnum.go +++ b/internal/jsnum/jsnum.go @@ -41,31 +41,33 @@ func isNonFinite(x float64) bool { } // https://tc39.es/ecma262/2024/multipage/abstract-operations.html#sec-touint32 -func (n Number) toUint32() uint32 { +func (x Number) toUint32() uint32 { + // The only difference between ToUint32 and ToInt32 is the interpretation of the bits. + return uint32(x.toInt32()) +} + +// https://tc39.es/ecma262/2024/multipage/abstract-operations.html#sec-toint32 +func (n Number) toInt32() int32 { x := float64(n) - // Fast path: if the number is the range (-2^31, 2^32), i.e. an SMI, + + // Fast path: if the number is in the range (-2^31, 2^32), i.e. an SMI, // then we don't need to do any special mapping. if smi := int32(x); float64(smi) == x { - return uint32(smi) + return smi } - // If the number is non-finite (NaN, +Inf, -Inf; exp=0x7FF), it maps to zero. + // 2. If number is not finite or number is either +0đ”Ŋ or -0đ”Ŋ, return +0đ”Ŋ. + // Zero was covered by the test above. if isNonFinite(x) { return 0 } - // Otherwise, take x modulo 2^32, mapping positive numbers - // to [0, 2^32) and negative numbers to (-2^32, -0.0]. + // Let int be truncate(ℝ(number)). + x = math.Trunc(x) + // Let int32bit be int modulo 2**32. x = math.Mod(x, 1<<32) - - // Convert to uint32, which will wrap negative numbers. - return uint32(x) -} - -// https://tc39.es/ecma262/2024/multipage/abstract-operations.html#sec-toint32 -func (x Number) toInt32() int32 { - // The only difference between ToUint32 and ToInt32 is the interpretation of the bits. - return int32(x.toUint32()) + // If int32bit â‰Ĩ 2**31, return đ”Ŋ(int32bit - 2**32); otherwise return đ”Ŋ(int32bit). + return int32(int64(x)) } func (x Number) toShiftCount() uint32 { diff --git a/internal/jsnum/jsnum_test.go b/internal/jsnum/jsnum_test.go index 6036d0be9d..53c358204d 100644 --- a/internal/jsnum/jsnum_test.go +++ b/internal/jsnum/jsnum_test.go @@ -109,18 +109,18 @@ func TestBitwiseNOT(t *testing.T) { t.Parallel() tests := []struct { - input, want Number + got, want Number }{ - {-2147483649, Number(2147483647).BitwiseNOT()}, - {-4294967296, Number(0).BitwiseNOT()}, - {2147483648, Number(-2147483648).BitwiseNOT()}, - {4294967296, Number(0).BitwiseNOT()}, + {Number(-2147483649).BitwiseNOT(), Number(2147483647).BitwiseNOT()}, + {Number(-4294967296).BitwiseNOT(), Number(0).BitwiseNOT()}, + {Number(2147483648).BitwiseNOT(), Number(-2147483648).BitwiseNOT()}, + {Number(4294967296).BitwiseNOT(), Number(0).BitwiseNOT()}, } for _, test := range tests { - t.Run(test.input.String(), func(t *testing.T) { + t.Run(test.got.String(), func(t *testing.T) { t.Parallel() - assertEqualNumber(t, test.input.BitwiseNOT(), test.want) + assertEqualNumber(t, test.got, test.want) }) } } diff --git a/internal/ls/autoimportfixes.go b/internal/ls/autoimportfixes.go index 4aa8104bb1..8e554880b4 100644 --- a/internal/ls/autoimportfixes.go +++ b/internal/ls/autoimportfixes.go @@ -1,10 +1,13 @@ package ls import ( + "slices" + "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/debug" + "github.com/microsoft/typescript-go/internal/stringutil" ) type Import struct { @@ -24,7 +27,6 @@ func (ct *changeTracker) doAddExistingFix( defaultImport *Import, namedImports []*Import, // removeExistingImportSpecifiers *core.Set[ImportSpecifier | BindingElement] // !!! remove imports not implemented - preferences *UserPreferences, ) { switch clause.Kind { case ast.KindObjectBindingPattern: @@ -81,19 +83,19 @@ func (ct *changeTracker) doAddExistingFix( } if len(namedImports) > 0 { - // !!! OrganizeImports not yet implemented - // specifierComparer, isSorted := OrganizeImports.getNamedImportSpecifierComparerWithDetection(importClause.Parent, preferences, sourceFile); + specifierComparer, isSorted := ct.ls.getNamedImportSpecifierComparerWithDetection(importClause.Parent, sourceFile) newSpecifiers := core.Map(namedImports, func(namedImport *Import) *ast.Node { var identifier *ast.Node if namedImport.propertyName != "" { identifier = ct.NodeFactory.NewIdentifier(namedImport.propertyName).AsIdentifier().AsNode() } return ct.NodeFactory.NewImportSpecifier( - (!importClause.IsTypeOnly() || promoteFromTypeOnly) && shouldUseTypeOnly(namedImport.addAsTypeOnly, preferences), + (!importClause.IsTypeOnly() || promoteFromTypeOnly) && shouldUseTypeOnly(namedImport.addAsTypeOnly, ct.ls.UserPreferences()), identifier, ct.NodeFactory.NewIdentifier(namedImport.name), ) - }) // !!! sort with specifierComparer + }) + slices.SortFunc(newSpecifiers, specifierComparer) // !!! remove imports not implemented // if (removeExistingImportSpecifiers) { @@ -108,30 +110,41 @@ func (ct *changeTracker) doAddExistingFix( // append(core.Filter(existingSpecifiers, func (s *ast.ImportSpecifier) bool {return !removeExistingImportSpecifiers.Has(s)}), newSpecifiers...), // !!! sort with specifierComparer // ), // ); - // } else if (len(existingSpecifiers) > 0 && isSorted != false) { - // !!! OrganizeImports not implemented - // The sorting preference computed earlier may or may not have validated that these particular - // import specifiers are sorted. If they aren't, `getImportSpecifierInsertionIndex` will return - // nonsense. So if there are existing specifiers, even if we know the sorting preference, we - // need to ensure that the existing specifiers are sorted according to the preference in order - // to do a sorted insertion. - // changed to check if existing specifiers are sorted - // if we're promoting the clause from type-only, we need to transform the existing imports before attempting to insert the new named imports - // transformedExistingSpecifiers := existingSpecifiers - // if promoteFromTypeOnly && existingSpecifiers { - // transformedExistingSpecifiers = ct.NodeFactory.updateNamedImports( - // importClause.NamedBindings.AsNamedImports(), - // core.SameMap(existingSpecifiers, func(e *ast.ImportSpecifier) *ast.ImportSpecifier { - // return ct.NodeFactory.updateImportSpecifier(e, /*isTypeOnly*/ true, e.propertyName, e.name) - // }), - // ).elements - // } - // for _, spec := range newSpecifiers { - // insertionIndex := OrganizeImports.getImportSpecifierInsertionIndex(transformedExistingSpecifiers, spec, specifierComparer); - // ct.insertImportSpecifierAtIndex(sourceFile, spec, importClause.namedBindings as NamedImports, insertionIndex); - // } - // } else - if len(existingSpecifiers) > 0 { + // + if len(existingSpecifiers) > 0 && isSorted != core.TSFalse { + // The sorting preference computed earlier may or may not have validated that these particular + // import specifiers are sorted. If they aren't, `getImportSpecifierInsertionIndex` will return + // nonsense. So if there are existing specifiers, even if we know the sorting preference, we + // need to ensure that the existing specifiers are sorted according to the preference in order + // to do a sorted insertion. + // if we're promoting the clause from type-only, we need to transform the existing imports before attempting to insert the new named imports + // transformedExistingSpecifiers := existingSpecifiers + // if promoteFromTypeOnly && existingSpecifiers { + // transformedExistingSpecifiers = ct.NodeFactory.updateNamedImports( + // importClause.NamedBindings.AsNamedImports(), + // core.SameMap(existingSpecifiers, func(e *ast.ImportSpecifier) *ast.ImportSpecifier { + // return ct.NodeFactory.updateImportSpecifier(e, /*isTypeOnly*/ true, e.propertyName, e.name) + // }), + // ).elements + // } + for _, spec := range newSpecifiers { + insertionIndex := getImportSpecifierInsertionIndex(existingSpecifiers, spec, specifierComparer) + ct.insertImportSpecifierAtIndex(sourceFile, spec, importClause.NamedBindings, insertionIndex) + } + } else if len(existingSpecifiers) > 0 && isSorted.IsTrue() { + // Existing specifiers are sorted, so insert each new specifier at the correct position + for _, spec := range newSpecifiers { + insertionIndex := getImportSpecifierInsertionIndex(existingSpecifiers, spec, specifierComparer) + if insertionIndex >= len(existingSpecifiers) { + // Insert at the end + ct.insertNodeInListAfter(sourceFile, existingSpecifiers[len(existingSpecifiers)-1], spec.AsNode(), existingSpecifiers) + } else { + // Insert before the element at insertionIndex + ct.insertNodeInListAfter(sourceFile, existingSpecifiers[insertionIndex], spec.AsNode(), existingSpecifiers) + } + } + } else if len(existingSpecifiers) > 0 { + // Existing specifiers may not be sorted, append to the end for _, spec := range newSpecifiers { ct.insertNodeInListAfter(sourceFile, existingSpecifiers[len(existingSpecifiers)-1], spec.AsNode(), existingSpecifiers) } @@ -194,7 +207,7 @@ func (ct *changeTracker) newBindingElementFromNameAndPropertyName(name string, p ) } -func (ct *changeTracker) insertImports(sourceFile *ast.SourceFile, imports []*ast.Statement, blankLineBetween bool, preferences *UserPreferences) { +func (ct *changeTracker) insertImports(sourceFile *ast.SourceFile, imports []*ast.Statement, blankLineBetween bool) { var existingImportStatements []*ast.Statement if imports[0].Kind == ast.KindVariableStatement { @@ -202,10 +215,11 @@ func (ct *changeTracker) insertImports(sourceFile *ast.SourceFile, imports []*as } else { existingImportStatements = core.Filter(sourceFile.Statements.Nodes, ast.IsAnyImportSyntax) } - // !!! OrganizeImports - // { comparer, isSorted } := OrganizeImports.getOrganizeImportsStringComparerWithDetection(existingImportStatements, preferences); - // sortedNewImports := isArray(imports) ? toSorted(imports, (a, b) => OrganizeImports.compareImportsOrRequireStatements(a, b, comparer)) : [imports]; - sortedNewImports := imports + comparer, isSorted := ct.ls.getOrganizeImportsStringComparerWithDetection(existingImportStatements) + sortedNewImports := slices.Clone(imports) + slices.SortFunc(sortedNewImports, func(a, b *ast.Statement) int { + return compareImportsOrRequireStatements(a, b, comparer) + }) // !!! FutureSourceFile // if !isFullSourceFile(sourceFile) { // for _, newImport := range sortedNewImports { @@ -216,22 +230,21 @@ func (ct *changeTracker) insertImports(sourceFile *ast.SourceFile, imports []*as // return; // } - // if len(existingImportStatements) > 0 && isSorted { - // for _, newImport := range sortedNewImports { - // insertionIndex := OrganizeImports.getImportDeclarationInsertionIndex(existingImportStatements, newImport, comparer) - // if insertionIndex == 0 { - // // If the first import is top-of-file, insert after the leading comment which is likely the header. - // options := existingImportStatements[0] == sourceFile.statements[0] ? { leadingTriviaOption: textchanges.LeadingTriviaOption.Exclude } : {}; - // ct.insertNodeBefore(sourceFile, existingImportStatements[0], newImport, /*blankLineBetween*/ false, options); - // } else { - // prevImport := existingImportStatements[insertionIndex - 1] - // ct.insertNodeAfter(sourceFile, prevImport, newImport); - // } - // } - // return - // } - - if len(existingImportStatements) > 0 { + if len(existingImportStatements) > 0 && isSorted { + // Existing imports are sorted, insert each new import at the correct position + for _, newImport := range sortedNewImports { + insertionIndex := getImportDeclarationInsertIndex(existingImportStatements, newImport, func(a, b *ast.Statement) stringutil.Comparison { + return compareImportsOrRequireStatements(a, b, comparer) + }) + if insertionIndex == 0 { + // If the first import is top-of-file, insert after the leading comment which is likely the header + ct.insertNodeAt(sourceFile, core.TextPos(astnav.GetStartOfNode(existingImportStatements[0], sourceFile, false)), newImport.AsNode(), changeNodeOptions{}) + } else { + prevImport := existingImportStatements[insertionIndex-1] + ct.insertNodeAfter(sourceFile, prevImport.AsNode(), newImport.AsNode()) + } + } + } else if len(existingImportStatements) > 0 { ct.insertNodesAfter(sourceFile, existingImportStatements[len(existingImportStatements)-1], sortedNewImports) } else { ct.insertAtTopOfFile(sourceFile, sortedNewImports, blankLineBetween) @@ -252,21 +265,23 @@ func (ct *changeTracker) makeImport(defaultImport *ast.IdentifierNode, namedImpo func (ct *changeTracker) getNewImports( moduleSpecifier string, - // quotePreference quotePreference, // !!! quotePreference + quotePreference quotePreference, defaultImport *Import, namedImports []*Import, namespaceLikeImport *Import, // { importKind: ImportKind.CommonJS | ImportKind.Namespace; } compilerOptions *core.CompilerOptions, - preferences *UserPreferences, ) []*ast.Statement { moduleSpecifierStringLiteral := ct.NodeFactory.NewStringLiteral(moduleSpecifier) + if quotePreference == quotePreferenceSingle { + moduleSpecifierStringLiteral.AsStringLiteral().TokenFlags |= ast.TokenFlagsSingleQuote + } var statements []*ast.Statement // []AnyImportSyntax if defaultImport != nil || len(namedImports) > 0 { // `verbatimModuleSyntax` should prefer top-level `import type` - // even though it's not an error, it would add unnecessary runtime emit. topLevelTypeOnly := (defaultImport == nil || needsTypeOnly(defaultImport.addAsTypeOnly)) && core.Every(namedImports, func(i *Import) bool { return needsTypeOnly(i.addAsTypeOnly) }) || - (compilerOptions.VerbatimModuleSyntax.IsTrue() || preferences.PreferTypeOnlyAutoImports) && + (compilerOptions.VerbatimModuleSyntax.IsTrue() || ct.ls.UserPreferences().PreferTypeOnlyAutoImports) && defaultImport != nil && defaultImport.addAsTypeOnly != AddAsTypeOnlyNotAllowed && !core.Some(namedImports, func(i *Import) bool { return i.addAsTypeOnly == AddAsTypeOnlyNotAllowed }) var defaultImportNode *ast.Node @@ -280,7 +295,7 @@ func (ct *changeTracker) getNewImports( namedImportPropertyName = ct.NodeFactory.NewIdentifier(namedImport.propertyName) } return ct.NodeFactory.NewImportSpecifier( - !topLevelTypeOnly && shouldUseTypeOnly(namedImport.addAsTypeOnly, preferences), + !topLevelTypeOnly && shouldUseTypeOnly(namedImport.addAsTypeOnly, ct.ls.UserPreferences()), namedImportPropertyName, ct.NodeFactory.NewIdentifier(namedImport.name), ) @@ -292,7 +307,7 @@ func (ct *changeTracker) getNewImports( if namespaceLikeImport.kind == ImportKindCommonJS { declaration = ct.NodeFactory.NewImportEqualsDeclaration( /*modifiers*/ nil, - shouldUseTypeOnly(namespaceLikeImport.addAsTypeOnly, preferences), + shouldUseTypeOnly(namespaceLikeImport.addAsTypeOnly, ct.ls.UserPreferences()), ct.NodeFactory.NewIdentifier(namespaceLikeImport.name), ct.NodeFactory.NewExternalModuleReference(moduleSpecifierStringLiteral), ) @@ -300,7 +315,7 @@ func (ct *changeTracker) getNewImports( declaration = ct.NodeFactory.NewImportDeclaration( /*modifiers*/ nil, ct.NodeFactory.NewImportClause( - /*phaseModifier*/ core.IfElse(shouldUseTypeOnly(namespaceLikeImport.addAsTypeOnly, preferences), ast.KindTypeKeyword, ast.KindUnknown), + /*phaseModifier*/ core.IfElse(shouldUseTypeOnly(namespaceLikeImport.addAsTypeOnly, ct.ls.UserPreferences()), ast.KindTypeKeyword, ast.KindUnknown), /*name*/ nil, ct.NodeFactory.NewNamespaceImport(ct.NodeFactory.NewIdentifier(namespaceLikeImport.name)), ), diff --git a/internal/ls/autoimports.go b/internal/ls/autoimports.go index cf89e08fab..1e586cc070 100644 --- a/internal/ls/autoimports.go +++ b/internal/ls/autoimports.go @@ -17,6 +17,7 @@ import ( "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/module" "github.com/microsoft/typescript-go/internal/modulespecifiers" + "github.com/microsoft/typescript-go/internal/packagejson" "github.com/microsoft/typescript-go/internal/stringutil" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -69,7 +70,7 @@ type CachedSymbolExportInfo struct { } type exportInfoMap struct { - exportInfo collections.MultiMap[ExportInfoMapKey, CachedSymbolExportInfo] + exportInfo collections.OrderedMap[ExportInfoMapKey, []*CachedSymbolExportInfo] symbols map[int]symbolExportEntry exportInfoId int usableByFileName tspath.Path @@ -83,7 +84,7 @@ type exportInfoMap struct { func (e *exportInfoMap) clear() { e.symbols = map[int]symbolExportEntry{} - e.exportInfo = collections.MultiMap[ExportInfoMapKey, CachedSymbolExportInfo]{} + e.exportInfo = collections.OrderedMap[ExportInfoMapKey, []*CachedSymbolExportInfo]{} e.usableByFileName = "" } @@ -91,7 +92,7 @@ func (e *exportInfoMap) get(importingFile tspath.Path, ch *checker.Checker, key if e.usableByFileName != importingFile { return nil } - return core.Map(e.exportInfo.Get(key), func(info CachedSymbolExportInfo) *SymbolExportInfo { return e.rehydrateCachedInfo(ch, info) }) + return core.Map(e.exportInfo.GetOrZero(key), func(info *CachedSymbolExportInfo) *SymbolExportInfo { return e.rehydrateCachedInfo(ch, info) }) } func (e *exportInfoMap) add( @@ -164,7 +165,8 @@ func (e *exportInfoMap) add( } moduleName := stringutil.StripQuotes(moduleSymbol.Name) - id := e.exportInfoId + 1 + e.exportInfoId++ + id := e.exportInfoId target := ch.SkipAlias(symbol) if flagMatch != nil && !flagMatch(target.Flags) { @@ -193,7 +195,9 @@ func (e *exportInfoMap) add( if moduleFile != nil { moduleFileName = moduleFile.FileName() } - e.exportInfo.Add(newExportInfoMapKey(symbolName, symbol, moduleKey, ch), CachedSymbolExportInfo{ + key := newExportInfoMapKey(symbolName, symbol, moduleKey, ch) + infos := e.exportInfo.GetOrZero(key) + infos = append(infos, &CachedSymbolExportInfo{ id: id, symbolTableKey: symbolTableKey, symbolName: symbolName, @@ -209,6 +213,7 @@ func (e *exportInfoMap) add( targetFlags: target.Flags, isFromPackageJson: isFromPackageJson, }) + e.exportInfo.Set(key, infos) } func (e *exportInfoMap) search( @@ -221,13 +226,13 @@ func (e *exportInfoMap) search( if importingFile != e.usableByFileName { return nil } - for key, info := range e.exportInfo.M { + for key, info := range e.exportInfo.Entries() { symbolName, ambientModuleName := key.SymbolName, key.AmbientModuleName if preferCapitalized && info[0].capitalizedSymbolName != "" { symbolName = info[0].capitalizedSymbolName } if matches(symbolName, info[0].targetFlags) { - rehydrated := core.Map(info, func(info CachedSymbolExportInfo) *SymbolExportInfo { + rehydrated := core.Map(info, func(info *CachedSymbolExportInfo) *SymbolExportInfo { return e.rehydrateCachedInfo(ch, info) }) filtered := core.FilterIndex(rehydrated, func(r *SymbolExportInfo, i int, _ []*SymbolExportInfo) bool { @@ -254,7 +259,7 @@ func (e *exportInfoMap) isNotShadowedByDeeperNodeModulesPackage(info *SymbolExpo return !ok || strings.HasPrefix(info.moduleFileName, packageDeepestNodeModulesPath) } -func (e *exportInfoMap) rehydrateCachedInfo(ch *checker.Checker, info CachedSymbolExportInfo) *SymbolExportInfo { +func (e *exportInfoMap) rehydrateCachedInfo(ch *checker.Checker, info *CachedSymbolExportInfo) *SymbolExportInfo { if info.symbol != nil && info.moduleSymbol != nil { return &SymbolExportInfo{ symbol: info.symbol, @@ -340,32 +345,6 @@ type packageJsonFilterResult struct { importable bool packageName string } -type projectPackageJsonInfo struct { - fileName string - parseable bool - dependencies map[string]string - devDependencies map[string]string - peerDependencies map[string]string - optionalDependencies map[string]string -} - -func (info *projectPackageJsonInfo) has(dependencyName string) bool { - if _, ok := info.dependencies[dependencyName]; ok { - return true - } - if _, ok := info.devDependencies[dependencyName]; ok { - return true - } - - if _, ok := info.peerDependencies[dependencyName]; ok { - return true - } - if _, ok := info.optionalDependencies[dependencyName]; ok { - return true - } - - return false -} func (l *LanguageService) getImportCompletionAction( ctx context.Context, @@ -378,29 +357,28 @@ func (l *LanguageService) getImportCompletionAction( symbolName string, // !!! needs *string ? isJsxTagName bool, // formatContext *formattingContext, - preferences *UserPreferences, ) (string, codeAction) { var exportInfos []*SymbolExportInfo // `exportMapKey` should be in the `itemData` of each auto-import completion entry and sent in resolving completion entry requests - exportInfos = l.getExportInfos(ctx, ch, sourceFile, preferences, exportMapKey) + exportInfos = l.getExportInfos(ctx, ch, sourceFile, exportMapKey) if len(exportInfos) == 0 { panic("Some exportInfo should match the specified exportMapKey") } isValidTypeOnlyUseSite := ast.IsValidTypeOnlyAliasUseSite(astnav.GetTokenAtPosition(sourceFile, position)) - fix := l.getImportFixForSymbol(ch, sourceFile, exportInfos, position, ptrTo(isValidTypeOnlyUseSite), preferences) + fix := l.getImportFixForSymbol(ch, sourceFile, exportInfos, position, ptrTo(isValidTypeOnlyUseSite)) if fix == nil { lineAndChar := l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(position)) panic(fmt.Sprintf("expected importFix at %s: (%v,%v)", sourceFile.FileName(), lineAndChar.Line, lineAndChar.Character)) } - return fix.moduleSpecifier, l.codeActionForFix(ctx, sourceFile, symbolName, fix /*includeSymbolNameInDescription*/, false, preferences) + return fix.moduleSpecifier, l.codeActionForFix(ctx, sourceFile, symbolName, fix /*includeSymbolNameInDescription*/, false) } func NewExportInfoMap(globalsTypingCacheLocation string) *exportInfoMap { return &exportInfoMap{ packages: map[string]string{}, symbols: map[int]symbolExportEntry{}, - exportInfo: collections.MultiMap[ExportInfoMapKey, CachedSymbolExportInfo]{}, + exportInfo: collections.OrderedMap[ExportInfoMapKey, []*CachedSymbolExportInfo]{}, globalTypingsCacheLocation: globalsTypingCacheLocation, } } @@ -409,7 +387,6 @@ func (l *LanguageService) isImportable( fromFile *ast.SourceFile, toFile *ast.SourceFile, toModule *ast.Symbol, - preferences *UserPreferences, packageJsonFilter *packageJsonImportFilter, // moduleSpecifierResolutionHost ModuleSpecifierResolutionHost, // moduleSpecifierCache ModuleSpecifierCache, @@ -529,7 +506,7 @@ type importSpecifierResolverForCompletions struct { func (r *importSpecifierResolverForCompletions) packageJsonImportFilter() *packageJsonImportFilter { if r.filter == nil { - r.filter = r.l.createPackageJsonImportFilter(r.SourceFile, *r.UserPreferences) + r.filter = r.l.createPackageJsonImportFilter(r.SourceFile) } return r.filter } @@ -542,15 +519,9 @@ func (i *importSpecifierResolverForCompletions) getModuleSpecifierForBestExportI ) *ImportFix { // !!! caching // used in completions, usually calculated once per `getCompletionData` call - var userPreferences UserPreferences - if i.UserPreferences == nil { - userPreferences = UserPreferences{} - } else { - userPreferences = *i.UserPreferences - } packageJsonImportFilter := i.packageJsonImportFilter() - _, fixes := i.l.getImportFixes(ch, exportInfo, ptrTo(i.l.converters.PositionToLineAndCharacter(i.SourceFile, core.TextPos(position))), ptrTo(isValidTypeOnlyUseSite), ptrTo(false), i.SourceFile, userPreferences, false /* fromCacheOnly */) - return i.l.getBestFix(fixes, i.SourceFile, packageJsonImportFilter.allowsImportingSpecifier, userPreferences) + _, fixes := i.l.getImportFixes(ch, exportInfo, ptrTo(i.l.converters.PositionToLineAndCharacter(i.SourceFile, core.TextPos(position))), ptrTo(isValidTypeOnlyUseSite), ptrTo(false), i.SourceFile, false /* fromCacheOnly */) + return i.l.getBestFix(fixes, i.SourceFile, packageJsonImportFilter.allowsImportingSpecifier) } func (l *LanguageService) getImportFixForSymbol( @@ -559,23 +530,17 @@ func (l *LanguageService) getImportFixForSymbol( exportInfos []*SymbolExportInfo, position int, isValidTypeOnlySite *bool, - preferences *UserPreferences, ) *ImportFix { - var userPreferences UserPreferences - if preferences != nil { - userPreferences = *preferences - } - if isValidTypeOnlySite == nil { isValidTypeOnlySite = ptrTo(ast.IsValidTypeOnlyAliasUseSite(astnav.GetTokenAtPosition(sourceFile, position))) } useRequire := getShouldUseRequire(sourceFile, l.GetProgram()) - packageJsonImportFilter := l.createPackageJsonImportFilter(sourceFile, userPreferences) - _, fixes := l.getImportFixes(ch, exportInfos, ptrTo(l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(position))), isValidTypeOnlySite, &useRequire, sourceFile, userPreferences, false /* fromCacheOnly */) - return l.getBestFix(fixes, sourceFile, packageJsonImportFilter.allowsImportingSpecifier, userPreferences) + packageJsonImportFilter := l.createPackageJsonImportFilter(sourceFile) + _, fixes := l.getImportFixes(ch, exportInfos, ptrTo(l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(position))), isValidTypeOnlySite, &useRequire, sourceFile, false /* fromCacheOnly */) + return l.getBestFix(fixes, sourceFile, packageJsonImportFilter.allowsImportingSpecifier) } -func (l *LanguageService) getBestFix(fixes []*ImportFix, sourceFile *ast.SourceFile, allowsImportingSpecifier func(moduleSpecifier string) bool, preferences UserPreferences) *ImportFix { +func (l *LanguageService) getBestFix(fixes []*ImportFix, sourceFile *ast.SourceFile, allowsImportingSpecifier func(moduleSpecifier string) bool) *ImportFix { if len(fixes) == 0 { return nil } @@ -588,12 +553,10 @@ func (l *LanguageService) getBestFix(fixes []*ImportFix, sourceFile *ast.SourceF best := fixes[0] for _, fix := range fixes { // Takes true branch of conditional if `fix` is better than `best` - if compareModuleSpecifiers( + if l.compareModuleSpecifiers( fix, best, sourceFile, - l.GetProgram(), - preferences, allowsImportingSpecifier, func(fileName string) tspath.Path { return tspath.ToPath(fileName, l.GetProgram().GetCurrentDirectory(), l.GetProgram().UseCaseSensitiveFileNames()) @@ -613,7 +576,6 @@ func (l *LanguageService) getImportFixes( isValidTypeOnlyUseSite *bool, useRequire *bool, sourceFile *ast.SourceFile, // | FutureSourceFile, - preferences UserPreferences, // importMap *importMap, fromCacheOnly bool, ) (int, []*ImportFix) { @@ -642,7 +604,6 @@ func (l *LanguageService) getImportFixes( usagePosition, *isValidTypeOnlyUseSite, *useRequire, - preferences, fromCacheOnly, ) computedWithoutCacheCount := 0 @@ -652,11 +613,24 @@ func (l *LanguageService) getImportFixes( return computedWithoutCacheCount, append(useNamespace, result...) } -func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile, preferences UserPreferences) *packageJsonImportFilter { - packageJsons := []*projectPackageJsonInfo{} - // packageJsons := ( - // (host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || getPackageJsonsVisibleToFile(fromFile.fileName, host) - // ).filter(p => p.parseable); +func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile) *packageJsonImportFilter { + // !!! The program package.json cache may not have every relevant package.json. + // This should eventually be integrated with the session. + var packageJsons []*packagejson.PackageJson + dir := tspath.GetDirectoryPath(fromFile.FileName()) + for { + packageJsonDir := l.GetProgram().GetNearestAncestorDirectoryWithPackageJson(dir) + if packageJsonDir == "" { + break + } + if packageJson := l.GetProgram().GetPackageJsonInfo(tspath.CombinePaths(packageJsonDir, "package.json")).GetContents(); packageJson != nil && packageJson.Parseable { + packageJsons = append(packageJsons, packageJson) + } + dir = tspath.GetDirectoryPath(packageJsonDir) + if dir == packageJsonDir { + break + } + } var usesNodeCoreModules *bool ambientModuleCache := map[*ast.Symbol]bool{} @@ -674,7 +648,7 @@ func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile moduleSpecifierIsCoveredByPackageJson := func(specifier string) bool { packageName := getNodeModuleRootSpecifier(specifier) for _, packageJson := range packageJsons { - if packageJson.has(packageName) || packageJson.has(module.GetTypesPackageName(packageName)) { + if packageJson.HasDependency(packageName) || packageJson.HasDependency(module.GetTypesPackageName(packageName)) { return true } } @@ -706,7 +680,7 @@ func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile fromFile, importedFileName, moduleSpecifierResolutionHost, - preferences.ModuleSpecifierPreferences(), + l.UserPreferences().ModuleSpecifierPreferences(), modulespecifiers.ModuleSpecifierOptions{}, ) if specifier == "" { @@ -721,7 +695,7 @@ func (l *LanguageService) createPackageJsonImportFilter(fromFile *ast.SourceFile } allowsImportingAmbientModule := func(moduleSymbol *ast.Symbol, moduleSpecifierResolutionHost modulespecifiers.ModuleSpecifierGenerationHost) bool { - if len(packageJsons) > 0 || moduleSymbol.ValueDeclaration == nil { + if len(packageJsons) == 0 || moduleSymbol.ValueDeclaration == nil { return true } @@ -978,7 +952,6 @@ func (l *LanguageService) getFixesForAddImport( usagePosition *lsproto.Position, isValidTypeOnlyUseSite bool, useRequire bool, - preferences UserPreferences, fromCacheOnly bool, ) []*ImportFix { // tries to create a new import statement using an existing import specifier @@ -995,7 +968,7 @@ func (l *LanguageService) getFixesForAddImport( return []*ImportFix{importWithExistingSpecifier} } - return l.getNewImportFixes(ch, sourceFile, usagePosition, isValidTypeOnlyUseSite, useRequire, exportInfos, preferences, fromCacheOnly) + return l.getNewImportFixes(ch, sourceFile, usagePosition, isValidTypeOnlyUseSite, useRequire, exportInfos, fromCacheOnly) } func (l *LanguageService) getNewImportFixes( @@ -1005,7 +978,6 @@ func (l *LanguageService) getNewImportFixes( isValidTypeOnlyUseSite bool, useRequire bool, exportInfos []*SymbolExportInfo, // !!! (SymbolExportInfo | FutureSymbolExportInfo)[], - preferences UserPreferences, fromCacheOnly bool, ) []*ImportFix /* FixAddNewImport | FixAddJsdocTypeImport */ { isJs := tspath.HasJSFileExtension(sourceFile.FileName()) @@ -1014,7 +986,7 @@ func (l *LanguageService) getNewImportFixes( // getChecker := createGetChecker(program, host)// memoized typechecker based on `isFromPackageJson` bool getModuleSpecifiers := func(moduleSymbol *ast.Symbol, checker *checker.Checker) ([]string, modulespecifiers.ResultKind) { - return modulespecifiers.GetModuleSpecifiersWithInfo(moduleSymbol, checker, compilerOptions, sourceFile, l.GetProgram(), preferences.ModuleSpecifierPreferences(), modulespecifiers.ModuleSpecifierOptions{}, true /*forAutoImport*/) + return modulespecifiers.GetModuleSpecifiersWithInfo(moduleSymbol, checker, compilerOptions, sourceFile, l.GetProgram(), l.UserPreferences().ModuleSpecifierPreferences(), modulespecifiers.ModuleSpecifierOptions{}, true /*forAutoImport*/) } // fromCacheOnly // ? (exportInfo: SymbolExportInfo | FutureSymbolExportInfo) => moduleSpecifiers.tryGetModuleSpecifiersFromCache(exportInfo.moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences) @@ -1329,7 +1301,6 @@ func getDefaultLikeExportNameFromDeclaration(symbol *ast.Symbol) string { func forEachExternalModuleToImportFrom( ch *checker.Checker, program *compiler.Program, - preferences *UserPreferences, // useAutoImportProvider bool, cb func(module *ast.Symbol, moduleFile *ast.SourceFile, checker *checker.Checker, isFromPackageJson bool), ) { @@ -1390,10 +1361,9 @@ func (l *LanguageService) codeActionForFix( symbolName string, fix *ImportFix, includeSymbolNameInDescription bool, - preferences *UserPreferences, ) codeAction { tracker := l.newChangeTracker(ctx) // !!! changetracker.with - diag := l.codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, preferences) + diag := l.codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription) changes := tracker.getChanges()[sourceFile.FileName()] return codeAction{description: diag.Message(), changes: changes} } @@ -1404,7 +1374,6 @@ func (l *LanguageService) codeActionForFixWorker( symbolName string, fix *ImportFix, includeSymbolNameInDescription bool, - preferences *UserPreferences, ) *diagnostics.Message { switch fix.kind { case ImportFixKindUseNamespace: @@ -1421,7 +1390,6 @@ func (l *LanguageService) codeActionForFixWorker( core.IfElse(fix.importKind == ImportKindDefault, &Import{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly}, nil), core.IfElse(fix.importKind == ImportKindNamed, []*Import{{name: symbolName, addAsTypeOnly: fix.addAsTypeOnly}}, nil), // nil /*removeExistingImportSpecifiers*/, - preferences, ) moduleSpecifierWithoutQuotes := stringutil.StripQuotes(fix.moduleSpecifier) if includeSymbolNameInDescription { @@ -1442,17 +1410,15 @@ func (l *LanguageService) codeActionForFixWorker( } if fix.useRequire { - // !!! require - // declarations = getNewRequires(fixAddNew.moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options(), preferences) + declarations = changeTracker.getNewRequires(fix.moduleSpecifier, defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options()) } else { - declarations = changeTracker.getNewImports(fix.moduleSpecifier, defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options(), preferences) + declarations = changeTracker.getNewImports(fix.moduleSpecifier, getQuotePreference(sourceFile, l.UserPreferences()), defaultImport, namedImports, namespaceLikeImport, l.GetProgram().Options()) } changeTracker.insertImports( sourceFile, declarations, /*blankLineBetween*/ true, - preferences, ) if qualification != nil { changeTracker.addNamespaceQualifier(sourceFile, qualification) @@ -1474,6 +1440,87 @@ func (l *LanguageService) codeActionForFixWorker( return nil } +func (c *changeTracker) getNewRequires( + moduleSpecifier string, + defaultImport *Import, + namedImports []*Import, + namespaceLikeImport *Import, + compilerOptions *core.CompilerOptions, +) []*ast.Statement { + quotedModuleSpecifier := c.NodeFactory.NewStringLiteral(moduleSpecifier) + var statements []*ast.Statement + + // const { default: foo, bar, etc } = require('./mod'); + if defaultImport != nil || len(namedImports) > 0 { + bindingElements := []*ast.Node{} + for _, namedImport := range namedImports { + var propertyName *ast.Node + if namedImport.propertyName != "" { + propertyName = c.NodeFactory.NewIdentifier(namedImport.propertyName) + } + bindingElements = append(bindingElements, c.NodeFactory.NewBindingElement( + /*dotDotDotToken*/ nil, + propertyName, + c.NodeFactory.NewIdentifier(namedImport.name), + /*initializer*/ nil, + )) + } + if defaultImport != nil { + bindingElements = append([]*ast.Node{ + c.NodeFactory.NewBindingElement( + /*dotDotDotToken*/ nil, + c.NodeFactory.NewIdentifier("default"), + c.NodeFactory.NewIdentifier(defaultImport.name), + /*initializer*/ nil, + ), + }, bindingElements...) + } + declaration := c.createConstEqualsRequireDeclaration( + c.NodeFactory.NewBindingPattern( + ast.KindObjectBindingPattern, + c.NodeFactory.NewNodeList(bindingElements), + ), + quotedModuleSpecifier, + ) + statements = append(statements, declaration) + } + + // const foo = require('./mod'); + if namespaceLikeImport != nil { + declaration := c.createConstEqualsRequireDeclaration( + c.NodeFactory.NewIdentifier(namespaceLikeImport.name), + quotedModuleSpecifier, + ) + statements = append(statements, declaration) + } + + debug.AssertIsDefined(statements) + return statements +} + +func (c *changeTracker) createConstEqualsRequireDeclaration(name *ast.Node, quotedModuleSpecifier *ast.Node) *ast.Statement { + return c.NodeFactory.NewVariableStatement( + /*modifiers*/ nil, + c.NodeFactory.NewVariableDeclarationList( + ast.NodeFlagsConst, + c.NodeFactory.NewNodeList([]*ast.Node{ + c.NodeFactory.NewVariableDeclaration( + name, + /*exclamationToken*/ nil, + /*type*/ nil, + c.NodeFactory.NewCallExpression( + c.NodeFactory.NewIdentifier("require"), + /*questionDotToken*/ nil, + /*typeArguments*/ nil, + c.NodeFactory.NewNodeList([]*ast.Node{quotedModuleSpecifier}), + ast.NodeFlagsNone, + ), + ), + }), + ), + ) +} + func getModuleSpecifierText(promotedDeclaration *ast.ImportDeclaration) string { if promotedDeclaration.Kind == ast.KindImportEqualsDeclaration { importEqualsDeclaration := promotedDeclaration.AsImportEqualsDeclaration() diff --git a/internal/ls/autoimportsexportinfo.go b/internal/ls/autoimportsexportinfo.go index 65de5e82ad..9b1b66703c 100644 --- a/internal/ls/autoimportsexportinfo.go +++ b/internal/ls/autoimportsexportinfo.go @@ -8,13 +8,13 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/scanner" + "github.com/microsoft/typescript-go/internal/stringutil" ) func (l *LanguageService) getExportInfos( ctx context.Context, ch *checker.Checker, importingFile *ast.SourceFile, - preferences *UserPreferences, exportMapKey ExportInfoMapKey, ) []*SymbolExportInfo { expInfoMap := NewExportInfoMap(l.GetProgram().GetGlobalTypingsCacheLocation()) @@ -25,13 +25,12 @@ func (l *LanguageService) getExportInfos( forEachExternalModuleToImportFrom( ch, l.GetProgram(), - preferences, // /*useAutoImportProvider*/ true, func(moduleSymbol *ast.Symbol, moduleFile *ast.SourceFile, ch *checker.Checker, isFromPackageJson bool) { if moduleCount = moduleCount + 1; moduleCount%100 == 0 && ctx.Err() != nil { return } - if moduleFile == nil && moduleSymbol.Name != exportMapKey.AmbientModuleName { + if moduleFile == nil && stringutil.StripQuotes(moduleSymbol.Name) != exportMapKey.AmbientModuleName { return } seenExports := collections.Set[string]{} @@ -80,7 +79,6 @@ func (l *LanguageService) searchExportInfosForCompletions( ctx context.Context, ch *checker.Checker, importingFile *ast.SourceFile, - preferences *UserPreferences, isForImportStatementCompletion bool, isRightOfOpenTag bool, isTypeOnlyLocation bool, @@ -124,7 +122,6 @@ func (l *LanguageService) searchExportInfosForCompletions( forEachExternalModuleToImportFrom( ch, l.GetProgram(), - preferences, // /*useAutoImportProvider*/ true, func(moduleSymbol *ast.Symbol, moduleFile *ast.SourceFile, ch *checker.Checker, isFromPackageJson bool) { if moduleCount = moduleCount + 1; moduleCount%100 == 0 && ctx.Err() != nil { diff --git a/internal/ls/changetracker.go b/internal/ls/changetracker.go index 34397aa546..971ab03c7a 100644 --- a/internal/ls/changetracker.go +++ b/internal/ls/changetracker.go @@ -91,8 +91,8 @@ type changeTracker struct { func (ls *LanguageService) newChangeTracker(ctx context.Context) *changeTracker { emitContext := printer.NewEmitContext() newLine := ls.GetProgram().Options().NewLine.GetNewLineCharacter() - formatCodeSettings := format.GetDefaultFormatCodeSettings(newLine) // !!! format.GetFormatCodeSettingsFromContext(ctx), - ctx = format.WithFormatCodeSettings(ctx, formatCodeSettings, newLine) + formatCodeSettings := ls.FormatOptions() + ctx = format.WithFormatCodeSettings(ctx, formatCodeSettings, newLine) // !!! formatSettings in context? return &changeTracker{ ls: ls, EmitContext: emitContext, @@ -165,6 +165,10 @@ func (ct *changeTracker) insertNodesAfter(sourceFile *ast.SourceFile, after *ast ct.insertNodesAt(sourceFile, endPosition, newNodes, ct.getInsertNodeAfterOptions(sourceFile, after)) } +func (ct *changeTracker) insertNodeBefore(sourceFile *ast.SourceFile, before *ast.Node, newNode *ast.Node, blankLineBetween bool) { + ct.insertNodeAt(sourceFile, core.TextPos(ct.getAdjustedStartPosition(sourceFile, before, leadingTriviaOptionNone, false)), newNode, ct.getOptionsForInsertNodeBefore(before, newNode, blankLineBetween)) +} + func (ct *changeTracker) endPosForInsertNodeAfter(sourceFile *ast.SourceFile, after *ast.Node, newNode *ast.Node) core.TextPos { if (needSemicolonBetween(after, newNode)) && (rune(sourceFile.Text()[after.End()-1]) != ';') { // check if previous statement ends with semicolon @@ -213,10 +217,10 @@ func (ct *changeTracker) insertNodeInListAfter(sourceFile *ast.SourceFile, after // ###b, // c, nextNode := containingList[index+1] - startPos := scanner.SkipTriviaEx(sourceFile.Text(), nextNode.Pos(), &scanner.SkipTriviaOptions{StopAfterLineBreak: true, StopAtComments: false}) + startPos := scanner.SkipTriviaEx(sourceFile.Text(), nextNode.Pos(), &scanner.SkipTriviaOptions{StopAfterLineBreak: false, StopAtComments: true}) // write separator and leading trivia of the next element as suffix - suffix := scanner.TokenToString(nextToken.Kind) + sourceFile.Text()[nextNode.End():startPos] + suffix := scanner.TokenToString(nextToken.Kind) + sourceFile.Text()[nextToken.End():startPos] ct.insertNodeAt(sourceFile, core.TextPos(startPos), newNode, changeNodeOptions{suffix: suffix}) } return @@ -278,6 +282,21 @@ func (ct *changeTracker) insertNodeInListAfter(sourceFile *ast.SourceFile, after ) } +// insertImportSpecifierAtIndex inserts a new import specifier at the specified index in a NamedImports list +func (ct *changeTracker) insertImportSpecifierAtIndex(sourceFile *ast.SourceFile, newSpecifier *ast.Node, namedImports *ast.Node, index int) { + namedImportsNode := namedImports.AsNamedImports() + elements := namedImportsNode.Elements.Nodes + + if index > 0 && len(elements) > index { + ct.insertNodeInListAfter(sourceFile, elements[index-1], newSpecifier, elements) + } else { + // Insert before the first element + firstElement := elements[0] + multiline := printer.GetLinesBetweenPositions(sourceFile, firstElement.Pos(), namedImports.Parent.Parent.Pos()) != 0 + ct.insertNodeBefore(sourceFile, firstElement, newSpecifier, multiline) + } +} + func (ct *changeTracker) insertAtTopOfFile(sourceFile *ast.SourceFile, insert []*ast.Statement, blankLineBetween bool) { if len(insert) == 0 { return @@ -288,7 +307,7 @@ func (ct *changeTracker) insertAtTopOfFile(sourceFile *ast.SourceFile, insert [] if pos != 0 { options.prefix = ct.newLine } - if !stringutil.IsLineBreak(rune(sourceFile.Text()[pos])) { + if len(sourceFile.Text()) == 0 || !stringutil.IsLineBreak(rune(sourceFile.Text()[pos])) { options.suffix = ct.newLine } if blankLineBetween { @@ -334,3 +353,32 @@ func (ct *changeTracker) getInsertNodeAfterOptions(sourceFile *ast.SourceFile, n return options } + +func (ct *changeTracker) getOptionsForInsertNodeBefore(before *ast.Node, inserted *ast.Node, blankLineBetween bool) changeNodeOptions { + if ast.IsStatement(before) || ast.IsClassOrTypeElement(before) { + if blankLineBetween { + return changeNodeOptions{suffix: ct.newLine + ct.newLine} + } + return changeNodeOptions{suffix: ct.newLine} + } else if before.Kind == ast.KindVariableDeclaration { + // insert `x = 1, ` into `const x = 1, y = 2; + return changeNodeOptions{suffix: ", "} + } else if before.Kind == ast.KindParameter { + if inserted.Kind == ast.KindParameter { + return changeNodeOptions{suffix: ", "} + } + return changeNodeOptions{} + } else if (before.Kind == ast.KindStringLiteral && before.Parent != nil && before.Parent.Kind == ast.KindImportDeclaration) || before.Kind == ast.KindNamedImports { + return changeNodeOptions{suffix: ", "} + } else if before.Kind == ast.KindImportSpecifier { + suffix := "," + if blankLineBetween { + suffix += ct.newLine + } else { + suffix += " " + } + return changeNodeOptions{suffix: suffix} + } + // We haven't handled this kind of node yet -- add it + panic("unimplemented node type " + before.Kind.String() + " in changeTracker.getOptionsForInsertNodeBefore") +} diff --git a/internal/ls/changetrackerimpl.go b/internal/ls/changetrackerimpl.go index e8f3d13e69..b36c1ea982 100644 --- a/internal/ls/changetrackerimpl.go +++ b/internal/ls/changetrackerimpl.go @@ -84,7 +84,7 @@ func (ct *changeTracker) computeNewText(change *trackerEdit, targetSourceFile *a if !(change.options.indentation != nil && *change.options.indentation != 0 || format.GetLineStartPositionForPosition(pos, targetSourceFile) == pos) { noIndent = strings.TrimLeftFunc(text, unicode.IsSpace) } - return change.options.prefix + noIndent // !!! +((!options.suffix || endsWith(noIndent, options.suffix)) ? "" : options.suffix); + return change.options.prefix + noIndent + core.IfElse(strings.HasSuffix(noIndent, change.options.suffix), "", change.options.suffix) } /** Note: this may mutate `nodeIn`. */ @@ -121,7 +121,6 @@ func getFormatCodeSettingsForWriting(options *format.FormatCodeSettings, sourceF return options } -/** Note: output node may be mutated input node. */ func (ct *changeTracker) getNonformattedText(node *ast.Node, sourceFile *ast.SourceFile) (string, *ast.Node) { nodeIn := node eofToken := ct.Factory.NewToken(ast.KindEndOfFile) @@ -146,6 +145,7 @@ func (ct *changeTracker) getNonformattedText(node *ast.Node, sourceFile *ast.Sou ).Write(nodeIn, sourceFile, writer, nil) text := writer.String() + text = strings.TrimSuffix(text, ct.newLine) // Newline artifact from printing a SourceFile instead of a node nodeOut := writer.AssignPositionsToNode(nodeIn, ct.NodeFactory) var sourceFileLike *ast.Node diff --git a/internal/ls/completions.go b/internal/ls/completions.go index 95934780dc..5a63be9df5 100644 --- a/internal/ls/completions.go +++ b/internal/ls/completions.go @@ -37,7 +37,6 @@ func (l *LanguageService) ProvideCompletion( LSPPosition lsproto.Position, context *lsproto.CompletionContext, clientOptions *lsproto.CompletionClientCapabilities, - preferences *UserPreferences, ) (lsproto.CompletionResponse, error) { _, file := l.getProgramAndFile(documentURI) var triggerCharacter *string @@ -50,7 +49,6 @@ func (l *LanguageService) ProvideCompletion( file, position, triggerCharacter, - preferences, clientOptions, ) completionList = ensureItemData(file.FileName(), position, completionList) @@ -63,7 +61,7 @@ func ensureItemData(fileName string, pos int, list *lsproto.CompletionList) *lsp } for _, item := range list.Items { if item.Data == nil { - var data any = &itemData{ + var data any = &CompletionItemData{ FileName: fileName, Position: pos, Name: item.Label, @@ -87,7 +85,7 @@ type completionDataData struct { location *ast.Node keywordFilters KeywordCompletionFilters literals []literalValue - symbolToOriginInfoMap map[ast.SymbolId]*symbolOriginInfo + symbolToOriginInfoMap map[int]*symbolOriginInfo symbolToSortTextMap map[ast.SymbolId]sortText recommendedCompletion *ast.Symbol previousToken *ast.Node @@ -246,7 +244,7 @@ func (origin *symbolOriginInfo) moduleSymbol() *ast.Symbol { } } -func (origin *symbolOriginInfo) toCompletionEntryData() *completionEntryData { +func (origin *symbolOriginInfo) toCompletionEntryData() *AutoImportData { debug.Assert(origin.kind&symbolOriginInfoKindExport != 0, fmt.Sprintf("completionEntryData is not generated for symbolOriginInfo of type %T", origin.data)) var ambientModuleName *string if origin.fileName == "" { @@ -258,12 +256,12 @@ func (origin *symbolOriginInfo) toCompletionEntryData() *completionEntryData { } data := origin.data.(*symbolOriginInfoExport) - return &completionEntryData{ + return &AutoImportData{ ExportName: data.exportName, ExportMapKey: data.exportMapKey, ModuleSpecifier: data.moduleSpecifier, AmbientModuleName: ambientModuleName, - FileName: strPtrTo(origin.fileName), + FileName: origin.fileName, IsPackageJsonImport: isPackageJsonImport, } } @@ -344,7 +342,6 @@ func (l *LanguageService) getCompletionsAtPosition( file *ast.SourceFile, position int, triggerCharacter *string, - preferences *UserPreferences, clientOptions *lsproto.CompletionClientCapabilities, ) *lsproto.CompletionList { _, previousToken := getRelevantTokens(position, file) @@ -354,7 +351,7 @@ func (l *LanguageService) getCompletionsAtPosition( if triggerCharacter != nil && *triggerCharacter == " " { // `isValidTrigger` ensures we are at `import |` - if preferences.IncludeCompletionsForImportStatements.IsTrue() { + if l.UserPreferences().IncludeCompletionsForImportStatements.IsTrue() { return &lsproto.CompletionList{ IsIncomplete: true, } @@ -372,7 +369,6 @@ func (l *LanguageService) getCompletionsAtPosition( position, previousToken, compilerOptions, - preferences, clientOptions, ) if stringCompletions != nil { @@ -394,6 +390,7 @@ func (l *LanguageService) getCompletionsAtPosition( checker, done := l.GetProgram().GetTypeCheckerForFile(ctx, file) defer done() + preferences := l.UserPreferences() data := l.getCompletionData(ctx, checker, file, position, preferences) if data == nil { return nil @@ -408,7 +405,6 @@ func (l *LanguageService) getCompletionsAtPosition( file, compilerOptions, data, - preferences, position, clientOptions, optionalReplacementSpan, @@ -711,7 +707,8 @@ func (l *LanguageService) getCompletionData( hasUnresolvedAutoImports := false // This also gets mutated in nested-functions after the return var symbols []*ast.Symbol - symbolToOriginInfoMap := map[ast.SymbolId]*symbolOriginInfo{} + // Keys are indexes of `symbols`. + symbolToOriginInfoMap := map[int]*symbolOriginInfo{} symbolToSortTextMap := map[ast.SymbolId]sortText{} var seenPropertySymbols collections.Set[ast.SymbolId] importSpecifierResolver := &importSpecifierResolverForCompletions{SourceFile: file, UserPreferences: preferences, l: l} @@ -725,9 +722,9 @@ func (l *LanguageService) getCompletionData( addSymbolOriginInfo := func(symbol *ast.Symbol, insertQuestionDot bool, insertAwait bool) { symbolId := ast.GetSymbolId(symbol) if insertAwait && seenPropertySymbols.AddIfAbsent(symbolId) { - symbolToOriginInfoMap[symbolId] = &symbolOriginInfo{kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindPromise, insertQuestionDot)} + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindPromise, insertQuestionDot)} } else if insertQuestionDot { - symbolToOriginInfoMap[symbolId] = &symbolOriginInfo{kind: symbolOriginInfoKindNullable} + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{kind: symbolOriginInfoKindNullable} } } @@ -772,7 +769,7 @@ func (l *LanguageService) getCompletionData( if moduleSymbol == nil || !checker.IsExternalModuleSymbol(moduleSymbol) || typeChecker.TryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.Name, moduleSymbol) != firstAccessibleSymbol { - symbolToOriginInfoMap[firstAccessibleSymbolId] = &symbolOriginInfo{kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindSymbolMemberNoExport, insertQuestionDot)} + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindSymbolMemberNoExport, insertQuestionDot)} } else { var fileName string if tspath.IsExternalModuleNameRelative(stringutil.StripQuotes(moduleSymbol.Name)) { @@ -793,7 +790,7 @@ func (l *LanguageService) getCompletionData( ) if result != nil { - symbolToOriginInfoMap[ast.GetSymbolId(symbol)] = &symbolOriginInfo{ + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{ kind: getNullableSymbolOriginInfoKind(symbolOriginInfoKindSymbolMemberExport, insertQuestionDot), isDefaultExport: false, fileName: fileName, @@ -1204,7 +1201,6 @@ func (l *LanguageService) getCompletionData( file, toFile, i.moduleSymbol, - preferences, importSpecifierResolver.packageJsonImportFilter(), ) }) @@ -1262,7 +1258,7 @@ func (l *LanguageService) getCompletionData( moduleSpecifier: moduleSpecifier, }, } - symbolToOriginInfoMap[symbolId] = originInfo + symbolToOriginInfoMap[len(symbols)] = originInfo symbolToSortTextMap[symbolId] = core.IfElse(importStatementCompletion != nil, SortTextLocationPriority, SortTextAutoImportSuggestions) symbols = append(symbols, symbol) return nil @@ -1270,7 +1266,6 @@ func (l *LanguageService) getCompletionData( l.searchExportInfosForCompletions(ctx, typeChecker, file, - preferences, importStatementCompletion != nil, isRightOfOpenTag, isTypeOnlyLocation, @@ -1530,17 +1525,16 @@ func (l *LanguageService) getCompletionData( symbols = append(symbols, filterClassMembersList(baseSymbols, decl.Members(), classElementModifierFlags, file, position)...) - for _, symbol := range symbols { + for index, symbol := range symbols { declaration := symbol.ValueDeclaration if declaration != nil && ast.IsClassElement(declaration) && declaration.Name() != nil && ast.IsComputedPropertyName(declaration.Name()) { - symbolId := ast.GetSymbolId(symbol) origin := &symbolOriginInfo{ kind: symbolOriginInfoKindComputedPropertyName, data: &symbolOriginInfoComputedPropertyName{symbolName: typeChecker.SymbolToString(symbol)}, } - symbolToOriginInfoMap[symbolId] = origin + symbolToOriginInfoMap[index] = origin } } } @@ -1647,7 +1641,7 @@ func (l *LanguageService) getCompletionData( symbols = append(symbols, typeChecker.GetSymbolsInScope(scopeNode, symbolMeanings)...) core.CheckEachDefined(symbols, "getSymbolsInScope() should all be defined") - for _, symbol := range symbols { + for index, symbol := range symbols { symbolId := ast.GetSymbolId(symbol) if !typeChecker.IsArgumentsSymbol(symbol) && !core.Some(symbol.Declarations, func(decl *ast.Declaration) bool { @@ -1662,7 +1656,7 @@ func (l *LanguageService) getCompletionData( kind: symbolOriginInfoKindTypeOnlyAlias, data: &symbolOriginInfoTypeOnlyAlias{declaration: typeOnlyAliasDeclaration}, } - symbolToOriginInfoMap[symbolId] = origin + symbolToOriginInfoMap[index] = origin } } } @@ -1677,7 +1671,7 @@ func (l *LanguageService) getCompletionData( for _, symbol := range getPropertiesForCompletion(thisType, typeChecker) { symbolId := ast.GetSymbolId(symbol) symbols = append(symbols, symbol) - symbolToOriginInfoMap[symbolId] = &symbolOriginInfo{kind: symbolOriginInfoKindThisType} + symbolToOriginInfoMap[len(symbols)-1] = &symbolOriginInfo{kind: symbolOriginInfoKindThisType} symbolToSortTextMap[symbolId] = SortTextSuggestedClassMembers } } @@ -1829,7 +1823,6 @@ func (l *LanguageService) completionInfoFromData( file *ast.SourceFile, compilerOptions *core.CompilerOptions, data *completionDataData, - preferences *UserPreferences, position int, clientOptions *lsproto.CompletionClientCapabilities, optionalReplacementSpan *lsproto.Range, @@ -1838,6 +1831,7 @@ func (l *LanguageService) completionInfoFromData( isNewIdentifierLocation := data.isNewIdentifierLocation contextToken := data.contextToken literals := data.literals + preferences := l.UserPreferences() // Verify if the file is JSX language variant if file.LanguageVariant == core.LanguageVariantJSX { @@ -1879,7 +1873,6 @@ func (l *LanguageService) completionInfoFromData( nil, /*replacementToken*/ position, file, - preferences, compilerOptions, clientOptions, ) @@ -1943,7 +1936,6 @@ func (l *LanguageService) getCompletionEntriesFromSymbols( replacementToken *ast.Node, position int, file *ast.SourceFile, - preferences *UserPreferences, compilerOptions *core.CompilerOptions, clientOptions *lsproto.CompletionClientCapabilities, ) (uniqueNames collections.Set[string], sortedEntries []*lsproto.CompletionItem) { @@ -1957,9 +1949,8 @@ func (l *LanguageService) getCompletionEntriesFromSymbols( // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports. // So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name. uniques := make(uniqueNamesMap) - for _, symbol := range data.symbols { - symbolId := ast.GetSymbolId(symbol) - origin := data.symbolToOriginInfoMap[symbolId] + for index, symbol := range data.symbols { + origin := data.symbolToOriginInfoMap[index] name, needsConvertPropertyAccess := getCompletionEntryDisplayNameForSymbol( symbol, origin, @@ -2003,7 +1994,6 @@ func (l *LanguageService) getCompletionEntriesFromSymbols( origin, useSemicolons, compilerOptions, - preferences, clientOptions, isMemberCompletion, ) @@ -2070,7 +2060,6 @@ func (l *LanguageService) createCompletionItem( origin *symbolOriginInfo, useSemicolons bool, compilerOptions *core.CompilerOptions, - preferences *UserPreferences, clientOptions *lsproto.CompletionClientCapabilities, isMemberCompletion bool, ) *lsproto.CompletionItem { @@ -2081,7 +2070,7 @@ func (l *LanguageService) createCompletionItem( var isSnippet, hasAction bool source := getSourceFromOrigin(origin) var labelDetails *lsproto.CompletionItemLabelDetails - + preferences := l.UserPreferences() insertQuestionDot := originIsNullableMember(origin) useBraces := originIsSymbolMember(origin) || needsConvertPropertyAccess if originIsThisType(origin) { @@ -2294,7 +2283,7 @@ func (l *LanguageService) createCompletionItem( } } - var autoImportData *completionEntryData + var autoImportData *AutoImportData if originIsExport(origin) { autoImportData = origin.toCompletionEntryData() hasAction = data.importStatementCompletion == nil @@ -3289,10 +3278,7 @@ func getCompletionsSymbolKind(kind ScriptElementKind) lsproto.CompletionItemKind // Editors will use the `sortText` and then fall back to `name` for sorting, but leave ties in response order. // So, it's important that we sort those ties in the order we want them displayed if it matters. We don't // strictly need to sort by name or SortText here since clients are going to do it anyway, but we have to -// do the work of comparing them so we can sort those ties appropriately; plus, it makes the order returned -// by the language service consistent with what TS Server does and what editors typically do. This also makes -// completions tests make more sense. We used to sort only alphabetically and only in the server layer, but -// this made tests really weird, since most fourslash tests don't use the server. +// do the work of comparing them so we can sort those ties appropriately. func compareCompletionEntries(entryInSlice *lsproto.CompletionItem, entryToInsert *lsproto.CompletionItem) int { compareStrings := stringutil.CompareStringsCaseInsensitiveThenSensitive result := compareStrings(*entryInSlice.SortText, *entryToInsert.SortText) @@ -3300,14 +3286,22 @@ func compareCompletionEntries(entryInSlice *lsproto.CompletionItem, entryToInser result = compareStrings(entryInSlice.Label, entryToInsert.Label) } if result == stringutil.ComparisonEqual && entryInSlice.Data != nil && entryToInsert.Data != nil { - sliceEntryData, ok1 := (*entryInSlice.Data).(*completionEntryData) - insertEntryData, ok2 := (*entryToInsert.Data).(*completionEntryData) - if ok1 && ok2 && sliceEntryData.ModuleSpecifier != "" && insertEntryData.ModuleSpecifier != "" { + sliceEntryData, ok1 := (*entryInSlice.Data).(*CompletionItemData) + insertEntryData, ok2 := (*entryToInsert.Data).(*CompletionItemData) + if ok1 && ok2 && + sliceEntryData.AutoImport != nil && sliceEntryData.AutoImport.ModuleSpecifier != "" && + insertEntryData.AutoImport != nil && insertEntryData.AutoImport.ModuleSpecifier != "" { // Sort same-named auto-imports by module specifier result = compareNumberOfDirectorySeparators( - sliceEntryData.ModuleSpecifier, - insertEntryData.ModuleSpecifier, + sliceEntryData.AutoImport.ModuleSpecifier, + insertEntryData.AutoImport.ModuleSpecifier, ) + if result == stringutil.ComparisonEqual { + result = compareStrings( + sliceEntryData.AutoImport.ModuleSpecifier, + insertEntryData.AutoImport.ModuleSpecifier, + ) + } } } if result == stringutil.ComparisonEqual { @@ -4514,10 +4508,10 @@ func (l *LanguageService) createLSPCompletionItem( hasAction bool, preselect bool, source string, - autoImportEntryData *completionEntryData, + autoImportEntryData *AutoImportData, ) *lsproto.CompletionItem { kind := getCompletionsSymbolKind(elementKind) - var data any = &itemData{ + var data any = &CompletionItemData{ FileName: file.FileName(), Position: position, Source: source, @@ -4949,15 +4943,15 @@ func getArgumentInfoForCompletions(node *ast.Node, position int, file *ast.Sourc } } -type itemData struct { - FileName string `json:"fileName"` - Position int `json:"position"` - Source string `json:"source,omitempty"` - Name string `json:"name,omitempty"` - AutoImport *completionEntryData `json:"autoImport,omitempty"` +type CompletionItemData struct { + FileName string `json:"fileName"` + Position int `json:"position"` + Source string `json:"source,omitempty"` + Name string `json:"name,omitempty"` + AutoImport *AutoImportData `json:"autoImport,omitempty"` } -type completionEntryData struct { +type AutoImportData struct { /** * The name of the property or export in the module's symbol table. Differs from the completion name * in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default. @@ -4967,7 +4961,7 @@ type completionEntryData struct { ModuleSpecifier string `json:"moduleSpecifier"` /** The file name declaring the export's module symbol, if it was an external module */ - FileName *string `json:"fileName"` + FileName string `json:"fileName"` /** The module name (with quotes stripped) of the export's module symbol, if it was an ambient module */ AmbientModuleName *string `json:"ambientModuleName"` @@ -4975,7 +4969,7 @@ type completionEntryData struct { IsPackageJsonImport core.Tristate `json:"isPackageJsonImport"` } -func (d *completionEntryData) toSymbolOriginExport(symbolName string, moduleSymbol *ast.Symbol, isDefaultExport bool) *symbolOriginInfoExport { +func (d *AutoImportData) toSymbolOriginExport(symbolName string, moduleSymbol *ast.Symbol, isDefaultExport bool) *symbolOriginInfoExport { return &symbolOriginInfoExport{ symbolName: symbolName, moduleSymbol: moduleSymbol, @@ -5012,9 +5006,8 @@ const ( func (l *LanguageService) ResolveCompletionItem( ctx context.Context, item *lsproto.CompletionItem, - data *itemData, + data *CompletionItemData, clientOptions *lsproto.CompletionClientCapabilities, - preferences *UserPreferences, ) (*lsproto.CompletionItem, error) { if data == nil { return nil, errors.New("completion item data is nil") @@ -5025,15 +5018,15 @@ func (l *LanguageService) ResolveCompletionItem( return nil, fmt.Errorf("file not found: %s", data.FileName) } - return l.getCompletionItemDetails(ctx, program, data.Position, file, item, data, clientOptions, preferences), nil + return l.getCompletionItemDetails(ctx, program, data.Position, file, item, data, clientOptions), nil } -func GetCompletionItemData(item *lsproto.CompletionItem) (*itemData, error) { +func GetCompletionItemData(item *lsproto.CompletionItem) (*CompletionItemData, error) { bytes, err := json.Marshal(item.Data) if err != nil { return nil, fmt.Errorf("failed to marshal completion item data: %w", err) } - var itemData itemData + var itemData CompletionItemData if err := json.Unmarshal(bytes, &itemData); err != nil { return nil, fmt.Errorf("failed to unmarshal completion item data: %w", err) } @@ -5046,9 +5039,8 @@ func (l *LanguageService) getCompletionItemDetails( position int, file *ast.SourceFile, item *lsproto.CompletionItem, - itemData *itemData, + itemData *CompletionItemData, clientOptions *lsproto.CompletionClientCapabilities, - preferences *UserPreferences, ) *lsproto.CompletionItem { checker, done := program.GetTypeCheckerForFile(ctx, file) defer done() @@ -5062,7 +5054,6 @@ func (l *LanguageService) getCompletionItemDetails( file, position, contextToken, - preferences, ) } @@ -5074,8 +5065,9 @@ func (l *LanguageService) getCompletionItemDetails( position, itemData, clientOptions, - preferences, ) + preferences := l.UserPreferences() + switch { case symbolCompletion.request != nil: request := *symbolCompletion.request @@ -5098,8 +5090,8 @@ func (l *LanguageService) getCompletionItemDetails( } case symbolCompletion.symbol != nil: symbolDetails := symbolCompletion.symbol - actions := l.getCompletionItemActions(ctx, checker, file, position, itemData, symbolDetails, preferences) - return createCompletionDetailsForSymbol( + actions := l.getCompletionItemActions(ctx, checker, file, position, itemData, symbolDetails) + return l.createCompletionDetailsForSymbol( item, symbolDetails.symbol, checker, @@ -5145,9 +5137,8 @@ func (l *LanguageService) getSymbolCompletionFromItemData( ch *checker.Checker, file *ast.SourceFile, position int, - itemData *itemData, + itemData *CompletionItemData, clientOptions *lsproto.CompletionClientCapabilities, - preferences *UserPreferences, ) detailsData { if itemData.Source == SourceSwitchCases { return detailsData{ @@ -5177,6 +5168,7 @@ func (l *LanguageService) getSymbolCompletionFromItemData( data := completionData.(*completionDataData) + preferences := l.UserPreferences() var literal literalValue for _, l := range data.literals { if completionNameForLiteral(file, preferences, l) == itemData.Name { @@ -5194,9 +5186,8 @@ func (l *LanguageService) getSymbolCompletionFromItemData( // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - for _, symbol := range data.symbols { - symbolId := ast.GetSymbolId(symbol) - origin := data.symbolToOriginInfoMap[symbolId] + for index, symbol := range data.symbols { + origin := data.symbolToOriginInfoMap[index] displayName, _ := getCompletionEntryDisplayNameForSymbol(symbol, origin, data.completionKind, data.isJsxIdentifierExpected) if displayName == itemData.Name && (itemData.Source == string(completionSourceClassMemberSnippet) && symbol.Flags&ast.SymbolFlagsClassMember != 0 || @@ -5219,15 +5210,15 @@ func (l *LanguageService) getSymbolCompletionFromItemData( return detailsData{} } -func (l *LanguageService) getAutoImportSymbolFromCompletionEntryData(ch *checker.Checker, name string, autoImportData *completionEntryData) *symbolDetails { +func (l *LanguageService) getAutoImportSymbolFromCompletionEntryData(ch *checker.Checker, name string, autoImportData *AutoImportData) *symbolDetails { containingProgram := l.GetProgram() // !!! isPackageJson ? packageJsonAutoimportProvider : program var moduleSymbol *ast.Symbol if autoImportData.AmbientModuleName != nil { moduleSymbol = ch.TryFindAmbientModule(*autoImportData.AmbientModuleName) - } else if autoImportData.FileName != nil { - moduleSymbolSourceFile := containingProgram.GetSourceFile(*autoImportData.FileName) + } else if autoImportData.FileName != "" { + moduleSymbolSourceFile := containingProgram.GetSourceFile(autoImportData.FileName) if moduleSymbolSourceFile == nil { - panic("module sourceFile not found: " + *autoImportData.FileName) + panic("module sourceFile not found: " + autoImportData.FileName) } moduleSymbol = ch.GetMergedSymbol(moduleSymbolSourceFile.Symbol) } @@ -5253,7 +5244,7 @@ func (l *LanguageService) getAutoImportSymbolFromCompletionEntryData(ch *checker } origin := &symbolOriginInfo{ kind: symbolOriginInfoKindExport, - fileName: *autoImportData.FileName, + fileName: autoImportData.FileName, isFromPackageJson: autoImportData.IsPackageJsonImport.IsTrue(), isDefaultExport: isDefaultExport, data: autoImportData.toSymbolOriginExport(name, moduleSymbol, isDefaultExport), @@ -5296,7 +5287,7 @@ type codeAction struct { changes []*lsproto.TextEdit } -func createCompletionDetailsForSymbol( +func (l *LanguageService) createCompletionDetailsForSymbol( item *lsproto.CompletionItem, symbol *ast.Symbol, checker *checker.Checker, @@ -5309,7 +5300,7 @@ func createCompletionDetailsForSymbol( details = append(details, action.description) edits = append(edits, action.changes...) } - quickInfo, documentation := getQuickInfoAndDocumentationForSymbol(checker, symbol, location) + quickInfo, documentation := l.getQuickInfoAndDocumentationForSymbol(checker, symbol, location) details = append(details, quickInfo) if len(edits) != 0 { item.AdditionalTextEdits = &edits @@ -5318,7 +5309,7 @@ func createCompletionDetailsForSymbol( } // !!! snippets -func (l *LanguageService) getCompletionItemActions(ctx context.Context, ch *checker.Checker, file *ast.SourceFile, position int, itemData *itemData, symbolDetails *symbolDetails, preferences *UserPreferences) []codeAction { +func (l *LanguageService) getCompletionItemActions(ctx context.Context, ch *checker.Checker, file *ast.SourceFile, position int, itemData *CompletionItemData, symbolDetails *symbolDetails) []codeAction { if itemData.AutoImport != nil && itemData.AutoImport.ModuleSpecifier != "" && symbolDetails.previousToken != nil { // Import statement completion: 'import c|' if symbolDetails.contextToken != nil && l.getImportStatementCompletionInfo(symbolDetails.contextToken, file).replacementSpan != nil { @@ -5363,7 +5354,6 @@ func (l *LanguageService) getCompletionItemActions(ctx context.Context, ch *chec itemData.Name, isJsxOpeningTagName, // formatContext, - preferences, ) if !(moduleSpecifier == itemData.AutoImport.ModuleSpecifier || itemData.AutoImport.ModuleSpecifier == "") { diff --git a/internal/ls/converters.go b/internal/ls/converters.go index b7730f3e5d..2fb9d262a3 100644 --- a/internal/ls/converters.go +++ b/internal/ls/converters.go @@ -166,6 +166,8 @@ func (c *Converters) LineAndCharacterToPosition(script Script, lineAndCharacter func (c *Converters) PositionToLineAndCharacter(script Script, position core.TextPos) lsproto.Position { // UTF-8 offset to UTF-8/16 0-indexed line and character + position = min(position, core.TextPos(len(script.Text()))) + lineMap := c.getLineMap(script.FileName()) line, isLineStart := slices.BinarySearch(lineMap.LineStarts, position) diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index f0ed4ce0e0..bab0f63b61 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -51,7 +51,7 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen } func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, position int, node *ast.Node, program *compiler.Program, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { - options := refOptions{use: referenceUseReferences} + options := refOptions{use: referenceUseNone} referenceEntries := l.getReferencedSymbolsForNode(ctx, position, node, program, []*ast.SourceFile{sourceFile}, options, &collections.Set[string]{}) if referenceEntries == nil { return nil diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index 7e31e181e0..4b937d094e 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -349,7 +349,7 @@ func getSymbolScope(symbol *ast.Symbol) *ast.Node { // If this is private property or method, the scope is the containing class if symbol.Flags&(ast.SymbolFlagsProperty|ast.SymbolFlagsMethod) != 0 { privateDeclaration := core.Find(declarations, func(d *ast.Node) bool { - return checker.HasModifier(d, ast.ModifierFlagsPrivate) || ast.IsPrivateIdentifierClassElementDeclaration(d) + return ast.HasModifier(d, ast.ModifierFlagsPrivate) || ast.IsPrivateIdentifierClassElementDeclaration(d) }) if privateDeclaration != nil { return ast.FindAncestorKind(privateDeclaration, ast.KindClassDeclaration) @@ -611,6 +611,10 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit } } + if options.use == referenceUseReferences || options.use == referenceUseRename { + node = getAdjustedLocation(node, options.use == referenceUseRename, ast.GetSourceFileOfNode(node)) + } + checker, done := program.GetTypeChecker(ctx) defer done() diff --git a/internal/ls/format.go b/internal/ls/format.go index 548c766741..9e0f55cf19 100644 --- a/internal/ls/format.go +++ b/internal/ls/format.go @@ -113,7 +113,8 @@ func (l *LanguageService) getFormattingEditsAfterKeystroke( ) []core.TextChange { ctx = format.WithFormatCodeSettings(ctx, options, options.NewLineCharacter) - if isInComment(file, position, nil) == nil { + tokenAtPosition := astnav.GetTokenAtPosition(file, position) + if isInComment(file, position, tokenAtPosition) == nil { switch key { case "{": return format.FormatOnOpeningCurly(ctx, file, position) diff --git a/internal/ls/format_test.go b/internal/ls/format_test.go new file mode 100644 index 0000000000..b1f21d8fff --- /dev/null +++ b/internal/ls/format_test.go @@ -0,0 +1,72 @@ +package ls + +import ( + "context" + "testing" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/parser" +) + +// Test for issue: Panic Handling textDocument/onTypeFormatting +// This reproduces the panic when pressing enter in an empty file +func TestGetFormattingEditsAfterKeystroke_EmptyFile(t *testing.T) { + t.Parallel() + // Create an empty file + text := "" + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/index.ts", + Path: "/index.ts", + }, text, core.ScriptKindTS) + + // Create language service with nil program (we're only testing the formatting function) + langService := &LanguageService{} + + // Test formatting after keystroke with newline character at position 0 + ctx := context.Background() + options := format.GetDefaultFormatCodeSettings("\n") + + // This should not panic + edits := langService.getFormattingEditsAfterKeystroke( + ctx, + sourceFile, + options, + 0, // position + "\n", + ) + + // Should return nil or empty edits, not panic + _ = edits +} + +// Test with a simple statement +func TestGetFormattingEditsAfterKeystroke_SimpleStatement(t *testing.T) { + t.Parallel() + // Create a file with a simple statement + text := "const x = 1" + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/index.ts", + Path: "/index.ts", + }, text, core.ScriptKindTS) + + // Create language service with nil program + langService := &LanguageService{} + + // Test formatting after keystroke with newline character at end of statement + ctx := context.Background() + options := format.GetDefaultFormatCodeSettings("\n") + + // This should not panic + edits := langService.getFormattingEditsAfterKeystroke( + ctx, + sourceFile, + options, + len(text), // position at end of file + "\n", + ) + + // Should return nil or empty edits, not panic + _ = edits +} diff --git a/internal/ls/host.go b/internal/ls/host.go index dfeaa02a62..817fde173c 100644 --- a/internal/ls/host.go +++ b/internal/ls/host.go @@ -1,10 +1,15 @@ package ls -import "github.com/microsoft/typescript-go/internal/sourcemap" +import ( + "github.com/microsoft/typescript-go/internal/format" + "github.com/microsoft/typescript-go/internal/sourcemap" +) type Host interface { UseCaseSensitiveFileNames() bool ReadFile(path string) (contents string, ok bool) Converters() *Converters + UserPreferences() *UserPreferences + FormatOptions() *format.FormatCodeSettings GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo } diff --git a/internal/ls/hover.go b/internal/ls/hover.go index a608fdf024..d432908aa7 100644 --- a/internal/ls/hover.go +++ b/internal/ls/hover.go @@ -27,7 +27,7 @@ func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto. } c, done := program.GetTypeCheckerForFile(ctx, file) defer done() - quickInfo, documentation := getQuickInfoAndDocumentation(c, node) + quickInfo, documentation := l.getQuickInfoAndDocumentation(c, node) if quickInfo == "" { return lsproto.HoverOrNull{}, nil } @@ -43,11 +43,11 @@ func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto. }, nil } -func getQuickInfoAndDocumentation(c *checker.Checker, node *ast.Node) (string, string) { - return getQuickInfoAndDocumentationForSymbol(c, c.GetSymbolAtLocation(node), getNodeForQuickInfo(node)) +func (l *LanguageService) getQuickInfoAndDocumentation(c *checker.Checker, node *ast.Node) (string, string) { + return l.getQuickInfoAndDocumentationForSymbol(c, c.GetSymbolAtLocation(node), getNodeForQuickInfo(node)) } -func getQuickInfoAndDocumentationForSymbol(c *checker.Checker, symbol *ast.Symbol, node *ast.Node) (string, string) { +func (l *LanguageService) getQuickInfoAndDocumentationForSymbol(c *checker.Checker, symbol *ast.Symbol, node *ast.Node) (string, string) { quickInfo, declaration := getQuickInfoAndDeclarationAtLocation(c, symbol, node) if quickInfo == "" { return "", "" @@ -55,7 +55,7 @@ func getQuickInfoAndDocumentationForSymbol(c *checker.Checker, symbol *ast.Symbo var b strings.Builder if declaration != nil { if jsdoc := getJSDocOrTag(declaration); jsdoc != nil && !containsTypedefTag(jsdoc) { - writeComments(&b, jsdoc.Comments()) + l.writeComments(&b, c, jsdoc.Comments()) if jsdoc.Kind == ast.KindJSDoc { if tags := jsdoc.AsJSDoc().Tags; tags != nil { for _, tag := range tags.Nodes { @@ -90,7 +90,7 @@ func getQuickInfoAndDocumentationForSymbol(c *checker.Checker, symbol *ast.Symbo b.WriteString("— ") } } - writeComments(&b, comments) + l.writeComments(&b, c, comments) } } } @@ -411,61 +411,90 @@ func writeCode(b *strings.Builder, lang string, code string) { b.WriteByte('\n') } -func writeComments(b *strings.Builder, comments []*ast.Node) { +func (l *LanguageService) writeComments(b *strings.Builder, c *checker.Checker, comments []*ast.Node) { for _, comment := range comments { switch comment.Kind { case ast.KindJSDocText: b.WriteString(comment.Text()) - case ast.KindJSDocLink: - name := comment.Name() - text := comment.AsJSDocLink().Text() - if name != nil { - if text == "" { - writeEntityName(b, name) - } else { - writeEntityNameParts(b, name) - } - } - b.WriteString(text) + case ast.KindJSDocLink, ast.KindJSDocLinkPlain: + l.writeJSDocLink(b, c, comment, false /*quote*/) case ast.KindJSDocLinkCode: - // !!! TODO: This is a temporary placeholder implementation that needs to be updated later - name := comment.Name() - text := comment.AsJSDocLinkCode().Text() - if name != nil { - if text == "" { - writeEntityName(b, name) - } else { - writeEntityNameParts(b, name) - } - } - b.WriteString(text) - case ast.KindJSDocLinkPlain: - // !!! TODO: This is a temporary placeholder implementation that needs to be updated later - name := comment.Name() - text := comment.AsJSDocLinkPlain().Text() - if name != nil { - if text == "" { - writeEntityName(b, name) - } else { - writeEntityNameParts(b, name) - } + l.writeJSDocLink(b, c, comment, true /*quote*/) + } + } +} + +func (l *LanguageService) writeJSDocLink(b *strings.Builder, c *checker.Checker, link *ast.Node, quote bool) { + name := link.Name() + text := strings.Trim(link.Text(), " ") + if name == nil { + writeQuotedString(b, text, quote) + return + } + if ast.IsIdentifier(name) && (name.Text() == "http" || name.Text() == "https") && strings.HasPrefix(text, "://") { + linkText := name.Text() + text + linkUri := linkText + if commentPos := strings.IndexFunc(linkText, func(ch rune) bool { return ch == ' ' || ch == '|' }); commentPos >= 0 { + linkUri = linkText[:commentPos] + linkText = trimCommentPrefix(linkText[commentPos:]) + if linkText == "" { + linkText = linkUri } - b.WriteString(text) } + writeMarkdownLink(b, linkText, linkUri, quote) + return + } + declarations := getDeclarationsFromLocation(c, name) + if len(declarations) != 0 { + declaration := declarations[0] + file := ast.GetSourceFileOfNode(declaration) + node := core.OrElse(ast.GetNameOfDeclaration(declaration), declaration) + loc := l.getMappedLocation(file.FileName(), createRangeFromNode(node, file)) + prefixLen := core.IfElse(strings.HasPrefix(text, "()"), 2, 0) + linkText := trimCommentPrefix(text[prefixLen:]) + if linkText == "" { + linkText = getEntityNameString(name) + text[:prefixLen] + } + linkUri := fmt.Sprintf("%s#%d,%d-%d,%d", loc.Uri, loc.Range.Start.Line+1, loc.Range.Start.Character+1, loc.Range.End.Line+1, loc.Range.End.Character+1) + writeMarkdownLink(b, linkText, linkUri, quote) + return } + writeQuotedString(b, getEntityNameString(name)+" "+text, quote) +} + +func trimCommentPrefix(text string) string { + return strings.TrimLeft(strings.TrimPrefix(strings.TrimLeft(text, " "), "|"), " ") +} + +func writeMarkdownLink(b *strings.Builder, text string, uri string, quote bool) { + b.WriteString("[") + writeQuotedString(b, text, quote) + b.WriteString("](") + b.WriteString(uri) + b.WriteString(")") } func writeOptionalEntityName(b *strings.Builder, name *ast.Node) { if name != nil { b.WriteString(" ") - writeEntityName(b, name) + writeQuotedString(b, getEntityNameString(name), true /*quote*/) + } +} + +func writeQuotedString(b *strings.Builder, str string, quote bool) { + if quote && !strings.Contains(str, "`") { + b.WriteString("`") + b.WriteString(str) + b.WriteString("`") + } else { + b.WriteString(str) } } -func writeEntityName(b *strings.Builder, name *ast.Node) { - b.WriteString("`") - writeEntityNameParts(b, name) - b.WriteString("`") +func getEntityNameString(name *ast.Node) string { + var b strings.Builder + writeEntityNameParts(&b, name) + return b.String() } func writeEntityNameParts(b *strings.Builder, node *ast.Node) { diff --git a/internal/ls/languageservice.go b/internal/ls/languageservice.go index c7c4596dce..20038a3e07 100644 --- a/internal/ls/languageservice.go +++ b/internal/ls/languageservice.go @@ -3,6 +3,7 @@ package ls import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/format" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/sourcemap" ) @@ -30,6 +31,17 @@ func (l *LanguageService) GetProgram() *compiler.Program { return l.program } +func (l *LanguageService) UserPreferences() *UserPreferences { + return l.host.UserPreferences() +} + +func (l *LanguageService) FormatOptions() *format.FormatCodeSettings { + if formatOptions := l.host.FormatOptions(); formatOptions != nil { + return formatOptions + } + return format.GetDefaultFormatCodeSettings(l.GetProgram().Options().NewLine.GetNewLineCharacter()) +} + func (l *LanguageService) tryGetProgramAndFile(fileName string) (*compiler.Program, *ast.SourceFile) { program := l.GetProgram() file := program.GetSourceFile(fileName) diff --git a/internal/ls/organizeimports.go b/internal/ls/organizeimports.go index 8cdeddab5d..973fa269e1 100644 --- a/internal/ls/organizeimports.go +++ b/internal/ls/organizeimports.go @@ -2,15 +2,26 @@ package ls import ( "cmp" + "math" "strings" "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/modulespecifiers" + "github.com/microsoft/typescript-go/internal/stringutil" "github.com/microsoft/typescript-go/internal/tspath" ) +var ( + caseInsensitiveOrganizeImportsComparer = []func(a, b string) int{getOrganizeImportsOrdinalStringComparer(true)} + caseSensitiveOrganizeImportsComparer = []func(a, b string) int{getOrganizeImportsOrdinalStringComparer(false)} + organizeImportsComparers = []func(a, b string) int{ + caseInsensitiveOrganizeImportsComparer[0], + caseSensitiveOrganizeImportsComparer[0], + } +) + // statement = anyImportOrRequireStatement func getImportDeclarationInsertIndex(sortedImports []*ast.Statement, newImport *ast.Statement, comparer func(a, b *ast.Statement) int) int { // !!! @@ -20,12 +31,10 @@ func getImportDeclarationInsertIndex(sortedImports []*ast.Statement, newImport * // returns `-1` if `a` is better than `b` // // note: this sorts in descending order of preference; different than convention in other cmp-like functions -func compareModuleSpecifiers( +func (l *LanguageService) compareModuleSpecifiers( a *ImportFix, // !!! ImportFixWithModuleSpecifier b *ImportFix, // !!! ImportFixWithModuleSpecifier importingFile *ast.SourceFile, // | FutureSourceFile, - program *compiler.Program, - preferences UserPreferences, allowsImportingSpecifier func(specifier string) bool, toPath func(fileName string) tspath.Path, ) int { @@ -38,10 +47,10 @@ func compareModuleSpecifiers( ); comparison != 0 { return comparison } - if comparison := compareModuleSpecifierRelativity(a, b, preferences); comparison != 0 { + if comparison := compareModuleSpecifierRelativity(a, b, l.UserPreferences()); comparison != 0 { return comparison } - if comparison := compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program); comparison != 0 { + if comparison := compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, l.GetProgram()); comparison != 0 { return comparison } if comparison := compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile.Path(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile.Path(), toPath)); comparison != 0 { @@ -64,7 +73,7 @@ func compareBooleans(a, b bool) int { } // returns `-1` if `a` is better than `b` -func compareModuleSpecifierRelativity(a *ImportFix, b *ImportFix, preferences UserPreferences) int { +func compareModuleSpecifierRelativity(a *ImportFix, b *ImportFix, preferences *UserPreferences) int { switch preferences.ImportModuleSpecifierPreference { case modulespecifiers.ImportModuleSpecifierPreferenceNonRelative, modulespecifiers.ImportModuleSpecifierPreferenceProjectRelative: return compareBooleans(a.moduleSpecifierKind == modulespecifiers.ResultKindRelative, b.moduleSpecifierKind == modulespecifiers.ResultKindRelative) @@ -126,3 +135,252 @@ func isIndexFileName(fileName string) bool { } return fileName == "index" } + +func getOrganizeImportsOrdinalStringComparer(ignoreCase bool) func(a, b string) int { + if ignoreCase { + return stringutil.CompareStringsCaseInsensitiveEslintCompatible + } + return stringutil.CompareStringsCaseSensitive +} + +// getModuleSpecifierExpression returns the module specifier expression from an import/require statement +func getModuleSpecifierExpression(declaration *ast.Statement) *ast.Expression { + switch declaration.Kind { + case ast.KindImportEqualsDeclaration: + importEquals := declaration.AsImportEqualsDeclaration() + if importEquals.ModuleReference.Kind == ast.KindExternalModuleReference { + return importEquals.ModuleReference.AsExternalModuleReference().Expression + } + return nil + case ast.KindImportDeclaration: + return declaration.AsImportDeclaration().ModuleSpecifier + case ast.KindVariableStatement: + // For require statements: const x = require('...') + variableStatement := declaration.AsVariableStatement() + declarations := variableStatement.DeclarationList.AsVariableDeclarationList().Declarations.Nodes + if len(declarations) > 0 { + decl := declarations[0] + initializer := decl.Initializer() + if initializer != nil && initializer.Kind == ast.KindCallExpression { + callExpr := initializer.AsCallExpression() + if len(callExpr.Arguments.Nodes) > 0 { + return callExpr.Arguments.Nodes[0] + } + } + } + return nil + default: + return nil + } +} + +func getExternalModuleName(specifier *ast.Expression) string { + if specifier != nil && ast.IsStringLiteralLike(specifier.AsNode()) { + return specifier.Text() + } + return "" +} + +// compareModuleSpecifiersWorker compares two module specifiers +func compareModuleSpecifiersWorker(m1 *ast.Expression, m2 *ast.Expression, comparer func(a, b string) int) int { + name1 := getExternalModuleName(m1) + name2 := getExternalModuleName(m2) + if cmp := compareBooleans(name1 == "", name2 == ""); cmp != 0 { + return cmp + } + if cmp := compareBooleans(tspath.IsExternalModuleNameRelative(name1), tspath.IsExternalModuleNameRelative(name2)); cmp != 0 { + return cmp + } + return comparer(name1, name2) +} + +// compareImportKind returns comparison order based on import kind +func compareImportKind(s1 *ast.Statement, s2 *ast.Statement) int { + return cmp.Compare(getImportKindOrder(s1), getImportKindOrder(s2)) +} + +// getImportKindOrder returns the sort order for different import kinds: +// 1. Side-effect imports +// 2. Type-only imports +// 3. Namespace imports +// 4. Default imports +// 5. Named imports +// 6. ImportEqualsDeclarations +// 7. Require variable statements +func getImportKindOrder(s1 *ast.Statement) int { + switch s1.Kind { + case ast.KindImportDeclaration: + importDecl := s1.AsImportDeclaration() + if importDecl.ImportClause == nil { + return 0 // Side-effect import + } + importClause := importDecl.ImportClause.AsImportClause() + if importClause.IsTypeOnly() { + return 1 // Type-only import + } + if importClause.NamedBindings != nil && importClause.NamedBindings.Kind == ast.KindNamespaceImport { + return 2 // Namespace import + } + if importClause.Name() != nil { + return 3 // Default import + } + return 4 // Named imports + case ast.KindImportEqualsDeclaration: + return 5 + case ast.KindVariableStatement: + return 6 // Require statement + default: + return 7 + } +} + +// compareImportsOrRequireStatements compares two import or require statements for sorting +func compareImportsOrRequireStatements(s1 *ast.Statement, s2 *ast.Statement, comparer func(a, b string) int) int { + if cmp := compareModuleSpecifiersWorker(getModuleSpecifierExpression(s1), getModuleSpecifierExpression(s2), comparer); cmp != 0 { + return cmp + } + return compareImportKind(s1, s2) +} + +// compareImportOrExportSpecifiers compares two import or export specifiers +func compareImportOrExportSpecifiers(s1 *ast.Node, s2 *ast.Node, comparer func(a, b string) int, preferences *UserPreferences) int { + typeOrder := OrganizeImportsTypeOrderLast + if preferences != nil { + typeOrder = preferences.OrganizeImportsTypeOrder + } + + s1Name := s1.Name().Text() + s2Name := s2.Name().Text() + + switch typeOrder { + case OrganizeImportsTypeOrderFirst: + if cmp := compareBooleans(s2.IsTypeOnly(), s1.IsTypeOnly()); cmp != 0 { + return cmp + } + return comparer(s1Name, s2Name) + case OrganizeImportsTypeOrderInline: + return comparer(s1Name, s2Name) + default: // OrganizeImportsTypeOrderLast + if cmp := compareBooleans(s1.IsTypeOnly(), s2.IsTypeOnly()); cmp != 0 { + return cmp + } + return comparer(s1Name, s2Name) + } +} + +// getNamedImportSpecifierComparer returns a comparer function for import/export specifiers +func getNamedImportSpecifierComparer(preferences *UserPreferences, comparer func(a, b string) int) func(s1, s2 *ast.Node) int { + if comparer == nil { + ignoreCase := false + if preferences != nil && !preferences.OrganizeImportsIgnoreCase.IsUnknown() { + ignoreCase = preferences.OrganizeImportsIgnoreCase.IsTrue() + } + comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase) + } + return func(s1, s2 *ast.Node) int { + return compareImportOrExportSpecifiers(s1, s2, comparer, preferences) + } +} + +// getImportSpecifierInsertionIndex finds the insertion index for a new import specifier +func getImportSpecifierInsertionIndex(sortedImports []*ast.Node, newImport *ast.Node, comparer func(s1, s2 *ast.Node) int) int { + return core.FirstResult(core.BinarySearchUniqueFunc(sortedImports, func(mid int, value *ast.Node) int { + return comparer(value, newImport) + })) +} + +// getOrganizeImportsStringComparerWithDetection detects the string comparer to use based on existing imports +func (l *LanguageService) getOrganizeImportsStringComparerWithDetection(originalImportDecls []*ast.Statement) (comparer func(a, b string) int, isSorted bool) { + result := detectModuleSpecifierCaseBySort([][]*ast.Statement{originalImportDecls}, getComparers(l.UserPreferences())) + return result.comparer, result.isSorted +} + +func getComparers(preferences *UserPreferences) []func(a string, b string) int { + if preferences != nil { + switch preferences.OrganizeImportsIgnoreCase { + case core.TSTrue: + return caseInsensitiveOrganizeImportsComparer + case core.TSFalse: + return caseSensitiveOrganizeImportsComparer + } + } + + return organizeImportsComparers +} + +type caseSensitivityDetectionResult struct { + comparer func(a, b string) int + isSorted bool +} + +func detectModuleSpecifierCaseBySort(importDeclsByGroup [][]*ast.Statement, comparersToTest []func(a, b string) int) caseSensitivityDetectionResult { + moduleSpecifiersByGroup := make([][]string, 0, len(importDeclsByGroup)) + for _, importGroup := range importDeclsByGroup { + moduleNames := make([]string, 0, len(importGroup)) + for _, decl := range importGroup { + if expr := getModuleSpecifierExpression(decl); expr != nil { + moduleNames = append(moduleNames, getExternalModuleName(expr)) + } else { + moduleNames = append(moduleNames, "") + } + } + moduleSpecifiersByGroup = append(moduleSpecifiersByGroup, moduleNames) + } + return detectCaseSensitivityBySort(moduleSpecifiersByGroup, comparersToTest) +} + +func detectCaseSensitivityBySort(originalGroups [][]string, comparersToTest []func(a, b string) int) caseSensitivityDetectionResult { + var bestComparer func(a, b string) int + bestDiff := math.MaxInt + + for _, curComparer := range comparersToTest { + diffOfCurrentComparer := 0 + + for _, listToSort := range originalGroups { + if len(listToSort) <= 1 { + continue + } + diff := measureSortedness(listToSort, curComparer) + diffOfCurrentComparer += diff + } + + if diffOfCurrentComparer < bestDiff { + bestDiff = diffOfCurrentComparer + bestComparer = curComparer + } + } + + if bestComparer == nil && len(comparersToTest) > 0 { + bestComparer = comparersToTest[0] + } + + return caseSensitivityDetectionResult{ + comparer: bestComparer, + isSorted: bestDiff == 0, + } +} + +func measureSortedness[T any](arr []T, comparer func(a, b T) int) int { + i := 0 + for j := range len(arr) - 1 { + if comparer(arr[j], arr[j+1]) > 0 { + i++ + } + } + return i +} + +// getNamedImportSpecifierComparerWithDetection detects the appropriate comparer for named imports +func (l *LanguageService) getNamedImportSpecifierComparerWithDetection(importDecl *ast.Node, sourceFile *ast.SourceFile) (specifierComparer func(s1, s2 *ast.Node) int, isSorted core.Tristate) { + preferences := l.UserPreferences() + specifierComparer = getNamedImportSpecifierComparer(preferences, getComparers(preferences)[0]) + // Try to detect from the current import declaration + if (preferences == nil || preferences.OrganizeImportsIgnoreCase.IsUnknown() || preferences.OrganizeImportsTypeOrder == OrganizeImportsTypeOrderLast) && + importDecl.Kind == ast.KindImportDeclaration { + // For now, just return the default comparer + // Full detection logic would require porting detectNamedImportOrganizationBySort + return specifierComparer, core.TSUnknown + } + + return specifierComparer, core.TSUnknown +} diff --git a/internal/ls/selectionranges.go b/internal/ls/selectionranges.go new file mode 100644 index 0000000000..823730282d --- /dev/null +++ b/internal/ls/selectionranges.go @@ -0,0 +1,188 @@ +package ls + +import ( + "context" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/scanner" +) + +func (l *LanguageService) ProvideSelectionRanges(ctx context.Context, params *lsproto.SelectionRangeParams) (lsproto.SelectionRangeResponse, error) { + _, sourceFile := l.getProgramAndFile(params.TextDocument.Uri) + if sourceFile == nil { + return lsproto.SelectionRangesOrNull{}, nil + } + + var results []*lsproto.SelectionRange + for _, position := range params.Positions { + pos := l.converters.LineAndCharacterToPosition(sourceFile, position) + selectionRange := getSmartSelectionRange(l, sourceFile, int(pos)) + if selectionRange != nil { + results = append(results, selectionRange) + } + } + + return lsproto.SelectionRangesOrNull{SelectionRanges: &results}, nil +} + +func getSmartSelectionRange(l *LanguageService, sourceFile *ast.SourceFile, pos int) *lsproto.SelectionRange { + factory := &ast.NodeFactory{} + + nodeContainsPosition := func(node *ast.Node) bool { + if node == nil { + return false + } + start := scanner.GetTokenPosOfNode(node, sourceFile, true /*includeJSDoc*/) + end := node.End() + return start <= pos && pos < end + } + + pushSelectionRange := func(current *lsproto.SelectionRange, start, end int) *lsproto.SelectionRange { + if start == end { + return current + } + + if !(start <= pos && pos <= end) { + return current + } + + lspRange := l.converters.ToLSPRange(sourceFile, core.NewTextRange(start, end)) + + if current != nil && current.Range == lspRange { + return current + } + + return &lsproto.SelectionRange{ + Range: lspRange, + Parent: current, + } + } + + pushSelectionCommentRange := func(current *lsproto.SelectionRange, start, end int) *lsproto.SelectionRange { + current = pushSelectionRange(current, start, end) + + commentPos := start + text := sourceFile.Text() + for commentPos < end && commentPos < len(text) && text[commentPos] == '/' { + commentPos++ + } + current = pushSelectionRange(current, commentPos, end) + + return current + } + + positionsAreOnSameLine := func(pos1, pos2 int) bool { + if pos1 == pos2 { + return true + } + lspPos1 := l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(pos1)) + lspPos2 := l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(pos2)) + return lspPos1.Line == lspPos2.Line + } + + shouldSkipNode := func(node *ast.Node, parent *ast.Node) bool { + if ast.IsBlock(node) { + return true + } + + if ast.IsTemplateSpan(node) || ast.IsTemplateHead(node) || ast.IsTemplateTail(node) { + return true + } + + if parent != nil && ast.IsVariableDeclarationList(node) && ast.IsVariableStatement(parent) { + return true + } + + // Skip lone variable declarations + if parent != nil && ast.IsVariableDeclaration(node) && ast.IsVariableDeclarationList(parent) { + decl := parent.AsVariableDeclarationList() + if decl != nil && len(decl.Declarations.Nodes) == 1 { + return true + } + } + + if ast.IsJSDocTypeExpression(node) || ast.IsJSDocSignature(node) || ast.IsJSDocTypeLiteral(node) { + return true + } + + return false + } + + fullRange := l.converters.ToLSPRange(sourceFile, core.NewTextRange(sourceFile.Pos(), sourceFile.End())) + result := &lsproto.SelectionRange{ + Range: fullRange, + } + + var current *ast.Node + for current = sourceFile.AsNode(); current != nil; { + var next *ast.Node + parent := current + + visit := func(node *ast.Node) *ast.Node { + if node != nil && next == nil { + var foundComment *ast.CommentRange + for comment := range scanner.GetTrailingCommentRanges(factory, sourceFile.Text(), node.End()) { + foundComment = &comment + break + } + if foundComment != nil && foundComment.Kind == ast.KindSingleLineCommentTrivia { + result = pushSelectionCommentRange(result, foundComment.Pos(), foundComment.End()) + } + + if nodeContainsPosition(node) { + // Add range for multi-line function bodies before skipping the block + if ast.IsBlock(node) && ast.IsFunctionLikeDeclaration(parent) { + if !positionsAreOnSameLine(astnav.GetStartOfNode(node, sourceFile, false), node.End()) { + start := astnav.GetStartOfNode(node, sourceFile, false) + end := node.End() + result = pushSelectionRange(result, start, end) + } + } + + if !shouldSkipNode(node, parent) { + start := astnav.GetStartOfNode(node, sourceFile, false) + end := node.End() + result = pushSelectionRange(result, start, end) + } + + next = node + } + } + return node + } + + visitNodes := func(nodes *ast.NodeList, v *ast.NodeVisitor) *ast.NodeList { + if nodes != nil && len(nodes.Nodes) > 0 { + shouldSkipList := parent != nil && ast.IsVariableDeclarationList(parent) + + if !shouldSkipList { + start := astnav.GetStartOfNode(nodes.Nodes[0], sourceFile, false) + end := nodes.Nodes[len(nodes.Nodes)-1].End() + + if start <= pos && pos < end { + result = pushSelectionRange(result, start, end) + } + } + } + return v.VisitNodes(nodes) + } + + // Visit JSDoc nodes first if they exist + if current.Flags&ast.NodeFlagsHasJSDoc != 0 { + for _, jsdoc := range current.JSDoc(sourceFile) { + visit(jsdoc) + } + } + + tempVisitor := ast.NewNodeVisitor(visit, nil, ast.NodeVisitorHooks{ + VisitNodes: visitNodes, + }) + + current.VisitEachChild(tempVisitor) + current = next + } + return result +} diff --git a/internal/ls/signaturehelp.go b/internal/ls/signaturehelp.go index 09284f9594..b1d33260c8 100644 --- a/internal/ls/signaturehelp.go +++ b/internal/ls/signaturehelp.go @@ -43,7 +43,6 @@ func (l *LanguageService) ProvideSignatureHelp( position lsproto.Position, context *lsproto.SignatureHelpContext, clientOptions *lsproto.SignatureHelpClientCapabilities, - preferences *UserPreferences, ) (lsproto.SignatureHelpResponse, error) { program, sourceFile := l.getProgramAndFile(documentURI) items := l.GetSignatureHelpItems( @@ -52,8 +51,7 @@ func (l *LanguageService) ProvideSignatureHelp( program, sourceFile, context, - clientOptions, - preferences) + clientOptions) return lsproto.SignatureHelpOrNull{SignatureHelp: items}, nil } @@ -64,7 +62,6 @@ func (l *LanguageService) GetSignatureHelpItems( sourceFile *ast.SourceFile, context *lsproto.SignatureHelpContext, clientOptions *lsproto.SignatureHelpClientCapabilities, - preferences *UserPreferences, ) *lsproto.SignatureHelp { typeChecker, done := program.GetTypeCheckerForFile(ctx, sourceFile) defer done() diff --git a/internal/ls/source_map.go b/internal/ls/source_map.go index 62eafda161..c970070558 100644 --- a/internal/ls/source_map.go +++ b/internal/ls/source_map.go @@ -18,6 +18,12 @@ func (l *LanguageService) getMappedLocation(fileName string, fileRange core.Text } } endPos := l.tryGetSourcePosition(fileName, core.TextPos(fileRange.End())) + if endPos == nil { + endPos = &sourcemap.DocumentPosition{ + FileName: startPos.FileName, + Pos: startPos.Pos + fileRange.Len(), + } + } debug.Assert(endPos.FileName == startPos.FileName, "start and end should be in same file") newRange := core.NewTextRange(startPos.Pos, endPos.Pos) lspRange := l.createLspRangeFromRange(newRange, l.getScript(startPos.FileName)) diff --git a/internal/ls/string_completions.go b/internal/ls/string_completions.go index a1a3e6d7f8..749ad880c6 100644 --- a/internal/ls/string_completions.go +++ b/internal/ls/string_completions.go @@ -46,7 +46,6 @@ func (l *LanguageService) getStringLiteralCompletions( position int, contextToken *ast.Node, compilerOptions *core.CompilerOptions, - preferences *UserPreferences, clientOptions *lsproto.CompletionClientCapabilities, ) *lsproto.CompletionList { // !!! reference comment @@ -58,8 +57,7 @@ func (l *LanguageService) getStringLiteralCompletions( ctx, file, contextToken, - position, - preferences) + position) return l.convertStringLiteralCompletions( ctx, entries, @@ -67,7 +65,6 @@ func (l *LanguageService) getStringLiteralCompletions( file, position, compilerOptions, - preferences, clientOptions, ) } @@ -81,7 +78,6 @@ func (l *LanguageService) convertStringLiteralCompletions( file *ast.SourceFile, position int, options *core.CompilerOptions, - preferences *UserPreferences, clientOptions *lsproto.CompletionClientCapabilities, ) *lsproto.CompletionList { if completion == nil { @@ -108,7 +104,6 @@ func (l *LanguageService) convertStringLiteralCompletions( contextToken, /*replacementToken*/ position, file, - preferences, options, clientOptions, ) @@ -229,7 +224,6 @@ func (l *LanguageService) getStringLiteralCompletionEntries( file *ast.SourceFile, node *ast.StringLiteralLike, position int, - preferences *UserPreferences, ) *stringLiteralCompletions { typeChecker, done := l.GetProgram().GetTypeCheckerForFile(ctx, file) defer done() @@ -242,7 +236,6 @@ func (l *LanguageService) getStringLiteralCompletionEntries( file, node, l.GetProgram(), - preferences, ) } return fromUnionableLiteralType(grandparent, parent, position, typeChecker) @@ -323,7 +316,7 @@ func (l *LanguageService) getStringLiteralCompletionEntries( // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return getStringLiteralCompletionsFromModuleNames(file, node, l.GetProgram(), preferences) + return getStringLiteralCompletionsFromModuleNames(file, node, l.GetProgram()) case ast.KindCaseClause: tracker := newCaseClauseTracker(typeChecker, parent.Parent.AsCaseBlock().Clauses.Nodes) contextualTypes := fromContextualType(checker.ContextFlagsCompletions, node, typeChecker) @@ -527,7 +520,6 @@ func getStringLiteralCompletionsFromModuleNames( file *ast.SourceFile, node *ast.LiteralExpression, program *compiler.Program, - preferences *UserPreferences, ) *stringLiteralCompletions { // !!! needs `getModeForUsageLocationWorker` return nil @@ -678,7 +670,6 @@ func (l *LanguageService) getStringLiteralCompletionDetails( file *ast.SourceFile, position int, contextToken *ast.Node, - preferences *UserPreferences, ) *lsproto.CompletionItem { if contextToken == nil || !ast.IsStringLiteralLike(contextToken) { return item @@ -688,15 +679,14 @@ func (l *LanguageService) getStringLiteralCompletionDetails( file, contextToken, position, - preferences, ) if completions == nil { return item } - return stringLiteralCompletionDetails(item, name, contextToken, completions, file, checker) + return l.stringLiteralCompletionDetails(item, name, contextToken, completions, file, checker) } -func stringLiteralCompletionDetails( +func (l *LanguageService) stringLiteralCompletionDetails( item *lsproto.CompletionItem, name string, location *ast.Node, @@ -716,7 +706,7 @@ func stringLiteralCompletionDetails( properties := completion.fromProperties for _, symbol := range properties.symbols { if symbol.Name == name { - return createCompletionDetailsForSymbol(item, symbol, checker, location, nil /*actions*/) + return l.createCompletionDetailsForSymbol(item, symbol, checker, location, nil /*actions*/) } } case completion.fromTypes != nil: diff --git a/internal/ls/userpreferences.go b/internal/ls/userpreferences.go index 11be04d64a..aece6a49a7 100644 --- a/internal/ls/userpreferences.go +++ b/internal/ls/userpreferences.go @@ -1,10 +1,28 @@ package ls import ( + "slices" + "strings" + "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/modulespecifiers" + "github.com/microsoft/typescript-go/internal/tsoptions" ) +func NewDefaultUserPreferences() *UserPreferences { + return &UserPreferences{ + IncludeCompletionsForModuleExports: core.TSTrue, + IncludeCompletionsForImportStatements: core.TSTrue, + + AllowRenameOfImportPath: true, + ProvideRefactorNotApplicableReason: true, + IncludeCompletionsWithSnippetText: core.TSTrue, + DisplayPartsForJSDoc: true, + DisableLineTextInReferences: true, + InteractiveInlayHints: true, + } +} + type UserPreferences struct { QuotePreference QuotePreference LazyConfiguredProjectsFromExternalProject bool // !!! @@ -84,7 +102,7 @@ type UserPreferences struct { // This preference is ignored if organizeImportsCollation is not `unicode`. // // Default: `true` - OrganizeImportsAccentCollation OrganizeImportsAccentCollation // !!! + OrganizeImportsAccentCollation bool // !!! // Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale // specified in organizeImportsCollationLocale is used. // @@ -97,7 +115,7 @@ type UserPreferences struct { OrganizeImportsCaseFirst OrganizeImportsCaseFirst // !!! // Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is type-only. // - // Default: `last` + // Default: `auto`, which defaults to `last` OrganizeImportsTypeOrder OrganizeImportsTypeOrder // !!! // ------- MoveToFile ------- @@ -137,12 +155,52 @@ type UserPreferences struct { type JsxAttributeCompletionStyle string const ( - JsxAttributeCompletionStyleUnknown JsxAttributeCompletionStyle = "" + JsxAttributeCompletionStyleUnknown JsxAttributeCompletionStyle = "" // !!! JsxAttributeCompletionStyleAuto JsxAttributeCompletionStyle = "auto" JsxAttributeCompletionStyleBraces JsxAttributeCompletionStyle = "braces" JsxAttributeCompletionStyleNone JsxAttributeCompletionStyle = "none" ) +func parseJsxAttributeCompletionStyle(val any) JsxAttributeCompletionStyle { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "braces": + return JsxAttributeCompletionStyleBraces + case "none": + return JsxAttributeCompletionStyleNone + } + } + return JsxAttributeCompletionStyleAuto +} + +func parseImportModuleSpecifierPreference(val any) modulespecifiers.ImportModuleSpecifierPreference { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "project-relative": + return modulespecifiers.ImportModuleSpecifierPreferenceProjectRelative + case "relative": + return modulespecifiers.ImportModuleSpecifierPreferenceRelative + case "non-relative": + return modulespecifiers.ImportModuleSpecifierPreferenceNonRelative + } + } + return modulespecifiers.ImportModuleSpecifierPreferenceShortest +} + +func parseImportModuleSpecifierEndingPreference(val any) modulespecifiers.ImportModuleSpecifierEndingPreference { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "minimal": + return modulespecifiers.ImportModuleSpecifierEndingPreferenceMinimal + case "index": + return modulespecifiers.ImportModuleSpecifierEndingPreferenceIndex + case "js": + return modulespecifiers.ImportModuleSpecifierEndingPreferenceJs + } + } + return modulespecifiers.ImportModuleSpecifierEndingPreferenceAuto +} + type IncludeInlayParameterNameHints string const ( @@ -151,15 +209,41 @@ const ( IncludeInlayParameterNameHintsLiterals IncludeInlayParameterNameHints = "literals" ) +func parseInlayParameterNameHints(val any) IncludeInlayParameterNameHints { + if prefStr, ok := val.(string); ok { + switch prefStr { + case "all": + return IncludeInlayParameterNameHintsAll + case "literals": + return IncludeInlayParameterNameHintsLiterals + } + } + return IncludeInlayParameterNameHintsNone +} + type IncludePackageJsonAutoImports string const ( - IncludePackageJsonAutoImportsUnknown IncludePackageJsonAutoImports = "" + IncludePackageJsonAutoImportsUnknown IncludePackageJsonAutoImports = "" // !!! IncludePackageJsonAutoImportsAuto IncludePackageJsonAutoImports = "auto" IncludePackageJsonAutoImportsOn IncludePackageJsonAutoImports = "on" IncludePackageJsonAutoImportsOff IncludePackageJsonAutoImports = "off" ) +func parseIncludePackageJsonAutoImports(val any) IncludePackageJsonAutoImports { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "on": + return IncludePackageJsonAutoImportsOn + case "off": + return IncludePackageJsonAutoImportsOff + default: + return IncludePackageJsonAutoImportsAuto + } + } + return IncludePackageJsonAutoImportsUnknown +} + type OrganizeImportsCollation bool const ( @@ -167,12 +251,12 @@ const ( OrganizeImportsCollationUnicode OrganizeImportsCollation = true ) -type OrganizeImportsAccentCollation int - -const ( - OrganizeImportsAccentCollationTrue OrganizeImportsAccentCollation = 0 - OrganizeImportsAccentCollationFalse OrganizeImportsAccentCollation = 1 -) +func parseOrganizeImportsCollation(val any) OrganizeImportsCollation { + if b, ok := val.(string); ok && strings.ToLower(b) == "unicode" { + return OrganizeImportsCollationUnicode + } + return OrganizeImportsCollationOrdinal +} type OrganizeImportsCaseFirst int @@ -182,14 +266,41 @@ const ( OrganizeImportsCaseFirstUpper OrganizeImportsCaseFirst = 2 ) +func parseOrganizeImportsCaseFirst(caseFirst any) OrganizeImportsCaseFirst { + if caseFirstStr, ok := caseFirst.(string); ok { + switch caseFirstStr { + case "lower": + return OrganizeImportsCaseFirstLower + case "upper": + return OrganizeImportsCaseFirstUpper + } + } + return OrganizeImportsCaseFirstFalse +} + type OrganizeImportsTypeOrder int const ( - OrganizeImportsTypeOrderLast OrganizeImportsTypeOrder = 0 - OrganizeImportsTypeOrderInline OrganizeImportsTypeOrder = 1 - OrganizeImportsTypeOrderFirst OrganizeImportsTypeOrder = 2 + OrganizeImportsTypeOrderAuto OrganizeImportsTypeOrder = 0 + OrganizeImportsTypeOrderLast OrganizeImportsTypeOrder = 1 + OrganizeImportsTypeOrderInline OrganizeImportsTypeOrder = 2 + OrganizeImportsTypeOrderFirst OrganizeImportsTypeOrder = 3 ) +func parseOrganizeImportsTypeOrder(typeOrder any) OrganizeImportsTypeOrder { + if typeOrderStr, ok := typeOrder.(string); ok { + switch typeOrderStr { + case "last": + return OrganizeImportsTypeOrderLast + case "inline": + return OrganizeImportsTypeOrderInline + case "first": + return OrganizeImportsTypeOrderFirst + } + } + return OrganizeImportsTypeOrderAuto +} + type QuotePreference string const ( @@ -199,7 +310,35 @@ const ( QuotePreferenceSingle QuotePreference = "single" ) -func (p *UserPreferences) Parse(config map[string]interface{}) { +func parseQuotePreference(val any) QuotePreference { + if s, ok := val.(string); ok { + switch strings.ToLower(s) { + case "auto": + return QuotePreferenceAuto + case "double": + return QuotePreferenceDouble + case "single": + return QuotePreferenceSingle + } + } + return QuotePreferenceUnknown +} + +func (p *UserPreferences) Copy() *UserPreferences { + if p == nil { + return nil + } + prefCopy := *p + prefCopy.AutoImportSpecifierExcludeRegexes = slices.Clone(p.AutoImportSpecifierExcludeRegexes) + prefCopy.AutoImportFileExcludePatterns = slices.Clone(p.AutoImportFileExcludePatterns) + return &prefCopy +} + +func (p *UserPreferences) CopyOrDefault() *UserPreferences { + if p == nil { + return NewDefaultUserPreferences() + } + return p.Copy() } func (p *UserPreferences) ModuleSpecifierPreferences() modulespecifiers.UserPreferences { @@ -209,3 +348,289 @@ func (p *UserPreferences) ModuleSpecifierPreferences() modulespecifiers.UserPref AutoImportSpecifierExcludeRegexes: p.AutoImportSpecifierExcludeRegexes, } } + +// ------ Parsing Config Response ------- + +// returns non-nil if should break loop +func (p *UserPreferences) Parse(item any) *UserPreferences { + if item == nil { + // continue + } else if config, ok := item.(map[string]any); ok { + p.parseWorker(config) + } else if item, ok := item.(*UserPreferences); ok { + // case for fourslash + return item.CopyOrDefault() + } + return nil +} + +func (p *UserPreferences) parseWorker(config map[string]interface{}) { + // Process unstable preferences first so that they do not overwrite stable properties + if unstable, ok := config["unstable"]; ok { + // unstable properties must be named the same as userPreferences + p.parseAll(unstable) + } + for name, values := range config { + switch name { + case "unstable": + continue + case "inlayHints": + p.parseInlayHints(values) + case "suggest": + p.parseSuggest(values) + case "preferences": + p.parsePreferences(values) + case "format": + // !!! + case "tsserver": + // !!! + case "tsc": + // !!! + case "experimental": + // !!! + default: + p.set(name, values) + } + } +} + +func (p *UserPreferences) parseAll(prefs any) { + prefsMap, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range prefsMap { + p.set(name, value) + } +} + +func (p *UserPreferences) parseInlayHints(prefs any) { + inlayHintsPreferences, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range inlayHintsPreferences { + if v, ok := value.(map[string]any); ok { + // vscode's inlay hints settings are nested objects with "enabled" and other properties + switch name { + case "parameterNames": + if enabled, ok := v["enabled"]; ok { + p.set("includeInlayParameterNameHints", enabled) + } + p.IncludeInlayParameterNameHintsWhenArgumentMatchesName = parseSupress(v, "supressWhenArgumentMatchesName") + case "parameterTypes": + p.IncludeInlayFunctionParameterTypeHints = parseEnabledBool(v) + case "variableTypes": + p.IncludeInlayVariableTypeHints = parseEnabledBool(v) + p.IncludeInlayVariableTypeHintsWhenTypeMatchesName = parseSupress(v, "supressWhenTypeMatchesName") + case "propertyDeclarationTypes": + p.IncludeInlayPropertyDeclarationTypeHints = parseEnabledBool(v) + case "functionLikeReturnTypes": + p.IncludeInlayFunctionLikeReturnTypeHints = parseEnabledBool(v) + case "enumMemberValues": + p.IncludeInlayEnumMemberValueHints = parseEnabledBool(v) + } + } else { + // non-vscode case + p.set(name, v) + } + } +} + +func (p *UserPreferences) parseSuggest(prefs any) { + completionsPreferences, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range completionsPreferences { + switch name { + case "autoImports": + p.set("includeCompletionsForModuleExports", value) + case "objectLiteralMethodSnippets": + if v, ok := value.(map[string]any); ok { + p.set("includeCompletionsWithObjectLiteralMethodSnippets", parseEnabledBool(v)) + } + case "classMemberSnippets": + if v, ok := value.(map[string]any); ok { + p.set("includeCompletionsWithClassMemberSnippets", parseEnabledBool(v)) + } + case "includeAutomaticOptionalChainCompletions": + p.set("includeAutomaticOptionalChainCompletions", value) + case "includeCompletionsForImportStatements": + p.set("includeCompletionsForImportStatements", value) + } + } +} + +func (p *UserPreferences) parsePreferences(prefs any) { + prefsMap, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range prefsMap { + if name == "organizeImports" { + p.parseOrganizeImportsPreferences(value) + } else { + p.set(name, value) + } + } +} + +func (p *UserPreferences) parseOrganizeImportsPreferences(prefs any) { + // !!! this used to be in the typescript-language-features extension + prefsMap, ok := prefs.(map[string]any) + if !ok { + return + } + if typeOrder, ok := prefsMap["typeOrder"]; ok { + p.set("organizeimportstypeorder", parseOrganizeImportsTypeOrder(typeOrder)) + } + if caseSensitivity, ok := prefsMap["caseSensitivity"]; ok { + if caseSensitivityStr, ok := caseSensitivity.(string); ok { + // default is already "auto" + switch caseSensitivityStr { + case "caseInsensitive": + p.OrganizeImportsIgnoreCase = core.TSTrue + case "caseSensitive": + p.OrganizeImportsIgnoreCase = core.TSFalse + } + } + } + if collation, ok := prefsMap["unicodeCollation"]; ok { + // The rest of the settings are only applicable when using unicode collation + if collationStr, ok := collation.(string); ok && collationStr == "unicode" { + p.set("organizeimportscollation", OrganizeImportsCollationUnicode) + if locale, ok := prefsMap["locale"]; ok { + p.set("organizeimportslocale", locale) + } + if numeric, ok := prefsMap["numericCollation"]; ok { + p.set("organizeimportsnumericcollation", numeric) + } + if accent, ok := prefsMap["accentCollation"]; ok { + p.set("organizeimportsaccentcollation", accent) + } + if caseFirst, ok := prefsMap["caseFirst"]; ok && !p.OrganizeImportsIgnoreCase.IsTrue() { + p.set("organizeimportscasefirst", caseFirst) + } + } + } +} + +func parseEnabledBool(v map[string]any) bool { + // vscode nested option + if enabled, ok := v["enabled"]; ok { + if e, ok := enabled.(bool); ok { + return e + } + } + return false +} + +func parseSupress(v map[string]any, name string) bool { + // vscode nested option + if val, ok := v[name]; ok { + if suppress, ok := val.(bool); ok { + return !suppress + } + } + return false +} + +func parseBoolWithDefault(val any, defaultV bool) bool { + if v, ok := val.(bool); ok { + return v + } + return defaultV +} + +func parseIntWithDefault(val any, defaultV int) int { + if v, ok := val.(int); ok { + return v + } + return defaultV +} + +func (p *UserPreferences) set(name string, value any) { + switch strings.ToLower(name) { + case "quotePreference": + p.QuotePreference = parseQuotePreference(value) + case "lazyconfiguredprojectsfromexternalproject": + p.LazyConfiguredProjectsFromExternalProject = parseBoolWithDefault(value, false) + case "maximumhoverlength": + p.MaximumHoverLength = parseIntWithDefault(value, 500) + case "includecompletionsformoduleexports": + p.IncludeCompletionsForModuleExports = tsoptions.ParseTristate(value) + case "includecompletionsforimportstatements": + p.IncludeCompletionsForImportStatements = tsoptions.ParseTristate(value) + case "includeautomaticoptionalchaincompletions": + p.IncludeAutomaticOptionalChainCompletions = tsoptions.ParseTristate(value) + case "includecompletionswithsnippettext": + p.IncludeCompletionsWithSnippetText = tsoptions.ParseTristate(value) + case "includecompletionswithclassmembersnippets": + p.IncludeCompletionsWithClassMemberSnippets = tsoptions.ParseTristate(value) + case "includecompletionswithobjectliteralmethodsnippets": + p.IncludeCompletionsWithObjectLiteralMethodSnippets = tsoptions.ParseTristate(value) + case "jsxattributecompletionstyle": + p.JsxAttributeCompletionStyle = parseJsxAttributeCompletionStyle(value) + case "importmodulespecifierpreference": + p.ImportModuleSpecifierPreference = parseImportModuleSpecifierPreference(value) + case "importmodulespecifierending": + p.ImportModuleSpecifierEnding = parseImportModuleSpecifierEndingPreference(value) + case "includepackagejsonautoimports": + p.IncludePackageJsonAutoImports = parseIncludePackageJsonAutoImports(value) + case "autoimportspecifierexcluderegexes": + p.AutoImportSpecifierExcludeRegexes = tsoptions.ParseStringArray(value) + case "autoimportfileexcludepatterns": + p.AutoImportFileExcludePatterns = tsoptions.ParseStringArray(value) + case "prefertypeonlyautoimports": + p.PreferTypeOnlyAutoImports = parseBoolWithDefault(value, false) + case "organizeimportsignorecase": + p.OrganizeImportsIgnoreCase = tsoptions.ParseTristate(value) + case "organizeimportscollation": + p.OrganizeImportsCollation = parseOrganizeImportsCollation(value) + case "organizeimportslocale": + p.OrganizeImportsLocale = tsoptions.ParseString(value) + case "organizeimportsnumericcollation": + p.OrganizeImportsNumericCollation = parseBoolWithDefault(value, false) + case "organizeimportsaccentcollation": + p.OrganizeImportsAccentCollation = parseBoolWithDefault(value, true) + case "organizeimportscasefirst": + p.OrganizeImportsCaseFirst = parseOrganizeImportsCaseFirst(value) + case "organizeimportstypeorder": + p.OrganizeImportsTypeOrder = parseOrganizeImportsTypeOrder(value) + case "allowtextchangesinnewfiles": + p.AllowTextChangesInNewFiles = parseBoolWithDefault(value, true) // !!! + case "usealiasesforrename", "provideprefixandsuffixtextforrename": + p.UseAliasesForRename = tsoptions.ParseTristate(value) + case "allowrenameofimportpath": + p.AllowRenameOfImportPath = parseBoolWithDefault(value, true) + case "providerefactornotapplicablereason": + p.ProvideRefactorNotApplicableReason = parseBoolWithDefault(value, true) + case "includeinlayparameternamehints": + p.IncludeInlayParameterNameHints = parseInlayParameterNameHints(value) + case "includeinlayparameternamehintswhenargumentmatchesname": + p.IncludeInlayParameterNameHintsWhenArgumentMatchesName = parseBoolWithDefault(value, false) + case "includeinlayfunctionparametertypeHints": + p.IncludeInlayFunctionParameterTypeHints = parseBoolWithDefault(value, false) + case "includeinlayvariabletypehints": + p.IncludeInlayVariableTypeHints = parseBoolWithDefault(value, false) + case "includeinlayvariabletypehintswhentypematchesname": + p.IncludeInlayVariableTypeHintsWhenTypeMatchesName = parseBoolWithDefault(value, false) + case "includeinlaypropertydeclarationtypehints": + p.IncludeInlayPropertyDeclarationTypeHints = parseBoolWithDefault(value, false) + case "includeinlayfunctionlikereturntypehints": + p.IncludeInlayFunctionLikeReturnTypeHints = parseBoolWithDefault(value, false) + case "includeinlayenummembervaluehints": + p.IncludeInlayEnumMemberValueHints = parseBoolWithDefault(value, false) + case "interactiveinlayhints": + p.InteractiveInlayHints = parseBoolWithDefault(value, true) + case "excludelibrarysymbolsinnavto": + p.ExcludeLibrarySymbolsInNavTo = parseBoolWithDefault(value, false) + case "disablesuggestions": + p.DisableSuggestions = parseBoolWithDefault(value, false) + case "disablelinetextinreferences": + p.DisableLineTextInReferences = parseBoolWithDefault(value, true) + case "displaypartsforjsdoc": + p.DisplayPartsForJSDoc = parseBoolWithDefault(value, true) + } +} diff --git a/internal/ls/utilities.go b/internal/ls/utilities.go index 86e27a9fb7..09d5a070a4 100644 --- a/internal/ls/utilities.go +++ b/internal/ls/utilities.go @@ -468,8 +468,27 @@ const ( quotePreferenceDouble ) -// !!! -func getQuotePreference(file *ast.SourceFile, preferences *UserPreferences) quotePreference { +func quotePreferenceFromString(str *ast.StringLiteral) quotePreference { + if str.TokenFlags&ast.TokenFlagsSingleQuote != 0 { + return quotePreferenceSingle + } + return quotePreferenceDouble +} + +func getQuotePreference(sourceFile *ast.SourceFile, preferences *UserPreferences) quotePreference { + if preferences.QuotePreference != "" && preferences.QuotePreference != "auto" { + if preferences.QuotePreference == "single" { + return quotePreferenceSingle + } + return quotePreferenceDouble + } + // ignore synthetic import added when importHelpers: true + firstModuleSpecifier := core.Find(sourceFile.Imports(), func(n *ast.Node) bool { + return ast.IsStringLiteral(n) && !ast.NodeIsSynthesized(n.Parent) + }) + if firstModuleSpecifier != nil { + return quotePreferenceFromString(firstModuleSpecifier.AsStringLiteral()) + } return quotePreferenceDouble } @@ -917,7 +936,7 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF // specially by `getSymbolAtLocation`. isModifier := func(node *ast.Node) bool { if ast.IsModifier(node) && (forRename || node.Kind != ast.KindDefaultKeyword) { - return ast.CanHaveModifiers(parent) && slices.Contains(parent.Modifiers().NodeList.Nodes, node) + return ast.CanHaveModifiers(parent) && parent.Modifiers() != nil && slices.Contains(parent.Modifiers().NodeList.Nodes, node) } switch node.Kind { case ast.KindClassKeyword: @@ -1659,6 +1678,13 @@ func getChildrenFromNonJSDocNode(node *ast.Node, sourceFile *ast.SourceFile) []* childNodes = append(childNodes, child) return false }) + + // If the node has no children, don't scan for tokens. + // This prevents creating tokens for leaf nodes' own text. + if len(childNodes) == 0 { + return nil + } + var children []*ast.Node pos := node.Pos() for _, child := range childNodes { diff --git a/internal/lsp/server.go b/internal/lsp/server.go index 54f78f2e16..275e1c92df 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -5,14 +5,10 @@ import ( "errors" "fmt" "io" - "os" - "os/exec" - "os/signal" "runtime/debug" "slices" "sync" "sync/atomic" - "syscall" "time" "github.com/go-json-experiment/json" @@ -39,6 +35,7 @@ type ServerOptions struct { DefaultLibraryPath string TypingsLocation string ParseCache *project.ParseCache + NpmInstall func(cwd string, args []string) ([]byte, error) } func NewServer(opts *ServerOptions) *Server { @@ -59,6 +56,7 @@ func NewServer(opts *ServerOptions) *Server { defaultLibraryPath: opts.DefaultLibraryPath, typingsLocation: opts.TypingsLocation, parseCache: opts.ParseCache, + npmInstall: opts.NpmInstall, } } @@ -157,6 +155,8 @@ type Server struct { compilerOptionsForInferredProjects *core.CompilerOptions // parseCache can be passed in so separate tests can share ASTs parseCache *project.ParseCache + + npmInstall func(cwd string, args []string) ([]byte, error) } // WatchFiles implements project.Client. @@ -218,10 +218,34 @@ func (s *Server) RefreshDiagnostics(ctx context.Context) error { return nil } -func (s *Server) Run() error { - ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) - defer stop() +func (s *Server) RequestConfiguration(ctx context.Context) (*ls.UserPreferences, error) { + if s.initializeParams.Capabilities == nil || s.initializeParams.Capabilities.Workspace == nil || + !ptrIsTrue(s.initializeParams.Capabilities.Workspace.Configuration) { + // if no configuration request capapbility, return default preferences + return s.session.NewUserPreferences(), nil + } + result, err := s.sendRequest(ctx, lsproto.MethodWorkspaceConfiguration, &lsproto.ConfigurationParams{ + Items: []*lsproto.ConfigurationItem{ + { + Section: ptrTo("typescript"), + }, + }, + }) + if err != nil { + return nil, fmt.Errorf("configure request failed: %w", err) + } + configs := result.([]any) + s.Log(fmt.Sprintf("\n\nconfiguration: %+v, %T\n\n", configs, configs)) + userPreferences := s.session.NewUserPreferences() + for _, item := range configs { + if parsed := userPreferences.Parse(item); parsed != nil { + return parsed, nil + } + } + return userPreferences, nil +} +func (s *Server) Run(ctx context.Context) error { g, ctx := errgroup.WithContext(ctx) g.Go(func() error { return s.dispatchLoop(ctx) }) g.Go(func() error { return s.writeLoop(ctx) }) @@ -441,6 +465,7 @@ var handlers = sync.OnceValue(func() handlerMap { registerRequestHandler(handlers, lsproto.ShutdownInfo, (*Server).handleShutdown) registerNotificationHandler(handlers, lsproto.ExitInfo, (*Server).handleExit) + registerNotificationHandler(handlers, lsproto.WorkspaceDidChangeConfigurationInfo, (*Server).handleDidChangeWorkspaceConfiguration) registerNotificationHandler(handlers, lsproto.TextDocumentDidOpenInfo, (*Server).handleDidOpen) registerNotificationHandler(handlers, lsproto.TextDocumentDidChangeInfo, (*Server).handleDidChange) registerNotificationHandler(handlers, lsproto.TextDocumentDidSaveInfo, (*Server).handleDidSave) @@ -462,6 +487,7 @@ var handlers = sync.OnceValue(func() handlerMap { registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDocumentSymbolInfo, (*Server).handleDocumentSymbol) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentRenameInfo, (*Server).handleRename) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDocumentHighlightInfo, (*Server).handleDocumentHighlight) + registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentSelectionRangeInfo, (*Server).handleSelectionRange) registerRequestHandler(handlers, lsproto.WorkspaceSymbolInfo, (*Server).handleWorkspaceSymbol) registerRequestHandler(handlers, lsproto.CompletionItemResolveInfo, (*Server).handleCompletionItemResolve) @@ -641,6 +667,9 @@ func (s *Server) handleInitialize(ctx context.Context, params *lsproto.Initializ DocumentHighlightProvider: &lsproto.BooleanOrDocumentHighlightOptions{ Boolean: ptrTo(true), }, + SelectionRangeProvider: &lsproto.BooleanOrSelectionRangeOptionsOrSelectionRangeRegistrationOptions{ + Boolean: ptrTo(true), + }, }, } @@ -686,6 +715,21 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali NpmExecutor: s, ParseCache: s.parseCache, }) + + if s.initializeParams != nil && s.initializeParams.InitializationOptions != nil && *s.initializeParams.InitializationOptions != nil { + // handle userPreferences from initializationOptions + userPreferences := s.session.NewUserPreferences() + userPreferences.Parse(*s.initializeParams.InitializationOptions) + s.session.InitializeWithConfig(userPreferences) + } else { + // request userPreferences if not provided at initialization + userPreferences, err := s.RequestConfiguration(ctx) + if err != nil { + return err + } + s.session.InitializeWithConfig(userPreferences) + } + // !!! temporary; remove when we have `handleDidChangeConfiguration`/implicit project config support if s.compilerOptionsForInferredProjects != nil { s.session.DidChangeCompilerOptionsForInferredProjects(ctx, s.compilerOptionsForInferredProjects) @@ -703,6 +747,16 @@ func (s *Server) handleExit(ctx context.Context, params any) error { return io.EOF } +func (s *Server) handleDidChangeWorkspaceConfiguration(ctx context.Context, params *lsproto.DidChangeConfigurationParams) error { + // !!! only implemented because needed for fourslash + userPreferences := s.session.UserPreferences() + if parsed := userPreferences.Parse(params.Settings); parsed != nil { + userPreferences = parsed + } + s.session.Configure(userPreferences) + return nil +} + func (s *Server) handleDidOpen(ctx context.Context, params *lsproto.DidOpenTextDocumentParams) error { s.session.DidOpenFile(ctx, params.TextDocument.Uri, params.TextDocument.Version, params.TextDocument.Text, params.TextDocument.LanguageId) return nil @@ -758,7 +812,6 @@ func (s *Server) handleSignatureHelp(ctx context.Context, languageService *ls.La params.Position, params.Context, s.initializeParams.Capabilities.TextDocument.SignatureHelp, - &ls.UserPreferences{}, ) } @@ -781,17 +834,13 @@ func (s *Server) handleImplementations(ctx context.Context, ls *ls.LanguageServi } func (s *Server) handleCompletion(ctx context.Context, languageService *ls.LanguageService, params *lsproto.CompletionParams) (lsproto.CompletionResponse, error) { - // !!! get user preferences return languageService.ProvideCompletion( ctx, params.TextDocument.Uri, params.Position, params.Context, getCompletionClientCapabilities(s.initializeParams), - &ls.UserPreferences{ - IncludeCompletionsForModuleExports: core.TSTrue, - IncludeCompletionsForImportStatements: core.TSTrue, - }) + ) } func (s *Server) handleCompletionItemResolve(ctx context.Context, params *lsproto.CompletionItem, reqMsg *lsproto.RequestMessage) (lsproto.CompletionResolveResponse, error) { @@ -809,10 +858,6 @@ func (s *Server) handleCompletionItemResolve(ctx context.Context, params *lsprot params, data, getCompletionClientCapabilities(s.initializeParams), - &ls.UserPreferences{ - IncludeCompletionsForModuleExports: core.TSTrue, - IncludeCompletionsForImportStatements: core.TSTrue, - }, ) } @@ -863,6 +908,10 @@ func (s *Server) handleDocumentHighlight(ctx context.Context, ls *ls.LanguageSer return ls.ProvideDocumentHighlights(ctx, params.TextDocument.Uri, params.Position) } +func (s *Server) handleSelectionRange(ctx context.Context, ls *ls.LanguageService, params *lsproto.SelectionRangeParams) (lsproto.SelectionRangeResponse, error) { + return ls.ProvideSelectionRanges(ctx, params) +} + func (s *Server) Log(msg ...any) { fmt.Fprintln(s.stderr, msg...) } @@ -877,9 +926,7 @@ func (s *Server) SetCompilerOptionsForInferredProjects(ctx context.Context, opti // NpmInstall implements ata.NpmExecutor func (s *Server) NpmInstall(cwd string, args []string) ([]byte, error) { - cmd := exec.Command("npm", args...) - cmd.Dir = cwd - return cmd.Output() + return s.npmInstall(cwd, args) } func isBlockingMethod(method lsproto.Method) bool { @@ -890,7 +937,9 @@ func isBlockingMethod(method lsproto.Method) bool { lsproto.MethodTextDocumentDidChange, lsproto.MethodTextDocumentDidSave, lsproto.MethodTextDocumentDidClose, - lsproto.MethodWorkspaceDidChangeWatchedFiles: + lsproto.MethodWorkspaceDidChangeWatchedFiles, + lsproto.MethodWorkspaceDidChangeConfiguration, + lsproto.MethodWorkspaceConfiguration: return true } return false diff --git a/internal/module/pnp/lib.go b/internal/module/pnp/lib.go new file mode 100644 index 0000000000..75efb4c5f7 --- /dev/null +++ b/internal/module/pnp/lib.go @@ -0,0 +1,442 @@ +// BSD 2-Clause License +// +// Copyright (c) 2016-present, Yarn Contributors. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +package pnp + +import ( + "errors" + "slices" + "strings" + + "github.com/go-json-experiment/json" + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/parser" + "github.com/microsoft/typescript-go/internal/tspath" + "github.com/microsoft/typescript-go/internal/vfs" +) + +type ResolutionKind int + +const ( + ResolutionSkipped ResolutionKind = iota + ResolutionResolved +) + +type PNPResolutionHost struct { + FindPNPManifest func(start string) (*Manifest, error) +} + +type ResolutionConfig struct { + Host PNPResolutionHost +} + +type Resolution struct { + Kind ResolutionKind + Path string + ModulePath *string +} + +func isNodeJSBuiltin(name string) bool { + return core.NodeCoreModules()[name] +} + +func parseScopedPackageName(spec string) (pkg string, sub *string, ok bool) { + parts := strings.SplitN(spec, "/", 3) + if len(parts) < 2 { + return "", nil, false + } + scope, name := parts[0], parts[1] + if scope == "" || name == "" { + return "", nil, false + } + pkg = scope + "/" + name + if len(parts) == 3 { + s := parts[2] + sub = &s + } + return pkg, sub, true +} + +func parseGlobalPackageName(spec string) (pkg string, sub *string, ok bool) { + parts := strings.SplitN(spec, "/", 2) + if len(parts) == 0 || parts[0] == "" { + return "", nil, false + } + pkg = parts[0] + if len(parts) == 2 { + s := parts[1] + sub = &s + } + return pkg, sub, true +} + +func ParseBareIdentifier(spec string) (string, *string, error) { + var ( + pkg string + sub *string + ok bool + ) + if strings.HasPrefix(spec, "@") { + pkg, sub, ok = parseScopedPackageName(spec) + } else { + pkg, sub, ok = parseGlobalPackageName(spec) + } + if !ok { + return "", nil, errors.New(diagnostics.Invalid_specifier.Format()) + } + return pkg, sub, nil +} + +func FindClosestPNPManifestPath(start string, fs vfs.FS) (string, bool) { + dir := tspath.NormalizePath(start) + + for { + candidate := tspath.CombinePaths(dir, ".pnp.cjs") + if fs.FileExists(candidate) { + return candidate, true + } + parent := tspath.GetDirectoryPath(dir) + if parent == dir { + break + } + dir = parent + } + return "", false +} + +func extractJSONFromPnPFile(path string, content string) (string, error) { + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: tspath.NormalizePath(path), + Path: tspath.Path(path), + }, content, core.ScriptKindJS) + if sourceFile == nil { + return "", errors.New(diagnostics.We_failed_to_locate_the_PnP_data_payload_inside_its_manifest_file_Did_you_manually_edit_the_file.Format()) + } + + var jsonData string + var found bool + + var visitNode func(*ast.Node) bool + visitNode = func(node *ast.Node) bool { + if node == nil { + return false + } + + // Look for variable declaration lists with RAW_RUNTIME_STATE (Yarn v4) + if node.Kind == ast.KindVariableDeclarationList { + declList := node.AsVariableDeclarationList() + if declList != nil && declList.Declarations != nil && len(declList.Declarations.Nodes) > 0 { + declarator := declList.Declarations.Nodes[0] + if declarator != nil && declarator.Name() != nil { + if name := declarator.Name().AsIdentifier(); name != nil && name.Text == "RAW_RUNTIME_STATE" { + if declarator.Initializer() != nil { + if init := declarator.Initializer().AsStringLiteral(); init != nil { + jsonData = init.Text + found = true + return true + } + } + } + } + } + } + + // Look for call expressions with hydrateRuntimeState(JSON.parse('...')) (Yarn v3) + if node.Kind == ast.KindCallExpression { + call := node.AsCallExpression() + if call != nil && call.Expression != nil { + if expr := call.Expression.AsIdentifier(); expr != nil && expr.Text == "hydrateRuntimeState" { + if call.Arguments != nil && len(call.Arguments.Nodes) > 0 && call.Arguments.Nodes[0] != nil { + if arg := call.Arguments.Nodes[0].AsCallExpression(); arg != nil && arg.Expression != nil { + if argExpr := arg.Expression.AsPropertyAccessExpression(); argExpr != nil { + if obj := argExpr.Expression.AsIdentifier(); obj != nil && obj.Text == "JSON" { + if prop := argExpr.Name().AsIdentifier(); prop != nil && prop.Text == "parse" { + if arg.Arguments != nil && len(arg.Arguments.Nodes) > 0 && arg.Arguments.Nodes[0] != nil { + if jsonArg := arg.Arguments.Nodes[0].AsStringLiteral(); jsonArg != nil { + jsonData = jsonArg.Text + found = true + return true + } + } + } + } + } + } + } + } + } + } + + return node.ForEachChild(visitNode) + } + + sourceFile.ForEachChild(visitNode) + + if !found { + return "", errors.New(diagnostics.We_failed_to_locate_the_PnP_data_payload_inside_its_manifest_file_Did_you_manually_edit_the_file.Format()) + } + + return jsonData, nil +} + +func InitPNPManifest(m *Manifest, manifestPath string) error { + m.ManifestPath = manifestPath + m.ManifestDir = tspath.GetDirectoryPath(manifestPath) + + m.LocationTrie = *NewLocationTrie[PackageLocator]() + + for name, ranges := range m.PackageRegistryData { + for reference, info := range ranges { + joined := tspath.CombinePaths(m.ManifestDir, info.PackageLocation) + + norm := tspath.NormalizePath(joined) + + info.PackageLocation = norm + ranges[reference] = info + + if !info.DiscardFromLookup { + m.LocationTrie.Insert( + info.PackageLocation, + PackageLocator{Name: name, Reference: reference}, + ) + } + } + } + + ranges, ok := m.PackageRegistryData[""] + if !ok { + return errors.New(diagnostics.X_assertion_failed_Colon_should_have_a_top_level_name_key.Format()) + } + top, ok := ranges[""] + if !ok { + return errors.New(diagnostics.X_assertion_failed_Colon_should_have_a_top_level_range_key.Format()) + } + + if m.FallbackPool == nil { + m.FallbackPool = make(FallbackPool) + } + for depName, dep := range top.PackageDependencies { + if _, exists := m.FallbackPool[depName]; !exists { + m.FallbackPool[depName] = dep + } + } + + return nil +} + +func LoadPNPManifest(p string, fs vfs.FS) (Manifest, error) { + content, ok := fs.ReadFile(p) + if !ok { + return Manifest{}, errors.New(diagnostics.We_failed_to_read_the_content_of_the_manifest_Colon_0.Format("failed to read file")) + } + + jsonData, err := extractJSONFromPnPFile(p, content) + if err != nil { + return Manifest{}, err + } + + var manifest Manifest + if err = json.Unmarshal([]byte(jsonData), &manifest); err != nil { + return Manifest{}, errors.New(diagnostics.We_failed_to_parse_the_PnP_data_payload_as_proper_JSON_Did_you_manually_edit_the_file_Colon_0.Format(err.Error())) + } + + err = InitPNPManifest(&manifest, p) + if err != nil { + return Manifest{}, errors.New(diagnostics.We_failed_to_init_the_PnP_manifest_Colon_0.Format(err.Error())) + } + return manifest, nil +} + +func FindPNPManifest(parent string, fs vfs.FS) (*Manifest, error) { + path, ok := FindClosestPNPManifestPath(parent, fs) + if !ok { + return nil, nil + } + manifest, err := LoadPNPManifest(path, fs) + if err != nil { + return nil, err + } + return &manifest, nil +} + +func IsDependencyTreeRoot(m *Manifest, loc *PackageLocator) bool { + return slices.Contains(m.DependencyTreeRoots, PackageLocator{ + Name: loc.Name, + Reference: loc.Reference, + }) +} + +func FindLocator(manifest *Manifest, path string) *PackageLocator { + rel := tspath.GetRelativePathFromDirectory(manifest.ManifestDir, path, tspath.ComparePathsOptions{UseCaseSensitiveFileNames: true}) + + if manifest.IgnorePatternData != nil { + _, err := manifest.IgnorePatternData.reg.MatchString(tspath.NormalizePath(rel)) + if err != nil { + return nil + } + } + + normFull := tspath.NormalizePath(path) + if v, ok := manifest.LocationTrie.GetAncestorValue(normFull); ok && v != nil { + return v + } + return nil +} + +func GetPackage(manifest *Manifest, locator *PackageLocator) (*PackageInformation, error) { + refs, ok := manifest.PackageRegistryData[locator.Name] + if !ok { + return nil, errors.New(diagnostics.X_should_have_an_entry_in_the_package_registry_for_0.Format(locator.Name)) + } + info, ok := refs[locator.Reference] + if !ok { + return nil, errors.New(diagnostics.X_should_have_an_entry_in_the_package_registry_for_0.Format(locator.Reference)) + } + return &info, nil +} + +func IsExcludedFromFallback(manifest *Manifest, locator *PackageLocator) bool { + if refs, ok := manifest.FallbackExclusionList[locator.Name]; ok { + for _, r := range refs { + if r == locator.Reference { + return true + } + } + } + return false +} + +func FindBrokenPeerDependencies(specifier string, parent *PackageLocator) []PackageLocator { + return []PackageLocator{} +} + +func viaSuffix(specifier string, ident string) string { + if ident != specifier { + return diagnostics.X_via_0.Format(ident) + } + return "" +} + +func ResolveToUnqualifiedViaManifest( + manifest *Manifest, + specifier string, + parentPath string, +) (Resolution, error) { + ident, modulePath, err := ParseBareIdentifier(specifier) + if err != nil { + return Resolution{}, err + } + + parentLocator := FindLocator(manifest, parentPath) + if parentLocator == nil { + return Resolution{Kind: ResolutionSkipped}, nil + } + + parentPkg, err := GetPackage(manifest, parentLocator) + if err != nil { + return Resolution{}, err + } + + var refOrAlias *PackageDependency + + if dep, ok := parentPkg.PackageDependencies[ident]; ok && dep != nil { + refOrAlias = dep + } + + if refOrAlias == nil && manifest.EnableTopLevelFallback && !IsExcludedFromFallback(manifest, parentLocator) { + if dep, ok := manifest.FallbackPool[ident]; ok { + refOrAlias = dep + } + } + + if refOrAlias == nil { + if isNodeJSBuiltin(specifier) { + if IsDependencyTreeRoot(manifest, parentLocator) { + return Resolution{}, errors.New(diagnostics.Your_application_tried_to_access_0_While_this_module_is_usually_interpreted_as_a_Node_builtin_your_resolver_is_running_inside_a_non_Node_resolution_context_where_such_builtins_are_ignored_Since_0_isn_t_otherwise_declared_in_your_dependencies_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_0_1_Required_by_Colon_2.Format(ident, ident, viaSuffix(specifier, ident), parentPath)) + } + return Resolution{}, errors.New(diagnostics.X_0_tried_to_access_1_While_this_module_is_usually_interpreted_as_a_Node_builtin_your_resolver_is_running_inside_a_non_Node_resolution_context_where_such_builtins_are_ignored_Since_1_isn_t_otherwise_declared_in_0_s_dependencies_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_1_2_Required_by_Colon_3.Format(parentLocator.Name, ident, ident, parentLocator.Name, viaSuffix(specifier, ident), parentPath)) + } + + if IsDependencyTreeRoot(manifest, parentLocator) { + return Resolution{}, errors.New(diagnostics.Your_application_tried_to_access_0_but_it_isn_t_declared_in_your_dependencies_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_0_1_Required_by_Colon_2.Format(ident, viaSuffix(specifier, ident), parentPath)) + } + + brokenAncestors := FindBrokenPeerDependencies(specifier, parentLocator) + allBrokenAreRoots := len(brokenAncestors) > 0 + if allBrokenAreRoots { + for _, brokenAncestor := range brokenAncestors { + if !IsDependencyTreeRoot(manifest, &brokenAncestor) { + allBrokenAreRoots = false + break + } + } + } + + if len(brokenAncestors) > 0 && allBrokenAreRoots { + return Resolution{}, errors.New(diagnostics.X_0_tried_to_access_1_a_peer_dependency_but_it_isn_t_provided_by_your_application_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_1_2_Required_by_Colon_0_3_via_4.Format(parentLocator.Name, ident, viaSuffix(specifier, ident), parentLocator.Reference, parentPath)) + } else { + return Resolution{}, errors.New(diagnostics.X_0_tried_to_access_1_a_peer_dependency_but_it_isn_t_provided_by_its_ancestors_this_makes_the_require_call_ambiguous_and_unsound_Required_package_Colon_1_2_Required_by_Colon_0_3_via_4.Format(parentLocator.Name, ident, viaSuffix(specifier, ident), parentLocator.Reference, parentPath)) + } + } + + var target PackageLocator + if refOrAlias.IsAlias { + target = PackageLocator{ + Name: refOrAlias.Alias[0], + Reference: refOrAlias.Alias[1], + } + } else { + target = PackageLocator{ + Name: ident, + Reference: refOrAlias.Reference, + } + } + depPkg, err := GetPackage(manifest, &target) + if err != nil { + return Resolution{}, err + } + + return Resolution{ + Kind: ResolutionResolved, + Path: depPkg.PackageLocation, + ModulePath: modulePath, + }, nil +} + +func ResolveToUnqualified(specifier, parentPath string, cfg *ResolutionConfig) (Resolution, error) { + if cfg == nil || cfg.Host.FindPNPManifest == nil { + return Resolution{}, errors.New(diagnostics.X_no_host_configured.Format()) + } + m, err := cfg.Host.FindPNPManifest(parentPath) + if err != nil { + return Resolution{}, err + } + if m == nil { + return Resolution{Kind: ResolutionSkipped}, nil + } + return ResolveToUnqualifiedViaManifest(m, specifier, parentPath) +} diff --git a/internal/module/pnp/lib_test.go b/internal/module/pnp/lib_test.go new file mode 100644 index 0000000000..60f065f457 --- /dev/null +++ b/internal/module/pnp/lib_test.go @@ -0,0 +1,211 @@ +package pnp + +import ( + "log" + "os" + "path/filepath" + "testing" + + "github.com/go-json-experiment/json" + "github.com/microsoft/typescript-go/internal/repo" + "github.com/microsoft/typescript-go/internal/vfs/osvfs" +) + +type TestSuite struct { + Manifest Manifest `json:"manifest"` + Tests []TestCase `json:"tests"` +} + +type TestCase struct { + Imported string `json:"imported"` + Importer string `json:"importer"` + Expected string `json:"expected"` + It string `json:"it"` +} + +func TestResolveToUnqualifiedExample(t *testing.T) { + t.Parallel() + pnpPath := filepath.Join(repo.TestDataPath, "fixtures", "pnp", "pnp-yarn-v3.cjs") + m, err := LoadPNPManifest(pnpPath, osvfs.FS()) + if err != nil { + log.Fatalf("Expected to load the .pnp.cjs file generated by Yarn 3: %v", err) + } + + host := PNPResolutionHost{ + FindPNPManifest: func(_ string) (*Manifest, error) { + return &m, nil + }, + } + cfg := &ResolutionConfig{Host: host} + + parentPath, err := filepath.Abs("/path/to/file") + if err != nil { + log.Fatalf("failed to filepath.Abs: %v", err) + } + + t.Run("Example", func(t *testing.T) { + t.Parallel() + res, resolutionErr := ResolveToUnqualified("lodash/cloneDeep", parentPath, cfg) + if resolutionErr != nil { + log.Printf("resolution error: %v", err) + return + } + + switch res.Kind { + case ResolutionResolved: + sub := "" + if res.ModulePath != nil { + sub = *res.ModulePath + } + log.Printf("Resolved: path=%s subpath=%s", res.Path, sub) + + case ResolutionSkipped: + log.Printf("Skipped by PnP resolver; use default resolver") + } + }) +} + +func TestLoadPnPManifest(t *testing.T) { + t.Parallel() + cases := []struct { + path string + msg string + }{ + {filepath.Join(repo.TestDataPath, "fixtures", "pnp", "pnp-yarn-v3.cjs"), "Expected to load the .pnp.cjs file generated by Yarn 3"}, + {filepath.Join(repo.TestDataPath, "fixtures", "pnp", "pnp-yarn-v4.cjs"), "Expected to load the .pnp.cjs file generated by Yarn 4"}, + } + + for _, tc := range cases { + t.Run(tc.path, func(t *testing.T) { + t.Parallel() + if _, err := LoadPNPManifest(tc.path, osvfs.FS()); err != nil { + t.Fatalf("%s: %v", tc.msg, err) + } + }) + } +} + +func TestResolveUnqualified(t *testing.T) { + t.Parallel() + expectationsPath := filepath.Join(repo.TestDataPath, "fixtures", "pnp", "test-expectations.json") + + content, err := os.ReadFile(expectationsPath) + if err != nil { + t.Fatalf("Assertion failed: Expected the expectations to be found: %v", err) + } + + var suites []TestSuite + if err = json.Unmarshal(content, &suites); err != nil { + t.Fatalf("Assertion failed: Expected the expectations to be loaded: %v", err) + } + + for si := range suites { + if si != 0 { + continue + } + testSuite := &suites[si] + + manifest := &testSuite.Manifest + err := InitPNPManifest(manifest, "/path/to/project/.pnp.cjs") + if err != nil { + t.Fatalf("failed to init pnp manifest: %v", err) + } + + for _, tc := range testSuite.Tests { + parent := filepath.Join(tc.Importer, "fooo") + manifestCopy := *manifest + + host := PNPResolutionHost{ + FindPNPManifest: func(_ string) (*Manifest, error) { + cp := manifestCopy + return &cp, nil + }, + } + cfg := &ResolutionConfig{Host: host} + + t.Run(tc.It, func(t *testing.T) { + t.Parallel() + res, unqualifiedErr := ResolveToUnqualified(tc.Imported, parent, cfg) + + switch { + case unqualifiedErr == nil && res.Kind == ResolutionResolved: + if res.Path != tc.Expected { + t.Fatalf("'%s': expected resolved path %q, got %q", tc.It, tc.Expected, res.Path) + } + case unqualifiedErr == nil && res.Kind == ResolutionSkipped: + if tc.Imported != tc.Expected { + t.Fatalf("'%s': expected skipped specifier %q, got %q", tc.It, tc.Expected, tc.Imported) + } + case unqualifiedErr != nil: + if tc.Expected != "error!" { + t.Fatalf("'%s': unexpected error: %v (expected=%q)", tc.It, err, tc.Expected) + } + default: + t.Fatalf("'%s': unreachable state", tc.It) + } + }) + } + } +} + +func TestParseSinglePackageName(t *testing.T) { + t.Parallel() + name, sub, err := ParseBareIdentifier("pkg") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if name != "pkg" { + t.Fatalf("expected name %q, got %q", "pkg", name) + } + if sub != nil { + t.Fatalf("expected subpath=nil, got %v", *sub) + } +} + +func TestParseScopedPackageName(t *testing.T) { + t.Parallel() + name, sub, err := ParseBareIdentifier("@scope/pkg") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if name != "@scope/pkg" { + t.Fatalf("expected name %q, got %q", "@scope/pkg", name) + } + if sub != nil { + t.Fatalf("expected subpath=nil, got %v", *sub) + } +} + +func TestParsePackageNameWithLongSubpath(t *testing.T) { + t.Parallel() + name, sub, err := ParseBareIdentifier("pkg/a/b/c/index.js") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if name != "pkg" { + t.Fatalf("expected name %q, got %q", "pkg", name) + } + if sub == nil || *sub != "a/b/c/index.js" { + if sub == nil { + t.Fatalf("expected subpath=%q, got nil", "a/b/c/index.js") + } + t.Fatalf("expected subpath=%q, got %q", "a/b/c/index.js", *sub) + } +} + +func TestParseScopedPackageWithLongSubpath(t *testing.T) { + t.Parallel() + name, sub, err := ParseBareIdentifier("@scope/pkg/a/b/c/index.js") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if name != "@scope/pkg" { + t.Fatalf("expected name %q, got %q", "@scope/pkg", name) + } + if sub == nil || *sub != "a/b/c/index.js" { + if sub == nil { + t.Fatalf("expected subpath=%q, got nil", "a/b/c/index.js") + } + t.Fatalf("expected subpath=%q, got %q", "a/b/c/index.js", *sub) + } +} diff --git a/internal/module/pnp/manifest.go b/internal/module/pnp/manifest.go new file mode 100644 index 0000000000..c51bb38d22 --- /dev/null +++ b/internal/module/pnp/manifest.go @@ -0,0 +1,358 @@ +package pnp + +import ( + "errors" + "fmt" + "strings" + + "github.com/dlclark/regexp2" + "github.com/go-json-experiment/json" + "github.com/go-json-experiment/json/jsontext" + + "github.com/microsoft/typescript-go/internal/tspath" +) + +type LocationTrie[T any] struct { + inner *Trie[T] +} + +type RegexDef struct { + Source string `json:"source"` + reg *regexp2.Regexp +} + +type Manifest struct { + ManifestDir string `json:"-"` + ManifestPath string `json:"-"` + LocationTrie LocationTrie[PackageLocator] `json:"-"` + + EnableTopLevelFallback bool `json:"enableTopLevelFallback"` + IgnorePatternData *RegexDef `json:"ignorePatternData,omitempty"` + + DependencyTreeRoots []PackageLocator `json:"dependencyTreeRoots"` + + FallbackPool FallbackPool `json:"fallbackPool"` + + FallbackExclusionList FallbackExclusionList `json:"fallbackExclusionList"` + + PackageRegistryData PackageRegistryData `json:"packageRegistryData"` +} + +type PackageLocator struct { + Name string `json:"name"` + Reference string `json:"reference"` +} + +type PackageInformation struct { + PackageLocation string `json:"packageLocation"` + + DiscardFromLookup bool `json:"discardFromLookup"` + + PackageDependencies FallbackPool `json:"packageDependencies"` +} + +type FallbackPool map[string]*PackageDependency + +type PackageDependency struct { + Reference string + Alias [2]string + IsAlias bool +} + +type PackageRegistryData map[string]map[string]PackageInformation + +var _ json.UnmarshalerFrom = (*Manifest)(nil) + +func (m *Manifest) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + if _, err := dec.ReadToken(); err != nil { + return err + } + for dec.PeekKind() != jsontext.EndObject.Kind() { + fieldName, err := dec.ReadValue() + if err != nil { + return err + } + + switch string(fieldName) { + case `"enableTopLevelFallback"`: + if err := json.UnmarshalDecode(dec, &m.EnableTopLevelFallback); err != nil { + return err + } + case `"ignorePatternData"`: + if err := json.UnmarshalDecode(dec, &m.IgnorePatternData); err != nil { + return err + } + case `"dependencyTreeRoots"`: + if err := json.UnmarshalDecode(dec, &m.DependencyTreeRoots); err != nil { + return err + } + case `"fallbackPool"`: + if err := json.UnmarshalDecode(dec, &m.FallbackPool); err != nil { + return err + } + case `"fallbackExclusionList"`: + if err := json.UnmarshalDecode(dec, &m.FallbackExclusionList); err != nil { + fmt.Println("error", err) + return err + } + case `"packageRegistryData"`: + if err := json.UnmarshalDecode(dec, &m.PackageRegistryData); err != nil { + return err + } + default: + if _, err := dec.ReadValue(); err != nil { + return err + } + } + } + if _, err := dec.ReadToken(); err != nil { + return err + } + + return nil +} + +var _ json.UnmarshalerFrom = (*PackageDependency)(nil) + +func (p *PackageDependency) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + switch dec.PeekKind() { + case '"': // string case + var s string + if err := json.UnmarshalDecode(dec, &s); err != nil { + return err + } + p.Reference = s + p.IsAlias = false + return nil + case '[': // array case + if _, err := dec.ReadToken(); err != nil { + return err + } + var arr []string + for dec.PeekKind() != jsontext.EndArray.Kind() { + var s string + if err := json.UnmarshalDecode(dec, &s); err != nil { + return err + } + arr = append(arr, s) + } + if _, err := dec.ReadToken(); err != nil { + return err + } + if len(arr) != 2 { + return errors.New("PackageDependency: array must have length 2") + } + p.IsAlias = true + p.Alias = [2]string{arr[0], arr[1]} + return nil + default: + return errors.New("PackageDependency: unsupported JSON shape") + } +} + +var _ json.UnmarshalerFrom = (*RegexDef)(nil) + +func (r *RegexDef) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + if dec.PeekKind() == jsontext.Null.Kind() { + if _, err := dec.ReadToken(); err != nil { + return err + } + *r = RegexDef{} + return nil + } + + var s string + if err := json.UnmarshalDecode(dec, &s); err != nil { + return err + } + r.Source = s + reg, err := regexp2.Compile(s, regexp2.ECMAScript) + if err != nil { + return err + } + r.reg = reg + return nil +} + +var _ json.UnmarshalerFrom = (*FallbackPool)(nil) + +func (f *FallbackPool) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + if _, err := dec.ReadToken(); err != nil { + return err + } + + res := make(FallbackPool) + + for dec.PeekKind() != jsontext.EndArray.Kind() { + if _, err := dec.ReadToken(); err != nil { + return err + } + + var key string + if err := json.UnmarshalDecode(dec, &key); err != nil { + return err + } + + if dec.PeekKind() == jsontext.Null.Kind() { + if _, err := dec.ReadToken(); err != nil { + return err + } + res[key] = nil + } else { + var dep PackageDependency + if err := json.UnmarshalDecode(dec, &dep); err != nil { + return err + } + res[key] = &dep + } + + if _, err := dec.ReadToken(); err != nil { + return err + } + } + + if _, err := dec.ReadToken(); err != nil { + return err + } + + *f = res + return nil +} + +type FallbackExclusionList map[string][]string + +var _ json.UnmarshalerFrom = (*FallbackExclusionList)(nil) + +func (f *FallbackExclusionList) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + // start of array + if _, err := dec.ReadToken(); err != nil { + return err + } + + res := make(FallbackExclusionList) + + for dec.PeekKind() != jsontext.EndArray.Kind() { + // start of array + if _, err := dec.ReadToken(); err != nil { + return err + } + + var key string + if err := json.UnmarshalDecode(dec, &key); err != nil { + return err + } + + var arr []string + if err := json.UnmarshalDecode(dec, &arr); err != nil { + return err + } + + res[key] = arr + + // end of array + if _, err := dec.ReadToken(); err != nil { + return err + } + } + + // end of array + if _, err := dec.ReadToken(); err != nil { + return err + } + + *f = res + return nil +} + +var _ json.UnmarshalerFrom = (*PackageRegistryData)(nil) + +func (m *PackageRegistryData) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + if _, err := dec.ReadToken(); err != nil { + return err + } + res := make(PackageRegistryData) + + for dec.PeekKind() != jsontext.EndArray.Kind() { + // start of array1 + if _, err := dec.ReadToken(); err != nil { + return err + } + var key1 *string + if err := json.UnmarshalDecode(dec, &key1); err != nil { + return err + } + k1 := "" + if key1 != nil { + k1 = *key1 + } + // start of array2 + if _, err := dec.ReadToken(); err != nil { + return err + } + innerMap := make(map[string]PackageInformation) + for dec.PeekKind() != jsontext.EndArray.Kind() { + if _, err := dec.ReadToken(); err != nil { + return err + } + + var key2 *string + if err := json.UnmarshalDecode(dec, &key2); err != nil { + return err + } + k2 := "" + if key2 != nil { + k2 = *key2 + } + + var info PackageInformation + if err := json.UnmarshalDecode(dec, &info); err != nil { + return err + } + + innerMap[k2] = info + + if _, err := dec.ReadToken(); err != nil { + return err + } + } + // end of array2 + if _, err := dec.ReadToken(); err != nil { + return err + } + res[k1] = innerMap + + // end of array1 + if _, err := dec.ReadToken(); err != nil { + return err + } + } + if _, err := dec.ReadToken(); err != nil { + return err + } + + *m = res + return nil +} + +func NewLocationTrie[T any]() *LocationTrie[T] { + return &LocationTrie[T]{inner: New[T]()} +} + +func (t *LocationTrie[T]) key(key string) string { + p := tspath.NormalizePath(key) + + if !strings.HasSuffix(p, "/") { + return p + "/" + } + + return p +} + +func (t *LocationTrie[T]) GetAncestorValue(p string) (*T, bool) { + v, ok := t.inner.GetAncestorValue(t.key(p)) + return &v, ok +} + +func (t *LocationTrie[T]) Insert(p string, v T) { + t.inner.Set(t.key(p), v) +} diff --git a/internal/module/pnp/trie.go b/internal/module/pnp/trie.go new file mode 100644 index 0000000000..c3dddab14a --- /dev/null +++ b/internal/module/pnp/trie.go @@ -0,0 +1,80 @@ +package pnp + +type Trie[T any] struct { + root *node[T] +} + +type node[T any] struct { + children map[rune]*node[T] + value T + hasValue bool +} + +func New[T any]() *Trie[T] { + return &Trie[T]{root: &node[T]{children: make(map[rune]*node[T])}} +} + +func (t *Trie[T]) Set(key string, v T) { + n := t.root + for _, r := range key { + child, ok := n.children[r] + if !ok { + child = &node[T]{children: make(map[rune]*node[T])} + n.children[r] = child + } + n = child + } + n.value = v + n.hasValue = true +} + +func (t *Trie[T]) Get(key string) (T, bool) { + n := t.root + for _, r := range key { + child, ok := n.children[r] + if !ok { + var zero T + return zero, false + } + n = child + } + if n.hasValue { + return n.value, true + } + var zero T + return zero, false +} + +func (t *Trie[T]) GetAncestorValue(key string) (T, bool) { + n := t.root + + var best T + var okBest bool + if n.hasValue { + best, okBest = n.value, true + } + + for _, r := range key { + child, ok := n.children[r] + if !ok { + var zero T + if okBest { + return best, true + } + return zero, false + } + n = child + if n.hasValue { + best, okBest = n.value, true + } + } + + if n.hasValue { + return n.value, true + } + var zero T + if okBest { + return best, true + } + return zero, false +} diff --git a/internal/module/pnp/trie_test.go b/internal/module/pnp/trie_test.go new file mode 100644 index 0000000000..93ec08ea08 --- /dev/null +++ b/internal/module/pnp/trie_test.go @@ -0,0 +1,172 @@ +package pnp + +import ( + "strconv" + "testing" +) + +func TestSetAndGet(t *testing.T) { + t.Parallel() + tr := New[string]() + tr.Set("foo", "A") + tr.Set("foobar", "B") + tr.Set("bar", "C") + + tests := []struct { + key string + want string + wantOkay bool + }{ + {"foo", "A", true}, + {"foobar", "B", true}, + {"bar", "C", true}, + {"fo", "", false}, + {"baz", "", false}, + } + + for _, tc := range tests { + got, ok := tr.Get(tc.key) + if ok != tc.wantOkay || (ok && got != tc.want) { + t.Fatalf("Get(%q) = (%q,%v), want (%q,%v)", tc.key, got, ok, tc.want, tc.wantOkay) + } + } +} + +func TestGetAncestorValue_Basic(t *testing.T) { + t.Parallel() + tr := New[string]() + tr.Set("foo", "A") + tr.Set("foobar", "B") + + tests := []struct { + key string + want string + wantOkay bool + }{ + {"foobar", "B", true}, + {"fo", "", false}, + {"foz", "", false}, + {"foobaz", "A", true}, + {"x", "", false}, + } + + for _, tc := range tests { + got, ok := tr.GetAncestorValue(tc.key) + if ok != tc.wantOkay || (ok && got != tc.want) { + t.Fatalf("GetAncestorValue(%q) = (%q,%v), want (%q,%v)", + tc.key, got, ok, tc.want, tc.wantOkay) + } + } +} + +func TestGetAncestorValue_Unicode(t *testing.T) { + t.Parallel() + tr := New[string]() + tr.Set("한", "H1") + tr.Set("한글", "H2") + tr.Set("한글날", "H3") + + tests := []struct { + key string + want string + wantOkay bool + }{ + {"한", "H1", true}, + {"한글", "H2", true}, + {"한글날", "H3", true}, + {"한글나ëŧ", "H2", true}, + {"한ęĩ­", "H1", true}, + } + + for _, tc := range tests { + got, ok := tr.GetAncestorValue(tc.key) + if ok != tc.wantOkay || (ok && got != tc.want) { + t.Fatalf("Unicode GetAncestorValue(%q) = (%q,%v), want (%q,%v)", + tc.key, got, ok, tc.want, tc.wantOkay) + } + } +} + +func TestRootValue_AsAncestor(t *testing.T) { + t.Parallel() + tr := New[string]() + tr.Set("", "ROOT") + tr.Set("a", "A") + + tests := []struct { + key string + want string + wantOkay bool + }{ + {"", "ROOT", true}, + {"x", "ROOT", true}, + {"ab", "A", true}, + } + + for _, tc := range tests { + got, ok := tr.GetAncestorValue(tc.key) + if ok != tc.wantOkay || (ok && got != tc.want) { + t.Fatalf("Root GetAncestorValue(%q) = (%q,%v), want (%q,%v)", + tc.key, got, ok, tc.want, tc.wantOkay) + } + } +} + +func TestZeroValue_Int(t *testing.T) { + t.Parallel() + tr := New[int]() + tr.Set("zero", 0) + tr.Set("one", 1) + + got, ok := tr.Get("zero") + if !ok || got != 0 { + t.Fatalf("Get(zero) = (%d,%v), want (0,true)", got, ok) + } + + got2, ok2 := tr.GetAncestorValue("zero-suffix") + if !ok2 || got2 != 0 { + t.Fatalf("GetAncestorValue(zero-suffix) = (%d,%v), want (0,true)", got2, ok2) + } +} + +func TestGetAncestorValue_NoAncestor(t *testing.T) { + t.Parallel() + tr := New[string]() + + if _, ok := tr.GetAncestorValue("anything"); ok { + t.Fatalf("expected no ancestor value, but got ok=true") + } +} + +func TestGetAncestorValue_LongestPrefixWins(t *testing.T) { + t.Parallel() + tr := New[string]() + // "a", "ab", "abc", ..., "abcdefghij" + prefix := "" + for i := range 10 { + prefix += "a" + tr.Set(prefix, "V"+strconv.Itoa(i)) + } + // "aaaaaaaaax" + key := prefix + "x" + + got, ok := tr.GetAncestorValue(key) + if !ok || got != "V9" { + t.Fatalf("LongestPrefix GetAncestorValue = (%q,%v), want (\"V9\",true)", got, ok) + } +} + +func BenchmarkGetAncestorValue(b *testing.B) { + tr := New[string]() + for i := range 1000 { + tr.Set("key-"+strconv.Itoa(i), "V"+strconv.Itoa(i)) + } + tr.Set("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "LONG") + + b.ResetTimer() + for range b.N { + _, _ = tr.GetAncestorValue("key-123-extra") + _, _ = tr.GetAncestorValue("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaax") + _, _ = tr.GetAncestorValue("zzz") + } +} diff --git a/internal/module/resolver.go b/internal/module/resolver.go index e88a468cc0..09ff102902 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -10,6 +10,7 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/module/pnp" "github.com/microsoft/typescript-go/internal/packagejson" "github.com/microsoft/typescript-go/internal/semver" "github.com/microsoft/typescript-go/internal/tspath" @@ -144,11 +145,11 @@ func GetCompilerOptionsWithRedirect(compilerOptions *core.CompilerOptions, redir type Resolver struct { caches - host ResolutionHost - compilerOptions *core.CompilerOptions - typingsLocation string - projectName string - // reportDiagnostic: DiagnosticReporter + host ResolutionHost + compilerOptions *core.CompilerOptions + typingsLocation string + projectName string + pnpResolutionConfig *pnp.ResolutionConfig } func NewResolver( @@ -156,13 +157,15 @@ func NewResolver( options *core.CompilerOptions, typingsLocation string, projectName string, + pnpResolutionConfig *pnp.ResolutionConfig, ) *Resolver { return &Resolver{ - host: host, - caches: newCaches(host.GetCurrentDirectory(), host.FS().UseCaseSensitiveFileNames(), options), - compilerOptions: options, - typingsLocation: typingsLocation, - projectName: projectName, + host: host, + caches: newCaches(host.GetCurrentDirectory(), host.FS().UseCaseSensitiveFileNames(), options), + compilerOptions: options, + typingsLocation: typingsLocation, + projectName: projectName, + pnpResolutionConfig: pnpResolutionConfig, } } @@ -327,32 +330,38 @@ func (r *tracer) traceTypeReferenceDirectiveResult(typeReferenceDirectiveName st func (r *resolutionState) resolveTypeReferenceDirective(typeRoots []string, fromConfig bool, fromInferredTypesContainingFile bool) *ResolvedTypeReferenceDirective { // Primary lookup - if len(typeRoots) > 0 { - if r.tracer != nil { - r.tracer.write(diagnostics.Resolving_with_primary_search_path_0.Format(strings.Join(typeRoots, ", "))) - } - for _, typeRoot := range typeRoots { - candidate := r.getCandidateFromTypeRoot(typeRoot) - directoryExists := r.resolver.host.FS().DirectoryExists(candidate) - if !directoryExists && r.tracer != nil { - r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it.Format(typeRoot)) - } - if fromConfig { - // Custom typeRoots resolve as file or directory just like we do modules - if resolvedFromFile := r.loadModuleFromFile(extensionsDeclaration, candidate, !directoryExists); !resolvedFromFile.shouldContinueSearching() { - packageDirectory := ParseNodeModuleFromPath(resolvedFromFile.path, false) - if packageDirectory != "" { - resolvedFromFile.packageId = r.getPackageId(resolvedFromFile.path, r.getPackageJsonInfo(packageDirectory, false /*onlyRecordFailures*/)) + if r.resolver.pnpResolutionConfig != nil { + if resolvedFromNearestNodeModulesDirectory := r.loadModuleFromNearestNodeModulesDirectory(true /*typesScopeOnly*/); !resolvedFromNearestNodeModulesDirectory.shouldContinueSearching() { + return r.createResolvedTypeReferenceDirective(resolvedFromNearestNodeModulesDirectory, true /*primary*/) + } + } else { + if len(typeRoots) > 0 { + if r.tracer != nil { + r.tracer.write(diagnostics.Resolving_with_primary_search_path_0.Format(strings.Join(typeRoots, ", "))) + } + for _, typeRoot := range typeRoots { + candidate := r.getCandidateFromTypeRoot(typeRoot) + directoryExists := r.resolver.host.FS().DirectoryExists(candidate) + if !directoryExists && r.tracer != nil { + r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it.Format(typeRoot)) + } + if fromConfig { + // Custom typeRoots resolve as file or directory just like we do modules + if resolvedFromFile := r.loadModuleFromFile(extensionsDeclaration, candidate, !directoryExists); !resolvedFromFile.shouldContinueSearching() { + packageDirectory := ParseNodeModuleFromPath(resolvedFromFile.path, false) + if packageDirectory != "" { + resolvedFromFile.packageId = r.getPackageId(resolvedFromFile.path, r.getPackageJsonInfo(packageDirectory, false /*onlyRecordFailures*/)) + } + return r.createResolvedTypeReferenceDirective(resolvedFromFile, true /*primary*/) } - return r.createResolvedTypeReferenceDirective(resolvedFromFile, true /*primary*/) + } + if resolvedFromDirectory := r.loadNodeModuleFromDirectory(extensionsDeclaration, candidate, !directoryExists, true /*considerPackageJson*/); !resolvedFromDirectory.shouldContinueSearching() { + return r.createResolvedTypeReferenceDirective(resolvedFromDirectory, true /*primary*/) } } - if resolvedFromDirectory := r.loadNodeModuleFromDirectory(extensionsDeclaration, candidate, !directoryExists, true /*considerPackageJson*/); !resolvedFromDirectory.shouldContinueSearching() { - return r.createResolvedTypeReferenceDirective(resolvedFromDirectory, true /*primary*/) - } + } else if r.tracer != nil { + r.tracer.write(diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths.Format()) } - } else if r.tracer != nil { - r.tracer.write(diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths.Format()) } // Secondary lookup @@ -899,8 +908,14 @@ func (r *resolutionState) loadModuleFromNearestNodeModulesDirectory(typesScopeOn if r.tracer != nil { r.tracer.write(diagnostics.Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0.Format(priorityExtensions.String())) } - if result := r.loadModuleFromNearestNodeModulesDirectoryWorker(priorityExtensions, mode, typesScopeOnly); !result.shouldContinueSearching() { - return result + if r.resolver.pnpResolutionConfig != nil { + if result := r.loadModuleFromPNP(priorityExtensions, typesScopeOnly); !result.shouldContinueSearching() { + return result + } + } else { + if result := r.loadModuleFromNearestNodeModulesDirectoryWorker(priorityExtensions, mode, typesScopeOnly); !result.shouldContinueSearching() { + return result + } } } // (2) @@ -908,8 +923,17 @@ func (r *resolutionState) loadModuleFromNearestNodeModulesDirectory(typesScopeOn if r.tracer != nil { r.tracer.write(diagnostics.Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0.Format(secondaryExtensions.String())) } - return r.loadModuleFromNearestNodeModulesDirectoryWorker(secondaryExtensions, mode, typesScopeOnly) + if r.resolver.pnpResolutionConfig != nil { + if result := r.loadModuleFromPNP(secondaryExtensions, typesScopeOnly); !result.shouldContinueSearching() { + return result + } + } else { + if result := r.loadModuleFromNearestNodeModulesDirectoryWorker(secondaryExtensions, mode, typesScopeOnly); !result.shouldContinueSearching() { + return result + } + } } + return continueSearching() } @@ -936,7 +960,10 @@ func (r *resolutionState) loadModuleFromImmediateNodeModulesDirectory(extensions } if !typesScopeOnly { - if packageResult := r.loadModuleFromSpecificNodeModulesDirectory(extensions, r.name, nodeModulesFolder, nodeModulesFolderExists); !packageResult.shouldContinueSearching() { + candidate := tspath.NormalizePath(tspath.CombinePaths(nodeModulesFolder, r.name)) + packageName, rest := ParsePackageName(r.name) + packageDirectory := tspath.CombinePaths(nodeModulesFolder, packageName) + if packageResult := r.loadModuleFromSpecificNodeModulesDirectory(extensions, candidate, packageDirectory, rest, nodeModulesFolderExists); !packageResult.shouldContinueSearching() { return packageResult } } @@ -947,17 +974,19 @@ func (r *resolutionState) loadModuleFromImmediateNodeModulesDirectory(extensions if !nodeModulesAtTypesExists && r.tracer != nil { r.tracer.write(diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it.Format(nodeModulesAtTypes)) } - return r.loadModuleFromSpecificNodeModulesDirectory(extensionsDeclaration, r.mangleScopedPackageName(r.name), nodeModulesAtTypes, nodeModulesAtTypesExists) + mangledName := r.mangleScopedPackageName(r.name) + + candidate := tspath.NormalizePath(tspath.CombinePaths(nodeModulesAtTypes, mangledName)) + packageName, rest := ParsePackageName(mangledName) + packageDirectory := tspath.CombinePaths(nodeModulesAtTypes, packageName) + + return r.loadModuleFromSpecificNodeModulesDirectory(extensionsDeclaration, candidate, packageDirectory, rest, nodeModulesAtTypesExists) } return continueSearching() } -func (r *resolutionState) loadModuleFromSpecificNodeModulesDirectory(ext extensions, moduleName string, nodeModulesDirectory string, nodeModulesDirectoryExists bool) *resolved { - candidate := tspath.NormalizePath(tspath.CombinePaths(nodeModulesDirectory, moduleName)) - packageName, rest := ParsePackageName(moduleName) - packageDirectory := tspath.CombinePaths(nodeModulesDirectory, packageName) - +func (r *resolutionState) loadModuleFromSpecificNodeModulesDirectory(ext extensions, candidate string, packageDirectory string, rest string, nodeModulesDirectoryExists bool) *resolved { var rootPackageInfo *packagejson.InfoCacheEntry // First look for a nested package.json, as in `node_modules/foo/bar/package.json` packageInfo := r.getPackageJsonInfo(candidate, !nodeModulesDirectoryExists) @@ -970,7 +999,6 @@ func (r *resolutionState) loadModuleFromSpecificNodeModulesDirectory(ext extensi if fromFile := r.loadModuleFromFile(ext, candidate, !nodeModulesDirectoryExists); !fromFile.shouldContinueSearching() { return fromFile } - if fromDirectory := r.loadNodeModuleFromDirectoryWorker(ext, candidate, !nodeModulesDirectoryExists, packageInfo); !fromDirectory.shouldContinueSearching() { fromDirectory.packageId = r.getPackageId(packageDirectory, packageInfo) return fromDirectory @@ -1016,7 +1044,8 @@ func (r *resolutionState) loadModuleFromSpecificNodeModulesDirectory(ext extensi packageInfo.Exists() && packageInfo.Contents.Exports.Type != packagejson.JSONValueTypeNotPresent { // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present, blocks them) - return r.loadModuleFromExports(packageInfo, ext, tspath.CombinePaths(".", rest)) + result := r.loadModuleFromExports(packageInfo, ext, tspath.CombinePaths(".", rest)) + return result } if rest != "" { versionPaths := packageInfo.Contents.GetVersionPaths(r.getTraceFunc()) @@ -1675,15 +1704,17 @@ func (r *resolutionState) getPackageJsonInfo(packageDirectory string, onlyRecord if directoryExists && r.resolver.host.FS().FileExists(packageJsonPath) { // Ignore error contents, _ := r.resolver.host.FS().ReadFile(packageJsonPath) - packageJsonContent, _ := packagejson.Parse([]byte(contents)) + packageJsonContent, err := packagejson.Parse([]byte(contents)) if r.tracer != nil { r.tracer.write(diagnostics.Found_package_json_at_0.Format(packageJsonPath)) } + result := &packagejson.InfoCacheEntry{ PackageDirectory: packageDirectory, DirectoryExists: true, Contents: &packagejson.PackageJson{ - Fields: packageJsonContent, + Fields: packageJsonContent, + Parseable: err == nil, }, } result = r.resolver.packageJsonInfoCache.Set(packageJsonPath, result) @@ -1973,7 +2004,7 @@ func extensionIsOk(extensions extensions, extension string) bool { } func ResolveConfig(moduleName string, containingFile string, host ResolutionHost) *ResolvedModule { - resolver := NewResolver(host, &core.CompilerOptions{ModuleResolution: core.ModuleResolutionKindNodeNext}, "", "") + resolver := NewResolver(host, &core.CompilerOptions{ModuleResolution: core.ModuleResolutionKindNodeNext}, "", "", nil) return resolver.resolveConfig(moduleName, containingFile) } diff --git a/internal/module/resolver_pnp.go b/internal/module/resolver_pnp.go new file mode 100644 index 0000000000..35b1692f49 --- /dev/null +++ b/internal/module/resolver_pnp.go @@ -0,0 +1,51 @@ +package module + +import ( + "strings" + + "github.com/microsoft/typescript-go/internal/module/pnp" + "github.com/microsoft/typescript-go/internal/tspath" +) + +func (r *resolutionState) loadPNPResolutionPath(moduleName string) (string, error) { + resolution, err := pnp.ResolveToUnqualified(moduleName, r.containingDirectory, r.resolver.pnpResolutionConfig) + if err != nil { + return "", err + } + + // Because the cache operates based on normalized paths with trailing slashes removed + // it always ensures that the paths are minimized. + return strings.TrimSuffix(resolution.Path, "/"), nil +} + +func (r *resolutionState) loadModuleFromPNP(extensions extensions, typesScopeOnly bool) *resolved { + packageName, rest := ParsePackageName(r.name) + + if !typesScopeOnly { + pnpPath, err := r.loadPNPResolutionPath(packageName) + + if err == nil && r.resolver.host.FS().DirectoryExists(pnpPath) { + candidate := tspath.NormalizePath(tspath.CombinePaths(pnpPath, rest)) + packageDirectory := pnpPath + + if result := r.loadModuleFromSpecificNodeModulesDirectory(extensions, candidate, packageDirectory, rest, true); !result.shouldContinueSearching() { + return result + } + } + } + + if extensions&extensionsDeclaration != 0 { + typesPackageName := "@types/" + r.mangleScopedPackageName(packageName) + pnpTypesPath, err := r.loadPNPResolutionPath(typesPackageName) + if err == nil && r.resolver.host.FS().DirectoryExists(pnpTypesPath) { + candidate := tspath.NormalizePath(tspath.CombinePaths(pnpTypesPath, rest)) + packageDirectory := pnpTypesPath + + if result := r.loadModuleFromSpecificNodeModulesDirectory(extensionsDeclaration, candidate, packageDirectory, rest, true); !result.shouldContinueSearching() { + return result + } + } + } + + return continueSearching() +} diff --git a/internal/module/resolver_test.go b/internal/module/resolver_test.go index eb777c8e33..429a305f64 100644 --- a/internal/module/resolver_test.go +++ b/internal/module/resolver_test.go @@ -300,7 +300,7 @@ func runTraceBaseline(t *testing.T, test traceTestCase) { t.Parallel() host := newVFSModuleResolutionHost(test.files, test.currentDirectory) - resolver := module.NewResolver(host, test.compilerOptions, "", "") + resolver := module.NewResolver(host, test.compilerOptions, "", "", nil) for _, call := range test.calls { doCall(t, resolver, call, false /*skipLocations*/) @@ -311,7 +311,7 @@ func runTraceBaseline(t *testing.T, test traceTestCase) { t.Run("concurrent", func(t *testing.T) { concurrentHost := newVFSModuleResolutionHost(test.files, test.currentDirectory) - concurrentResolver := module.NewResolver(concurrentHost, test.compilerOptions, "", "") + concurrentResolver := module.NewResolver(concurrentHost, test.compilerOptions, "", "", nil) var wg sync.WaitGroup for _, call := range test.calls { diff --git a/internal/module/util.go b/internal/module/util.go index 7f6d093d05..04f75150f4 100644 --- a/internal/module/util.go +++ b/internal/module/util.go @@ -45,7 +45,7 @@ func ParsePackageName(moduleName string) (packageName, rest string) { } func MangleScopedPackageName(packageName string) string { - if packageName[0] == '@' { + if len(packageName) > 0 && packageName[0] == '@' { idx := strings.Index(packageName, "/") if idx == -1 { return packageName diff --git a/internal/modulespecifiers/specifiers.go b/internal/modulespecifiers/specifiers.go index 1f8e26b040..fd040fc14e 100644 --- a/internal/modulespecifiers/specifiers.go +++ b/internal/modulespecifiers/specifiers.go @@ -793,6 +793,8 @@ func tryDirectoryWithPackageJson( fileName := moduleFileToTry[parts.PackageRootIndex+1:] if fileName == "index.d.ts" || fileName == "index.js" || fileName == "index.ts" || fileName == "index.tsx" { return pkgJsonDirAttemptResult{moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath} + } else { + return pkgJsonDirAttemptResult{moduleFileToTry: moduleFileToTry} } } @@ -801,11 +803,7 @@ func tryDirectoryWithPackageJson( importMode = host.GetDefaultResolutionModeForFile(importingSourceFile) } - var packageJsonContent *packagejson.PackageJson - if packageJson != nil { - packageJsonContent = packageJson.GetContents() - } - + packageJsonContent := packageJson.GetContents() if options.GetResolvePackageJsonImports() { // The package name that we found in node_modules could be different from the package // name in the package.json content via url/filepath dependency specifiers. We need to diff --git a/internal/modulespecifiers/types.go b/internal/modulespecifiers/types.go index 6cdfa3e689..c83dde2d83 100644 --- a/internal/modulespecifiers/types.go +++ b/internal/modulespecifiers/types.go @@ -68,7 +68,7 @@ type ModuleSpecifierGenerationHost interface { type ImportModuleSpecifierPreference string const ( - ImportModuleSpecifierPreferenceNone ImportModuleSpecifierPreference = "" + ImportModuleSpecifierPreferenceNone ImportModuleSpecifierPreference = "" // !!! ImportModuleSpecifierPreferenceShortest ImportModuleSpecifierPreference = "shortest" ImportModuleSpecifierPreferenceProjectRelative ImportModuleSpecifierPreference = "project-relative" ImportModuleSpecifierPreferenceRelative ImportModuleSpecifierPreference = "relative" @@ -78,7 +78,7 @@ const ( type ImportModuleSpecifierEndingPreference string const ( - ImportModuleSpecifierEndingPreferenceNone ImportModuleSpecifierEndingPreference = "" + ImportModuleSpecifierEndingPreferenceNone ImportModuleSpecifierEndingPreference = "" // !!! ImportModuleSpecifierEndingPreferenceAuto ImportModuleSpecifierEndingPreference = "auto" ImportModuleSpecifierEndingPreferenceMinimal ImportModuleSpecifierEndingPreference = "minimal" ImportModuleSpecifierEndingPreferenceIndex ImportModuleSpecifierEndingPreference = "index" diff --git a/internal/packagejson/cache.go b/internal/packagejson/cache.go index 7b72a4e3e9..ecff10e365 100644 --- a/internal/packagejson/cache.go +++ b/internal/packagejson/cache.go @@ -14,6 +14,7 @@ var typeScriptVersion = semver.MustParse(core.Version()) type PackageJson struct { Fields + Parseable bool versionPaths VersionPaths versionTraces []string once sync.Once diff --git a/internal/packagejson/packagejson.go b/internal/packagejson/packagejson.go index 5db60cebab..7ada92993e 100644 --- a/internal/packagejson/packagejson.go +++ b/internal/packagejson/packagejson.go @@ -28,6 +28,33 @@ type DependencyFields struct { OptionalDependencies Expected[map[string]string] `json:"optionalDependencies"` } +// HasDependency returns true if the package.json has a dependency with the given name +// under any of the dependency fields (dependencies, devDependencies, peerDependencies, +// optionalDependencies). +func (df *DependencyFields) HasDependency(name string) bool { + if deps, ok := df.Dependencies.GetValue(); ok { + if _, ok := deps[name]; ok { + return true + } + } + if devDeps, ok := df.DevDependencies.GetValue(); ok { + if _, ok := devDeps[name]; ok { + return true + } + } + if peerDeps, ok := df.PeerDependencies.GetValue(); ok { + if _, ok := peerDeps[name]; ok { + return true + } + } + if optDeps, ok := df.OptionalDependencies.GetValue(); ok { + if _, ok := optDeps[name]; ok { + return true + } + } + return false +} + type Fields struct { HeaderFields PathFields diff --git a/internal/parser/parser.go b/internal/parser/parser.go index ef87829bb6..a51566f02d 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -296,7 +296,7 @@ func (p *Parser) lookAhead(callback func(p *Parser) bool) bool { func (p *Parser) nextToken() ast.Kind { // if the keyword had an escape - if isKeyword(p.token) && (p.scanner.HasUnicodeEscape() || p.scanner.HasExtendedUnicodeEscape()) { + if ast.IsKeyword(p.token) && (p.scanner.HasUnicodeEscape() || p.scanner.HasExtendedUnicodeEscape()) { // issue a parse error for the escape p.parseErrorAtCurrentToken(diagnostics.Keywords_cannot_contain_escape_characters) } @@ -644,7 +644,7 @@ func (p *Parser) parsingContextErrors(context ParsingContext) { case PCHeritageClauseElement: p.parseErrorAtCurrentToken(diagnostics.Expression_expected) case PCVariableDeclarations: - if isKeyword(p.token) { + if ast.IsKeyword(p.token) { p.parseErrorAtCurrentToken(diagnostics.X_0_is_not_allowed_as_a_variable_declaration_name, scanner.TokenToString(p.token)) } else { p.parseErrorAtCurrentToken(diagnostics.Variable_declaration_expected) @@ -662,7 +662,7 @@ func (p *Parser) parsingContextErrors(context ParsingContext) { case PCJSDocParameters: p.parseErrorAtCurrentToken(diagnostics.Parameter_declaration_expected) case PCParameters: - if isKeyword(p.token) { + if ast.IsKeyword(p.token) { p.parseErrorAtCurrentToken(diagnostics.X_0_is_not_allowed_as_a_parameter_name, scanner.TokenToString(p.token)) } else { p.parseErrorAtCurrentToken(diagnostics.Parameter_declaration_expected) @@ -2352,7 +2352,7 @@ func (p *Parser) parseModuleExportName(disallowKeywords bool) (node *ast.Node, n if p.token == ast.KindStringLiteral { return p.parseLiteralExpression(false /*intern*/), nameOk } - if disallowKeywords && isKeyword(p.token) && !p.isIdentifier() { + if disallowKeywords && ast.IsKeyword(p.token) && !p.isIdentifier() { nameOk = false } return p.parseIdentifierName(), nameOk @@ -5835,7 +5835,7 @@ func (p *Parser) scanClassMemberStart() bool { // If we were able to get any potential identifier... if idToken != ast.KindUnknown { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if !isKeyword(idToken) || idToken == ast.KindSetKeyword || idToken == ast.KindGetKeyword { + if !ast.IsKeyword(idToken) || idToken == ast.KindSetKeyword || idToken == ast.KindGetKeyword { return true } // If it *is* a keyword, but not an accessor, check a little farther along @@ -6235,10 +6235,6 @@ func (p *Parser) skipRangeTrivia(textRange core.TextRange) core.TextRange { return core.NewTextRange(scanner.SkipTrivia(p.sourceText, textRange.Pos()), textRange.End()) } -func isKeyword(token ast.Kind) bool { - return ast.KindFirstKeyword <= token && token <= ast.KindLastKeyword -} - func isReservedWord(token ast.Kind) bool { return ast.KindFirstReservedWord <= token && token <= ast.KindLastReservedWord } diff --git a/internal/printer/printer.go b/internal/printer/printer.go index 6a1c10b6d8..85ee988b56 100644 --- a/internal/printer/printer.go +++ b/internal/printer/printer.go @@ -783,10 +783,9 @@ func (p *Printer) shouldEmitBlockFunctionBodyOnSingleLine(body *ast.Block) bool } func (p *Printer) shouldEmitOnNewLine(node *ast.Node, format ListFormat) bool { - // !!! TODO: enable multiline emit - // if p.emitContext.EmitFlags(node)&EFStartOnNewLine != 0 { - // return true - // } + if p.emitContext.EmitFlags(node)&EFStartOnNewLine != 0 { + return true + } return format&LFPreferNewLine != 0 } @@ -4385,18 +4384,24 @@ func (p *Printer) emitSourceFile(node *ast.SourceFile) { p.writeLine() - state := p.emitDetachedCommentsBeforeStatementList(node.AsNode(), node.Statements.Loc) p.pushNameGenerationScope(node.AsNode()) p.generateAllNames(node.Statements) index := 0 + var state *commentState if node.ScriptKind != core.ScriptKindJSON { p.emitShebangIfNeeded(node) index = p.emitPrologueDirectives(node.Statements) + if !p.writer.IsAtStartOfLine() { + p.writeLine() + } + state = p.emitDetachedCommentsBeforeStatementList(node.AsNode(), node.Statements.Loc) p.emitHelpers(node.AsNode()) if node.IsDeclarationFile { p.emitTripleSlashDirectives(node) } + } else { + state = p.emitDetachedCommentsBeforeStatementList(node.AsNode(), node.Statements.Loc) } // !!! Emit triple-slash directives @@ -5084,7 +5089,7 @@ func (p *Printer) emitDetachedCommentsBeforeStatementList(node *ast.Node, detach containerPos := p.containerPos containerEnd := p.containerEnd declarationListContainerEnd := p.declarationListContainerEnd - skipLeadingComments := emitFlags&EFNoLeadingComments == 0 && !ast.PositionIsSynthesized(detachedRange.Pos()) + skipLeadingComments := ast.PositionIsSynthesized(detachedRange.Pos()) || emitFlags&EFNoLeadingComments != 0 if !skipLeadingComments { p.emitDetachedCommentsAndUpdateCommentsInfo(detachedRange) diff --git a/internal/project/api.go b/internal/project/api.go index ea84b3adb5..ad96de170f 100644 --- a/internal/project/api.go +++ b/internal/project/api.go @@ -7,7 +7,7 @@ import ( ) func (s *Session) OpenProject(ctx context.Context, configFileName string) (*Project, error) { - fileChanges, overlays, ataChanges := s.flushChanges(ctx) + fileChanges, overlays, ataChanges, _ := s.flushChanges(ctx) newSnapshot := s.UpdateSnapshot(ctx, overlays, SnapshotChange{ fileChanges: fileChanges, ataChanges: ataChanges, diff --git a/internal/project/ata/ata.go b/internal/project/ata/ata.go index 16689bdb95..4d2d064406 100644 --- a/internal/project/ata/ata.go +++ b/internal/project/ata/ata.go @@ -186,7 +186,9 @@ func (ti *TypingsInstaller) installTypings( if packageNames, ok := ti.installWorker(projectID, requestID, scopedTypings, logger); ok { logger.Log(fmt.Sprintf("ATA:: Installed typings %v", packageNames)) var installedTypingFiles []string - resolver := module.NewResolver(ti.host, &core.CompilerOptions{ModuleResolution: core.ModuleResolutionKindNodeNext}, "", "") + // in the pnp environment, type packages are not installed. + // Support for them will be added later if needed. + resolver := module.NewResolver(ti.host, &core.CompilerOptions{ModuleResolution: core.ModuleResolutionKindNodeNext}, "", "", nil) for _, packageName := range filteredTypings { typingFile := ti.typingToFileName(resolver, packageName) if typingFile == "" { @@ -416,7 +418,9 @@ func (ti *TypingsInstaller) processCacheLocation(projectID string, fs vfs.FS, lo logger.Log("ATA:: Loaded content of " + packageLockJson + ": " + npmLockContents) // !!! sheetal strada uses Node10 - resolver := module.NewResolver(ti.host, &core.CompilerOptions{ModuleResolution: core.ModuleResolutionKindNodeNext}, "", "") + // in the pnp environment, type packages are not installed. + // Support for them will be added later if needed. + resolver := module.NewResolver(ti.host, &core.CompilerOptions{ModuleResolution: core.ModuleResolutionKindNodeNext}, "", "", nil) if npmConfig.DevDependencies != nil && (npmLock.Packages != nil || npmLock.Dependencies != nil) { for key := range npmConfig.DevDependencies { npmLockValue, npmLockValueExists := npmLock.Packages["node_modules/"+key] diff --git a/internal/project/bulkcache_test.go b/internal/project/bulkcache_test.go new file mode 100644 index 0000000000..e9b116f7c8 --- /dev/null +++ b/internal/project/bulkcache_test.go @@ -0,0 +1,341 @@ +package project_test + +import ( + "context" + "fmt" + "testing" + + "github.com/microsoft/typescript-go/internal/bundled" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/project" + "github.com/microsoft/typescript-go/internal/testutil/projecttestutil" + "gotest.tools/v3/assert" +) + +func TestBulkCacheInvalidation(t *testing.T) { + t.Parallel() + + if !bundled.Embedded { + t.Skip("bundled files are not embedded") + } + + // Base file structure for testing + baseFiles := map[string]any{ + "/project/tsconfig.json": `{ + "compilerOptions": { + "strict": true, + "target": "es2015", + "types": ["node"] + }, + "include": ["src/**/*"] + }`, + "/project/src/index.ts": `import { helper } from "./helper"; console.log(helper);`, + "/project/src/helper.ts": `export const helper = "test";`, + "/project/src/utils/lib.ts": `export function util() { return "util"; }`, + + "/project/node_modules/@types/node/index.d.ts": `import "./fs"; import "./console";`, + "/project/node_modules/@types/node/fs.d.ts": ``, + "/project/node_modules/@types/node/console.d.ts": ``, + } + + t.Run("large number of node_modules changes invalidates only node_modules cache", func(t *testing.T) { + t.Parallel() + test := func(t *testing.T, fileEvents []*lsproto.FileEvent, expectNodeModulesInvalidation bool) { + session, utils := projecttestutil.Setup(baseFiles) + + // Open a file to create the project + session.DidOpenFile(context.Background(), "file:///project/src/index.ts", 1, baseFiles["/project/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + + // Get initial snapshot and verify config + ls, err := session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetES2015) + + snapshotBefore, release := session.Snapshot() + defer release() + configBefore := snapshotBefore.ConfigFileRegistry + + // Update tsconfig.json on disk to test that configs don't get reloaded + err = utils.FS().WriteFile("/project/tsconfig.json", `{ + "compilerOptions": { + "strict": true, + "target": "esnext", + "types": ["node"] + }, + "include": ["src/**/*"] + }`, false) + assert.NilError(t, err) + // Update fs.d.ts in node_modules + err = utils.FS().WriteFile("/project/node_modules/@types/node/fs.d.ts", "new text", false) + assert.NilError(t, err) + + // Process the excessive node_modules changes + session.DidChangeWatchedFiles(context.Background(), fileEvents) + + // Get language service again to trigger snapshot update + ls, err = session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + + snapshotAfter, release := session.Snapshot() + defer release() + configAfter := snapshotAfter.ConfigFileRegistry + + // Config should NOT have been reloaded (target should remain ES2015, not esnext) + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetES2015, "Config should not have been reloaded for node_modules-only changes") + + // Config registry should be the same instance (no configs reloaded) + assert.Equal(t, configBefore, configAfter, "Config registry should not have changed for node_modules-only changes") + + fsDtsText := snapshotAfter.GetFile("/project/node_modules/@types/node/fs.d.ts").Content() + if expectNodeModulesInvalidation { + assert.Equal(t, fsDtsText, "new text") + } else { + assert.Equal(t, fsDtsText, "") + } + } + + t.Run("with file existing in cache", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/node_modules/generated/file%d.js", lsproto.FileChangeTypeCreated) + // Include two files in the program to trigger a full program creation. + // Exclude fs.d.ts to show that its content still gets invalidated. + fileEvents = append(fileEvents, &lsproto.FileEvent{ + Uri: "file:///project/node_modules/@types/node/index.d.ts", + Type: lsproto.FileChangeTypeChanged, + }, &lsproto.FileEvent{ + Uri: "file:///project/node_modules/@types/node/console.d.ts", + Type: lsproto.FileChangeTypeChanged, + }) + + test(t, fileEvents, true) + }) + + t.Run("without file existing in cache", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/node_modules/generated/file%d.js", lsproto.FileChangeTypeCreated) + test(t, fileEvents, false) + }) + }) + + t.Run("large number of changes outside node_modules", func(t *testing.T) { + t.Parallel() + test := func(t *testing.T, fileEvents []*lsproto.FileEvent, expectConfigReload bool) { + session, utils := projecttestutil.Setup(baseFiles) + + // Open a file to create the project + session.DidOpenFile(context.Background(), "file:///project/src/index.ts", 1, baseFiles["/project/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + + // Get initial state + ls, err := session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetES2015) + + // Update tsconfig.json on disk + err = utils.FS().WriteFile("/project/tsconfig.json", `{ + "compilerOptions": { + "strict": true, + "target": "esnext", + "types": ["node"] + }, + "include": ["src/**/*"] + }`, false) + assert.NilError(t, err) + // Add root file + err = utils.FS().WriteFile("/project/src/rootFile.ts", `console.log("root file")`, false) + assert.NilError(t, err) + + session.DidChangeWatchedFiles(context.Background(), fileEvents) + ls, err = session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + + if expectConfigReload { + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetESNext, "Config should have been reloaded for changes outside node_modules") + assert.Check(t, ls.GetProgram().GetSourceFile("/project/src/rootFile.ts") != nil, "New root file should be present") + } else { + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetES2015, "Config should not have been reloaded for changes outside node_modules") + assert.Check(t, ls.GetProgram().GetSourceFile("/project/src/rootFile.ts") == nil, "New root file should not be present") + } + } + + t.Run("with event matching include glob", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/generated/file%d.ts", lsproto.FileChangeTypeCreated) + fileEvents = append(fileEvents, &lsproto.FileEvent{ + Uri: "file:///project/src/rootFile.ts", + Type: lsproto.FileChangeTypeCreated, + }) + test(t, fileEvents, true) + }) + + t.Run("without event matching include glob", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/generated/file%d.ts", lsproto.FileChangeTypeCreated) + test(t, fileEvents, false) + }) + }) + + t.Run("large number of changes outside node_modules causes project reevaluation", func(t *testing.T) { + t.Parallel() + session, utils := projecttestutil.Setup(baseFiles) + + // Open a file that will initially use the root tsconfig + session.DidOpenFile(context.Background(), "file:///project/src/utils/lib.ts", 1, baseFiles["/project/src/utils/lib.ts"].(string), lsproto.LanguageKindTypeScript) + + // Initially, the file should use the root project (strict mode) + snapshot, release := session.Snapshot() + defer release() + initialProject := snapshot.GetDefaultProject("file:///project/src/utils/lib.ts") + assert.Equal(t, initialProject.Name(), "/project/tsconfig.json", "Should initially use root tsconfig") + + // Get language service to verify initial strict mode + ls, err := session.GetLanguageService(context.Background(), "file:///project/src/utils/lib.ts") + assert.NilError(t, err) + assert.Equal(t, ls.GetProgram().Options().Strict, core.TSTrue, "Should initially use strict mode from root config") + + // Now create the nested tsconfig (this would normally be detected, but we'll simulate a missed event) + err = utils.FS().WriteFile("/project/src/utils/tsconfig.json", `{ + "compilerOptions": { + "strict": false, + "target": "esnext" + } + }`, false) + assert.NilError(t, err) + + // Create excessive changes to trigger bulk invalidation + fileEvents := generateFileEvents(1001, "file:///project/src/generated/file%d.ts", lsproto.FileChangeTypeCreated) + + // Process the excessive changes - this should trigger project reevaluation + session.DidChangeWatchedFiles(context.Background(), fileEvents) + + // Get language service - this should now find the nested config and switch projects + ls, err = session.GetLanguageService(context.Background(), "file:///project/src/utils/lib.ts") + assert.NilError(t, err) + + snapshot, release = session.Snapshot() + defer release() + newProject := snapshot.GetDefaultProject("file:///project/src/utils/lib.ts") + + // The file should now use the nested tsconfig + assert.Equal(t, newProject.Name(), "/project/src/utils/tsconfig.json", "Should now use nested tsconfig after bulk invalidation") + assert.Equal(t, ls.GetProgram().Options().Strict, core.TSFalse, "Should now use non-strict mode from nested config") + assert.Equal(t, ls.GetProgram().Options().Target, core.ScriptTargetESNext, "Should use esnext target from nested config") + }) + + t.Run("config file names cache", func(t *testing.T) { + t.Parallel() + test := func(t *testing.T, fileEvents []*lsproto.FileEvent, expectConfigDiscovery bool, testName string) { + files := map[string]any{ + "/project/src/index.ts": `console.log("test");`, // No tsconfig initially + } + session, utils := projecttestutil.Setup(files) + + // Open file without tsconfig - should create inferred project + session.DidOpenFile(context.Background(), "file:///project/src/index.ts", 1, files["/project/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + + snapshot, release := session.Snapshot() + defer release() + assert.Assert(t, snapshot.ProjectCollection.InferredProject() != nil, "Should have inferred project") + assert.Equal(t, snapshot.GetDefaultProject("file:///project/src/index.ts").Kind, project.KindInferred) + + // Create a tsconfig that would affect this file (simulating a missed creation event) + err := utils.FS().WriteFile("/project/tsconfig.json", `{ + "compilerOptions": { + "strict": true + }, + "include": ["src/**/*"] + }`, false) + assert.NilError(t, err) + + // Process the changes + session.DidChangeWatchedFiles(context.Background(), fileEvents) + + // Get language service to trigger config discovery + _, err = session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + + snapshot, release = session.Snapshot() + defer release() + newProject := snapshot.GetDefaultProject("file:///project/src/index.ts") + + // Check expected behavior + if expectConfigDiscovery { + // Should now use configured project instead of inferred + assert.Equal(t, newProject.Kind, project.KindConfigured, "Should now use configured project after cache invalidation") + assert.Equal(t, newProject.Name(), "/project/tsconfig.json", "Should use the newly discovered tsconfig") + } else { + // Should still use inferred project (config file names cache not cleared) + assert.Assert(t, newProject == snapshot.ProjectCollection.InferredProject(), "Should still use inferred project after node_modules-only changes") + } + } + + t.Run("excessive changes only in node_modules does not affect config file names cache", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/node_modules/generated/file%d.js", lsproto.FileChangeTypeCreated) + test(t, fileEvents, false, "node_modules changes should not clear config cache") + }) + + t.Run("excessive changes outside node_modules clears config file names cache", func(t *testing.T) { + t.Parallel() + fileEvents := generateFileEvents(1001, "file:///project/src/generated/file%d.ts", lsproto.FileChangeTypeCreated) + // Presence of any tsconfig.json file event triggers rediscovery for config for all open files + fileEvents = append(fileEvents, &lsproto.FileEvent{ + Uri: lsproto.DocumentUri("file:///project/src/generated/tsconfig.json"), + Type: lsproto.FileChangeTypeCreated, + }) + test(t, fileEvents, true, "non-node_modules changes should clear config cache") + }) + }) + + // Simulate external build tool changing files in dist/ (not included by any project) + t.Run("excessive changes in dist folder do not invalidate", func(t *testing.T) { + t.Parallel() + files := map[string]any{ + "/project/src/index.ts": `console.log("test");`, // No tsconfig initially + } + session, utils := projecttestutil.Setup(files) + + // Open file without tsconfig - should create inferred project + session.DidOpenFile(context.Background(), "file:///project/src/index.ts", 1, files["/project/src/index.ts"].(string), lsproto.LanguageKindTypeScript) + + snapshot, release := session.Snapshot() + defer release() + assert.Equal(t, snapshot.GetDefaultProject("file:///project/src/index.ts").Kind, project.KindInferred) + + // Create a tsconfig that would affect this file (simulating a missed creation event) + // This should NOT be discovered after dist-folder changes + err := utils.FS().WriteFile("/project/tsconfig.json", `{ + "compilerOptions": { + "strict": true + }, + "include": ["src/**/*"] + }`, false) + assert.NilError(t, err) + + // Create excessive changes in dist folder only + fileEvents := generateFileEvents(1001, "file:///project/dist/generated/file%d.js", lsproto.FileChangeTypeCreated) + session.DidChangeWatchedFiles(context.Background(), fileEvents) + + // File should still use inferred project (config file names cache NOT cleared for dist changes) + _, err = session.GetLanguageService(context.Background(), "file:///project/src/index.ts") + assert.NilError(t, err) + + snapshot, release = session.Snapshot() + defer release() + newProject := snapshot.GetDefaultProject("file:///project/src/index.ts") + assert.Equal(t, newProject.Kind, project.KindInferred, "dist-folder changes should not cause config discovery") + // This assertion will fail until we implement logic to ignore dist folder changes + }) +} + +// Helper function to generate excessive file change events +func generateFileEvents(count int, pathTemplate string, changeType lsproto.FileChangeType) []*lsproto.FileEvent { + var events []*lsproto.FileEvent + for i := range count { + events = append(events, &lsproto.FileEvent{ + Uri: lsproto.DocumentUri(fmt.Sprintf(pathTemplate, i)), + Type: changeType, + }) + } + return events +} diff --git a/internal/project/compilerhost.go b/internal/project/compilerhost.go index d58b3522b8..9040a297a8 100644 --- a/internal/project/compilerhost.go +++ b/internal/project/compilerhost.go @@ -6,6 +6,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/module/pnp" "github.com/microsoft/typescript-go/internal/project/logging" "github.com/microsoft/typescript-go/internal/tsoptions" "github.com/microsoft/typescript-go/internal/tspath" @@ -24,9 +25,10 @@ type compilerHost struct { configFileRegistry *ConfigFileRegistry seenFiles *collections.SyncSet[tspath.Path] - project *Project - builder *projectCollectionBuilder - logger *logging.LogTree + project *Project + builder *projectCollectionBuilder + logger *logging.LogTree + pnpResolutionConfig *pnp.ResolutionConfig } type builderFileSource struct { @@ -108,6 +110,11 @@ func (c *compilerHost) GetCurrentDirectory() string { return c.currentDirectory } +// GetPNPResolutionConfig implements compiler.CompilerHost. +func (c *compilerHost) GetPNPResolutionConfig() *pnp.ResolutionConfig { + return c.pnpResolutionConfig +} + // GetResolvedProjectReference implements compiler.CompilerHost. func (c *compilerHost) GetResolvedProjectReference(fileName string, path tspath.Path) *tsoptions.ParsedCommandLine { if c.builder == nil { diff --git a/internal/project/configfileregistry.go b/internal/project/configfileregistry.go index 801d249be7..1b6613a613 100644 --- a/internal/project/configfileregistry.go +++ b/internal/project/configfileregistry.go @@ -19,6 +19,7 @@ type ConfigFileRegistry struct { } type configFileEntry struct { + fileName string pendingReload PendingReload commandLine *tsoptions.ParsedCommandLine // retainingProjects is the set of projects that have called acquireConfig @@ -46,6 +47,7 @@ type configFileEntry struct { func newConfigFileEntry(fileName string) *configFileEntry { return &configFileEntry{ + fileName: fileName, pendingReload: PendingReloadFull, rootFilesWatch: NewWatchedFiles( "root files for "+fileName, @@ -55,8 +57,9 @@ func newConfigFileEntry(fileName string) *configFileEntry { } } -func newExtendedConfigFileEntry(extendingConfigPath tspath.Path) *configFileEntry { +func newExtendedConfigFileEntry(fileName string, extendingConfigPath tspath.Path) *configFileEntry { return &configFileEntry{ + fileName: fileName, pendingReload: PendingReloadFull, retainingConfigs: map[tspath.Path]struct{}{extendingConfigPath: {}}, } @@ -64,6 +67,7 @@ func newExtendedConfigFileEntry(extendingConfigPath tspath.Path) *configFileEntr func (e *configFileEntry) Clone() *configFileEntry { return &configFileEntry{ + fileName: e.fileName, pendingReload: e.pendingReload, commandLine: e.commandLine, // !!! eagerly cloning these maps makes everything more convenient, diff --git a/internal/project/configfileregistrybuilder.go b/internal/project/configfileregistrybuilder.go index a4b5a7ff6d..c8fc308500 100644 --- a/internal/project/configfileregistrybuilder.go +++ b/internal/project/configfileregistrybuilder.go @@ -122,7 +122,7 @@ func (c *configFileRegistryBuilder) updateExtendingConfigs(extendingConfigPath t for _, extendedConfig := range newCommandLine.ExtendedSourceFiles() { extendedConfigPath := c.fs.toPath(extendedConfig) newExtendedConfigPaths.Add(extendedConfigPath) - entry, loaded := c.configs.LoadOrStore(extendedConfigPath, newExtendedConfigFileEntry(extendingConfigPath)) + entry, loaded := c.configs.LoadOrStore(extendedConfigPath, newExtendedConfigFileEntry(extendedConfig, extendingConfigPath)) if loaded { entry.ChangeIf( func(config *configFileEntry) bool { @@ -317,10 +317,48 @@ func (r changeFileResult) IsEmpty() bool { return len(r.affectedProjects) == 0 && len(r.affectedFiles) == 0 } +func (c *configFileRegistryBuilder) invalidateCache(logger *logging.LogTree) changeFileResult { + var affectedProjects map[tspath.Path]struct{} + var affectedFiles map[tspath.Path]struct{} + + logger.Log("Too many files changed; marking all configs for reload") + c.configFileNames.Range(func(entry *dirty.MapEntry[tspath.Path, *configFileNames]) bool { + if affectedFiles == nil { + affectedFiles = make(map[tspath.Path]struct{}) + } + affectedFiles[entry.Key()] = struct{}{} + return true + }) + c.configFileNames.Clear() + + c.configs.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *configFileEntry]) bool { + entry.Change(func(entry *configFileEntry) { + affectedProjects = core.CopyMapInto(affectedProjects, entry.retainingProjects) + if entry.pendingReload != PendingReloadFull { + text, ok := c.FS().ReadFile(entry.fileName) + if !ok || text != entry.commandLine.ConfigFile.SourceFile.Text() { + entry.pendingReload = PendingReloadFull + } else { + entry.pendingReload = PendingReloadFileNames + } + } + }) + return true + }) + + return changeFileResult{ + affectedProjects: affectedProjects, + affectedFiles: affectedFiles, + } +} + func (c *configFileRegistryBuilder) DidChangeFiles(summary FileChangeSummary, logger *logging.LogTree) changeFileResult { var affectedProjects map[tspath.Path]struct{} var affectedFiles map[tspath.Path]struct{} + var shouldInvalidateCache bool + logger.Log("Summarizing file changes") + hasExcessiveChanges := summary.HasExcessiveWatchEvents() && summary.IncludesWatchChangeOutsideNodeModules createdFiles := make(map[tspath.Path]string, summary.Created.Len()) createdOrDeletedFiles := make(map[tspath.Path]struct{}, summary.Created.Len()+summary.Deleted.Len()) createdOrChangedOrDeletedFiles := make(map[tspath.Path]struct{}, summary.Changed.Len()+summary.Deleted.Len()) @@ -366,6 +404,10 @@ func (c *configFileRegistryBuilder) DidChangeFiles(summary FileChangeSummary, lo logger.Log("Checking if any changed files are config files") for path := range createdOrChangedOrDeletedFiles { if entry, ok := c.configs.Load(path); ok { + if hasExcessiveChanges { + return c.invalidateCache(logger) + } + affectedProjects = core.CopyMapInto(affectedProjects, c.handleConfigChange(entry, logger)) for extendingConfigPath := range entry.Value().retainingConfigs { if extendingConfigEntry, ok := c.configs.Load(extendingConfigPath); ok { @@ -377,6 +419,27 @@ func (c *configFileRegistryBuilder) DidChangeFiles(summary FileChangeSummary, lo } } + // Handle created/deleted files named "tsconfig.json" or "jsconfig.json" + for path := range createdOrDeletedFiles { + baseName := tspath.GetBaseFileName(string(path)) + if baseName == "tsconfig.json" || baseName == "jsconfig.json" { + if hasExcessiveChanges { + return c.invalidateCache(logger) + } + directoryPath := path.GetDirectoryPath() + c.configFileNames.Range(func(entry *dirty.MapEntry[tspath.Path, *configFileNames]) bool { + if directoryPath.ContainsPath(entry.Key()) { + if affectedFiles == nil { + affectedFiles = make(map[tspath.Path]struct{}) + } + affectedFiles[entry.Key()] = struct{}{} + entry.Delete() + } + return true + }) + } + } + // Handle possible root file creation if len(createdFiles) > 0 { c.configs.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *configFileEntry]) bool { @@ -400,27 +463,13 @@ func (c *configFileRegistryBuilder) DidChangeFiles(summary FileChangeSummary, lo } maps.Copy(affectedProjects, config.retainingProjects) logger.Logf("Root files for config %s changed", entry.Key()) + shouldInvalidateCache = hasExcessiveChanges }, ) - return true + return !shouldInvalidateCache }) - } - - // Handle created/deleted files named "tsconfig.json" or "jsconfig.json" - for path := range createdOrDeletedFiles { - baseName := tspath.GetBaseFileName(string(path)) - if baseName == "tsconfig.json" || baseName == "jsconfig.json" { - directoryPath := path.GetDirectoryPath() - c.configFileNames.Range(func(entry *dirty.MapEntry[tspath.Path, *configFileNames]) bool { - if directoryPath.ContainsPath(entry.Key()) { - if affectedFiles == nil { - affectedFiles = make(map[tspath.Path]struct{}) - } - affectedFiles[entry.Key()] = struct{}{} - entry.Delete() - } - return true - }) + if shouldInvalidateCache { + return c.invalidateCache(logger) } } @@ -465,7 +514,7 @@ func (c *configFileRegistryBuilder) computeConfigFileName(fileName string, skipS return result } -func (c *configFileRegistryBuilder) getConfigFileNameForFile(fileName string, path tspath.Path, loadKind projectLoadKind, logger *logging.LogTree) string { +func (c *configFileRegistryBuilder) getConfigFileNameForFile(fileName string, path tspath.Path, logger *logging.LogTree) string { if isDynamicFileName(fileName) { return "" } @@ -474,10 +523,6 @@ func (c *configFileRegistryBuilder) getConfigFileNameForFile(fileName string, pa return entry.Value().nearestConfigFileName } - if loadKind == projectLoadKindFind { - return "" - } - configName := c.computeConfigFileName(fileName, false, logger) if _, ok := c.fs.overlays[path]; ok { @@ -488,7 +533,7 @@ func (c *configFileRegistryBuilder) getConfigFileNameForFile(fileName string, pa return configName } -func (c *configFileRegistryBuilder) getAncestorConfigFileName(fileName string, path tspath.Path, configFileName string, loadKind projectLoadKind, logger *logging.LogTree) string { +func (c *configFileRegistryBuilder) getAncestorConfigFileName(fileName string, path tspath.Path, configFileName string, logger *logging.LogTree) string { if isDynamicFileName(fileName) { return "" } @@ -501,10 +546,6 @@ func (c *configFileRegistryBuilder) getAncestorConfigFileName(fileName string, p return ancestorConfigName } - if loadKind == projectLoadKindFind { - return "" - } - // Look for config in parent folders of config file result := c.computeConfigFileName(configFileName, true, logger) diff --git a/internal/project/dirty/map.go b/internal/project/dirty/map.go index 9097afc579..10f72d7ae4 100644 --- a/internal/project/dirty/map.go +++ b/internal/project/dirty/map.go @@ -127,6 +127,11 @@ func (m *Map[K, V]) Range(fn func(*MapEntry[K, V]) bool) { } } +func (m *Map[K, V]) Clear() { + m.dirty = make(map[K]*MapEntry[K, V]) + m.base = make(map[K]V) +} + func (m *Map[K, V]) Finalize() (result map[K]V, changed bool) { if len(m.dirty) == 0 { return m.base, false // no changes, return base map diff --git a/internal/project/filechange.go b/internal/project/filechange.go index 2f702add0e..e23184bff5 100644 --- a/internal/project/filechange.go +++ b/internal/project/filechange.go @@ -6,6 +6,8 @@ import ( "github.com/zeebo/xxh3" ) +const excessiveChangeThreshold = 1000 + type FileChangeKind int const ( @@ -18,6 +20,10 @@ const ( FileChangeKindWatchDelete ) +func (k FileChangeKind) IsWatchKind() bool { + return k == FileChangeKindWatchCreate || k == FileChangeKindWatchChange || k == FileChangeKindWatchDelete +} + type FileChange struct { Kind FileChangeKind URI lsproto.DocumentUri @@ -38,8 +44,20 @@ type FileChangeSummary struct { Created collections.Set[lsproto.DocumentUri] // Only set when file watching is enabled Deleted collections.Set[lsproto.DocumentUri] + + // IncludesWatchChangeOutsideNodeModules is true if the summary includes a create, change, or delete watch + // event of a file outside a node_modules directory. + IncludesWatchChangeOutsideNodeModules bool } func (f FileChangeSummary) IsEmpty() bool { return f.Opened == "" && len(f.Closed) == 0 && f.Changed.Len() == 0 && f.Created.Len() == 0 && f.Deleted.Len() == 0 } + +func (f FileChangeSummary) HasExcessiveWatchEvents() bool { + return f.Created.Len()+f.Deleted.Len()+f.Changed.Len() > excessiveChangeThreshold +} + +func (f FileChangeSummary) HasExcessiveNonCreateWatchEvents() bool { + return f.Deleted.Len()+f.Changed.Len() > excessiveChangeThreshold +} diff --git a/internal/project/overlayfs.go b/internal/project/overlayfs.go index 47ec2d95f9..26c6e2aa68 100644 --- a/internal/project/overlayfs.go +++ b/internal/project/overlayfs.go @@ -2,6 +2,7 @@ package project import ( "maps" + "strings" "sync" "github.com/microsoft/typescript-go/internal/core" @@ -237,6 +238,10 @@ func (fs *overlayFS) processChanges(changes []FileChange) (FileChangeSummary, ma fileEventMap[uri] = events } + if !result.IncludesWatchChangeOutsideNodeModules && change.Kind.IsWatchKind() && !strings.Contains(string(uri), "/node_modules/") { + result.IncludesWatchChangeOutsideNodeModules = true + } + switch change.Kind { case FileChangeKindOpen: events.openChange = &change diff --git a/internal/project/projectcollectionbuilder.go b/internal/project/projectcollectionbuilder.go index c898292bea..c7ed8bd2f9 100644 --- a/internal/project/projectcollectionbuilder.go +++ b/internal/project/projectcollectionbuilder.go @@ -186,6 +186,18 @@ func (b *projectCollectionBuilder) DidChangeFiles(summary FileChangeSummary, log logChangeFileResult(configChangeResult, configChangeLogger) b.forEachProject(func(entry dirty.Value[*Project]) bool { + // Only consider change/delete; creates are handled by the config file registry + if summary.HasExcessiveNonCreateWatchEvents() { + entry.Change(func(p *Project) { + p.dirty = true + p.dirtyFilePath = "" + if logger != nil { + logger.Logf("Marking project as dirty due to excessive watch changes: %s", p.configFilePath) + } + }) + return true + } + // Handle closed and changed files b.markFilesChanged(entry, changedFiles, lsproto.FileChangeTypeChanged, logger) if entry.Value().Kind == KindInferred && len(summary.Closed) > 0 { @@ -617,7 +629,7 @@ func (b *projectCollectionBuilder) findOrCreateDefaultConfiguredProjectWorker( return *fallback } } - if ancestorConfigName := b.configFileRegistryBuilder.getAncestorConfigFileName(fileName, path, configFileName, loadKind, logger); ancestorConfigName != "" { + if ancestorConfigName := b.configFileRegistryBuilder.getAncestorConfigFileName(fileName, path, configFileName, logger); ancestorConfigName != "" { return b.findOrCreateDefaultConfiguredProjectWorker( fileName, path, @@ -655,7 +667,7 @@ func (b *projectCollectionBuilder) findOrCreateDefaultConfiguredProjectForOpenSc entry, _ := b.configuredProjects.Load(key) return searchResult{project: entry} } - if configFileName := b.configFileRegistryBuilder.getConfigFileNameForFile(fileName, path, loadKind, logger); configFileName != "" { + if configFileName := b.configFileRegistryBuilder.getConfigFileNameForFile(fileName, path, logger); configFileName != "" { startTime := time.Now() result := b.findOrCreateDefaultConfiguredProjectWorker( fileName, diff --git a/internal/project/session.go b/internal/project/session.go index a51831ed21..ce00336111 100644 --- a/internal/project/session.go +++ b/internal/project/session.go @@ -79,6 +79,9 @@ type Session struct { // released from the parseCache. programCounter *programCounter + // read-only after initialization + initialPreferences *ls.UserPreferences + userPreferences *ls.UserPreferences // !!! update to Config compilerOptionsForInferredProjects *core.CompilerOptions typingsInstaller *ata.TypingsInstaller backgroundQueue *background.Queue @@ -92,6 +95,9 @@ type Session struct { snapshot *Snapshot snapshotMu sync.RWMutex + pendingConfigChanges bool + configRWMu sync.Mutex + // pendingFileChanges are accumulated from textDocument/* events delivered // by the LSP server through DidOpenFile(), DidChangeFile(), etc. They are // applied to the next snapshot update. @@ -151,6 +157,7 @@ func NewSession(init *SessionInit) *Session { extendedConfigCache, &ConfigFileRegistry{}, nil, + Config{}, toPath, ), pendingATAChanges: make(map[tspath.Path]*ATAStateChange), @@ -177,11 +184,35 @@ func (s *Session) GetCurrentDirectory() string { return s.options.CurrentDirectory } +// Gets current UserPreferences, always a copy +func (s *Session) UserPreferences() *ls.UserPreferences { + s.configRWMu.Lock() + defer s.configRWMu.Unlock() + return s.userPreferences.Copy() +} + +// Gets original UserPreferences of the session +func (s *Session) NewUserPreferences() *ls.UserPreferences { + return s.initialPreferences.CopyOrDefault() +} + // Trace implements module.ResolutionHost func (s *Session) Trace(msg string) { panic("ATA module resolution should not use tracing") } +func (s *Session) Configure(userPreferences *ls.UserPreferences) { + s.configRWMu.Lock() + defer s.configRWMu.Unlock() + s.pendingConfigChanges = true + s.userPreferences = userPreferences +} + +func (s *Session) InitializeWithConfig(userPreferences *ls.UserPreferences) { + s.initialPreferences = userPreferences.CopyOrDefault() + s.Configure(s.initialPreferences) +} + func (s *Session) DidOpenFile(ctx context.Context, uri lsproto.DocumentUri, version int32, content string, languageKind lsproto.LanguageKind) { s.cancelDiagnosticsRefresh() s.pendingFileChangesMu.Lock() @@ -341,8 +372,8 @@ func (s *Session) Snapshot() (*Snapshot, func()) { func (s *Session) GetLanguageService(ctx context.Context, uri lsproto.DocumentUri) (*ls.LanguageService, error) { var snapshot *Snapshot - fileChanges, overlays, ataChanges := s.flushChanges(ctx) - updateSnapshot := !fileChanges.IsEmpty() || len(ataChanges) > 0 + fileChanges, overlays, ataChanges, newConfig := s.flushChanges(ctx) + updateSnapshot := !fileChanges.IsEmpty() || len(ataChanges) > 0 || newConfig != nil if updateSnapshot { // If there are pending file changes, we need to update the snapshot. // Sending the requested URI ensures that the project for this URI is loaded. @@ -350,6 +381,7 @@ func (s *Session) GetLanguageService(ctx context.Context, uri lsproto.DocumentUr reason: UpdateReasonRequestedLanguageServicePendingChanges, fileChanges: fileChanges, ataChanges: ataChanges, + newConfig: newConfig, requestedURIs: []lsproto.DocumentUri{uri}, }) } else { @@ -394,6 +426,7 @@ func (s *Session) UpdateSnapshot(ctx context.Context, overlays map[tspath.Path]* } // Enqueue logging, watch updates, and diagnostic refresh tasks + // !!! userPreferences/configuration updates s.backgroundQueue.Enqueue(context.Background(), func(ctx context.Context) { if s.options.LoggingEnabled { s.logger.Write(newSnapshot.builderLogs.String()) @@ -553,7 +586,7 @@ func (s *Session) Close() { s.backgroundQueue.Close() } -func (s *Session) flushChanges(ctx context.Context) (FileChangeSummary, map[tspath.Path]*overlay, map[tspath.Path]*ATAStateChange) { +func (s *Session) flushChanges(ctx context.Context) (FileChangeSummary, map[tspath.Path]*overlay, map[tspath.Path]*ATAStateChange, *Config) { s.pendingFileChangesMu.Lock() defer s.pendingFileChangesMu.Unlock() s.pendingATAChangesMu.Lock() @@ -561,7 +594,16 @@ func (s *Session) flushChanges(ctx context.Context) (FileChangeSummary, map[tspa pendingATAChanges := s.pendingATAChanges s.pendingATAChanges = make(map[tspath.Path]*ATAStateChange) fileChanges, overlays := s.flushChangesLocked(ctx) - return fileChanges, overlays, pendingATAChanges + s.configRWMu.Lock() + defer s.configRWMu.Unlock() + var newConfig *Config + if s.pendingConfigChanges { + newConfig = &Config{ + tsUserPreferences: s.userPreferences.Copy(), + } + } + s.pendingConfigChanges = false + return fileChanges, overlays, pendingATAChanges, newConfig } // flushChangesLocked should only be called with s.pendingFileChangesMu held. diff --git a/internal/project/snapshot.go b/internal/project/snapshot.go index 8d41e426c5..9c90c21455 100644 --- a/internal/project/snapshot.go +++ b/internal/project/snapshot.go @@ -8,6 +8,7 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/format" "github.com/microsoft/typescript-go/internal/ls" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/project/ata" @@ -33,6 +34,7 @@ type Snapshot struct { ProjectCollection *ProjectCollection ConfigFileRegistry *ConfigFileRegistry compilerOptionsForInferredProjects *core.CompilerOptions + config Config builderLogs *logging.LogTree apiError error @@ -47,6 +49,7 @@ func NewSnapshot( extendedConfigCache *extendedConfigCache, configFileRegistry *ConfigFileRegistry, compilerOptionsForInferredProjects *core.CompilerOptions, + config Config, toPath func(fileName string) tspath.Path, ) *Snapshot { s := &Snapshot{ @@ -59,6 +62,7 @@ func NewSnapshot( ConfigFileRegistry: configFileRegistry, ProjectCollection: &ProjectCollection{toPath: toPath}, compilerOptionsForInferredProjects: compilerOptionsForInferredProjects, + config: config, } s.converters = ls.NewConverters(s.sessionOptions.PositionEncoding, s.LSPLineMap) s.refCount.Store(1) @@ -89,6 +93,14 @@ func (s *Snapshot) GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo { return nil } +func (s *Snapshot) UserPreferences() *ls.UserPreferences { + return s.config.tsUserPreferences +} + +func (s *Snapshot) FormatOptions() *format.FormatCodeSettings { + return s.config.formatOptions +} + func (s *Snapshot) Converters() *ls.Converters { return s.converters } @@ -126,11 +138,19 @@ type SnapshotChange struct { // It should only be set the value in the next snapshot should be changed. If nil, the // value from the previous snapshot will be copied to the new snapshot. compilerOptionsForInferredProjects *core.CompilerOptions + newConfig *Config // ataChanges contains ATA-related changes to apply to projects in the new snapshot. ataChanges map[tspath.Path]*ATAStateChange apiRequest *APISnapshotRequest } +type Config struct { + tsUserPreferences *ls.UserPreferences + // jsUserPreferences *ls.UserPreferences + formatOptions *format.FormatCodeSettings + // tsserverOptions +} + // ATAStateChange represents a change to a project's ATA state. type ATAStateChange struct { ProjectID tspath.Path @@ -174,7 +194,21 @@ func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays ma start := time.Now() fs := newSnapshotFSBuilder(session.fs.fs, overlays, s.fs.diskFiles, session.options.PositionEncoding, s.toPath) - fs.markDirtyFiles(change.fileChanges) + if change.fileChanges.HasExcessiveWatchEvents() { + invalidateStart := time.Now() + if !fs.watchChangesOverlapCache(change.fileChanges) { + change.fileChanges.Changed = collections.Set[lsproto.DocumentUri]{} + change.fileChanges.Deleted = collections.Set[lsproto.DocumentUri]{} + } else if change.fileChanges.IncludesWatchChangeOutsideNodeModules { + fs.invalidateCache() + logger.Logf("Excessive watch changes detected, invalidated file cache in %v", time.Since(invalidateStart)) + } else { + fs.invalidateNodeModulesCache() + logger.Logf("npm install detected, invalidated node_modules cache in %v", time.Since(invalidateStart)) + } + } else { + fs.markDirtyFiles(change.fileChanges) + } compilerOptionsForInferredProjects := s.compilerOptionsForInferredProjects if change.compilerOptionsForInferredProjects != nil { @@ -245,6 +279,16 @@ func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays ma } } + config := s.config + if change.newConfig != nil { + if change.newConfig.tsUserPreferences != nil { + config.tsUserPreferences = change.newConfig.tsUserPreferences.CopyOrDefault() + } + if change.newConfig.formatOptions != nil { + config.formatOptions = change.newConfig.formatOptions + } + } + snapshotFS, _ := fs.Finalize() newSnapshot := NewSnapshot( newSnapshotID, @@ -254,6 +298,7 @@ func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays ma session.extendedConfigCache, nil, compilerOptionsForInferredProjects, + config, s.toPath, ) newSnapshot.parentId = s.id diff --git a/internal/project/snapshotfs.go b/internal/project/snapshotfs.go index 441299e318..1537b8d0aa 100644 --- a/internal/project/snapshotfs.go +++ b/internal/project/snapshotfs.go @@ -1,6 +1,7 @@ package project import ( + "strings" "sync" "github.com/microsoft/typescript-go/internal/collections" @@ -122,6 +123,42 @@ func (s *snapshotFSBuilder) GetFileByPath(fileName string, path tspath.Path) Fil return entry.Value() } +func (s *snapshotFSBuilder) watchChangesOverlapCache(change FileChangeSummary) bool { + for uri := range change.Changed.Keys() { + path := s.toPath(uri.FileName()) + if _, ok := s.diskFiles.Load(path); ok { + return true + } + } + for uri := range change.Deleted.Keys() { + path := s.toPath(uri.FileName()) + if _, ok := s.diskFiles.Load(path); ok { + return true + } + } + return false +} + +func (s *snapshotFSBuilder) invalidateCache() { + s.diskFiles.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *diskFile]) bool { + entry.Change(func(file *diskFile) { + file.needsReload = true + }) + return true + }) +} + +func (s *snapshotFSBuilder) invalidateNodeModulesCache() { + s.diskFiles.Range(func(entry *dirty.SyncMapEntry[tspath.Path, *diskFile]) bool { + if strings.Contains(string(entry.Key()), "/node_modules/") { + entry.Change(func(file *diskFile) { + file.needsReload = true + }) + } + return true + }) +} + func (s *snapshotFSBuilder) markDirtyFiles(change FileChangeSummary) { for uri := range change.Changed.Keys() { path := s.toPath(uri.FileName()) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 58bb1d81c8..707be30d89 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1455,6 +1455,9 @@ func (s *Scanner) scanIdentifierParts() string { func (s *Scanner) scanString(jsxAttributeString bool) string { quote := s.char() + if quote == '\'' { + s.tokenFlags |= ast.TokenFlagsSingleQuote + } s.pos++ // Fast path for simple strings without escape sequences. strLen := strings.IndexRune(s.text[s.pos:], quote) diff --git a/internal/stringutil/compare.go b/internal/stringutil/compare.go index 832e1dbcf1..0fb1cd3975 100644 --- a/internal/stringutil/compare.go +++ b/internal/stringutil/compare.go @@ -98,3 +98,23 @@ func CompareStringsCaseInsensitiveThenSensitive(a, b string) Comparison { } return CompareStringsCaseSensitive(a, b) } + +// CompareStringsCaseInsensitiveEslintCompatible performs a case-insensitive comparison +// using toLowerCase() instead of toUpperCase() for ESLint compatibility. +// +// `CompareStringsCaseInsensitive` transforms letters to uppercase for unicode reasons, +// while eslint's `sort-imports` rule transforms letters to lowercase. Which one you choose +// affects the relative order of letters and ASCII characters 91-96, of which `_` is a +// valid character in an identifier. So if we used `CompareStringsCaseInsensitive` for +// import sorting, TypeScript and eslint would disagree about the correct case-insensitive +// sort order for `__String` and `Foo`. Since eslint's whole job is to create consistency +// by enforcing nitpicky details like this, it makes way more sense for us to just adopt +// their convention so users can have auto-imports without making eslint angry. +func CompareStringsCaseInsensitiveEslintCompatible(a, b string) Comparison { + if a == b { + return ComparisonEqual + } + a = strings.ToLower(a) + b = strings.ToLower(b) + return strings.Compare(a, b) +} diff --git a/internal/testrunner/compiler_runner.go b/internal/testrunner/compiler_runner.go index 215cba9c8d..35eac30102 100644 --- a/internal/testrunner/compiler_runner.go +++ b/internal/testrunner/compiler_runner.go @@ -337,11 +337,6 @@ func newCompilerTest( } var concurrentSkippedErrorBaselines = map[string]string{ - "circular1.ts": "Circular error reported in an extra position.", - "circular3.ts": "Circular error reported in an extra position.", - "recursiveExportAssignmentAndFindAliasedType1.ts": "Circular error reported in an extra position.", - "recursiveExportAssignmentAndFindAliasedType2.ts": "Circular error reported in an extra position.", - "recursiveExportAssignmentAndFindAliasedType3.ts": "Circular error reported in an extra position.", "typeOnlyMerge2.ts": "Type-only merging is not detected when files are checked on different checkers.", "typeOnlyMerge3.ts": "Type-only merging is not detected when files are checked on different checkers.", } diff --git a/internal/testutil/harnessutil/harnessutil.go b/internal/testutil/harnessutil/harnessutil.go index 772eb169c0..cb822bca21 100644 --- a/internal/testutil/harnessutil/harnessutil.go +++ b/internal/testutil/harnessutil/harnessutil.go @@ -30,6 +30,7 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" "github.com/microsoft/typescript-go/internal/vfs" "github.com/microsoft/typescript-go/internal/vfs/vfstest" + "github.com/microsoft/typescript-go/internal/vfs/zipvfs" ) // Posix-style path to additional test libraries @@ -606,8 +607,12 @@ func createCompilerHost(fs vfs.FS, defaultLibraryPath string, currentDirectory s UseCaseSensitiveFileNames: fs.UseCaseSensitiveFileNames(), CurrentDirectory: currentDirectory, }, &strings.Builder{}) + pnpResolutionConfig := compiler.TryGetPnpResolutionConfig(currentDirectory, fs) + if pnpResolutionConfig != nil { + fs = zipvfs.From(fs) + } return &cachedCompilerHost{ - CompilerHost: compiler.NewCompilerHost(currentDirectory, fs, defaultLibraryPath, nil, tracer.Trace), + CompilerHost: compiler.NewCompilerHost(currentDirectory, fs, defaultLibraryPath, nil, tracer.Trace, pnpResolutionConfig), tracer: tracer, } } diff --git a/internal/transformers/declarations/transform.go b/internal/transformers/declarations/transform.go index 6217557d5f..e81bf4f602 100644 --- a/internal/transformers/declarations/transform.go +++ b/internal/transformers/declarations/transform.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/debug" "github.com/microsoft/typescript-go/internal/diagnostics" @@ -11,6 +12,7 @@ import ( "github.com/microsoft/typescript-go/internal/modulespecifiers" "github.com/microsoft/typescript-go/internal/nodebuilder" "github.com/microsoft/typescript-go/internal/printer" + "github.com/microsoft/typescript-go/internal/scanner" "github.com/microsoft/typescript-go/internal/transformers" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -56,6 +58,7 @@ type DeclarationTransformer struct { resultHasExternalModuleIndicator bool suppressNewDiagnosticContexts bool lateStatementReplacementMap map[ast.NodeId]*ast.Node + expandoHosts collections.Set[ast.NodeId] rawReferencedFiles []ReferencedFilePair rawTypeReferenceDirectives []*ast.FileReference rawLibReferenceDirectives []*ast.FileReference @@ -124,7 +127,6 @@ func (tx *DeclarationTransformer) visit(node *ast.Node) *ast.Node { ast.KindContinueStatement, ast.KindDebuggerStatement, ast.KindDoStatement, - ast.KindExpressionStatement, ast.KindEmptyStatement, ast.KindForInStatement, ast.KindForOfStatement, @@ -141,6 +143,8 @@ func (tx *DeclarationTransformer) visit(node *ast.Node) *ast.Node { ast.KindBlock, ast.KindMissingDeclaration: return nil + case ast.KindExpressionStatement: + return tx.visitExpressionStatement(node.AsExpressionStatement()) // parts of things, things we just visit children of default: return tx.visitDeclarationSubtree(node) @@ -166,6 +170,7 @@ func (tx *DeclarationTransformer) visitSourceFile(node *ast.SourceFile) *ast.Nod tx.suppressNewDiagnosticContexts = false tx.state.lateMarkedStatements = make([]*ast.Node, 0) tx.lateStatementReplacementMap = make(map[ast.NodeId]*ast.Node) + tx.expandoHosts = collections.Set[ast.NodeId]{} tx.rawReferencedFiles = make([]ReferencedFilePair, 0) tx.rawTypeReferenceDirectives = make([]*ast.FileReference, 0) tx.rawLibReferenceDirectives = make([]*ast.FileReference, 0) @@ -231,12 +236,12 @@ func (tx *DeclarationTransformer) transformAndReplaceLatePaintedStatements(state next := tx.state.lateMarkedStatements[0] tx.state.lateMarkedStatements = tx.state.lateMarkedStatements[1:] - priorNeedsDeclare := tx.needsDeclare + saveNeedsDeclare := tx.needsDeclare tx.needsDeclare = next.Parent != nil && ast.IsSourceFile(next.Parent) && !(ast.IsExternalModule(next.Parent.AsSourceFile()) && tx.isBundledEmit) result := tx.transformTopLevelDeclaration(next) - tx.needsDeclare = priorNeedsDeclare + tx.needsDeclare = saveNeedsDeclare original := tx.EmitContext().MostOriginal(next) id := ast.GetNodeId(original) tx.lateStatementReplacementMap[id] = result @@ -789,8 +794,6 @@ func (tx *DeclarationTransformer) transformGetAccesorDeclaration(input *ast.GetA ) } -const defaultModifierFlagsMask = ast.ModifierFlagsAll ^ ast.ModifierFlagsPublic - func (tx *DeclarationTransformer) updateAccessorParamList(input *ast.Node, isPrivate bool) *ast.ParameterList { var newParams []*ast.Node if !isPrivate { @@ -955,11 +958,11 @@ func (tx *DeclarationTransformer) visitDeclarationStatements(input *ast.Node) *a tx.removeAllComments(assignment) return tx.Factory().NewSyntaxList([]*ast.Node{statement, assignment}) default: - result := tx.transformTopLevelDeclaration(input) - // Don't actually transform yet; just leave as original node - will be elided/swapped by late pass - original := tx.EmitContext().MostOriginal(input) - id := ast.GetNodeId(original) - tx.lateStatementReplacementMap[id] = result + id := ast.GetNodeId(tx.EmitContext().MostOriginal(input)) + if tx.lateStatementReplacementMap[id] == nil { + // Don't actually transform yet; just leave as original node - will be elided/swapped by late pass + tx.lateStatementReplacementMap[id] = tx.transformTopLevelDeclaration(input) + } return input } } @@ -1100,7 +1103,7 @@ func (tx *DeclarationTransformer) transformTopLevelDeclaration(input *ast.Node) if canProdiceDiagnostic { tx.state.getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input) } - previousNeedsDeclare := tx.needsDeclare + saveNeedsDeclare := tx.needsDeclare var result *ast.Node switch input.Kind { @@ -1125,7 +1128,7 @@ func (tx *DeclarationTransformer) transformTopLevelDeclaration(input *ast.Node) tx.enclosingDeclaration = previousEnclosingDeclaration tx.state.getSymbolAccessibilityDiagnostic = oldDiag - tx.needsDeclare = previousNeedsDeclare + tx.needsDeclare = saveNeedsDeclare tx.state.errorNameNode = oldName return result } @@ -1153,7 +1156,7 @@ func (tx *DeclarationTransformer) transformInterfaceDeclaration(input *ast.Inter } func (tx *DeclarationTransformer) transformFunctionDeclaration(input *ast.FunctionDeclaration) *ast.Node { - updated := tx.Factory().UpdateFunctionDeclaration( + return tx.Factory().UpdateFunctionDeclaration( input, tx.ensureModifiers(input.AsNode()), nil, @@ -1164,17 +1167,6 @@ func (tx *DeclarationTransformer) transformFunctionDeclaration(input *ast.Functi nil, /*fullSignature*/ nil, ) - if updated == nil || !tx.resolver.IsExpandoFunctionDeclaration(input.AsNode()) || !shouldEmitFunctionProperties(input) { - return updated - } - // Add expando function properties to result - - // !!! TODO: expando function support - // props := tx.resolver.GetPropertiesOfContainerFunction(input) - // if tx.state.isolatedDeclarations { - // tx.state.reportExpandoFunctionErrors(input.AsNode()) - // } - return updated // !!! } func (tx *DeclarationTransformer) transformModuleDeclaration(input *ast.ModuleDeclaration) *ast.Node { @@ -1182,7 +1174,7 @@ func (tx *DeclarationTransformer) transformModuleDeclaration(input *ast.ModuleDe // It'd be good to collapse those back in the declaration output, but the AST can't represent the // `namespace a.b.c` shape for the printer (without using invalid identifier names). mods := tx.ensureModifiers(input.AsNode()) - oldNeedsDeclare := tx.needsDeclare + saveNeedsDeclare := tx.needsDeclare tx.needsDeclare = false inner := input.Body keyword := input.Keyword @@ -1213,7 +1205,7 @@ func (tx *DeclarationTransformer) transformModuleDeclaration(input *ast.ModuleDe } body := tx.Factory().UpdateModuleBlock(inner.AsModuleBlock(), lateStatements) - tx.needsDeclare = oldNeedsDeclare + tx.needsDeclare = saveNeedsDeclare tx.needsScopeFixMarker = oldNeedsScopeFix tx.resultHasScopeMarker = oldHasScopeFix @@ -1817,3 +1809,172 @@ func (tx *DeclarationTransformer) transformJSDocOptionalType(input *ast.JSDocOpt tx.EmitContext().SetOriginal(replacement, input.AsNode()) return replacement } + +func (tx *DeclarationTransformer) visitExpressionStatement(node *ast.ExpressionStatement) *ast.Node { + expression := node.Expression + if expression == nil { + return nil + } + + if expression.Kind == ast.KindBinaryExpression && + ast.GetAssignmentDeclarationKind(expression.AsBinaryExpression()) == ast.JSDeclarationKindProperty { + return tx.transformExpandoAssignment(expression.AsBinaryExpression()) + } + + return nil +} + +func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExpression) *ast.Node { + left := node.Left + + symbol := node.Symbol + if symbol == nil || symbol.Flags&ast.SymbolFlagsAssignment == 0 { + return nil + } + + ns := ast.GetLeftmostAccessExpression(left) + if ns == nil || ns.Kind != ast.KindIdentifier { + return nil + } + + declaration := tx.resolver.GetReferencedValueDeclaration(ns) + if declaration == nil { + return nil + } + + host := declaration.Symbol() + if host == nil { + return nil + } + + name := tx.Factory().NewIdentifier(ns.Text()) + property := tx.tryGetPropertyName(left) + if property == "" || !scanner.IsIdentifierText(property, core.LanguageVariantStandard) { + return nil + } + + tx.transformExpandoHost(name, declaration) + + if ast.IsFunctionDeclaration(declaration) && !shouldEmitFunctionProperties(declaration.AsFunctionDeclaration()) { + return nil + } + + isNonContextualKeywordName := ast.IsNonContextualKeyword(scanner.StringToToken(property)) + exportName := core.IfElse(isNonContextualKeywordName, tx.Factory().NewGeneratedNameForNode(left), tx.Factory().NewIdentifier(property)) + + synthesizedNamespace := tx.Factory().NewModuleDeclaration(nil /*modifiers*/, ast.KindNamespaceKeyword, name, tx.Factory().NewModuleBlock(tx.Factory().NewNodeList([]*ast.Node{}))) + synthesizedNamespace.Parent = tx.enclosingDeclaration + + declarationData := synthesizedNamespace.DeclarationData() + declarationData.Symbol = host + + containerData := synthesizedNamespace.LocalsContainerData() + containerData.Locals = make(ast.SymbolTable, 0) + + saveDiag := tx.state.getSymbolAccessibilityDiagnostic + tx.state.getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(node.AsNode()) + t := tx.resolver.CreateTypeOfExpression(tx.EmitContext(), left, synthesizedNamespace, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags|nodebuilder.InternalFlagsNoSyntacticPrinter, tx.tracker) + tx.state.getSymbolAccessibilityDiagnostic = saveDiag + + statements := []*ast.Statement{ + tx.Factory().NewVariableStatement( + nil, /*modifiers*/ + tx.Factory().NewVariableDeclarationList( + ast.NodeFlagsNone, + tx.Factory().NewNodeList([]*ast.Node{ + tx.Factory().NewVariableDeclaration(exportName, nil /*exclamationToken*/, t, nil /*initializer*/), + }), + ), + ), + } + + if isNonContextualKeywordName { + namedExports := tx.Factory().NewNamedExports(tx.Factory().NewNodeList( + []*ast.Node{ + tx.Factory().NewExportSpecifier(false /*isTypeOnly*/, exportName, tx.Factory().NewIdentifier(left.Name().Text())), + }, + )) + statements = append(statements, tx.Factory().NewExportDeclaration(nil /*modifiers*/, false /*isTypeOnly*/, namedExports, nil /*moduleSpecifier*/, nil /*attributes*/)) + } + + flags := tx.host.GetEffectiveDeclarationFlags(tx.EmitContext().ParseNode(declaration), ast.ModifierFlagsAll) + modifierFlags := ast.ModifierFlagsAmbient + + if flags&ast.ModifierFlagsExport != 0 { + if flags&ast.ModifierFlagsDefault == 0 { + modifierFlags |= ast.ModifierFlagsExport + } + tx.resultHasScopeMarker = true + tx.resultHasExternalModuleIndicator = true + } + + return tx.Factory().NewModuleDeclaration(tx.Factory().NewModifierList(ast.CreateModifiersFromModifierFlags(modifierFlags, tx.Factory().NewModifier)), ast.KindNamespaceKeyword, name, tx.Factory().NewModuleBlock(tx.Factory().NewNodeList(statements))) +} + +func (tx *DeclarationTransformer) transformExpandoHost(name *ast.Node, declaration *ast.Declaration) { + root := core.IfElse(ast.IsVariableDeclaration(declaration), declaration.Parent.Parent, declaration) + id := ast.GetNodeId(tx.EmitContext().MostOriginal(root)) + + if tx.expandoHosts.Has(id) { + return + } + + saveNeedsDeclare := tx.needsDeclare + tx.needsDeclare = true + + modifierFlags := tx.ensureModifierFlags(root) + defaultExport := modifierFlags&ast.ModifierFlagsExport != 0 && modifierFlags&ast.ModifierFlagsDefault != 0 + + tx.needsDeclare = saveNeedsDeclare + + if defaultExport { + modifierFlags |= ast.ModifierFlagsAmbient + modifierFlags ^= ast.ModifierFlagsDefault + modifierFlags ^= ast.ModifierFlagsExport + } + + modifiers := tx.Factory().NewModifierList(ast.CreateModifiersFromModifierFlags(modifierFlags, tx.Factory().NewModifier)) + replacement := make([]*ast.Node, 0) + + if ast.IsFunctionDeclaration(declaration) { + typeParameters, parameters, asteriskToken := extractExpandoHostParams(declaration) + replacement = append(replacement, tx.Factory().UpdateFunctionDeclaration(declaration.AsFunctionDeclaration(), modifiers, asteriskToken, declaration.Name(), tx.ensureTypeParams(declaration, typeParameters), tx.updateParamList(declaration, parameters), tx.ensureType(declaration, false), nil /*fullSignature*/, nil /*body*/)) + } else if ast.IsVariableDeclaration(declaration) && ast.IsFunctionExpressionOrArrowFunction(declaration.Initializer()) { + fn := declaration.Initializer() + typeParameters, parameters, asteriskToken := extractExpandoHostParams(fn) + replacement = append(replacement, tx.Factory().NewFunctionDeclaration(modifiers, asteriskToken, tx.Factory().NewIdentifier(name.Text()), tx.ensureTypeParams(fn, typeParameters), tx.updateParamList(fn, parameters), tx.ensureType(fn, false), nil /*fullSignature*/, nil /*body*/)) + } else { + return + } + + if defaultExport { + replacement = append(replacement, tx.Factory().NewExportAssignment(nil /*modifiers*/, false /*isExportEquals*/, nil /*typeNode*/, name)) + } + + tx.expandoHosts.Add(id) + tx.lateStatementReplacementMap[id] = tx.Factory().NewSyntaxList(replacement) +} + +func extractExpandoHostParams(node *ast.Node) (typeParameters *ast.TypeParameterList, parameters *ast.ParameterList, asteriskToken *ast.TokenNode) { + switch node.Kind { + case ast.KindFunctionExpression: + fn := node.AsFunctionExpression() + return fn.TypeParameters, fn.Parameters, fn.AsteriskToken + case ast.KindArrowFunction: + fn := node.AsArrowFunction() + return fn.TypeParameters, fn.Parameters, fn.AsteriskToken + default: + fn := node.AsFunctionDeclaration() + return fn.TypeParameters, fn.Parameters, fn.AsteriskToken + } +} + +func (tx *DeclarationTransformer) tryGetPropertyName(node *ast.Node) string { + if ast.IsElementAccessExpression(node) { + return tx.resolver.GetElementAccessExpressionName(node.AsElementAccessExpression()) + } + if ast.IsPropertyAccessExpression(node) { + return node.Name().Text() + } + return "" +} diff --git a/internal/transformers/jsxtransforms/jsx.go b/internal/transformers/jsxtransforms/jsx.go index 3372a23339..2f6915e3ea 100644 --- a/internal/transformers/jsxtransforms/jsx.go +++ b/internal/transformers/jsxtransforms/jsx.go @@ -319,8 +319,9 @@ func (tx *JSXTransformer) convertJsxChildrenToChildrenPropObject(children []*ast } func (tx *JSXTransformer) transformJsxChildToExpression(node *ast.Node) *ast.Node { + prev := tx.inJsxChild tx.setInChild(true) - defer tx.setInChild(false) + defer tx.setInChild(prev) return tx.Visitor().Visit(node) } @@ -688,14 +689,18 @@ func (tx *JSXTransformer) visitJsxOpeningLikeElementCreateElement(element *ast.N for _, c := range children.Nodes { res := tx.transformJsxChildToExpression(c) if res != nil { - if len(children.Nodes) > 1 { - tx.EmitContext().AddEmitFlags(res, printer.EFStartOnNewLine) - } newChildren = append(newChildren, res) } } } + // Add StartOnNewLine flag only if there are multiple actual children (after filtering) + if len(newChildren) > 1 { + for _, child := range newChildren { + tx.EmitContext().AddEmitFlags(child, printer.EFStartOnNewLine) + } + } + args := make([]*ast.Expression, 0, len(newChildren)+2) args = append(args, tagName) args = append(args, objectProperties) @@ -725,14 +730,18 @@ func (tx *JSXTransformer) visitJsxOpeningFragmentCreateElement(fragment *ast.Jsx for _, c := range children.Nodes { res := tx.transformJsxChildToExpression(c) if res != nil { - if len(children.Nodes) > 1 { - tx.EmitContext().AddEmitFlags(res, printer.EFStartOnNewLine) - } newChildren = append(newChildren, res) } } } + // Add StartOnNewLine flag only if there are multiple actual children (after filtering) + if len(newChildren) > 1 { + for _, child := range newChildren { + tx.EmitContext().AddEmitFlags(child, printer.EFStartOnNewLine) + } + } + args := make([]*ast.Expression, 0, len(newChildren)+2) args = append(args, tagName) args = append(args, tx.Factory().NewKeywordExpression(ast.KindNullKeyword)) diff --git a/internal/tsoptions/declsbuild.go b/internal/tsoptions/declsbuild.go index dff42a7b8e..19726e85b8 100644 --- a/internal/tsoptions/declsbuild.go +++ b/internal/tsoptions/declsbuild.go @@ -6,8 +6,6 @@ import ( "github.com/microsoft/typescript-go/internal/diagnostics" ) -var BuildOpts = slices.Concat(commonOptionsWithBuild, optionsForBuild) - var TscBuildOption = CommandLineOption{ Name: "build", Kind: "boolean", @@ -18,7 +16,7 @@ var TscBuildOption = CommandLineOption{ DefaultValueDescription: false, } -var optionsForBuild = []*CommandLineOption{ +var OptionsForBuild = []*CommandLineOption{ &TscBuildOption, { Name: "verbose", @@ -59,3 +57,5 @@ var optionsForBuild = []*CommandLineOption{ DefaultValueDescription: false, }, } + +var BuildOpts = slices.Concat(commonOptionsWithBuild, OptionsForBuild) diff --git a/internal/tsoptions/declswatch.go b/internal/tsoptions/declswatch.go index 0e7d81d793..b190a6641c 100644 --- a/internal/tsoptions/declswatch.go +++ b/internal/tsoptions/declswatch.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/diagnostics" ) -var optionsForWatch = []*CommandLineOption{ +var OptionsForWatch = []*CommandLineOption{ { Name: "watchInterval", Kind: CommandLineOptionTypeNumber, diff --git a/internal/tsoptions/diagnostics.go b/internal/tsoptions/diagnostics.go index 9aec10d96e..73936da069 100644 --- a/internal/tsoptions/diagnostics.go +++ b/internal/tsoptions/diagnostics.go @@ -46,7 +46,7 @@ func getParseCommandLineWorkerDiagnostics(decls []*CommandLineOption) *ParseComm var watchOptionsDidYouMeanDiagnostics = &ParseCommandLineWorkerDiagnostics{ didYouMean: DidYouMeanOptionsDiagnostics{ // no alternateMode - OptionDeclarations: optionsForWatch, + OptionDeclarations: OptionsForWatch, UnknownOptionDiagnostic: diagnostics.Unknown_watch_option_0, UnknownDidYouMeanDiagnostic: diagnostics.Unknown_watch_option_0_Did_you_mean_1, }, diff --git a/internal/tsoptions/namemap.go b/internal/tsoptions/namemap.go index 31a8b98d48..6cc2785e79 100644 --- a/internal/tsoptions/namemap.go +++ b/internal/tsoptions/namemap.go @@ -9,7 +9,7 @@ import ( var ( CompilerNameMap = GetNameMapFromList(OptionsDeclarations) BuildNameMap = GetNameMapFromList(BuildOpts) - WatchNameMap = GetNameMapFromList(optionsForWatch) + WatchNameMap = GetNameMapFromList(OptionsForWatch) ) func GetNameMapFromList(optDecls []*CommandLineOption) *NameMap { diff --git a/internal/tsoptions/parsinghelpers.go b/internal/tsoptions/parsinghelpers.go index bf16518be2..91944af6a7 100644 --- a/internal/tsoptions/parsinghelpers.go +++ b/internal/tsoptions/parsinghelpers.go @@ -11,7 +11,7 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" ) -func parseTristate(value any) core.Tristate { +func ParseTristate(value any) core.Tristate { if value == nil { return core.TSUnknown } @@ -25,7 +25,7 @@ func parseTristate(value any) core.Tristate { } } -func parseStringArray(value any) []string { +func ParseStringArray(value any) []string { if arr, ok := value.([]any); ok { if arr == nil { return nil @@ -45,14 +45,14 @@ func parseStringMap(value any) *collections.OrderedMap[string, []string] { if m, ok := value.(*collections.OrderedMap[string, any]); ok { result := collections.NewOrderedMapWithSizeHint[string, []string](m.Size()) for k, v := range m.Entries() { - result.Set(k, parseStringArray(v)) + result.Set(k, ParseStringArray(v)) } return result } return nil } -func parseString(value any) string { +func ParseString(value any) string { if str, ok := value.(string); ok { return str } @@ -186,119 +186,119 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption } switch key { case "allowJs": - allOptions.AllowJs = parseTristate(value) + allOptions.AllowJs = ParseTristate(value) case "allowImportingTsExtensions": - allOptions.AllowImportingTsExtensions = parseTristate(value) + allOptions.AllowImportingTsExtensions = ParseTristate(value) case "allowSyntheticDefaultImports": - allOptions.AllowSyntheticDefaultImports = parseTristate(value) + allOptions.AllowSyntheticDefaultImports = ParseTristate(value) case "allowNonTsExtensions": - allOptions.AllowNonTsExtensions = parseTristate(value) + allOptions.AllowNonTsExtensions = ParseTristate(value) case "allowUmdGlobalAccess": - allOptions.AllowUmdGlobalAccess = parseTristate(value) + allOptions.AllowUmdGlobalAccess = ParseTristate(value) case "allowUnreachableCode": - allOptions.AllowUnreachableCode = parseTristate(value) + allOptions.AllowUnreachableCode = ParseTristate(value) case "allowUnusedLabels": - allOptions.AllowUnusedLabels = parseTristate(value) + allOptions.AllowUnusedLabels = ParseTristate(value) case "allowArbitraryExtensions": - allOptions.AllowArbitraryExtensions = parseTristate(value) + allOptions.AllowArbitraryExtensions = ParseTristate(value) case "alwaysStrict": - allOptions.AlwaysStrict = parseTristate(value) + allOptions.AlwaysStrict = ParseTristate(value) case "assumeChangesOnlyAffectDirectDependencies": - allOptions.AssumeChangesOnlyAffectDirectDependencies = parseTristate(value) + allOptions.AssumeChangesOnlyAffectDirectDependencies = ParseTristate(value) case "baseUrl": - allOptions.BaseUrl = parseString(value) + allOptions.BaseUrl = ParseString(value) case "build": - allOptions.Build = parseTristate(value) + allOptions.Build = ParseTristate(value) case "checkJs": - allOptions.CheckJs = parseTristate(value) + allOptions.CheckJs = ParseTristate(value) case "customConditions": - allOptions.CustomConditions = parseStringArray(value) + allOptions.CustomConditions = ParseStringArray(value) case "composite": - allOptions.Composite = parseTristate(value) + allOptions.Composite = ParseTristate(value) case "declarationDir": - allOptions.DeclarationDir = parseString(value) + allOptions.DeclarationDir = ParseString(value) case "diagnostics": - allOptions.Diagnostics = parseTristate(value) + allOptions.Diagnostics = ParseTristate(value) case "disableSizeLimit": - allOptions.DisableSizeLimit = parseTristate(value) + allOptions.DisableSizeLimit = ParseTristate(value) case "disableSourceOfProjectReferenceRedirect": - allOptions.DisableSourceOfProjectReferenceRedirect = parseTristate(value) + allOptions.DisableSourceOfProjectReferenceRedirect = ParseTristate(value) case "disableSolutionSearching": - allOptions.DisableSolutionSearching = parseTristate(value) + allOptions.DisableSolutionSearching = ParseTristate(value) case "disableReferencedProjectLoad": - allOptions.DisableReferencedProjectLoad = parseTristate(value) + allOptions.DisableReferencedProjectLoad = ParseTristate(value) case "declarationMap": - allOptions.DeclarationMap = parseTristate(value) + allOptions.DeclarationMap = ParseTristate(value) case "declaration": - allOptions.Declaration = parseTristate(value) + allOptions.Declaration = ParseTristate(value) case "downlevelIteration": - allOptions.DownlevelIteration = parseTristate(value) + allOptions.DownlevelIteration = ParseTristate(value) case "erasableSyntaxOnly": - allOptions.ErasableSyntaxOnly = parseTristate(value) + allOptions.ErasableSyntaxOnly = ParseTristate(value) case "emitDeclarationOnly": - allOptions.EmitDeclarationOnly = parseTristate(value) + allOptions.EmitDeclarationOnly = ParseTristate(value) case "extendedDiagnostics": - allOptions.ExtendedDiagnostics = parseTristate(value) + allOptions.ExtendedDiagnostics = ParseTristate(value) case "emitDecoratorMetadata": - allOptions.EmitDecoratorMetadata = parseTristate(value) + allOptions.EmitDecoratorMetadata = ParseTristate(value) case "emitBOM": - allOptions.EmitBOM = parseTristate(value) + allOptions.EmitBOM = ParseTristate(value) case "esModuleInterop": - allOptions.ESModuleInterop = parseTristate(value) + allOptions.ESModuleInterop = ParseTristate(value) case "exactOptionalPropertyTypes": - allOptions.ExactOptionalPropertyTypes = parseTristate(value) + allOptions.ExactOptionalPropertyTypes = ParseTristate(value) case "explainFiles": - allOptions.ExplainFiles = parseTristate(value) + allOptions.ExplainFiles = ParseTristate(value) case "experimentalDecorators": - allOptions.ExperimentalDecorators = parseTristate(value) + allOptions.ExperimentalDecorators = ParseTristate(value) case "forceConsistentCasingInFileNames": - allOptions.ForceConsistentCasingInFileNames = parseTristate(value) + allOptions.ForceConsistentCasingInFileNames = ParseTristate(value) case "generateCpuProfile": - allOptions.GenerateCpuProfile = parseString(value) + allOptions.GenerateCpuProfile = ParseString(value) case "generateTrace": - allOptions.GenerateTrace = parseString(value) + allOptions.GenerateTrace = ParseString(value) case "isolatedModules": - allOptions.IsolatedModules = parseTristate(value) + allOptions.IsolatedModules = ParseTristate(value) case "ignoreDeprecations": - allOptions.IgnoreDeprecations = parseString(value) + allOptions.IgnoreDeprecations = ParseString(value) case "importHelpers": - allOptions.ImportHelpers = parseTristate(value) + allOptions.ImportHelpers = ParseTristate(value) case "incremental": - allOptions.Incremental = parseTristate(value) + allOptions.Incremental = ParseTristate(value) case "init": - allOptions.Init = parseTristate(value) + allOptions.Init = ParseTristate(value) case "inlineSourceMap": - allOptions.InlineSourceMap = parseTristate(value) + allOptions.InlineSourceMap = ParseTristate(value) case "inlineSources": - allOptions.InlineSources = parseTristate(value) + allOptions.InlineSources = ParseTristate(value) case "isolatedDeclarations": - allOptions.IsolatedDeclarations = parseTristate(value) + allOptions.IsolatedDeclarations = ParseTristate(value) case "jsx": allOptions.Jsx = floatOrInt32ToFlag[core.JsxEmit](value) case "jsxFactory": - allOptions.JsxFactory = parseString(value) + allOptions.JsxFactory = ParseString(value) case "jsxFragmentFactory": - allOptions.JsxFragmentFactory = parseString(value) + allOptions.JsxFragmentFactory = ParseString(value) case "jsxImportSource": - allOptions.JsxImportSource = parseString(value) + allOptions.JsxImportSource = ParseString(value) case "lib": if _, ok := value.([]string); ok { allOptions.Lib = value.([]string) } else { - allOptions.Lib = parseStringArray(value) + allOptions.Lib = ParseStringArray(value) } case "libReplacement": - allOptions.LibReplacement = parseTristate(value) + allOptions.LibReplacement = ParseTristate(value) case "listEmittedFiles": - allOptions.ListEmittedFiles = parseTristate(value) + allOptions.ListEmittedFiles = ParseTristate(value) case "listFiles": - allOptions.ListFiles = parseTristate(value) + allOptions.ListFiles = ParseTristate(value) case "listFilesOnly": - allOptions.ListFilesOnly = parseTristate(value) + allOptions.ListFilesOnly = ParseTristate(value) case "locale": - allOptions.Locale = parseString(value) + allOptions.Locale = ParseString(value) case "mapRoot": - allOptions.MapRoot = parseString(value) + allOptions.MapRoot = ParseString(value) case "module": allOptions.Module = floatOrInt32ToFlag[core.ModuleKind](value) case "moduleDetectionKind": @@ -306,143 +306,143 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption case "moduleResolution": allOptions.ModuleResolution = floatOrInt32ToFlag[core.ModuleResolutionKind](value) case "moduleSuffixes": - allOptions.ModuleSuffixes = parseStringArray(value) + allOptions.ModuleSuffixes = ParseStringArray(value) case "moduleDetection": allOptions.ModuleDetection = floatOrInt32ToFlag[core.ModuleDetectionKind](value) case "noCheck": - allOptions.NoCheck = parseTristate(value) + allOptions.NoCheck = ParseTristate(value) case "noFallthroughCasesInSwitch": - allOptions.NoFallthroughCasesInSwitch = parseTristate(value) + allOptions.NoFallthroughCasesInSwitch = ParseTristate(value) case "noEmitForJsFiles": - allOptions.NoEmitForJsFiles = parseTristate(value) + allOptions.NoEmitForJsFiles = ParseTristate(value) case "noErrorTruncation": - allOptions.NoErrorTruncation = parseTristate(value) + allOptions.NoErrorTruncation = ParseTristate(value) case "noImplicitAny": - allOptions.NoImplicitAny = parseTristate(value) + allOptions.NoImplicitAny = ParseTristate(value) case "noImplicitThis": - allOptions.NoImplicitThis = parseTristate(value) + allOptions.NoImplicitThis = ParseTristate(value) case "noLib": - allOptions.NoLib = parseTristate(value) + allOptions.NoLib = ParseTristate(value) case "noPropertyAccessFromIndexSignature": - allOptions.NoPropertyAccessFromIndexSignature = parseTristate(value) + allOptions.NoPropertyAccessFromIndexSignature = ParseTristate(value) case "noUncheckedIndexedAccess": - allOptions.NoUncheckedIndexedAccess = parseTristate(value) + allOptions.NoUncheckedIndexedAccess = ParseTristate(value) case "noEmitHelpers": - allOptions.NoEmitHelpers = parseTristate(value) + allOptions.NoEmitHelpers = ParseTristate(value) case "noEmitOnError": - allOptions.NoEmitOnError = parseTristate(value) + allOptions.NoEmitOnError = ParseTristate(value) case "noImplicitReturns": - allOptions.NoImplicitReturns = parseTristate(value) + allOptions.NoImplicitReturns = ParseTristate(value) case "noUnusedLocals": - allOptions.NoUnusedLocals = parseTristate(value) + allOptions.NoUnusedLocals = ParseTristate(value) case "noUnusedParameters": - allOptions.NoUnusedParameters = parseTristate(value) + allOptions.NoUnusedParameters = ParseTristate(value) case "noImplicitOverride": - allOptions.NoImplicitOverride = parseTristate(value) + allOptions.NoImplicitOverride = ParseTristate(value) case "noUncheckedSideEffectImports": - allOptions.NoUncheckedSideEffectImports = parseTristate(value) + allOptions.NoUncheckedSideEffectImports = ParseTristate(value) case "outFile": - allOptions.OutFile = parseString(value) + allOptions.OutFile = ParseString(value) case "noResolve": - allOptions.NoResolve = parseTristate(value) + allOptions.NoResolve = ParseTristate(value) case "paths": allOptions.Paths = parseStringMap(value) case "preserveWatchOutput": - allOptions.PreserveWatchOutput = parseTristate(value) + allOptions.PreserveWatchOutput = ParseTristate(value) case "preserveConstEnums": - allOptions.PreserveConstEnums = parseTristate(value) + allOptions.PreserveConstEnums = ParseTristate(value) case "preserveSymlinks": - allOptions.PreserveSymlinks = parseTristate(value) + allOptions.PreserveSymlinks = ParseTristate(value) case "project": - allOptions.Project = parseString(value) + allOptions.Project = ParseString(value) case "pretty": - allOptions.Pretty = parseTristate(value) + allOptions.Pretty = ParseTristate(value) case "resolveJsonModule": - allOptions.ResolveJsonModule = parseTristate(value) + allOptions.ResolveJsonModule = ParseTristate(value) case "resolvePackageJsonExports": - allOptions.ResolvePackageJsonExports = parseTristate(value) + allOptions.ResolvePackageJsonExports = ParseTristate(value) case "resolvePackageJsonImports": - allOptions.ResolvePackageJsonImports = parseTristate(value) + allOptions.ResolvePackageJsonImports = ParseTristate(value) case "reactNamespace": - allOptions.ReactNamespace = parseString(value) + allOptions.ReactNamespace = ParseString(value) case "rewriteRelativeImportExtensions": - allOptions.RewriteRelativeImportExtensions = parseTristate(value) + allOptions.RewriteRelativeImportExtensions = ParseTristate(value) case "rootDir": - allOptions.RootDir = parseString(value) + allOptions.RootDir = ParseString(value) case "rootDirs": - allOptions.RootDirs = parseStringArray(value) + allOptions.RootDirs = ParseStringArray(value) case "removeComments": - allOptions.RemoveComments = parseTristate(value) + allOptions.RemoveComments = ParseTristate(value) case "strict": - allOptions.Strict = parseTristate(value) + allOptions.Strict = ParseTristate(value) case "strictBindCallApply": - allOptions.StrictBindCallApply = parseTristate(value) + allOptions.StrictBindCallApply = ParseTristate(value) case "strictBuiltinIteratorReturn": - allOptions.StrictBuiltinIteratorReturn = parseTristate(value) + allOptions.StrictBuiltinIteratorReturn = ParseTristate(value) case "strictFunctionTypes": - allOptions.StrictFunctionTypes = parseTristate(value) + allOptions.StrictFunctionTypes = ParseTristate(value) case "strictNullChecks": - allOptions.StrictNullChecks = parseTristate(value) + allOptions.StrictNullChecks = ParseTristate(value) case "strictPropertyInitialization": - allOptions.StrictPropertyInitialization = parseTristate(value) + allOptions.StrictPropertyInitialization = ParseTristate(value) case "skipDefaultLibCheck": - allOptions.SkipDefaultLibCheck = parseTristate(value) + allOptions.SkipDefaultLibCheck = ParseTristate(value) case "sourceMap": - allOptions.SourceMap = parseTristate(value) + allOptions.SourceMap = ParseTristate(value) case "sourceRoot": - allOptions.SourceRoot = parseString(value) + allOptions.SourceRoot = ParseString(value) case "stripInternal": - allOptions.StripInternal = parseTristate(value) + allOptions.StripInternal = ParseTristate(value) case "suppressOutputPathCheck": - allOptions.SuppressOutputPathCheck = parseTristate(value) + allOptions.SuppressOutputPathCheck = ParseTristate(value) case "target": allOptions.Target = floatOrInt32ToFlag[core.ScriptTarget](value) case "traceResolution": - allOptions.TraceResolution = parseTristate(value) + allOptions.TraceResolution = ParseTristate(value) case "tsBuildInfoFile": - allOptions.TsBuildInfoFile = parseString(value) + allOptions.TsBuildInfoFile = ParseString(value) case "typeRoots": - allOptions.TypeRoots = parseStringArray(value) + allOptions.TypeRoots = ParseStringArray(value) case "types": - allOptions.Types = parseStringArray(value) + allOptions.Types = ParseStringArray(value) case "useDefineForClassFields": - allOptions.UseDefineForClassFields = parseTristate(value) + allOptions.UseDefineForClassFields = ParseTristate(value) case "useUnknownInCatchVariables": - allOptions.UseUnknownInCatchVariables = parseTristate(value) + allOptions.UseUnknownInCatchVariables = ParseTristate(value) case "verbatimModuleSyntax": - allOptions.VerbatimModuleSyntax = parseTristate(value) + allOptions.VerbatimModuleSyntax = ParseTristate(value) case "version": - allOptions.Version = parseTristate(value) + allOptions.Version = ParseTristate(value) case "help": - allOptions.Help = parseTristate(value) + allOptions.Help = ParseTristate(value) case "all": - allOptions.All = parseTristate(value) + allOptions.All = ParseTristate(value) case "maxNodeModuleJsDepth": allOptions.MaxNodeModuleJsDepth = parseNumber(value) case "skipLibCheck": - allOptions.SkipLibCheck = parseTristate(value) + allOptions.SkipLibCheck = ParseTristate(value) case "noEmit": - allOptions.NoEmit = parseTristate(value) + allOptions.NoEmit = ParseTristate(value) case "showConfig": - allOptions.ShowConfig = parseTristate(value) + allOptions.ShowConfig = ParseTristate(value) case "configFilePath": - allOptions.ConfigFilePath = parseString(value) + allOptions.ConfigFilePath = ParseString(value) case "noDtsResolution": - allOptions.NoDtsResolution = parseTristate(value) + allOptions.NoDtsResolution = ParseTristate(value) case "pathsBasePath": - allOptions.PathsBasePath = parseString(value) + allOptions.PathsBasePath = ParseString(value) case "outDir": - allOptions.OutDir = parseString(value) + allOptions.OutDir = ParseString(value) case "newLine": allOptions.NewLine = floatOrInt32ToFlag[core.NewLineKind](value) case "watch": - allOptions.Watch = parseTristate(value) + allOptions.Watch = ParseTristate(value) case "pprofDir": - allOptions.PprofDir = parseString(value) + allOptions.PprofDir = ParseString(value) case "singleThreaded": - allOptions.SingleThreaded = parseTristate(value) + allOptions.SingleThreaded = ParseTristate(value) case "quiet": - allOptions.Quiet = parseTristate(value) + allOptions.Quiet = ParseTristate(value) default: // different than any key above return false @@ -477,11 +477,11 @@ func ParseWatchOptions(key string, value any, allOptions *core.WatchOptions) []* allOptions.FallbackPolling = value.(core.PollingKind) } case "synchronousWatchDirectory": - allOptions.SyncWatchDir = parseTristate(value) + allOptions.SyncWatchDir = ParseTristate(value) case "excludeDirectories": - allOptions.ExcludeDir = parseStringArray(value) + allOptions.ExcludeDir = ParseStringArray(value) case "excludeFiles": - allOptions.ExcludeFiles = parseStringArray(value) + allOptions.ExcludeFiles = ParseStringArray(value) } return nil } @@ -495,13 +495,13 @@ func ParseTypeAcquisition(key string, value any, allOptions *core.TypeAcquisitio } switch key { case "enable": - allOptions.Enable = parseTristate(value) + allOptions.Enable = ParseTristate(value) case "include": - allOptions.Include = parseStringArray(value) + allOptions.Include = ParseStringArray(value) case "exclude": - allOptions.Exclude = parseStringArray(value) + allOptions.Exclude = ParseStringArray(value) case "disableFilenameBasedTypeAcquisition": - allOptions.DisableFilenameBasedTypeAcquisition = parseTristate(value) + allOptions.DisableFilenameBasedTypeAcquisition = ParseTristate(value) } return nil } @@ -519,15 +519,15 @@ func ParseBuildOptions(key string, value any, allOptions *core.BuildOptions) []* } switch key { case "clean": - allOptions.Clean = parseTristate(value) + allOptions.Clean = ParseTristate(value) case "dry": - allOptions.Dry = parseTristate(value) + allOptions.Dry = ParseTristate(value) case "force": - allOptions.Force = parseTristate(value) + allOptions.Force = ParseTristate(value) case "stopBuildOnErrors": - allOptions.StopBuildOnErrors = parseTristate(value) + allOptions.StopBuildOnErrors = ParseTristate(value) case "verbose": - allOptions.Verbose = parseTristate(value) + allOptions.Verbose = ParseTristate(value) } return nil } diff --git a/internal/tspath/extension.go b/internal/tspath/extension.go index cc30d48a66..1b4422e791 100644 --- a/internal/tspath/extension.go +++ b/internal/tspath/extension.go @@ -51,7 +51,7 @@ func RemoveFileExtension(path string) string { } } // Otherwise just remove single dot extension, if any - return path[:len(path)-len(filepath.Ext(path))] + return path[:len(path)-len(filepath.Ext(path))] //nolint:forbidigo } func TryGetExtensionFromPath(p string) string { diff --git a/internal/vfs/zipvfs/zipvfs.go b/internal/vfs/zipvfs/zipvfs.go new file mode 100644 index 0000000000..7b366c3462 --- /dev/null +++ b/internal/vfs/zipvfs/zipvfs.go @@ -0,0 +1,419 @@ +package zipvfs + +import ( + "archive/zip" + "io" + "strconv" + "strings" + "sync" + "time" + + "github.com/microsoft/typescript-go/internal/vfs" +) + +type EntryKind uint8 + +const ( + DirEntry EntryKind = 1 + FileEntry EntryKind = 2 +) + +type ZipFS struct { + inner vfs.FS + + zipFilesMutex sync.Mutex + zipFiles map[string]*zipFile +} + +type zipFile struct { + reader *zip.ReadCloser + err error + + dirs map[string]*compressedDir + files map[string]*compressedFile + once sync.Once +} + +type compressedDir struct { + entries map[string]EntryKind + path string + mutex sync.Mutex +} + +type compressedFile struct { + compressed *zip.File + + // The file is decompressed lazily + mutex sync.Mutex + contents string + err error + wasRead bool +} + +func From(baseFS vfs.FS) *ZipFS { + return &ZipFS{ + inner: baseFS, + zipFiles: make(map[string]*zipFile), + } +} + +func (fs *ZipFS) checkForZip(path string, kind EntryKind) (*zipFile, string) { + var zipPath string + var pathTail string + + if before, after, ok := strings.Cut(path, ".zip/"); ok { + zipPath = before + ".zip" + pathTail = after + } else if kind == DirEntry && strings.HasSuffix(path, ".zip") { + zipPath = path + } else { + return nil, "" + } + + // If there is one, then check whether it's a file on the file system or not + fs.zipFilesMutex.Lock() + archive := fs.zipFiles[zipPath] + if archive != nil { + fs.zipFilesMutex.Unlock() + archive.once.Do(func() { + // wait if another goroutine is initializing the archive + }) + } else { + archive = &zipFile{} + archive.once.Do(func() { + fs.zipFiles[zipPath] = archive + fs.zipFilesMutex.Unlock() + + tryToReadZipArchive(zipPath, archive) + }) + } + + if archive.err != nil { + return nil, "" + } + return archive, pathTail +} + +func tryToReadZipArchive(zipPath string, archive *zipFile) { + reader, err := zip.OpenReader(zipPath) + if err != nil { + archive.err = err + return + } + + dirs := make(map[string]*compressedDir) + files := make(map[string]*compressedFile) + seeds := []string{} + + // Build an index of all files in the archive + for _, file := range reader.File { + baseName := strings.TrimSuffix(file.Name, "/") + dirPath := "" + if slash := strings.LastIndexByte(baseName, '/'); slash != -1 { + dirPath = baseName[:slash] + baseName = baseName[slash+1:] + } + if file.FileInfo().IsDir() { + // Handle a directory + lowerDir := strings.ToLower(dirPath) + if _, ok := dirs[lowerDir]; !ok { + dir := &compressedDir{ + path: dirPath, + entries: make(map[string]EntryKind), + } + + // List the same directory both with and without the slash + dirs[lowerDir] = dir + dirs[lowerDir+"/"] = dir + seeds = append(seeds, lowerDir) + } + } else { + // Handle a file + files[strings.ToLower(file.Name)] = &compressedFile{compressed: file} + lowerDir := strings.ToLower(dirPath) + dir, ok := dirs[lowerDir] + if !ok { + dir = &compressedDir{ + path: dirPath, + entries: make(map[string]EntryKind), + } + + // List the same directory both with and without the slash + dirs[lowerDir] = dir + dirs[lowerDir+"/"] = dir + seeds = append(seeds, lowerDir) + } + dir.entries[baseName] = FileEntry + } + } + + // Populate child directories + for _, baseName := range seeds { + for baseName != "" { + dirPath := "" + if slash := strings.LastIndexByte(baseName, '/'); slash != -1 { + dirPath = baseName[:slash] + baseName = baseName[slash+1:] + } + lowerDir := strings.ToLower(dirPath) + dir, ok := dirs[lowerDir] + if !ok { + dir = &compressedDir{ + path: dirPath, + entries: make(map[string]EntryKind), + } + + // List the same directory both with and without the slash + dirs[lowerDir] = dir + dirs[lowerDir+"/"] = dir + } + dir.entries[baseName] = DirEntry + baseName = dirPath + } + } + + archive.dirs = dirs + archive.files = files + archive.reader = reader +} + +func (fs *ZipFS) UseCaseSensitiveFileNames() bool { + return fs.inner.UseCaseSensitiveFileNames() +} + +func (fs *ZipFS) FileExists(path string) bool { + path = mangleYarnPnPVirtualPath(path) + + if fs.inner.FileExists(path) { + return true + } + + zip, pathTail := fs.checkForZip(path, FileEntry) + if zip == nil { + return false + } + + _, ok := zip.files[strings.ToLower(pathTail)] + return ok +} + +func (fs *ZipFS) ReadFile(path string) (contents string, ok bool) { + path = mangleYarnPnPVirtualPath(path) + + contents, ok = fs.inner.ReadFile(path) + if ok { + return contents, ok + } + + // If the file doesn't exist, try reading from an enclosing zip archive + zip, pathTail := fs.checkForZip(path, FileEntry) + if zip == nil { + return "", false + } + + // Does the zip archive have this file? + file, ok := zip.files[strings.ToLower(pathTail)] + if !ok { + return "", false + } + + // Check whether it has already been read + file.mutex.Lock() + defer file.mutex.Unlock() + + if file.wasRead { + return file.contents, file.err == nil + } + file.wasRead = true + + // If not, try to open it + reader, err := file.compressed.Open() + if err != nil { + file.err = err + return "", err == nil + } + defer reader.Close() + + // Then try to read it + bytes, err := io.ReadAll(reader) + if err != nil { + file.err = err + return "", false + } + + file.contents = string(bytes) + + return file.contents, true +} + +func (fs *ZipFS) WriteFile(path string, data string, writeByteOrderMark bool) error { + err := fs.inner.WriteFile(path, data, writeByteOrderMark) + if err != nil { + fs.tryZipFileAssertion(path) + return err + } + return nil +} + +func (fs *ZipFS) Remove(path string) error { + err := fs.inner.Remove(path) + if err != nil { + fs.tryZipFileAssertion(path) + return err + } + return nil +} + +func (fs *ZipFS) Chtimes(path string, aTime time.Time, mTime time.Time) error { + err := fs.inner.Chtimes(path, aTime, mTime) + if err != nil { + fs.tryZipFileAssertion(path) + return err + } + return nil +} + +func (fs *ZipFS) DirectoryExists(path string) bool { + path = mangleYarnPnPVirtualPath(path) + + if fs.inner.DirectoryExists(path) { + return true + } + + zip, pathTail := fs.checkForZip(path, DirEntry) + if zip == nil { + return false + } + + _, ok := zip.dirs[strings.ToLower(pathTail)] + return ok +} + +func (fs *ZipFS) GetAccessibleEntries(path string) vfs.Entries { + path = mangleYarnPnPVirtualPath(path) + + entries := fs.inner.GetAccessibleEntries(path) + if len(entries.Files) > 0 || len(entries.Directories) > 0 { + return entries + } + + zip, pathTail := fs.checkForZip(path, DirEntry) + if zip == nil { + return entries + } + + dir, ok := zip.dirs[strings.ToLower(pathTail)] + if !ok { + return entries + } + + var files []string + var dirs []string + + dir.mutex.Lock() + defer dir.mutex.Unlock() + + for name, kind := range dir.entries { + switch kind { + case FileEntry: + files = append(files, name) + case DirEntry: + dirs = append(dirs, name) + } + } + + return vfs.Entries{ + Files: files, + Directories: dirs, + } +} + +func (fs *ZipFS) Stat(path string) vfs.FileInfo { + return fs.inner.Stat(path) +} + +func (fs *ZipFS) WalkDir(root string, walkFn vfs.WalkDirFunc) error { + return fs.inner.WalkDir(root, walkFn) +} + +func (fs *ZipFS) Realpath(path string) string { + return fs.inner.Realpath(path) +} + +func (fs *ZipFS) tryZipFileAssertion(path string) { + zip, _ := fs.checkForZip(path, FileEntry) + if zip == nil { + return + } + panic("do not use this method for zip file: " + path) +} + +func ParseYarnPnPVirtualPath(path string) (string, string, bool) { + i := 0 + + for { + start := i + slash := strings.IndexAny(path[i:], "/\\") + if slash == -1 { + break + } + i += slash + 1 + + // Replace the segments "__virtual__//" with N times the ".." + // operation. Note: The "__virtual__" folder name appeared with Yarn 3.0. + // Earlier releases used "$$virtual", but it was changed after discovering + // that this pattern triggered bugs in software where paths were used as + // either regexps or replacement. For example, "$$" found in the second + // parameter of "String.prototype.replace" silently turned into "$". + if segment := path[start : i-1]; segment == "__virtual__" || segment == "$$virtual" { + if slash := strings.IndexAny(path[i:], "/\\"); slash != -1 { + var count string + var suffix string + j := i + slash + 1 + + // Find the range of the count + if slash := strings.IndexAny(path[j:], "/\\"); slash != -1 { + count = path[j : j+slash] + suffix = path[j+slash:] + } else { + count = path[j:] + } + + // Parse the count + if n, err := strconv.ParseInt(count, 10, 64); err == nil { + prefix := path[:start] + + // Apply N times the ".." operator + for n > 0 && (strings.HasSuffix(prefix, "/") || strings.HasSuffix(prefix, "\\")) { + slash := strings.LastIndexAny(prefix[:len(prefix)-1], "/\\") + if slash == -1 { + break + } + prefix = prefix[:slash+1] + n-- + } + + // Make sure the prefix and suffix work well when joined together + if suffix == "" && strings.IndexAny(prefix, "/\\") != strings.LastIndexAny(prefix, "/\\") { + prefix = prefix[:len(prefix)-1] + } else if prefix == "" { + prefix = "." + } else if strings.HasPrefix(suffix, "/") || strings.HasPrefix(suffix, "\\") { + suffix = suffix[1:] + } + + return prefix, suffix, true + } + } + } + } + + return "", "", false +} + +func mangleYarnPnPVirtualPath(path string) string { + if prefix, suffix, ok := ParseYarnPnPVirtualPath(path); ok { + return prefix + suffix + } + return path +} diff --git a/testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.js b/testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.js new file mode 100644 index 0000000000..54a3a527f9 --- /dev/null +++ b/testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/blockedScopeVariableNotUnused1.ts] //// + +//// [blockedScopeVariableNotUnused1.ts] +export function foo() { + const _fn = () => { + ;(() => numFilesSelected)() + } + + const numFilesSelected = 1 +} + + +//// [blockedScopeVariableNotUnused1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; +function foo() { + const _fn = () => { + ; + (() => numFilesSelected)(); + }; + const numFilesSelected = 1; +} diff --git a/testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.symbols b/testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.symbols new file mode 100644 index 0000000000..7cb8b2fb75 --- /dev/null +++ b/testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/blockedScopeVariableNotUnused1.ts] //// + +=== blockedScopeVariableNotUnused1.ts === +export function foo() { +>foo : Symbol(foo, Decl(blockedScopeVariableNotUnused1.ts, 0, 0)) + + const _fn = () => { +>_fn : Symbol(_fn, Decl(blockedScopeVariableNotUnused1.ts, 1, 7)) + + ;(() => numFilesSelected)() +>numFilesSelected : Symbol(numFilesSelected, Decl(blockedScopeVariableNotUnused1.ts, 5, 7)) + } + + const numFilesSelected = 1 +>numFilesSelected : Symbol(numFilesSelected, Decl(blockedScopeVariableNotUnused1.ts, 5, 7)) +} + diff --git a/testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.types b/testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.types new file mode 100644 index 0000000000..51f64d7851 --- /dev/null +++ b/testdata/baselines/reference/compiler/blockedScopeVariableNotUnused1.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/blockedScopeVariableNotUnused1.ts] //// + +=== blockedScopeVariableNotUnused1.ts === +export function foo() { +>foo : () => void + + const _fn = () => { +>_fn : () => void +>() => { ;(() => numFilesSelected)() } : () => void + + ;(() => numFilesSelected)() +>(() => numFilesSelected)() : number +>(() => numFilesSelected) : () => number +>() => numFilesSelected : () => number +>numFilesSelected : 1 + } + + const numFilesSelected = 1 +>numFilesSelected : 1 +>1 : 1 +} + diff --git a/testdata/baselines/reference/compiler/declarationEmitExpandoFunction.js b/testdata/baselines/reference/compiler/declarationEmitExpandoFunction.js new file mode 100644 index 0000000000..c54f345dd5 --- /dev/null +++ b/testdata/baselines/reference/compiler/declarationEmitExpandoFunction.js @@ -0,0 +1,57 @@ +//// [tests/cases/compiler/declarationEmitExpandoFunction.ts] //// + +//// [declarationEmitExpandoFunction.ts] +export function A() { + return 'A'; +} + +export function B() { + return 'B'; +} + +export enum C { + C +} + +A.a = C; +A.b = C; + +B.c = C; + + +//// [declarationEmitExpandoFunction.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +exports.A = A; +exports.B = B; +function A() { + return 'A'; +} +function B() { + return 'B'; +} +var C; +(function (C) { + C[C["C"] = 0] = "C"; +})(C || (exports.C = C = {})); +A.a = C; +A.b = C; +B.c = C; + + +//// [declarationEmitExpandoFunction.d.ts] +export declare function A(): string; +export declare function B(): string; +export declare enum C { + C = 0 +} +export declare namespace A { + var a: typeof C; +} +export declare namespace A { + var b: typeof C; +} +export declare namespace B { + var c: typeof C; +} diff --git a/testdata/baselines/reference/compiler/declarationEmitExpandoFunction.symbols b/testdata/baselines/reference/compiler/declarationEmitExpandoFunction.symbols new file mode 100644 index 0000000000..41183b30b5 --- /dev/null +++ b/testdata/baselines/reference/compiler/declarationEmitExpandoFunction.symbols @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/declarationEmitExpandoFunction.ts] //// + +=== declarationEmitExpandoFunction.ts === +export function A() { +>A : Symbol(A, Decl(declarationEmitExpandoFunction.ts, 0, 0)) + + return 'A'; +} + +export function B() { +>B : Symbol(B, Decl(declarationEmitExpandoFunction.ts, 2, 1)) + + return 'B'; +} + +export enum C { +>C : Symbol(C, Decl(declarationEmitExpandoFunction.ts, 6, 1)) + + C +>C : Symbol(C.C, Decl(declarationEmitExpandoFunction.ts, 8, 15)) +} + +A.a = C; +>A.a : Symbol(A.a, Decl(declarationEmitExpandoFunction.ts, 10, 1)) +>A : Symbol(A, Decl(declarationEmitExpandoFunction.ts, 0, 0)) +>a : Symbol(A.a, Decl(declarationEmitExpandoFunction.ts, 10, 1)) +>C : Symbol(C, Decl(declarationEmitExpandoFunction.ts, 6, 1)) + +A.b = C; +>A.b : Symbol(A.b, Decl(declarationEmitExpandoFunction.ts, 12, 8)) +>A : Symbol(A, Decl(declarationEmitExpandoFunction.ts, 0, 0)) +>b : Symbol(A.b, Decl(declarationEmitExpandoFunction.ts, 12, 8)) +>C : Symbol(C, Decl(declarationEmitExpandoFunction.ts, 6, 1)) + +B.c = C; +>B.c : Symbol(B.c, Decl(declarationEmitExpandoFunction.ts, 13, 8)) +>B : Symbol(B, Decl(declarationEmitExpandoFunction.ts, 2, 1)) +>c : Symbol(B.c, Decl(declarationEmitExpandoFunction.ts, 13, 8)) +>C : Symbol(C, Decl(declarationEmitExpandoFunction.ts, 6, 1)) + diff --git a/testdata/baselines/reference/compiler/declarationEmitExpandoFunction.types b/testdata/baselines/reference/compiler/declarationEmitExpandoFunction.types new file mode 100644 index 0000000000..0e7b87870c --- /dev/null +++ b/testdata/baselines/reference/compiler/declarationEmitExpandoFunction.types @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/declarationEmitExpandoFunction.ts] //// + +=== declarationEmitExpandoFunction.ts === +export function A() { +>A : { (): string; a: typeof C; b: typeof C; } + + return 'A'; +>'A' : "A" +} + +export function B() { +>B : { (): string; c: typeof C; } + + return 'B'; +>'B' : "B" +} + +export enum C { +>C : C + + C +>C : C.C +} + +A.a = C; +>A.a = C : typeof C +>A.a : typeof C +>A : { (): string; a: typeof C; b: typeof C; } +>a : typeof C +>C : typeof C + +A.b = C; +>A.b = C : typeof C +>A.b : typeof C +>A : { (): string; a: typeof C; b: typeof C; } +>b : typeof C +>C : typeof C + +B.c = C; +>B.c = C : typeof C +>B.c : typeof C +>B : { (): string; c: typeof C; } +>c : typeof C +>C : typeof C + diff --git a/testdata/baselines/reference/compiler/declarationEmitNoCrashOnCrossFileNode.js b/testdata/baselines/reference/compiler/declarationEmitNoCrashOnCrossFileNode.js index e76b2fcda6..a62af024ff 100644 --- a/testdata/baselines/reference/compiler/declarationEmitNoCrashOnCrossFileNode.js +++ b/testdata/baselines/reference/compiler/declarationEmitNoCrashOnCrossFileNode.js @@ -16,11 +16,11 @@ export function foo(): ({ a, b }: { a: string, b: string }) => void { //// [other.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.foo = foo; /** * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eu aliquet lectus, nec rhoncus metus. Donec dapibus consectetur risus vitae porta. Aenean nisi neque, dignissim quis varius vel, volutpat vel tellus. Praesent lacinia molestie est, vel convallis odio ornare id. Pellentesque quis purus ante. Morbi a nisl justo. Etiam malesuada ipsum sem, fringilla rhoncus turpis ullamcorper et. Aenean laoreet, nisl id tempus pellentesque, elit elit congue felis, sit amet luctus nulla orci sit amet velit. Praesent non tincidunt nisi, at tempor eros. Quisque tincidunt euismod posuere. Ut blandit mauris elit, a porttitor orci aliquam ac. Duis imperdiet gravida ultrices. In. */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.foo = foo; function foo() { return () => { }; } diff --git a/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments2.js b/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments2.js index 890f9d0031..30a336e781 100644 --- a/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments2.js +++ b/testdata/baselines/reference/compiler/emitEndOfFileJSDocComments2.js @@ -23,8 +23,8 @@ function test(param) { //// [emitEndOfFileJSDocComments2.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** @typedef {number} A */ +Object.defineProperty(exports, "__esModule", { value: true }); /** * JSDoc comment for function * @param {string} param - A string parameter diff --git a/testdata/baselines/reference/compiler/invalidJsdocType.errors.txt b/testdata/baselines/reference/compiler/invalidJsdocType.errors.txt new file mode 100644 index 0000000000..e122d03076 --- /dev/null +++ b/testdata/baselines/reference/compiler/invalidJsdocType.errors.txt @@ -0,0 +1,8 @@ +a.js(1,12): error TS1110: Type expected. + + +==== a.js (1 errors) ==== + /** @type {@import("a").Type} */ + ~ +!!! error TS1110: Type expected. + let x; \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/invalidJsdocType.symbols b/testdata/baselines/reference/compiler/invalidJsdocType.symbols new file mode 100644 index 0000000000..0f8b4e2b0a --- /dev/null +++ b/testdata/baselines/reference/compiler/invalidJsdocType.symbols @@ -0,0 +1,7 @@ +//// [tests/cases/compiler/invalidJsdocType.ts] //// + +=== a.js === +/** @type {@import("a").Type} */ +let x; +>x : Symbol(x, Decl(a.js, 1, 3)) + diff --git a/testdata/baselines/reference/compiler/invalidJsdocType.types b/testdata/baselines/reference/compiler/invalidJsdocType.types new file mode 100644 index 0000000000..50b41486a2 --- /dev/null +++ b/testdata/baselines/reference/compiler/invalidJsdocType.types @@ -0,0 +1,7 @@ +//// [tests/cases/compiler/invalidJsdocType.ts] //// + +=== a.js === +/** @type {@import("a").Type} */ +let x; +>x : any + diff --git a/testdata/baselines/reference/compiler/invocationErrorRecovery.errors.txt b/testdata/baselines/reference/compiler/invocationErrorRecovery.errors.txt new file mode 100644 index 0000000000..aaabcef494 --- /dev/null +++ b/testdata/baselines/reference/compiler/invocationErrorRecovery.errors.txt @@ -0,0 +1,16 @@ +index.ts(2,1): error TS2349: This expression is not callable. + Type '{ default: () => void; }' has no call signatures. + + +==== foo.d.ts (0 errors) ==== + declare function foo(): void; + declare namespace foo {} + export = foo; +==== index.ts (1 errors) ==== + import * as foo from "./foo"; + foo() + ~~~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type '{ default: () => void; }' has no call signatures. +!!! related TS7038 index.ts:1:1: Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead. + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/invocationErrorRecovery.symbols b/testdata/baselines/reference/compiler/invocationErrorRecovery.symbols new file mode 100644 index 0000000000..4dfa6b4fd9 --- /dev/null +++ b/testdata/baselines/reference/compiler/invocationErrorRecovery.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/invocationErrorRecovery.ts] //// + +=== foo.d.ts === +declare function foo(): void; +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +declare namespace foo {} +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +export = foo; +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +=== index.ts === +import * as foo from "./foo"; +>foo : Symbol(foo, Decl(index.ts, 0, 6)) + +foo() +>foo : Symbol(foo, Decl(index.ts, 0, 6)) + diff --git a/testdata/baselines/reference/compiler/invocationErrorRecovery.types b/testdata/baselines/reference/compiler/invocationErrorRecovery.types new file mode 100644 index 0000000000..5bdbe9b0e7 --- /dev/null +++ b/testdata/baselines/reference/compiler/invocationErrorRecovery.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/invocationErrorRecovery.ts] //// + +=== foo.d.ts === +declare function foo(): void; +>foo : () => void + +declare namespace foo {} +export = foo; +>foo : () => void + +=== index.ts === +import * as foo from "./foo"; +>foo : { default: () => void; } + +foo() +>foo() : any +>foo : { default: () => void; } + diff --git a/testdata/baselines/reference/compiler/jsxNestedIndentation.js b/testdata/baselines/reference/compiler/jsxNestedIndentation.js new file mode 100644 index 0000000000..24315ed9a2 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsxNestedIndentation.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/jsxNestedIndentation.tsx] //// + +//// [jsxNestedIndentation.tsx] +declare var React: any; +declare function Child(props: { children?: any }): any; +function Test() { + return + + + + +} + + +//// [jsxNestedIndentation.js] +function Test() { + return React.createElement(Child, null, + React.createElement(Child, null, + React.createElement(Child, null))); +} diff --git a/testdata/baselines/reference/compiler/jsxNestedIndentation.symbols b/testdata/baselines/reference/compiler/jsxNestedIndentation.symbols new file mode 100644 index 0000000000..630e254a6c --- /dev/null +++ b/testdata/baselines/reference/compiler/jsxNestedIndentation.symbols @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/jsxNestedIndentation.tsx] //// + +=== jsxNestedIndentation.tsx === +declare var React: any; +>React : Symbol(React, Decl(jsxNestedIndentation.tsx, 0, 11)) + +declare function Child(props: { children?: any }): any; +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) +>props : Symbol(props, Decl(jsxNestedIndentation.tsx, 1, 23)) +>children : Symbol(children, Decl(jsxNestedIndentation.tsx, 1, 31)) + +function Test() { +>Test : Symbol(Test, Decl(jsxNestedIndentation.tsx, 1, 55)) + + return +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) + + +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) + + +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) + + +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) + + +>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23)) +} + diff --git a/testdata/baselines/reference/compiler/jsxNestedIndentation.types b/testdata/baselines/reference/compiler/jsxNestedIndentation.types new file mode 100644 index 0000000000..f910202c49 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsxNestedIndentation.types @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/jsxNestedIndentation.tsx] //// + +=== jsxNestedIndentation.tsx === +declare var React: any; +>React : any + +declare function Child(props: { children?: any }): any; +>Child : (props: { children?: any; }) => any +>props : { children?: any; } +>children : any + +function Test() { +>Test : () => any + + return +> : any +>Child : (props: { children?: any; }) => any + + +> : any +>Child : (props: { children?: any; }) => any + + +> : any +>Child : (props: { children?: any; }) => any +>Child : (props: { children?: any; }) => any + + +>Child : (props: { children?: any; }) => any + + +>Child : (props: { children?: any; }) => any +} + diff --git a/testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.js b/testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.js index a179ad9931..107acc3fb6 100644 --- a/testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.js +++ b/testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.js @@ -34,7 +34,9 @@ export const InlineUnicodeChar = () => { }; export const StandaloneUnicodeChar = () => { // This should reproduce the issue - unicode character on its own line - return (_jsxs("div", { children: [_jsx("span", { children: "\u26A0" }), "\u26A0"] })); + return (_jsxs("div", { children: [ + _jsx("span", { children: "\u26A0" }), + "\u26A0"] })); }; export const MultipleUnicodeChars = () => { // Test multiple unicode characters diff --git a/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion2.baseline.md b/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion2.baseline.md index 1fff3fc8ff..a679c95fee 100644 --- a/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion2.baseline.md +++ b/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion2.baseline.md @@ -6,7 +6,7 @@ someVar; a/**/ ``````ts -import {someVar,anotherVar} from "./a.ts"; +import {anotherVar, someVar} from "./a.ts"; someVar; a diff --git a/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion3.baseline.md b/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion3.baseline.md index e565df0c68..b70487e0b7 100644 --- a/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion3.baseline.md +++ b/testdata/baselines/reference/fourslash/autoImports/autoImportCompletion3.baseline.md @@ -6,7 +6,7 @@ someVar; b/**/ ``````ts -import { aa, someVar,bb } from "./a.ts"; +import { aa, bb, someVar } from "./a.ts"; someVar; b diff --git a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences1.baseline.jsonc index 360000f99d..ee50558949 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences1.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /constructorFindAllReferences1.ts === // export class C { -// /*FIND ALL REFS*/public constructor() { } +// /*FIND ALL REFS*/public [|constructor|]() { } // public foo() { } // } // -// new C().foo(); \ No newline at end of file +// new [|C|]().foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences2.baseline.jsonc index ebe82fac1e..a6c3c02e0f 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences2.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /constructorFindAllReferences2.ts === // export class C { -// /*FIND ALL REFS*/private constructor() { } +// /*FIND ALL REFS*/private [|constructor|]() { } // public foo() { } // } // -// new C().foo(); \ No newline at end of file +// new [|C|]().foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences4.baseline.jsonc index a9c98eaea2..cf4ebb836b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences4.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /constructorFindAllReferences4.ts === // export class C { -// /*FIND ALL REFS*/protected constructor() { } +// /*FIND ALL REFS*/protected [|constructor|]() { } // public foo() { } // } // -// new C().foo(); \ No newline at end of file +// new [|C|]().foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc index cf2a41e027..af501fac1d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc @@ -18,7 +18,7 @@ // === /foo.ts === // export function foo() { return "foo"; } // import("./foo") -// /*FIND ALL REFS*/var x = import("./foo") +// /*FIND ALL REFS*/var [|x|] = import("./foo") diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfJsonModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfJsonModule.baseline.jsonc index b573d0da76..2560521003 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfJsonModule.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfJsonModule.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /foo.ts === -// /*FIND ALL REFS*/import settings from "./settings.json"; -// settings; +// /*FIND ALL REFS*/import [|settings|] from "./settings.json"; +// [|settings|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc index a0e7b903e9..4b37e613d9 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /findAllRefsDeclareClass.ts === -// /*FIND ALL REFS*/declare class C { +// /*FIND ALL REFS*/declare class [|C|] { // static m(): void; // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumAsNamespace.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumAsNamespace.baseline.jsonc index 459666328e..4bd7d96f89 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumAsNamespace.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumAsNamespace.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsEnumAsNamespace.ts === -// /*FIND ALL REFS*/enum E { A } -// let e: E.A; +// /*FIND ALL REFS*/enum [|E|] { A } +// let e: [|E|].A; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc index 3734653d91..bc114597e4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc @@ -8,10 +8,10 @@ // === findAllReferences === // === /a.ts === // type T = number; -// /*FIND ALL REFS*/[|export|] = T; +// /*FIND ALL REFS*/export = [|T|]; // === /b.ts === -// import T = require("[|./a|]"); +// import [|T|] = require("./a"); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc index a7e3cdedf6..f936ce1ea0 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsForDefaultExport01.ts === -// /*FIND ALL REFS*/export default class DefaultExportedClass { +// /*FIND ALL REFS*/export default class [|DefaultExportedClass|] { // } // -// var x: DefaultExportedClass; +// var x: [|DefaultExportedClass|]; // -// var y = new DefaultExportedClass; +// var y = new [|DefaultExportedClass|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport02.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport02.baseline.jsonc index 00007d570f..6f553cd654 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport02.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport02.baseline.jsonc @@ -1,10 +1,15 @@ // === findAllReferences === // === /findAllRefsForDefaultExport02.ts === -// /*FIND ALL REFS*/export default function DefaultExportedFunction() { -// return DefaultExportedFunction; +// /*FIND ALL REFS*/export default function [|DefaultExportedFunction|]() { +// return [|DefaultExportedFunction|]; // } // -// // --- (line: 5) skipped --- +// var x: typeof [|DefaultExportedFunction|]; +// +// var y = [|DefaultExportedFunction|](); +// +// namespace DefaultExportedFunction { +// } @@ -74,7 +79,7 @@ // // var y = DefaultExportedFunction(); // -// /*FIND ALL REFS*/namespace DefaultExportedFunction { +// /*FIND ALL REFS*/namespace [|DefaultExportedFunction|] { // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc new file mode 100644 index 0000000000..137945bf4a --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc @@ -0,0 +1,141 @@ +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// /*FIND ALL REFS*/function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function /*FIND ALL REFS*/[|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// /*FIND ALL REFS*/export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default /*FIND ALL REFS*/[|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof /*FIND ALL REFS*/[|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = /*FIND ALL REFS*/[|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// /*FIND ALL REFS*/namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace /*FIND ALL REFS*/[|f|] { +// var local = 100; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause01.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause01.baseline.jsonc index e63980b63d..4064c53b01 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause01.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsForVariableInExtendsClause01.ts === -// /*FIND ALL REFS*/var Base = class { }; -// class C extends Base { } +// /*FIND ALL REFS*/var [|Base|] = class { }; +// class C extends [|Base|] { } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause02.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause02.baseline.jsonc index 635f9d38cb..692886f089 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause02.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForVariableInExtendsClause02.baseline.jsonc @@ -1,9 +1,9 @@ // === findAllReferences === // === /findAllRefsForVariableInExtendsClause02.ts === -// /*FIND ALL REFS*/interface Base { } +// /*FIND ALL REFS*/interface [|Base|] { } // namespace n { // var Base = class { }; -// interface I extends Base { } +// interface I extends [|Base|] { } // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc index d7491ce03c..479db50506 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc @@ -1,7 +1,10 @@ // === findAllReferences === // === /a.js === // module.exports = 0; -// /*FIND ALL REFS*/export type N = number; +// /*FIND ALL REFS*/export type [|N|] = number; + +// === /b.js === +// type T = import("./a").[|N|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc index d70f81e56a..b433189590 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsInsideTemplates1.ts === -// /*FIND ALL REFS*/var x = 10; -// var y = `${ x } ${ x }` +// /*FIND ALL REFS*/var [|x|] = 10; +// var y = `${ [|x|] } ${ [|x|] }` diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc index 9d2e0aa91d..8ca4acea24 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsInsideTemplates2.ts === -// /*FIND ALL REFS*/function f(...rest: any[]) { } -// f `${ f } ${ f }` +// /*FIND ALL REFS*/function [|f|](...rest: any[]) { } +// [|f|] `${ [|f|] } ${ [|f|] }` diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc index 118d6ab98c..19b1d2ba3d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc @@ -1,10 +1,13 @@ // === findAllReferences === // === /findAllRefsInsideWithBlock.ts === -// /*FIND ALL REFS*/var x = 0; +// /*FIND ALL REFS*/var [|x|] = 0; // // with ({}) { // var y = x; // Reference of x here should not be picked -// // --- (line: 5) skipped --- +// y++; // also reference for y should be ignored +// } +// +// [|x|] = [|x|] + 1; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDecorators.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDecorators.baseline.jsonc index 8cef99ffaa..a362eb779e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDecorators.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDecorators.baseline.jsonc @@ -1,9 +1,16 @@ // === findAllReferences === // === /a.ts === -// /*FIND ALL REFS*/function decorator(target) { +// /*FIND ALL REFS*/function [|decorator|](target) { // return target; // } -// decorator(); +// [|decorator|](); + +// === /b.ts === +// @[|decorator|] @[|decorator|]("again") +// class C { +// @[|decorator|] +// method() {} +// } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition.baseline.jsonc index c27ee5460e..1ce9c15254 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition.baseline.jsonc @@ -4,12 +4,19 @@ // // } // -// /*FIND ALL REFS*/public start(){ +// /*FIND ALL REFS*/public [|start|](){ // return this; // } // // // --- (line: 11) skipped --- +// === /findAllRefsOnDefinition.ts === +// import Second = require("./findAllRefsOnDefinition-import"); +// +// var second = new Second.Test() +// second.[|start|](); +// second.stop(); + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition2.baseline.jsonc index 97030d14d0..948c4ea942 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnDefinition2.baseline.jsonc @@ -2,11 +2,17 @@ // === /findAllRefsOnDefinition2-import.ts === // export module Test{ // -// /*FIND ALL REFS*/export interface start { } +// /*FIND ALL REFS*/export interface [|start|] { } // // export interface stop { } // } +// === /findAllRefsOnDefinition2.ts === +// import Second = require("./findAllRefsOnDefinition2-import"); +// +// var start: Second.Test.[|start|]; +// var stop: Second.Test.stop; + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnPrivateParameterProperty1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnPrivateParameterProperty1.baseline.jsonc index a353dee861..ff228b6549 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnPrivateParameterProperty1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnPrivateParameterProperty1.baseline.jsonc @@ -1,11 +1,13 @@ // === findAllReferences === // === /findAllRefsOnPrivateParameterProperty1.ts === // class ABCD { -// constructor(private x: number, public y: number, /*FIND ALL REFS*/private z: number) { +// constructor(private x: number, public y: number, /*FIND ALL REFS*/private [|z|]: number) { // } // // func() { -// // --- (line: 6) skipped --- +// return this.[|z|]; +// } +// } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameAccessors.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameAccessors.baseline.jsonc index 450a19bbe9..590bc48285 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameAccessors.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrivateNameAccessors.baseline.jsonc @@ -1,11 +1,14 @@ // === findAllReferences === // === /findAllRefsPrivateNameAccessors.ts === // class C { -// /*FIND ALL REFS*/get #foo(){ return 1; } -// set #foo(value: number){ } +// /*FIND ALL REFS*/get [|#foo|](){ return 1; } +// set [|#foo|](value: number){ } // constructor() { -// this.#foo(); -// // --- (line: 6) skipped --- +// this.[|#foo|](); +// } +// } +// class D extends C { +// // --- (line: 9) skipped --- @@ -26,12 +29,14 @@ // === findAllReferences === // === /findAllRefsPrivateNameAccessors.ts === // class C { -// get #foo(){ return 1; } -// /*FIND ALL REFS*/set #foo(value: number){ } +// get [|#foo|](){ return 1; } +// /*FIND ALL REFS*/set [|#foo|](value: number){ } // constructor() { -// this.#foo(); +// this.[|#foo|](); // } -// // --- (line: 7) skipped --- +// } +// class D extends C { +// // --- (line: 9) skipped --- @@ -69,10 +74,10 @@ // } // } // class E { -// /*FIND ALL REFS*/get #foo(){ return 1; } -// set #foo(value: number){ } +// /*FIND ALL REFS*/get [|#foo|](){ return 1; } +// set [|#foo|](value: number){ } // constructor() { -// this.#foo(); +// this.[|#foo|](); // } // } @@ -95,13 +100,14 @@ // === findAllReferences === // === /findAllRefsPrivateNameAccessors.ts === -// --- (line: 12) skipped --- +// --- (line: 11) skipped --- +// } // } // class E { -// get #foo(){ return 1; } -// /*FIND ALL REFS*/set #foo(value: number){ } +// get [|#foo|](){ return 1; } +// /*FIND ALL REFS*/set [|#foo|](value: number){ } // constructor() { -// this.#foo(); +// this.[|#foo|](); // } // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames1.baseline.jsonc index 275b2415e7..38bc2fe401 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames1.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames1.ts === // class Foo { -// /*FIND ALL REFS*/public _bar() { return 0; } +// /*FIND ALL REFS*/public [|_bar|]() { return 0; } // } // // var x: Foo; -// x._bar; +// x.[|_bar|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames2.baseline.jsonc index 0627485bd8..def74d86dd 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames2.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames2.ts === // class Foo { -// /*FIND ALL REFS*/public __bar() { return 0; } +// /*FIND ALL REFS*/public [|__bar|]() { return 0; } // } // // var x: Foo; -// x.__bar; +// x.[|__bar|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames3.baseline.jsonc index ba2b00295d..b1c169241e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames3.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames3.ts === // class Foo { -// /*FIND ALL REFS*/public ___bar() { return 0; } +// /*FIND ALL REFS*/public [|___bar|]() { return 0; } // } // // var x: Foo; -// x.___bar; +// x.[|___bar|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames4.baseline.jsonc index 4c995ceb99..ba04ab6467 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames4.baseline.jsonc @@ -1,11 +1,11 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames4.ts === // class Foo { -// /*FIND ALL REFS*/public ____bar() { return 0; } +// /*FIND ALL REFS*/public [|____bar|]() { return 0; } // } // // var x: Foo; -// x.____bar; +// x.[|____bar|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames5.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames5.baseline.jsonc index 68b9058871..18e8118cfb 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames5.baseline.jsonc @@ -3,11 +3,15 @@ // class Foo { // public _bar; // public __bar; -// /*FIND ALL REFS*/public ___bar; +// /*FIND ALL REFS*/public [|___bar|]; // public ____bar; // } // -// // --- (line: 8) skipped --- +// var x: Foo; +// x._bar; +// x.__bar; +// x.[|___bar|]; +// x.____bar; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames6.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames6.baseline.jsonc index 5cea661dd5..371052938b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames6.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames6.baseline.jsonc @@ -2,11 +2,16 @@ // === /findAllRefsWithLeadingUnderscoreNames6.ts === // class Foo { // public _bar; -// /*FIND ALL REFS*/public __bar; +// /*FIND ALL REFS*/public [|__bar|]; // public ___bar; // public ____bar; // } -// // --- (line: 7) skipped --- +// +// var x: Foo; +// x._bar; +// x.[|__bar|]; +// x.___bar; +// x.____bar; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames7.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames7.baseline.jsonc index 761a4899a3..46abb67ad4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames7.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames7.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findAllRefsWithLeadingUnderscoreNames7.ts === -// /*FIND ALL REFS*/function __foo() { -// __foo(); +// /*FIND ALL REFS*/function [|__foo|]() { +// [|__foo|](); // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_meaningAtLocation.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_meaningAtLocation.baseline.jsonc index 41f5903eec..a39cb0e4e4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_meaningAtLocation.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_meaningAtLocation.baseline.jsonc @@ -1,8 +1,12 @@ // === findAllReferences === // === /a.ts === -// /*FIND ALL REFS*/export type T = 0; +// /*FIND ALL REFS*/export type [|T|] = 0; // export const T = 0; +// === /b.ts === +// const x: import("./a").[|T|] = 0; +// const x: typeof import("./a").T = 0; + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_named.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_named.baseline.jsonc index 55c3e1d76c..2d8b8e38a2 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_named.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_named.baseline.jsonc @@ -1,8 +1,12 @@ // === findAllReferences === // === /a.ts === -// /*FIND ALL REFS*/export type T = number; +// /*FIND ALL REFS*/export type [|T|] = number; // export type U = string; +// === /b.ts === +// const x: import("./a").[|T|] = 0; +// const x: import("./a").U = 0; + // === findAllReferences === @@ -19,7 +23,11 @@ // === findAllReferences === // === /a.ts === // export type T = number; -// /*FIND ALL REFS*/export type U = string; +// /*FIND ALL REFS*/export type [|U|] = string; + +// === /b.ts === +// const x: import("./a").T = 0; +// const x: import("./a").[|U|] = 0; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc index 33e67cb257..b1dc44da2b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /b.ts === -// /*FIND ALL REFS*/const x: typeof import("./a") = { x: 0 }; +// /*FIND ALL REFS*/const [|x|]: typeof import("./a") = { x: 0 }; // const y: typeof import("./a") = { x: 0 }; @@ -15,7 +15,7 @@ // === findAllReferences === // === /b.ts === // const x: typeof import("./a") = { x: 0 }; -// /*FIND ALL REFS*/const y: typeof import("./a") = { x: 0 }; +// /*FIND ALL REFS*/const [|y|]: typeof import("./a") = { x: 0 }; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_jsEnum.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_jsEnum.baseline.jsonc index 14c23a2f5f..77cd5d46e7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_jsEnum.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_jsEnum.baseline.jsonc @@ -1,10 +1,10 @@ // === findAllReferences === // === /a.js === // /** @enum {string} */ -// /*FIND ALL REFS*/const E = { A: "" }; -// E["A"]; +// /*FIND ALL REFS*/const [|E|] = { A: "" }; +// [|E|]["A"]; // /** @type {E} */ -// const e = E.A; +// const e = [|E|].A; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesAcrossMultipleProjects.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesAcrossMultipleProjects.baseline.jsonc index ec494e6888..2b80f1d44d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesAcrossMultipleProjects.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesAcrossMultipleProjects.baseline.jsonc @@ -1,6 +1,14 @@ // === findAllReferences === // === /a.ts === -// /*FIND ALL REFS*/var x: number; +// /*FIND ALL REFS*/var [|x|]: number; + +// === /b.ts === +// /// +// [|x|]++; + +// === /c.ts === +// /// +// [|x|]++; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName2.baseline.jsonc index a3b65b722a..aac6454a10 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName2.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /index.tsx === -// /*FIND ALL REFS*/const obj = {Component: () =>

}; -// const element = ; +// /*FIND ALL REFS*/const [|obj|] = {Component: () =>
}; +// const element = <[|obj|].Component/>; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfArrowFunction.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfArrowFunction.baseline.jsonc index d47a9cd615..45d4e9154c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfArrowFunction.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfArrowFunction.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfArrowFunction.ts === -// /*FIND ALL REFS*/var f = x => x + 1; -// f(12); +// /*FIND ALL REFS*/var [|f|] = x => x + 1; +// [|f|](12); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc index 66aa26aa9b..250b824282 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc @@ -1,10 +1,12 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfClass.ts === -// /*FIND ALL REFS*/class C { +// /*FIND ALL REFS*/class [|C|] { // n: number; // constructor() { // this.n = 12; -// // --- (line: 5) skipped --- +// } +// } +// let c = new [|C|](); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfEnum.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfEnum.baseline.jsonc index e0b28c98c1..fc51da704e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfEnum.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfEnum.baseline.jsonc @@ -1,10 +1,10 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfEnum.ts === -// /*FIND ALL REFS*/enum E { +// /*FIND ALL REFS*/enum [|E|] { // First, // Second // } -// let first = E.First; +// let first = [|E|].First; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfFunction.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfFunction.baseline.jsonc index 93a9afb726..fb25553e8f 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfFunction.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfFunction.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfFunction.ts === -// /*FIND ALL REFS*/function func(x: number) { +// /*FIND ALL REFS*/function [|func|](x: number) { // } -// func(x) +// [|func|](x) diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterface.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterface.baseline.jsonc index 1d3cb221db..3465e29156 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterface.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterface.baseline.jsonc @@ -1,9 +1,9 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterface.ts === -// /*FIND ALL REFS*/interface I { +// /*FIND ALL REFS*/interface [|I|] { // p: number; // } -// let i: I = { p: 12 }; +// let i: [|I|] = { p: 12 }; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc index 0482d27845..06b881e54c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc @@ -1,10 +1,18 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterfaceClassMerge.ts === -// /*FIND ALL REFS*/interface Numbers { +// /*FIND ALL REFS*/interface [|Numbers|] { // p: number; // } -// interface Numbers { -// // --- (line: 5) skipped --- +// interface [|Numbers|] { +// m: number; +// } +// class [|Numbers|] { +// f(n: number) { +// return this.p + this.m + n; +// } +// } +// let i: [|Numbers|] = new [|Numbers|](); +// let x = i.f(i.p + i.m); @@ -28,14 +36,19 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterfaceClassMerge.ts === -// interface Numbers { +// interface [|Numbers|] { // p: number; // } -// /*FIND ALL REFS*/interface Numbers { +// /*FIND ALL REFS*/interface [|Numbers|] { // m: number; // } -// class Numbers { -// // --- (line: 8) skipped --- +// class [|Numbers|] { +// f(n: number) { +// return this.p + this.m + n; +// } +// } +// let i: [|Numbers|] = new [|Numbers|](); +// let x = i.f(i.p + i.m); @@ -59,15 +72,19 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterfaceClassMerge.ts === -// --- (line: 3) skipped --- -// interface Numbers { +// interface [|Numbers|] { +// p: number; +// } +// interface [|Numbers|] { // m: number; // } -// /*FIND ALL REFS*/class Numbers { +// /*FIND ALL REFS*/class [|Numbers|] { // f(n: number) { // return this.p + this.m + n; // } -// // --- (line: 11) skipped --- +// } +// let i: [|Numbers|] = new [|Numbers|](); +// let x = i.f(i.p + i.m); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfNamespace.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfNamespace.baseline.jsonc index bba65c8c91..1ea8914044 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfNamespace.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfNamespace.baseline.jsonc @@ -1,9 +1,9 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfNamespace.ts === -// /*FIND ALL REFS*/namespace Numbers { +// /*FIND ALL REFS*/namespace [|Numbers|] { // export var n = 12; // } -// let x = Numbers.n + 1; +// let x = [|Numbers|].n + 1; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfTypeAlias.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfTypeAlias.baseline.jsonc index 588c2d0769..7dfa3f7a3b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfTypeAlias.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfTypeAlias.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfTypeAlias.ts === -// /*FIND ALL REFS*/type Alias= number; -// let n: Alias = 12; +// /*FIND ALL REFS*/type [|Alias|]= number; +// let n: [|Alias|] = 12; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfVariable.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfVariable.baseline.jsonc index 3e18059318..9ee407ef13 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfVariable.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfVariable.baseline.jsonc @@ -1,10 +1,22 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfVariable.ts === -// /*FIND ALL REFS*/var x = 0; -// var assignmentRightHandSide = x; -// var assignmentRightHandSide2 = 1 + x; +// /*FIND ALL REFS*/var [|x|] = 0; +// var assignmentRightHandSide = [|x|]; +// var assignmentRightHandSide2 = 1 + [|x|]; +// +// [|x|] = 1; +// [|x|] = [|x|] + [|x|]; +// +// [|x|] == 1; +// [|x|] <= 1; // -// // --- (line: 5) skipped --- +// var preIncrement = ++[|x|]; +// var postIncrement = [|x|]++; +// var preDecrement = --[|x|]; +// var postDecrement = [|x|]--; +// +// [|x|] += 1; +// [|x|] <<= 1; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning0.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning0.baseline.jsonc index 662ccb87d3..db5fd49cb4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning0.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning0.baseline.jsonc @@ -19,9 +19,9 @@ // === findAllReferences === // === /a.js === // /** @typedef {number} T */ -// /*FIND ALL REFS*/const T = 1; +// /*FIND ALL REFS*/const [|T|] = 1; // /** @type {T} */ -// const n = T; +// const n = [|T|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning1.baseline.jsonc index 72f2f31da3..f67cbe6091 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/jsdocTypedefTagSemanticMeaning1.baseline.jsonc @@ -1,9 +1,9 @@ // === findAllReferences === // === /a.js === // /** @typedef {number} */ -// /*FIND ALL REFS*/const T = 1; +// /*FIND ALL REFS*/const [|T|] = 1; // /** @type {T} */ -// const n = T; +// const n = [|T|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/localGetReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/localGetReferences.baseline.jsonc index 3dd7634782..11a750c0a7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/localGetReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/localGetReferences.baseline.jsonc @@ -2,11 +2,71 @@ // === /localGetReferences_1.ts === // // Comment Refence Test: globalVar // // References to a variable declared in global. -// /*FIND ALL REFS*/var globalVar: number = 2; +// /*FIND ALL REFS*/var [|globalVar|]: number = 2; // // class fooCls { // // References to static variable declared in a class. -// // --- (line: 7) skipped --- +// static clsSVar = 1; +// // References to a variable declared in a class. +// clsVar = 1; +// +// constructor (public clsParam: number) { +// //Increments +// [|globalVar|]++; +// this.clsVar++; +// fooCls.clsSVar++; +// // References to a class parameter. +// // --- (line: 17) skipped --- + +// --- (line: 25) skipped --- +// +// //Increments +// fooCls.clsSVar++; +// [|globalVar|]++; +// modTest.modVar++; +// fnVar++; +// +// // --- (line: 33) skipped --- + +// --- (line: 38) skipped --- +// export var modVar:number; +// +// //Increments +// [|globalVar|]++; +// fooCls.clsSVar++; +// modVar++; +// +// // --- (line: 46) skipped --- + +// --- (line: 50) skipped --- +// static boo = foo; +// +// //Increments +// [|globalVar|]++; +// fooCls.clsSVar++; +// modVar++; +// } +// // --- (line: 58) skipped --- + +// --- (line: 65) skipped --- +// +// //Arguments +// // References to a class argument. +// clsTest = new fooCls([|globalVar|]); +// // References to a function argument. +// foo([|globalVar|]); +// +// //Increments +// fooCls.clsSVar++; +// modTest.modVar++; +// [|globalVar|] = [|globalVar|] + [|globalVar|]; +// +// //ETC - Other cases +// [|globalVar|] = 3; +// // References to illegal assignment. +// foo = foo + 1; +// err = err++; +// // --- (line: 83) skipped --- @@ -88,11 +148,59 @@ // // class fooCls { // // References to static variable declared in a class. -// /*FIND ALL REFS*/static clsSVar = 1; +// /*FIND ALL REFS*/static [|clsSVar|] = 1; // // References to a variable declared in a class. // clsVar = 1; // -// // --- (line: 11) skipped --- +// constructor (public clsParam: number) { +// //Increments +// globalVar++; +// this.clsVar++; +// fooCls.[|clsSVar|]++; +// // References to a class parameter. +// this.clsParam++; +// modTest.modVar++; +// // --- (line: 19) skipped --- + +// --- (line: 24) skipped --- +// var fnVar = 1; +// +// //Increments +// fooCls.[|clsSVar|]++; +// globalVar++; +// modTest.modVar++; +// fnVar++; +// // --- (line: 32) skipped --- + +// --- (line: 39) skipped --- +// +// //Increments +// globalVar++; +// fooCls.[|clsSVar|]++; +// modVar++; +// +// class testCls { +// // --- (line: 47) skipped --- + +// --- (line: 51) skipped --- +// +// //Increments +// globalVar++; +// fooCls.[|clsSVar|]++; +// modVar++; +// } +// +// // --- (line: 59) skipped --- + +// --- (line: 70) skipped --- +// foo(globalVar); +// +// //Increments +// fooCls.[|clsSVar|]++; +// modTest.modVar++; +// globalVar = globalVar + globalVar; +// +// // --- (line: 78) skipped --- @@ -183,11 +291,17 @@ // // References to a variable declared in a class. // clsVar = 1; // -// constructor (/*FIND ALL REFS*/public clsParam: number) { +// constructor (/*FIND ALL REFS*/public [|clsParam|]: number) { // //Increments // globalVar++; // this.clsVar++; -// // --- (line: 15) skipped --- +// fooCls.clsSVar++; +// // References to a class parameter. +// this.[|clsParam|]++; +// modTest.modVar++; +// } +// } +// // --- (line: 21) skipped --- @@ -390,12 +504,55 @@ // } // // // References to a function parameter. -// /*FIND ALL REFS*/function foo(x: number) { +// /*FIND ALL REFS*/function [|foo|](x: number) { // // References to a variable declared in a function. // var fnVar = 1; // // // --- (line: 27) skipped --- +// --- (line: 43) skipped --- +// modVar++; +// +// class testCls { +// static boo = [|foo|]; +// } +// +// function testFn(){ +// static boo = [|foo|]; +// +// //Increments +// globalVar++; +// fooCls.clsSVar++; +// modVar++; +// } +// +// module testMod { +// var boo = [|foo|]; +// } +// } +// +// // --- (line: 64) skipped --- + +// --- (line: 67) skipped --- +// // References to a class argument. +// clsTest = new fooCls(globalVar); +// // References to a function argument. +// [|foo|](globalVar); +// +// //Increments +// fooCls.clsSVar++; +// modTest.modVar++; +// globalVar = globalVar + globalVar; +// +// //ETC - Other cases +// globalVar = 3; +// // References to illegal assignment. +// [|foo|] = [|foo|] + 1; +// err = err++; +// +// //Shadowed fn Parameter +// // --- (line: 85) skipped --- + // === findAllReferences === @@ -485,11 +642,17 @@ // // References to a function parameter. // function foo(x: number) { // // References to a variable declared in a function. -// /*FIND ALL REFS*/var fnVar = 1; +// /*FIND ALL REFS*/var [|fnVar|] = 1; // // //Increments // fooCls.clsSVar++; -// // --- (line: 29) skipped --- +// globalVar++; +// modTest.modVar++; +// [|fnVar|]++; +// +// //Return +// return x++; +// // --- (line: 35) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients.baseline.jsonc index b70c6b36cd..9643fbc873 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForAmbients.baseline.jsonc @@ -1,10 +1,15 @@ // === findAllReferences === // === /referencesForAmbients.ts === -// /*FIND ALL REFS*/declare module "foo" { +// /*FIND ALL REFS*/declare module "[|foo|]" { // var f: number; // } // -// // --- (line: 5) skipped --- +// declare module "bar" { +// export import foo = require("[|foo|]"); +// var f2: typeof foo.f; +// } +// +// // --- (line: 10) skipped --- @@ -26,11 +31,16 @@ // === findAllReferences === // === /referencesForAmbients.ts === // declare module "foo" { -// /*FIND ALL REFS*/var f: number; +// /*FIND ALL REFS*/var [|f|]: number; // } // // declare module "bar" { -// // --- (line: 6) skipped --- +// export import foo = require("foo"); +// var f2: typeof foo.[|f|]; +// } +// +// declare module "baz" { +// // --- (line: 11) skipped --- @@ -56,11 +66,15 @@ // var f: number; // } // -// /*FIND ALL REFS*/declare module "bar" { +// /*FIND ALL REFS*/declare module "[|bar|]" { // export import foo = require("foo"); // var f2: typeof foo.f; // } -// // --- (line: 9) skipped --- +// +// declare module "baz" { +// import bar = require("[|bar|]"); +// var f2: typeof bar.foo; +// } @@ -89,11 +103,14 @@ // } // // declare module "bar" { -// /*FIND ALL REFS*/export import foo = require("foo"); -// var f2: typeof foo.f; +// /*FIND ALL REFS*/export import [|foo|] = require("foo"); +// var f2: typeof [|foo|].f; // } // -// // --- (line: 10) skipped --- +// declare module "baz" { +// import bar = require("bar"); +// var f2: typeof bar.[|foo|]; +// } @@ -170,8 +187,8 @@ // } // // declare module "baz" { -// /*FIND ALL REFS*/import bar = require("bar"); -// var f2: typeof bar.foo; +// /*FIND ALL REFS*/import [|bar|] = require("bar"); +// var f2: typeof [|bar|].foo; // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassLocal.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassLocal.baseline.jsonc index 6eba7c7b66..1644f2ca65 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassLocal.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassLocal.baseline.jsonc @@ -3,11 +3,18 @@ // var n = 14; // // class foo { -// /*FIND ALL REFS*/private n = 0; +// /*FIND ALL REFS*/private [|n|] = 0; // // public bar() { -// this.n = 9; -// // --- (line: 8) skipped --- +// this.[|n|] = 9; +// } +// +// constructor() { +// this.[|n|] = 4; +// } +// +// public bar2() { +// // --- (line: 15) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassParameter.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassParameter.baseline.jsonc index e5b662d166..b1565d329a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassParameter.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForClassParameter.baseline.jsonc @@ -5,11 +5,17 @@ // class p { } // // class foo { -// constructor (/*FIND ALL REFS*/public p: any) { +// constructor (/*FIND ALL REFS*/public [|p|]: any) { // } // // public f(p) { -// // --- (line: 10) skipped --- +// this.[|p|] = p; +// } +// +// } +// +// var n = new foo(undefined); +// n.[|p|] = null; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForDeclarationKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForDeclarationKeywords.baseline.jsonc index 1eaba5ce64..f690bc1ada 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForDeclarationKeywords.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForDeclarationKeywords.baseline.jsonc @@ -2,7 +2,7 @@ // === /referencesForDeclarationKeywords.ts === // class Base {} // interface Implemented1 {} -// /*FIND ALL REFS*/class C1 extends Base implements Implemented1 { +// /*FIND ALL REFS*/class [|C1|] extends Base implements Implemented1 { // get e() { return 1; } // set e(v) {} // } @@ -12,21 +12,25 @@ // === findAllReferences === // === /referencesForDeclarationKeywords.ts === -// class Base {} +// class [|Base|] {} // interface Implemented1 {} -// class C1 /*FIND ALL REFS*/extends Base implements Implemented1 { +// class C1 /*FIND ALL REFS*/extends [|Base|] implements Implemented1 { // get e() { return 1; } // set e(v) {} // } -// // --- (line: 7) skipped --- +// interface I1 extends [|Base|] { } +// type T = { } +// enum E { } +// namespace N { } +// // --- (line: 11) skipped --- // === findAllReferences === // === /referencesForDeclarationKeywords.ts === // class Base {} -// interface Implemented1 {} -// class C1 extends Base /*FIND ALL REFS*/implements Implemented1 { +// interface [|Implemented1|] {} +// class C1 extends Base /*FIND ALL REFS*/implements [|Implemented1|] { // get e() { return 1; } // set e(v) {} // } @@ -50,11 +54,12 @@ // class Base {} // interface Implemented1 {} // class C1 extends Base implements Implemented1 { -// /*FIND ALL REFS*/get e() { return 1; } -// set e(v) {} +// /*FIND ALL REFS*/get [|e|]() { return 1; } +// set [|e|](v) {} // } // interface I1 extends Base { } -// // --- (line: 8) skipped --- +// type T = { } +// // --- (line: 9) skipped --- @@ -63,8 +68,8 @@ // class Base {} // interface Implemented1 {} // class C1 extends Base implements Implemented1 { -// get e() { return 1; } -// /*FIND ALL REFS*/set e(v) {} +// get [|e|]() { return 1; } +// /*FIND ALL REFS*/set [|e|](v) {} // } // interface I1 extends Base { } // type T = { } @@ -78,7 +83,7 @@ // get e() { return 1; } // set e(v) {} // } -// /*FIND ALL REFS*/interface I1 extends Base { } +// /*FIND ALL REFS*/interface [|I1|] extends Base { } // type T = { } // enum E { } // namespace N { } @@ -88,11 +93,13 @@ // === findAllReferences === // === /referencesForDeclarationKeywords.ts === -// --- (line: 3) skipped --- +// class [|Base|] {} +// interface Implemented1 {} +// class C1 extends [|Base|] implements Implemented1 { // get e() { return 1; } // set e(v) {} // } -// interface I1 /*FIND ALL REFS*/extends Base { } +// interface I1 /*FIND ALL REFS*/extends [|Base|] { } // type T = { } // enum E { } // namespace N { } @@ -116,7 +123,7 @@ // set e(v) {} // } // interface I1 extends Base { } -// /*FIND ALL REFS*/type T = { } +// /*FIND ALL REFS*/type [|T|] = { } // enum E { } // namespace N { } // module M { } @@ -130,7 +137,7 @@ // } // interface I1 extends Base { } // type T = { } -// /*FIND ALL REFS*/enum E { } +// /*FIND ALL REFS*/enum [|E|] { } // namespace N { } // module M { } // function fn() {} @@ -144,7 +151,7 @@ // interface I1 extends Base { } // type T = { } // enum E { } -// /*FIND ALL REFS*/namespace N { } +// /*FIND ALL REFS*/namespace [|N|] { } // module M { } // function fn() {} // var x; @@ -158,7 +165,7 @@ // type T = { } // enum E { } // namespace N { } -// /*FIND ALL REFS*/module M { } +// /*FIND ALL REFS*/module [|M|] { } // function fn() {} // var x; // let y; @@ -172,7 +179,7 @@ // enum E { } // namespace N { } // module M { } -// /*FIND ALL REFS*/function fn() {} +// /*FIND ALL REFS*/function [|fn|]() {} // var x; // let y; // const z = 1; @@ -186,7 +193,7 @@ // namespace N { } // module M { } // function fn() {} -// /*FIND ALL REFS*/var x; +// /*FIND ALL REFS*/var [|x|]; // let y; // const z = 1; // interface Implemented2 {} @@ -200,7 +207,7 @@ // module M { } // function fn() {} // var x; -// /*FIND ALL REFS*/let y; +// /*FIND ALL REFS*/let [|y|]; // const z = 1; // interface Implemented2 {} // interface Implemented3 {} @@ -215,7 +222,7 @@ // function fn() {} // var x; // let y; -// /*FIND ALL REFS*/const z = 1; +// /*FIND ALL REFS*/const [|z|] = 1; // interface Implemented2 {} // interface Implemented3 {} // class C2 implements Implemented2, Implemented3 {} diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExpressionKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExpressionKeywords.baseline.jsonc index 845f1c7ced..c7d0181ab8 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExpressionKeywords.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExpressionKeywords.baseline.jsonc @@ -1,83 +1,114 @@ // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// class C { +// class [|C|] { // static x = 1; // } -// /*FIND ALL REFS*/new C(); -// void C; -// typeof C; -// delete C.x; -// // --- (line: 8) skipped --- +// /*FIND ALL REFS*/new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; +// async function* f() { +// yield [|C|]; +// await [|C|]; +// } +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// class C { +// class [|C|] { // static x = 1; // } -// new C(); -// /*FIND ALL REFS*/void C; -// typeof C; -// delete C.x; +// new [|C|](); +// /*FIND ALL REFS*/void [|C|]; +// typeof [|C|]; +// delete [|C|].x; // async function* f() { -// // --- (line: 9) skipped --- +// yield [|C|]; +// await [|C|]; +// } +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// class C { +// class [|C|] { // static x = 1; // } -// new C(); -// void C; -// /*FIND ALL REFS*/[|typeof|] C; -// delete C.x; +// new [|C|](); +// void [|C|]; +// /*FIND ALL REFS*/typeof [|C|]; +// delete [|C|].x; // async function* f() { -// yield C; -// // --- (line: 10) skipped --- +// yield [|C|]; +// await [|C|]; +// } +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 5) skipped --- -// typeof C; -// delete C.x; +// class [|C|] { +// static x = 1; +// } +// new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; // async function* f() { -// /*FIND ALL REFS*/yield C; -// await C; +// /*FIND ALL REFS*/yield [|C|]; +// await [|C|]; // } -// "x" in C; -// undefined instanceof C; -// undefined as C; +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 6) skipped --- -// delete C.x; +// class [|C|] { +// static x = 1; +// } +// new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; // async function* f() { -// yield C; -// /*FIND ALL REFS*/await C; +// yield [|C|]; +// /*FIND ALL REFS*/await [|C|]; // } -// "x" in C; -// undefined instanceof C; -// undefined as C; +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 8) skipped --- -// yield C; -// await C; +// class [|C|] { +// static x = 1; // } -// "x" /*FIND ALL REFS*/in C; -// undefined instanceof C; -// undefined as C; +// new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; +// async function* f() { +// yield [|C|]; +// await [|C|]; +// } +// "x" /*FIND ALL REFS*/in [|C|]; +// undefined instanceof [|C|]; +// undefined as [|C|]; @@ -102,21 +133,32 @@ // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 10) skipped --- +// class [|C|] { +// static x = 1; // } -// "x" in C; -// undefined instanceof C; -// undefined /*FIND ALL REFS*/as C; +// new [|C|](); +// void [|C|]; +// typeof [|C|]; +// delete [|C|].x; +// async function* f() { +// yield [|C|]; +// await [|C|]; +// } +// "x" in [|C|]; +// undefined instanceof [|C|]; +// undefined /*FIND ALL REFS*/as [|C|]; // === findAllReferences === // === /referencesForExpressionKeywords.ts === -// --- (line: 3) skipped --- +// class C { +// static [|x|] = 1; +// } // new C(); // void C; // typeof C; -// /*FIND ALL REFS*/delete C.x; +// /*FIND ALL REFS*/delete C.[|x|]; // async function* f() { // yield C; // await C; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExternalModuleNames.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExternalModuleNames.baseline.jsonc index 6f1cb201fe..cdbcdc4593 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForExternalModuleNames.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForExternalModuleNames.baseline.jsonc @@ -1,9 +1,12 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/declare module "foo" { +// /*FIND ALL REFS*/declare module "[|foo|]" { // var f: number; // } +// === /referencesForGlobals_2.ts === +// import f = require("[|foo|]"); + // === findAllReferences === @@ -19,7 +22,7 @@ // === findAllReferences === // === /referencesForGlobals_2.ts === -// /*FIND ALL REFS*/import f = require("foo"); +// /*FIND ALL REFS*/import [|f|] = require("foo"); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForFunctionOverloads.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForFunctionOverloads.baseline.jsonc index 86de4ff51c..02172bb86d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForFunctionOverloads.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForFunctionOverloads.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /referencesForFunctionOverloads.ts === -// /*FIND ALL REFS*/function foo(x: string); -// function foo(x: string, y: number) { -// foo('', 43); +// /*FIND ALL REFS*/function [|foo|](x: string); +// function [|foo|](x: string, y: number) { +// [|foo|]('', 43); // } @@ -18,9 +18,9 @@ // === findAllReferences === // === /referencesForFunctionOverloads.ts === -// function foo(x: string); -// /*FIND ALL REFS*/function foo(x: string, y: number) { -// foo('', 43); +// function [|foo|](x: string); +// /*FIND ALL REFS*/function [|foo|](x: string, y: number) { +// [|foo|]('', 43); // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals.baseline.jsonc index 54bec186f0..7942e20845 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals.baseline.jsonc @@ -1,10 +1,26 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/var global = 2; +// /*FIND ALL REFS*/var [|global|] = 2; // // class foo { // constructor (public global) { } -// // --- (line: 5) skipped --- +// public f(global) { } +// public f2(global) { } +// } +// +// class bar { +// constructor () { +// var n = [|global|]; +// +// var f = new foo(''); +// f.global = ''; +// } +// } +// +// var k = [|global|]; + +// === /referencesForGlobals_2.ts === +// var m = [|global|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc index 31467511fe..d610d04261 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc @@ -1,9 +1,12 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/class globalClass { +// /*FIND ALL REFS*/class [|globalClass|] { // public f() { } // } +// === /referencesForGlobals_2.ts === +// var c = [|globalClass|](); + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals3.baseline.jsonc index 79f09ba209..900a8652b7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals3.baseline.jsonc @@ -1,9 +1,12 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/interface globalInterface { +// /*FIND ALL REFS*/interface [|globalInterface|] { // f(); // } +// === /referencesForGlobals_2.ts === +// var i: [|globalInterface|]; + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals4.baseline.jsonc index 92d11768c4..0d1e16d30b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals4.baseline.jsonc @@ -1,9 +1,12 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// /*FIND ALL REFS*/module globalModule { +// /*FIND ALL REFS*/module [|globalModule|] { // export f() { }; // } +// === /referencesForGlobals_2.ts === +// var m = [|globalModule|]; + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals5.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals5.baseline.jsonc index 1345e76576..1fe53ef3aa 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals5.baseline.jsonc @@ -4,7 +4,10 @@ // export var x; // } // -// /*FIND ALL REFS*/import globalAlias = globalModule; +// /*FIND ALL REFS*/import [|globalAlias|] = globalModule; + +// === /referencesForGlobals_2.ts === +// var m = [|globalAlias|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc index 73e1bc6410..f676331fc7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc @@ -1,10 +1,11 @@ // === findAllReferences === // === /referencesForGlobalsInExternalModule.ts === -// /*FIND ALL REFS*/var topLevelVar = 2; -// var topLevelVar2 = topLevelVar; +// /*FIND ALL REFS*/var [|topLevelVar|] = 2; +// var topLevelVar2 = [|topLevelVar|]; // // class topLevelClass { } -// // --- (line: 5) skipped --- +// var c = new topLevelClass(); +// // --- (line: 6) skipped --- @@ -35,11 +36,12 @@ // var topLevelVar = 2; // var topLevelVar2 = topLevelVar; // -// /*FIND ALL REFS*/class topLevelClass { } -// var c = new topLevelClass(); +// /*FIND ALL REFS*/class [|topLevelClass|] { } +// var c = new [|topLevelClass|](); // // interface topLevelInterface { } -// // --- (line: 8) skipped --- +// var i: topLevelInterface; +// // --- (line: 9) skipped --- @@ -77,11 +79,12 @@ // class topLevelClass { } // var c = new topLevelClass(); // -// /*FIND ALL REFS*/interface topLevelInterface { } -// var i: topLevelInterface; +// /*FIND ALL REFS*/interface [|topLevelInterface|] { } +// var i: [|topLevelInterface|]; // // module topLevelModule { -// // --- (line: 11) skipped --- +// export var x; +// // --- (line: 12) skipped --- @@ -121,10 +124,10 @@ // interface topLevelInterface { } // var i: topLevelInterface; // -// /*FIND ALL REFS*/module topLevelModule { +// /*FIND ALL REFS*/module [|topLevelModule|] { // export var x; // } -// var x = topLevelModule.x; +// var x = [|topLevelModule|].x; // // export = x; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForImports.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForImports.baseline.jsonc index 81aaedb024..bd03e117e5 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForImports.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForImports.baseline.jsonc @@ -4,8 +4,8 @@ // function $(s: string): any; // export = $; // } -// /*FIND ALL REFS*/import $ = require("jquery"); -// $("a"); +// /*FIND ALL REFS*/import [|$|] = require("jquery"); +// [|$|]("a"); // import $ = require("jquery"); @@ -40,7 +40,7 @@ // } // import $ = require("jquery"); // $("a"); -// /*FIND ALL REFS*/import $ = require("jquery"); +// /*FIND ALL REFS*/import [|$|] = require("jquery"); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations.baseline.jsonc index 9a876c8f4b..d6508f7d33 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations.baseline.jsonc @@ -1,11 +1,18 @@ // === findAllReferences === // === /referencesForMergedDeclarations.ts === -// /*FIND ALL REFS*/interface Foo { +// /*FIND ALL REFS*/interface [|Foo|] { // } // // module Foo { // // --- (line: 5) skipped --- +// --- (line: 8) skipped --- +// } +// +// var f1: Foo.Bar; +// var f2: [|Foo|]; +// Foo.bind(this); + // === findAllReferences === @@ -30,11 +37,16 @@ // interface Foo { // } // -// /*FIND ALL REFS*/module Foo { +// /*FIND ALL REFS*/module [|Foo|] { // export interface Bar { } // } // -// // --- (line: 8) skipped --- +// function Foo(): void { +// } +// +// var f1: [|Foo|].Bar; +// var f2: Foo; +// Foo.bind(this); @@ -62,12 +74,12 @@ // export interface Bar { } // } // -// /*FIND ALL REFS*/function Foo(): void { +// /*FIND ALL REFS*/function [|Foo|](): void { // } // // var f1: Foo.Bar; // var f2: Foo; -// Foo.bind(this); +// [|Foo|].bind(this); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations2.baseline.jsonc index 377113b9d1..fa095d184e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations2.baseline.jsonc @@ -4,10 +4,10 @@ // // function ATest() { } // -// /*FIND ALL REFS*/import alias = ATest; // definition +// /*FIND ALL REFS*/import [|alias|] = ATest; // definition // -// var a: alias.Bar; // namespace -// alias.call(this); // value +// var a: [|alias|].Bar; // namespace +// [|alias|].call(this); // value diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc index fc54de7f4b..5896510ddb 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc @@ -1,10 +1,24 @@ // === findAllReferences === // === /referencesForMergedDeclarations4.ts === -// /*FIND ALL REFS*/class testClass { +// /*FIND ALL REFS*/class [|testClass|] { // static staticMethod() { } // method() { } // } -// // --- (line: 5) skipped --- +// +// module [|testClass|] { +// export interface Bar { +// +// } +// export var s = 0; +// } +// +// var c1: [|testClass|]; +// var c2: [|testClass|].Bar; +// [|testClass|].staticMethod(); +// [|testClass|].prototype.method(); +// [|testClass|].bind(this); +// [|testClass|].s; +// new [|testClass|](); @@ -34,16 +48,25 @@ // === findAllReferences === // === /referencesForMergedDeclarations4.ts === -// class testClass { +// class [|testClass|] { // static staticMethod() { } // method() { } // } // -// /*FIND ALL REFS*/module testClass { +// /*FIND ALL REFS*/module [|testClass|] { // export interface Bar { // // } -// // --- (line: 10) skipped --- +// export var s = 0; +// } +// +// var c1: [|testClass|]; +// var c2: [|testClass|].Bar; +// [|testClass|].staticMethod(); +// [|testClass|].prototype.method(); +// [|testClass|].bind(this); +// [|testClass|].s; +// new [|testClass|](); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations6.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations6.baseline.jsonc index f7f9fd6965..7746adb1e4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations6.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations6.baseline.jsonc @@ -1,11 +1,14 @@ // === findAllReferences === // === /referencesForMergedDeclarations6.ts === // interface Foo { } -// /*FIND ALL REFS*/module Foo { +// /*FIND ALL REFS*/module [|Foo|] { // export interface Bar { } // export module Bar { export interface Baz { } } // export function Bar() { } -// // --- (line: 6) skipped --- +// } +// +// // module +// import a1 = [|Foo|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations8.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations8.baseline.jsonc index ce8d974534..01b41d14f3 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations8.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations8.baseline.jsonc @@ -3,12 +3,12 @@ // interface Foo { } // module Foo { // export interface Bar { } -// /*FIND ALL REFS*/export module Bar { export interface Baz { } } +// /*FIND ALL REFS*/export module [|Bar|] { export interface Baz { } } // export function Bar() { } // } // // // module -// import a3 = Foo.Bar.Baz; +// import a3 = Foo.[|Bar|].Baz; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForModifiers.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForModifiers.baseline.jsonc index b4505a6fce..5edfd5392f 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForModifiers.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForModifiers.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /referencesForModifiers.ts === -// /*FIND ALL REFS*/declare abstract class C1 { +// /*FIND ALL REFS*/declare abstract class [|C1|] { // static a; // readonly b; // public c; @@ -10,7 +10,7 @@ // === findAllReferences === // === /referencesForModifiers.ts === -// declare /*FIND ALL REFS*/abstract class C1 { +// declare /*FIND ALL REFS*/abstract class [|C1|] { // static a; // readonly b; // public c; @@ -21,7 +21,7 @@ // === findAllReferences === // === /referencesForModifiers.ts === // declare abstract class C1 { -// /*FIND ALL REFS*/static a; +// /*FIND ALL REFS*/static [|a|]; // readonly b; // public c; // protected d; @@ -33,7 +33,7 @@ // === /referencesForModifiers.ts === // declare abstract class C1 { // static a; -// /*FIND ALL REFS*/readonly b; +// /*FIND ALL REFS*/readonly [|b|]; // public c; // protected d; // private e; @@ -46,7 +46,7 @@ // declare abstract class C1 { // static a; // readonly b; -// /*FIND ALL REFS*/public c; +// /*FIND ALL REFS*/public [|c|]; // protected d; // private e; // } @@ -60,7 +60,7 @@ // static a; // readonly b; // public c; -// /*FIND ALL REFS*/protected d; +// /*FIND ALL REFS*/protected [|d|]; // private e; // } // const enum E { @@ -75,7 +75,7 @@ // readonly b; // public c; // protected d; -// /*FIND ALL REFS*/private e; +// /*FIND ALL REFS*/private [|e|]; // } // const enum E { // } @@ -90,7 +90,7 @@ // protected d; // private e; // } -// /*FIND ALL REFS*/const enum E { +// /*FIND ALL REFS*/const enum [|E|] { // } // async function fn() {} // export default class C2 {} @@ -103,7 +103,7 @@ // } // const enum E { // } -// /*FIND ALL REFS*/async function fn() {} +// /*FIND ALL REFS*/async function [|fn|]() {} // export default class C2 {} @@ -114,7 +114,7 @@ // const enum E { // } // async function fn() {} -// /*FIND ALL REFS*/export default class C2 {} +// /*FIND ALL REFS*/export default class [|C2|] {} diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatic.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatic.baseline.jsonc index d51eb433e8..05be2ced9c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatic.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatic.baseline.jsonc @@ -3,11 +3,29 @@ // var n = 43; // // class foo { -// /*FIND ALL REFS*/static n = ''; +// /*FIND ALL REFS*/static [|n|] = ''; // // public bar() { -// foo.n = "'"; -// // --- (line: 8) skipped --- +// foo.[|n|] = "'"; +// if(foo.[|n|]) { +// var x = foo.[|n|]; +// } +// } +// } +// +// class foo2 { +// private x = foo.[|n|]; +// constructor() { +// foo.[|n|] = x; +// } +// +// function b(n) { +// n = foo.[|n|]; +// } +// } + +// === /referencesOnStatic_2.ts === +// var q = foo.[|n|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStaticsAndMembersWithSameNames.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStaticsAndMembersWithSameNames.baseline.jsonc index 84334b385e..98a98b58e6 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStaticsAndMembersWithSameNames.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStaticsAndMembersWithSameNames.baseline.jsonc @@ -27,12 +27,20 @@ // module MixedStaticsClassTest { // export class Foo { // bar: Foo; -// /*FIND ALL REFS*/static bar: Foo; +// /*FIND ALL REFS*/static [|bar|]: Foo; // // public foo(): void { // } // // --- (line: 9) skipped --- +// --- (line: 18) skipped --- +// +// // static function +// MixedStaticsClassTest.Foo.foo(); +// MixedStaticsClassTest.Foo.[|bar|]; +// } +// } + // === findAllReferences === @@ -63,11 +71,21 @@ // bar: Foo; // static bar: Foo; // -// /*FIND ALL REFS*/public foo(): void { +// /*FIND ALL REFS*/public [|foo|](): void { // } // public static foo(): void { // } -// // --- (line: 11) skipped --- +// } +// } +// +// function test() { +// // instance function +// var x = new MixedStaticsClassTest.Foo(); +// x.[|foo|](); +// x.bar; +// +// // static function +// // --- (line: 21) skipped --- @@ -101,12 +119,21 @@ // // public foo(): void { // } -// /*FIND ALL REFS*/public static foo(): void { +// /*FIND ALL REFS*/public static [|foo|](): void { // } // } // } // // --- (line: 13) skipped --- +// --- (line: 17) skipped --- +// x.bar; +// +// // static function +// MixedStaticsClassTest.Foo.[|foo|](); +// MixedStaticsClassTest.Foo.bar; +// } +// } + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStringLiteralPropertyNames3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStringLiteralPropertyNames3.baseline.jsonc index 3a61f5954d..d2ff4badc6 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStringLiteralPropertyNames3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStringLiteralPropertyNames3.baseline.jsonc @@ -1,12 +1,12 @@ // === findAllReferences === // === /referencesForStringLiteralPropertyNames3.ts === // class Foo2 { -// /*FIND ALL REFS*/get "42"() { return 0; } -// set 42(n) { } +// /*FIND ALL REFS*/get "[|42|]"() { return 0; } +// set [|42|](n) { } // } // // var y: Foo2; -// y[42]; +// y[[|42|]]; @@ -25,12 +25,12 @@ // === findAllReferences === // === /referencesForStringLiteralPropertyNames3.ts === // class Foo2 { -// get "42"() { return 0; } -// /*FIND ALL REFS*/set 42(n) { } +// get "[|42|]"() { return 0; } +// /*FIND ALL REFS*/set [|42|](n) { } // } // // var y: Foo2; -// y[42]; +// y[[|42|]]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForTypeKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForTypeKeywords.baseline.jsonc index e458b9c5e7..343a4a0883 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForTypeKeywords.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForTypeKeywords.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /referencesForTypeKeywords.ts === -// interface I {} -// function f() {} +// interface [|I|] {} +// function f() {} // type A1 = T extends U ? 1 : 0; // type A2 = T extends infer U ? 1 : 0; // type A3 = { [P in keyof T]: 1 }; @@ -14,7 +14,7 @@ // === /referencesForTypeKeywords.ts === // interface I {} // function f() {} -// type A1 = T /*FIND ALL REFS*/extends U ? 1 : 0; +// type A1 = T /*FIND ALL REFS*/extends [|U|] ? 1 : 0; // type A2 = T extends infer U ? 1 : 0; // type A3 = { [P in keyof T]: 1 }; // type A4 = keyof T; @@ -27,7 +27,7 @@ // interface I {} // function f() {} // type A1 = T extends U ? 1 : 0; -// type A2 = T extends /*FIND ALL REFS*/[|infer|] U ? 1 : 0; +// type A2 = T extends /*FIND ALL REFS*/infer [|U|] ? 1 : 0; // type A3 = { [P in keyof T]: 1 }; // type A4 = keyof T; // type A5 = readonly T[]; @@ -40,7 +40,7 @@ // function f() {} // type A1 = T extends U ? 1 : 0; // type A2 = T extends infer U ? 1 : 0; -// type A3 = { [P /*FIND ALL REFS*/in keyof T]: 1 }; +// type A3 = { [[|P|] /*FIND ALL REFS*/in keyof T]: 1 }; // type A4 = keyof T; // type A5 = readonly T[]; @@ -52,8 +52,8 @@ // function f() {} // type A1 = T extends U ? 1 : 0; // type A2 = T extends infer U ? 1 : 0; -// type A3 = { [P in [|keyof|] T]: 1 }; -// type A4 = /*FIND ALL REFS*/[|keyof|] T; +// type A3 = { [P in keyof T]: 1 }; +// type A4<[|T|]> = /*FIND ALL REFS*/keyof [|T|]; // type A5 = readonly T[]; @@ -64,4 +64,4 @@ // type A2 = T extends infer U ? 1 : 0; // type A3 = { [P in keyof T]: 1 }; // type A4 = keyof T; -// type A5 = /*FIND ALL REFS*/[|readonly|] T[]; \ No newline at end of file +// type A5<[|T|]> = /*FIND ALL REFS*/readonly [|T|][]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc index 2515a755e4..3858ed4b25 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc @@ -682,12 +682,71 @@ // === findAllReferences === +// === /remoteGetReferences_1.ts === +// --- (line: 85) skipped --- +// var remoteclsTest: remotefooCls; +// +// //Arguments +// remoteclsTest = new remotefooCls([|remoteglobalVar|]); +// remotefoo([|remoteglobalVar|]); +// +// //Increments +// remotefooCls.remoteclsSVar++; +// remotemodTest.remotemodVar++; +// [|remoteglobalVar|] = [|remoteglobalVar|] + [|remoteglobalVar|]; +// +// //ETC - Other cases +// [|remoteglobalVar|] = 3; +// +// //Find References misses method param +// var +// // --- (line: 102) skipped --- + // === /remoteGetReferences_2.ts === -// /*FIND ALL REFS*/var remoteglobalVar: number = 2; +// /*FIND ALL REFS*/var [|remoteglobalVar|]: number = 2; // // class remotefooCls { // //Declare -// // --- (line: 5) skipped --- +// remoteclsVar = 1; +// static remoteclsSVar = 1; +// +// constructor(public remoteclsParam: number) { +// //Increments +// [|remoteglobalVar|]++; +// this.remoteclsVar++; +// remotefooCls.remoteclsSVar++; +// this.remoteclsParam++; +// // --- (line: 14) skipped --- + +// --- (line: 20) skipped --- +// +// //Increments +// remotefooCls.remoteclsSVar++; +// [|remoteglobalVar|]++; +// remotemodTest.remotemodVar++; +// remotefnVar++; +// +// // --- (line: 28) skipped --- + +// --- (line: 33) skipped --- +// export var remotemodVar: number; +// +// //Increments +// [|remoteglobalVar|]++; +// remotefooCls.remoteclsSVar++; +// remotemodVar++; +// +// // --- (line: 41) skipped --- + +// --- (line: 45) skipped --- +// static remoteboo = remotefoo; +// +// //Increments +// [|remoteglobalVar|]++; +// remotefooCls.remoteclsSVar++; +// remotemodVar++; +// } +// // --- (line: 53) skipped --- @@ -761,14 +820,71 @@ // === findAllReferences === +// === /remoteGetReferences_1.ts === +// --- (line: 82) skipped --- +// +// //Remotes +// //Type test +// var remoteclsTest: [|remotefooCls|]; +// +// //Arguments +// remoteclsTest = new [|remotefooCls|](remoteglobalVar); +// remotefoo(remoteglobalVar); +// +// //Increments +// [|remotefooCls|].remoteclsSVar++; +// remotemodTest.remotemodVar++; +// remoteglobalVar = remoteglobalVar + remoteglobalVar; +// +// // --- (line: 97) skipped --- + // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; // -// /*FIND ALL REFS*/class remotefooCls { +// /*FIND ALL REFS*/class [|remotefooCls|] { // //Declare // remoteclsVar = 1; // static remoteclsSVar = 1; -// // --- (line: 7) skipped --- +// +// constructor(public remoteclsParam: number) { +// //Increments +// remoteglobalVar++; +// this.remoteclsVar++; +// [|remotefooCls|].remoteclsSVar++; +// this.remoteclsParam++; +// remotemodTest.remotemodVar++; +// } +// // --- (line: 16) skipped --- + +// --- (line: 19) skipped --- +// var remotefnVar = 1; +// +// //Increments +// [|remotefooCls|].remoteclsSVar++; +// remoteglobalVar++; +// remotemodTest.remotemodVar++; +// remotefnVar++; +// // --- (line: 27) skipped --- + +// --- (line: 34) skipped --- +// +// //Increments +// remoteglobalVar++; +// [|remotefooCls|].remoteclsSVar++; +// remotemodVar++; +// +// class remotetestCls { +// // --- (line: 42) skipped --- + +// --- (line: 46) skipped --- +// +// //Increments +// remoteglobalVar++; +// [|remotefooCls|].remoteclsSVar++; +// remotemodVar++; +// } +// +// // --- (line: 54) skipped --- @@ -862,17 +978,64 @@ // === findAllReferences === +// === /remoteGetReferences_1.ts === +// --- (line: 89) skipped --- +// remotefoo(remoteglobalVar); +// +// //Increments +// remotefooCls.[|remoteclsSVar|]++; +// remotemodTest.remotemodVar++; +// remoteglobalVar = remoteglobalVar + remoteglobalVar; +// +// // --- (line: 97) skipped --- + // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; // // class remotefooCls { // //Declare // remoteclsVar = 1; -// /*FIND ALL REFS*/static remoteclsSVar = 1; +// /*FIND ALL REFS*/static [|remoteclsSVar|] = 1; // // constructor(public remoteclsParam: number) { // //Increments -// // --- (line: 10) skipped --- +// remoteglobalVar++; +// this.remoteclsVar++; +// remotefooCls.[|remoteclsSVar|]++; +// this.remoteclsParam++; +// remotemodTest.remotemodVar++; +// } +// // --- (line: 16) skipped --- + +// --- (line: 19) skipped --- +// var remotefnVar = 1; +// +// //Increments +// remotefooCls.[|remoteclsSVar|]++; +// remoteglobalVar++; +// remotemodTest.remotemodVar++; +// remotefnVar++; +// // --- (line: 27) skipped --- + +// --- (line: 34) skipped --- +// +// //Increments +// remoteglobalVar++; +// remotefooCls.[|remoteclsSVar|]++; +// remotemodVar++; +// +// class remotetestCls { +// // --- (line: 42) skipped --- + +// --- (line: 46) skipped --- +// +// //Increments +// remoteglobalVar++; +// remotefooCls.[|remoteclsSVar|]++; +// remotemodVar++; +// } +// +// // --- (line: 54) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc index a65332382e..2fb055c836 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc @@ -4,11 +4,14 @@ // } // interface ElementAttributesProperty { props } // } -// /*FIND ALL REFS*/class MyClass { +// /*FIND ALL REFS*/class [|MyClass|] { // props: { // name?: string; // size?: number; -// // --- (line: 11) skipped --- +// } +// +// +// var x = <[|MyClass|] name='hello'>; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences5.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences5.baseline.jsonc index 8c15f502a3..c7fa566bf2 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences5.baseline.jsonc @@ -4,12 +4,12 @@ // propString: string // optional?: boolean // } -// /*FIND ALL REFS*/declare function Opt(attributes: OptionPropBag): JSX.Element; -// let opt = ; -// let opt1 = ; -// let opt2 = ; -// let opt3 = ; -// let opt4 = ; +// /*FIND ALL REFS*/declare function [|Opt|](attributes: OptionPropBag): JSX.Element; +// let opt = <[|Opt|] />; +// let opt1 = <[|Opt|] propx={100} propString />; +// let opt2 = <[|Opt|] propx={100} optional/>; +// let opt3 = <[|Opt|] wrong />; +// let opt4 = <[|Opt|] propx={100} propString="hi" />; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences8.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences8.baseline.jsonc index 4cce5cf782..dac2cf2682 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences8.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences8.baseline.jsonc @@ -4,11 +4,15 @@ // interface LinkProps extends ClickableProps { // goTo: string; // } -// /*FIND ALL REFS*/declare function MainButton(buttonProps: ButtonProps): JSX.Element; -// declare function MainButton(linkProps: LinkProps): JSX.Element; -// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element; -// let opt = ; -// // --- (line: 21) skipped --- +// /*FIND ALL REFS*/declare function [|MainButton|](buttonProps: ButtonProps): JSX.Element; +// declare function [|MainButton|](linkProps: LinkProps): JSX.Element; +// declare function [|MainButton|](props: ButtonProps | LinkProps): JSX.Element; +// let opt = <[|MainButton|] />; +// let opt = <[|MainButton|] children="chidlren" />; +// let opt = <[|MainButton|] onClick={()=>{}} />; +// let opt = <[|MainButton|] onClick={()=>{}} ignore-prop />; +// let opt = <[|MainButton|] goTo="goTo" />; +// let opt = <[|MainButton|] wrong />; @@ -32,15 +36,19 @@ // === findAllReferences === // === /file.tsx === -// --- (line: 14) skipped --- +// --- (line: 13) skipped --- +// interface LinkProps extends ClickableProps { // goTo: string; // } -// declare function MainButton(buttonProps: ButtonProps): JSX.Element; -// /*FIND ALL REFS*/declare function MainButton(linkProps: LinkProps): JSX.Element; -// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element; -// let opt = ; -// let opt = ; -// // --- (line: 22) skipped --- +// declare function [|MainButton|](buttonProps: ButtonProps): JSX.Element; +// /*FIND ALL REFS*/declare function [|MainButton|](linkProps: LinkProps): JSX.Element; +// declare function [|MainButton|](props: ButtonProps | LinkProps): JSX.Element; +// let opt = <[|MainButton|] />; +// let opt = <[|MainButton|] children="chidlren" />; +// let opt = <[|MainButton|] onClick={()=>{}} />; +// let opt = <[|MainButton|] onClick={()=>{}} ignore-prop />; +// let opt = <[|MainButton|] goTo="goTo" />; +// let opt = <[|MainButton|] wrong />; @@ -64,15 +72,19 @@ // === findAllReferences === // === /file.tsx === -// --- (line: 15) skipped --- +// --- (line: 13) skipped --- +// interface LinkProps extends ClickableProps { +// goTo: string; // } -// declare function MainButton(buttonProps: ButtonProps): JSX.Element; -// declare function MainButton(linkProps: LinkProps): JSX.Element; -// /*FIND ALL REFS*/declare function MainButton(props: ButtonProps | LinkProps): JSX.Element; -// let opt = ; -// let opt = ; -// let opt = {}} />; -// // --- (line: 23) skipped --- +// declare function [|MainButton|](buttonProps: ButtonProps): JSX.Element; +// declare function [|MainButton|](linkProps: LinkProps): JSX.Element; +// /*FIND ALL REFS*/declare function [|MainButton|](props: ButtonProps | LinkProps): JSX.Element; +// let opt = <[|MainButton|] />; +// let opt = <[|MainButton|] children="chidlren" />; +// let opt = <[|MainButton|] onClick={()=>{}} />; +// let opt = <[|MainButton|] onClick={()=>{}} ignore-prop />; +// let opt = <[|MainButton|] goTo="goTo" />; +// let opt = <[|MainButton|] wrong />; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType1.baseline.jsonc index f93c9e0604..590e0bcf5c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType1.baseline.jsonc @@ -4,8 +4,8 @@ // function SFC2(prop: { x: boolean }) { // return

World

; // } -// /*FIND ALL REFS*/var SFCComp = SFC1 || SFC2; -// +// /*FIND ALL REFS*/var [|SFCComp|] = SFC1 || SFC2; +// <[|SFCComp|] x={ "hi" } /> diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType2.baseline.jsonc index fa4cc25d78..b02df6df6e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferencesUnionElementType2.baseline.jsonc @@ -4,8 +4,8 @@ // } // private method() { } // } -// /*FIND ALL REFS*/var RCComp = RC1 || RC2; -// +// /*FIND ALL REFS*/var [|RCComp|] = RC1 || RC2; +// <[|RCComp|] /> diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToTypeDefinition4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToTypeDefinition4.baseline.jsonc new file mode 100644 index 0000000000..a639362681 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToDefinition/goToTypeDefinition4.baseline.jsonc @@ -0,0 +1,8 @@ +// === goToDefinition === +// === /foo.ts === +// export type [|T|] = string; +// export const [|T|] = ""; + +// === /bar.ts === +// import { T } from "./foo"; +// let x: /*GOTO DEF*/T; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition.baseline.jsonc new file mode 100644 index 0000000000..1ff73db085 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition.baseline.jsonc @@ -0,0 +1,9 @@ +// === goToType === +// === /goToTypeDefinition_Definition.ts === +// class [|C|] { +// p; +// } +// var c: C; + +// === /goToTypeDefinition_Consumption.ts === +// /*GOTO TYPE*/c = undefined; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition2.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition2.baseline.jsonc new file mode 100644 index 0000000000..beaf380dc5 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition2.baseline.jsonc @@ -0,0 +1,11 @@ +// === goToType === +// === /goToTypeDefinition2_Definition.ts === +// interface [|I1|] { +// p; +// } +// type propertyType = I1; +// // --- (line: 5) skipped --- + +// === /goToTypeDefinition2_Consumption.ts === +// var i2: I2; +// i2.prop/*GOTO TYPE*/erty; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition3.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition3.baseline.jsonc new file mode 100644 index 0000000000..6067823559 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition3.baseline.jsonc @@ -0,0 +1,4 @@ +// === goToType === +// === /goToTypeDefinition3.ts === +// type [|T|] = string; +// const x: /*GOTO TYPE*/T; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition4.baseline.jsonc new file mode 100644 index 0000000000..61504f639c --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition4.baseline.jsonc @@ -0,0 +1,4 @@ +// === goToType === +// === /bar.ts === +// import { T } from "./foo"; +// let x: /*GOTO TYPE*/T; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition5.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition5.baseline.jsonc new file mode 100644 index 0000000000..4f3d334efb --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition5.baseline.jsonc @@ -0,0 +1,5 @@ +// === goToType === +// === /foo.ts === +// let Foo: unresolved; +// type Foo = { x: string }; +// /*GOTO TYPE*/Foo; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionAliases.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionAliases.baseline.jsonc new file mode 100644 index 0000000000..dd9f252f4b --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionAliases.baseline.jsonc @@ -0,0 +1,23 @@ +// === goToType === +// === /goToTypeDefinitioAliases_module1.ts === +// interface [|I|] { +// p; +// } +// export {I as I2}; + +// === /goToTypeDefinitioAliases_module3.ts === +// import {/*GOTO TYPE*/v2 as v3} from "./goToTypeDefinitioAliases_module2"; +// v3; + + + +// === goToType === +// === /goToTypeDefinitioAliases_module1.ts === +// interface [|I|] { +// p; +// } +// export {I as I2}; + +// === /goToTypeDefinitioAliases_module3.ts === +// import {v2 as v3} from "./goToTypeDefinitioAliases_module2"; +// /*GOTO TYPE*/v3; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionEnumMembers.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionEnumMembers.baseline.jsonc new file mode 100644 index 0000000000..7e09546c95 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionEnumMembers.baseline.jsonc @@ -0,0 +1,9 @@ +// === goToType === +// === /goToTypeDefinitionEnumMembers.ts === +// enum E { +// value1, +// [|value2|] +// } +// var x = E.value2; +// +// /*GOTO TYPE*/x; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionImportMeta.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionImportMeta.baseline.jsonc new file mode 100644 index 0000000000..11fd9f4d3d --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionImportMeta.baseline.jsonc @@ -0,0 +1,9 @@ +// === goToType === +// === /bar.d.ts === +// interface [|ImportMeta|] { +// } + +// === /foo.ts === +// /// +// /// +// import.me/*GOTO TYPE*/ta; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionModifiers.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionModifiers.baseline.jsonc new file mode 100644 index 0000000000..c6416aa695 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionModifiers.baseline.jsonc @@ -0,0 +1,227 @@ +// === goToType === +// === /a.ts === +// /*GOTO TYPE*/export class [|A|] { +// +// private z: string; +// +// // --- (line: 5) skipped --- + + + +// === goToType === +// === /a.ts === +// export class [|A|]/*GOTO TYPE*/ { +// +// private z: string; +// +// // --- (line: 5) skipped --- + + + +// === goToType === +// === /a.ts === +// export class A { +// +// /*GOTO TYPE*/private z: string; +// +// private y: A; +// +// // --- (line: 7) skipped --- + + + +// === goToType === +// === /a.ts === +// export class A { +// +// private z/*GOTO TYPE*/: string; +// +// private y: A; +// +// // --- (line: 7) skipped --- + + + +// === goToType === +// === /a.ts === +// export class [|A|] { +// +// private z: string; +// +// /*GOTO TYPE*/private y: A; +// +// readonly x: string; +// +// // --- (line: 9) skipped --- + + + +// === goToType === +// === /a.ts === +// export class [|A|] { +// +// private z: string; +// +// private y/*GOTO TYPE*/: A; +// +// readonly x: string; +// +// // --- (line: 9) skipped --- + + + +// === goToType === +// === /a.ts === +// --- (line: 3) skipped --- +// +// private y: A; +// +// /*GOTO TYPE*/readonly x: string; +// +// async a() { } +// +// // --- (line: 11) skipped --- + + + +// === goToType === +// === /a.ts === +// --- (line: 3) skipped --- +// +// private y: A; +// +// readonly x/*GOTO TYPE*/: string; +// +// async a() { } +// +// // --- (line: 11) skipped --- + + + +// === goToType === +// === /a.ts === +// --- (line: 5) skipped --- +// +// readonly x: string; +// +// /*GOTO TYPE*/async a() { } +// +// override b() {} +// +// // --- (line: 13) skipped --- + + + +// === goToType === +// === /a.ts === +// --- (line: 5) skipped --- +// +// readonly x: string; +// +// async a/*GOTO TYPE*/() { } +// +// override b() {} +// +// // --- (line: 13) skipped --- + + + +// === goToType === +// === /a.ts === +// --- (line: 7) skipped --- +// +// async a() { } +// +// /*GOTO TYPE*/override b() {} +// +// public async c() { } +// } +// +// export function foo() { } + + + +// === goToType === +// === /a.ts === +// --- (line: 7) skipped --- +// +// async a() { } +// +// override b/*GOTO TYPE*/() {} +// +// public async c() { } +// } +// +// export function foo() { } + + + +// === goToType === +// === /a.ts === +// --- (line: 9) skipped --- +// +// override b() {} +// +// /*GOTO TYPE*/public async c() { } +// } +// +// export function foo() { } + + + +// === goToType === +// === /a.ts === +// --- (line: 9) skipped --- +// +// override b() {} +// +// public/*GOTO TYPE*/ async c() { } +// } +// +// export function foo() { } + + + +// === goToType === +// === /a.ts === +// --- (line: 9) skipped --- +// +// override b() {} +// +// public as/*GOTO TYPE*/ync c() { } +// } +// +// export function foo() { } + + + +// === goToType === +// === /a.ts === +// --- (line: 9) skipped --- +// +// override b() {} +// +// public async c/*GOTO TYPE*/() { } +// } +// +// export function foo() { } + + + +// === goToType === +// === /a.ts === +// --- (line: 12) skipped --- +// public async c() { } +// } +// +// exp/*GOTO TYPE*/ort function foo() { } + + + +// === goToType === +// === /a.ts === +// --- (line: 12) skipped --- +// public async c() { } +// } +// +// export function foo/*GOTO TYPE*/() { } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionModule.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionModule.baseline.jsonc new file mode 100644 index 0000000000..e4615be10b --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionModule.baseline.jsonc @@ -0,0 +1,23 @@ +// === goToType === +// === /module1.ts === +// module [|M|] { +// export var p; +// } +// var m: typeof M; + +// === /module3.ts === +// /*GOTO TYPE*/M; +// m; + + + +// === goToType === +// === /module1.ts === +// module [|M|] { +// export var p; +// } +// var m: typeof M; + +// === /module3.ts === +// M; +// /*GOTO TYPE*/m; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionPrimitives.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionPrimitives.baseline.jsonc new file mode 100644 index 0000000000..04785ee8ff --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionPrimitives.baseline.jsonc @@ -0,0 +1,33 @@ +// === goToType === +// === /module2.ts === +// w./*GOTO TYPE*/a; +// x; +// y; +// y; + + + +// === goToType === +// === /module2.ts === +// w.a; +// /*GOTO TYPE*/x; +// y; +// y; + + + +// === goToType === +// === /module2.ts === +// w.a; +// x; +// /*GOTO TYPE*/y; +// y; + + + +// === goToType === +// === /module2.ts === +// w.a; +// x; +// y; +// /*GOTO TYPE*/y; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionUnionType.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionUnionType.baseline.jsonc new file mode 100644 index 0000000000..b29b559356 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinitionUnionType.baseline.jsonc @@ -0,0 +1,19 @@ +// === goToType === +// === /goToTypeDefinitionUnionType.ts === +// class [|C|] { +// p; +// } +// +// interface [|I|] { +// x; +// } +// +// module M { +// export interface [|I|] { +// y; +// } +// } +// +// var x: C | I | M.I; +// +// /*GOTO TYPE*/x; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_Pick.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_Pick.baseline.jsonc new file mode 100644 index 0000000000..e15dcddec0 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_Pick.baseline.jsonc @@ -0,0 +1,19 @@ +// === goToType === +// === /goToTypeDefinition_Pick.ts === +// type User = [|{ id: number; name: string; }|]; +// declare const user: Pick +// /*GOTO TYPE*/user +// +// type PickedUser = Pick +// declare const user2: PickedUser +// user2 + + + +// === goToType === +// === /goToTypeDefinition_Pick.ts === +// --- (line: 3) skipped --- +// +// type PickedUser = Pick +// declare const user2: PickedUser +// /*GOTO TYPE*/user2 \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_arrayType.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_arrayType.baseline.jsonc new file mode 100644 index 0000000000..e984cc5804 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_arrayType.baseline.jsonc @@ -0,0 +1,37 @@ +// === goToType === +// === /goToTypeDefinition_arrayType.ts === +// type User = [|{ name: string }|]; +// declare const users: User[] +// /*GOTO TYPE*/users +// +// type UsersArr = Array +// declare const users2: UsersArr +// // --- (line: 7) skipped --- + + + +// === goToType === +// === /goToTypeDefinition_arrayType.ts === +// type User = [|{ name: string }|]; +// declare const users: User[] +// users +// +// type UsersArr = Array +// declare const users2: UsersArr +// /*GOTO TYPE*/users2 +// +// class CustomArray extends Array { immutableReverse() { return [...this].reverse() } } +// declare const users3: CustomArray +// users3 + + + +// === goToType === +// === /goToTypeDefinition_arrayType.ts === +// --- (line: 5) skipped --- +// declare const users2: UsersArr +// users2 +// +// class [|CustomArray|] extends Array { immutableReverse() { return [...this].reverse() } } +// declare const users3: CustomArray +// /*GOTO TYPE*/users3 \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_promiseType.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_promiseType.baseline.jsonc new file mode 100644 index 0000000000..18eae436c2 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_promiseType.baseline.jsonc @@ -0,0 +1,19 @@ +// === goToType === +// === /goToTypeDefinition_promiseType.ts === +// type User = [|{ name: string }|]; +// async function /*GOTO TYPE*/getUser() { return { name: "Bob" } satisfies User as User } +// +// const promisedBob = getUser() +// +// export {} + + + +// === goToType === +// === /goToTypeDefinition_promiseType.ts === +// type User = [|{ name: string }|]; +// async function getUser() { return { name: "Bob" } satisfies User as User } +// +// const /*GOTO TYPE*/promisedBob = getUser() +// +// export {} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_returnType.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_returnType.baseline.jsonc new file mode 100644 index 0000000000..33d20e328a --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_returnType.baseline.jsonc @@ -0,0 +1,179 @@ +// === goToType === +// === /goToTypeDefinition_returnType.ts === +// interface [|I|] { x: number; } +// interface J { y: number; } +// +// function f0(): I { return { x: 0 }; } +// // --- (line: 5) skipped --- + +// --- (line: 21) skipped --- +// function f8(j: J): J; +// function f8(ij: any): any { return ij; } +// +// /*GOTO TYPE*/f0(); +// f1(); +// f2(); +// f3(); +// // --- (line: 29) skipped --- + + + +// === goToType === +// === /goToTypeDefinition_returnType.ts === +// interface I { x: number; } +// interface J { y: number; } +// +// function f0(): I { return { x: 0 }; } +// +// type T = [|(i: I) => I|]; +// const f1: T = i => ({ x: i.x + 1 }); +// +// const f2 = (i: I): I => ({ x: i.x + 1 }); +// // --- (line: 10) skipped --- + +// --- (line: 22) skipped --- +// function f8(ij: any): any { return ij; } +// +// f0(); +// /*GOTO TYPE*/f1(); +// f2(); +// f3(); +// f4(); +// // --- (line: 30) skipped --- + + + +// === goToType === +// === /goToTypeDefinition_returnType.ts === +// interface [|I|] { x: number; } +// interface J { y: number; } +// +// function f0(): I { return { x: 0 }; } +// // --- (line: 5) skipped --- + +// --- (line: 23) skipped --- +// +// f0(); +// f1(); +// /*GOTO TYPE*/f2(); +// f3(); +// f4(); +// f5(); +// // --- (line: 31) skipped --- + + + +// === goToType === +// === /goToTypeDefinition_returnType.ts === +// --- (line: 7) skipped --- +// +// const f2 = (i: I): I => ({ x: i.x + 1 }); +// +// const f3 = (i: I) => ([|{ x: i.x + 1 }|]); +// +// const f4 = (i: I) => i; +// +// // --- (line: 15) skipped --- + +// --- (line: 24) skipped --- +// f0(); +// f1(); +// f2(); +// /*GOTO TYPE*/f3(); +// f4(); +// f5(); +// f6(); +// f7(); +// f8(); + + + +// === goToType === +// === /goToTypeDefinition_returnType.ts === +// interface [|I|] { x: number; } +// interface J { y: number; } +// +// function f0(): I { return { x: 0 }; } +// // --- (line: 5) skipped --- + +// --- (line: 25) skipped --- +// f1(); +// f2(); +// f3(); +// /*GOTO TYPE*/f4(); +// f5(); +// f6(); +// f7(); +// f8(); + + + +// === goToType === +// === /goToTypeDefinition_returnType.ts === +// interface [|I|] { x: number; } +// interface [|J|] { y: number; } +// +// function f0(): I { return { x: 0 }; } +// +// // --- (line: 6) skipped --- + +// --- (line: 26) skipped --- +// f2(); +// f3(); +// f4(); +// /*GOTO TYPE*/f5(); +// f6(); +// f7(); +// f8(); + + + +// === goToType === +// === /goToTypeDefinition_returnType.ts === +// interface [|I|] { x: number; } +// interface [|J|] { y: number; } +// +// function f0(): I { return { x: 0 }; } +// +// // --- (line: 6) skipped --- + +// --- (line: 27) skipped --- +// f3(); +// f4(); +// f5(); +// /*GOTO TYPE*/f6(); +// f7(); +// f8(); + + + +// === goToType === +// === /goToTypeDefinition_returnType.ts === +// --- (line: 28) skipped --- +// f4(); +// f5(); +// f6(); +// /*GOTO TYPE*/f7(); +// f8(); + + + +// === goToType === +// === /goToTypeDefinition_returnType.ts === +// --- (line: 17) skipped --- +// +// const f7 = (i: I) => {}; +// +// function [|f8|](i: I): I; +// function [|f8|](j: J): J; +// function [|f8|](ij: any): any { return ij; } +// +// f0(); +// f1(); +// f2(); +// f3(); +// f4(); +// f5(); +// f6(); +// f7(); +// /*GOTO TYPE*/f8(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_typeReference.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_typeReference.baseline.jsonc new file mode 100644 index 0000000000..b5a668654f --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_typeReference.baseline.jsonc @@ -0,0 +1,6 @@ +// === goToType === +// === /goToTypeDefinition_typeReference.ts === +// type User = { name: string }; +// type Box = [|{ value: T }|]; +// declare const boxedUser: Box +// /*GOTO TYPE*/boxedUser \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_typedef.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_typedef.baseline.jsonc new file mode 100644 index 0000000000..beeae33cc7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/goToTypeDefinition_typedef.baseline.jsonc @@ -0,0 +1,9 @@ +// === goToType === +// === /a.js === +// /** +// * @typedef {object} I +// * [|@property {number} x +// |]*/ +// +// /** @type {I} */ +// const /*GOTO TYPE*/i = { x: 0 }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToType/typedefinition01.baseline.jsonc b/testdata/baselines/reference/fourslash/goToType/typedefinition01.baseline.jsonc new file mode 100644 index 0000000000..5803b2d492 --- /dev/null +++ b/testdata/baselines/reference/fourslash/goToType/typedefinition01.baseline.jsonc @@ -0,0 +1,7 @@ +// === goToType === +// === /a.ts === +// export class [|Foo|] {} + +// === /b.ts === +// import n = require('./a'); +// var x/*GOTO TYPE*/ = new n.Foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink1.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink1.baseline index 8c1c73c68e..4475c15804 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink1.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink1.baseline @@ -16,14 +16,14 @@ // | ```tsx // | function CC(): void // | ``` -// | `C` +// | [C](file:///jsdocLink1.ts#1,7-1,8) // | -// | *@wat* — Makes a `C`. A default one. -// | C() -// | C|postfix text -// | unformattedpostfix text +// | *@wat* — Makes a [C](file:///jsdocLink1.ts#1,7-1,8). A default one. +// | [C()](file:///jsdocLink1.ts#1,7-1,8) +// | [postfix text](file:///jsdocLink1.ts#1,7-1,8) +// | unformatted postfix text // | -// | *@see* — `C` its great +// | *@see* — [C](file:///jsdocLink1.ts#1,7-1,8) its great // | // | ---------------------------------------------------------------------- // } @@ -41,7 +41,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction CC(): void\n```\n`C`\n\n*@wat* — Makes a `C`. A default one.\nC()\nC|postfix text\nunformattedpostfix text\n\n*@see* — `C` its great\n" + "value": "```tsx\nfunction CC(): void\n```\n[C](file:///jsdocLink1.ts#1,7-1,8)\n\n*@wat* — Makes a [C](file:///jsdocLink1.ts#1,7-1,8). A default one.\n[C()](file:///jsdocLink1.ts#1,7-1,8)\n[postfix text](file:///jsdocLink1.ts#1,7-1,8)\nunformatted postfix text\n\n*@see* — [C](file:///jsdocLink1.ts#1,7-1,8) its great\n" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink4.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink4.baseline index 34f8283b55..b99603e33b 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink4.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink4.baseline @@ -8,7 +8,7 @@ // | ```tsx // | (method) I.bar(): void // | ``` -// | `I` +// | [I](file:///jsdocLink4.ts#1,15-1,16) // | ---------------------------------------------------------------------- // } // /** {@link I} */ @@ -18,7 +18,7 @@ // | ```tsx // | var n: number // | ``` -// | `I` +// | [I](file:///jsdocLink4.ts#1,15-1,16) // | ---------------------------------------------------------------------- // /** // * A real, very serious {@link I to an interface}. Right there. @@ -32,9 +32,9 @@ // | ```tsx // | function f(x: any): void // | ``` -// | A real, very serious Ito an interface. Right there. +// | A real, very serious [to an interface](file:///jsdocLink4.ts#1,15-1,16). Right there. // | -// | *@param* `x` — one Poshere too +// | *@param* `x` — one [here too](file:///jsdocLink4.ts#14,6-14,9) // | ---------------------------------------------------------------------- // type Pos = [number, number] [ @@ -51,7 +51,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(method) I.bar(): void\n```\n`I`" + "value": "```tsx\n(method) I.bar(): void\n```\n[I](file:///jsdocLink4.ts#1,15-1,16)" } } }, @@ -68,7 +68,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar n: number\n```\n`I`" + "value": "```tsx\nvar n: number\n```\n[I](file:///jsdocLink4.ts#1,15-1,16)" } } }, @@ -85,7 +85,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction f(x: any): void\n```\nA real, very serious Ito an interface. Right there.\n\n*@param* `x` — one Poshere too" + "value": "```tsx\nfunction f(x: any): void\n```\nA real, very serious [to an interface](file:///jsdocLink4.ts#1,15-1,16). Right there.\n\n*@param* `x` — one [here too](file:///jsdocLink4.ts#14,6-14,9)" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink5.baseline b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink5.baseline index 462571cb64..182df343bc 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/jsdocLink5.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/jsdocLink5.baseline @@ -13,8 +13,8 @@ // | ```tsx // | function f(x: any): void // | ``` -// | g() g() g() g() 0 g()1 g() 2 -// | u() u() u() u() 0 u()1 u() 2 +// | [g()](file:///jsdocLink5.ts#1,10-1,11) [g()](file:///jsdocLink5.ts#1,10-1,11) [g()](file:///jsdocLink5.ts#1,10-1,11) [0](file:///jsdocLink5.ts#1,10-1,11) [1](file:///jsdocLink5.ts#1,10-1,11) [2](file:///jsdocLink5.ts#1,10-1,11) +// | u () u () u () u () 0 u ()1 u () 2 // | ---------------------------------------------------------------------- [ { @@ -30,7 +30,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction f(x: any): void\n```\ng() g() g() g() 0 g()1 g() 2\nu() u() u() u() 0 u()1 u() 2" + "value": "```tsx\nfunction f(x: any): void\n```\n[g()](file:///jsdocLink5.ts#1,10-1,11) [g()](file:///jsdocLink5.ts#1,10-1,11) [g()](file:///jsdocLink5.ts#1,10-1,11) [0](file:///jsdocLink5.ts#1,10-1,11) [1](file:///jsdocLink5.ts#1,10-1,11) [2](file:///jsdocLink5.ts#1,10-1,11)\nu () u () u () u () 0 u ()1 u () 2" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline index f119b73655..21e502884b 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline @@ -52,7 +52,7 @@ // | ``` // | // | -// | *@see* — https://hva +// | *@see* — [https://hva](https://hva) // | ---------------------------------------------------------------------- // // /** {@link https://hvaD} */ @@ -62,7 +62,7 @@ // | ```tsx // | var see3: boolean // | ``` -// | https://hvaD +// | [https://hvaD](https://hvaD) // | ---------------------------------------------------------------------- [ { @@ -146,7 +146,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar see2: boolean\n```\n\n\n*@see* — https://hva " + "value": "```tsx\nvar see2: boolean\n```\n\n\n*@see* — [https://hva](https://hva) " } } }, @@ -163,7 +163,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar see3: boolean\n```\nhttps://hvaD" + "value": "```tsx\nvar see3: boolean\n```\n[https://hvaD](https://hvaD)" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithUnresolvedHttpLinks.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithUnresolvedHttpLinks.baseline index fcd61bd90e..efdfa13552 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithUnresolvedHttpLinks.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithUnresolvedHttpLinks.baseline @@ -9,7 +9,7 @@ // | ``` // | // | -// | *@see* — https://hva +// | *@see* — [https://hva](https://hva) // | ---------------------------------------------------------------------- // // /** {@link https://hvaD} */ @@ -19,7 +19,7 @@ // | ```tsx // | var see3: boolean // | ``` -// | https://hvaD +// | [https://hvaD](https://hvaD) // | ---------------------------------------------------------------------- [ { @@ -35,7 +35,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar see2: boolean\n```\n\n\n*@see* — https://hva " + "value": "```tsx\nvar see2: boolean\n```\n\n\n*@see* — [https://hva](https://hva) " } } }, @@ -52,7 +52,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nvar see3: boolean\n```\nhttps://hvaD" + "value": "```tsx\nvar see3: boolean\n```\n[https://hvaD](https://hvaD)" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink10.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink10.baseline index 9436eebded..e091db0a12 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink10.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink10.baseline @@ -9,7 +9,7 @@ // | ```tsx // | const a: () => number // | ``` -// | start https://vscode.dev/ | end +// | start [end](https://vscode.dev/) // | ---------------------------------------------------------------------- [ { @@ -25,7 +25,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst a: () => number\n```\nstart https://vscode.dev/ | end" + "value": "```tsx\nconst a: () => number\n```\nstart [end](https://vscode.dev/)" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink11.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink11.baseline index 50655f184b..922626732d 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink11.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink11.baseline @@ -14,10 +14,10 @@ // | ```tsx // | function f(): void // | ``` -// | https://vscode.dev +// | [https://vscode.dev](https://vscode.dev) // | [link text]{https://vscode.dev} -// | https://vscode.dev|link text -// | https://vscode.dev link text +// | [link text](https://vscode.dev) +// | [link text](https://vscode.dev) // | ---------------------------------------------------------------------- [ { @@ -33,7 +33,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nfunction f(): void\n```\nhttps://vscode.dev\n[link text]{https://vscode.dev}\nhttps://vscode.dev|link text\nhttps://vscode.dev link text" + "value": "```tsx\nfunction f(): void\n```\n[https://vscode.dev](https://vscode.dev)\n[link text]{https://vscode.dev}\n[link text](https://vscode.dev)\n[link text](https://vscode.dev)" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink5.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink5.baseline index 6064786e91..abac5e34e6 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink5.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink5.baseline @@ -10,7 +10,7 @@ // | ```tsx // | const B: 456 // | ``` -// | See A| constant A instead +// | See [constant A](file:///quickInfoLink5.ts#1,7-1,8) instead // | ---------------------------------------------------------------------- [ { @@ -26,7 +26,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst B: 456\n```\nSee A| constant A instead" + "value": "```tsx\nconst B: 456\n```\nSee [constant A](file:///quickInfoLink5.ts#1,7-1,8) instead" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink6.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink6.baseline index 44aee68e6e..bce3d3bbc1 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink6.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink6.baseline @@ -10,7 +10,7 @@ // | ```tsx // | const B: 456 // | ``` -// | See A|constant A instead +// | See [constant A](file:///quickInfoLink6.ts#1,7-1,8) instead // | ---------------------------------------------------------------------- [ { @@ -26,7 +26,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst B: 456\n```\nSee A|constant A instead" + "value": "```tsx\nconst B: 456\n```\nSee [constant A](file:///quickInfoLink6.ts#1,7-1,8) instead" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink7.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink7.baseline index 72b2cb44ce..79918ed05f 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink7.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink7.baseline @@ -9,7 +9,7 @@ // | ```tsx // | const B: 456 // | ``` -// | See | instead +// | See | instead // | ---------------------------------------------------------------------- [ { @@ -25,7 +25,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst B: 456\n```\nSee | instead" + "value": "```tsx\nconst B: 456\n```\nSee | instead" } } } diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink8.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink8.baseline index d336abcb17..07025af4a0 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink8.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoLink8.baseline @@ -10,7 +10,7 @@ // | ```tsx // | const B: 456 // | ``` -// | See A| constant A instead +// | See [constant A](file:///quickInfoLink8.ts#1,7-1,8) instead // | ---------------------------------------------------------------------- [ { @@ -26,7 +26,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\nconst B: 456\n```\nSee A| constant A instead" + "value": "```tsx\nconst B: 456\n```\nSee [constant A](file:///quickInfoLink8.ts#1,7-1,8) instead" } } } diff --git a/testdata/baselines/reference/submodule/compiler/APISample_Watch.js b/testdata/baselines/reference/submodule/compiler/APISample_Watch.js index de90b96724..ce29e2fa65 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_Watch.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_Watch.js @@ -85,6 +85,11 @@ watchMain(); //// [APISample_Watch.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript-wiki/blob/master/Using-the-Compiler-API.md#writing-an-incremental-program-watcher + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); const formatHost = { diff --git a/testdata/baselines/reference/submodule/compiler/APISample_Watch.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_Watch.js.diff index 499c77d7d5..a44deac7f4 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_Watch.js.diff +++ b/testdata/baselines/reference/submodule/compiler/APISample_Watch.js.diff @@ -1,14 +1,8 @@ --- old.APISample_Watch.js +++ new.APISample_Watch.js -@@= skipped -84, +84 lines =@@ - - //// [APISample_Watch.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript-wiki/blob/master/Using-the-Compiler-API.md#writing-an-incremental-program-watcher -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ +@@= skipped -90, +90 lines =@@ + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); -var ts = require("typescript"); +const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js index d5b1a505ba..eda1e3f02b 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js @@ -58,6 +58,10 @@ watchMain(); //// [APISample_WatchWithDefaults.js] "use strict"; +/* + * Note: This test is a public API sample. This uses default sys interface without having to pass anything + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); function watchMain() { diff --git a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js.diff index 495001bf42..be2d9cde75 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js.diff +++ b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithDefaults.js.diff @@ -1,13 +1,8 @@ --- old.APISample_WatchWithDefaults.js +++ new.APISample_WatchWithDefaults.js -@@= skipped -57, +57 lines =@@ - - //// [APISample_WatchWithDefaults.js] - "use strict"; --/* -- * Note: This test is a public API sample. This uses default sys interface without having to pass anything -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ +@@= skipped -62, +62 lines =@@ + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); -var ts = require("typescript"); +const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js index 8e48f3cffc..915dc80a83 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js @@ -65,6 +65,10 @@ watchMain(); //// [APISample_WatchWithOwnWatchHost.js] "use strict"; +/* + * Note: This test is a public API sample. This sample verifies creating abstract builder to watch list of root files + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); function watchMain() { diff --git a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js.diff index 25d0f11df7..4d88a0aa98 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js.diff +++ b/testdata/baselines/reference/submodule/compiler/APISample_WatchWithOwnWatchHost.js.diff @@ -1,13 +1,8 @@ --- old.APISample_WatchWithOwnWatchHost.js +++ new.APISample_WatchWithOwnWatchHost.js -@@= skipped -64, +64 lines =@@ - - //// [APISample_WatchWithOwnWatchHost.js] - "use strict"; --/* -- * Note: This test is a public API sample. This sample verifies creating abstract builder to watch list of root files -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ +@@= skipped -69, +69 lines =@@ + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); -var ts = require("typescript"); +const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_compile.js b/testdata/baselines/reference/submodule/compiler/APISample_compile.js index 20616a8c0c..fdf4166c68 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_compile.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_compile.js @@ -48,6 +48,11 @@ compile(process.argv.slice(2), { //// [APISample_compile.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); exports.compile = compile; const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_compile.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_compile.js.diff index b2e0459c6f..9b6c00442b 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_compile.js.diff +++ b/testdata/baselines/reference/submodule/compiler/APISample_compile.js.diff @@ -1,14 +1,7 @@ --- old.APISample_compile.js +++ new.APISample_compile.js -@@= skipped -47, +47 lines =@@ - - //// [APISample_compile.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ +@@= skipped -54, +54 lines =@@ + */ Object.defineProperty(exports, "__esModule", { value: true }); exports.compile = compile; -var ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js b/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js index e9c98da1e3..3a50a28422 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js @@ -123,6 +123,12 @@ function getSomeOtherTags(node: ts.Node) { //// [APISample_jsdoc.js] "use strict"; +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); // excerpted from https://github.com/YousefED/typescript-json-schema diff --git a/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js.diff index 939a10fa62..9989abff97 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js.diff +++ b/testdata/baselines/reference/submodule/compiler/APISample_jsdoc.js.diff @@ -1,15 +1,8 @@ --- old.APISample_jsdoc.js +++ new.APISample_jsdoc.js -@@= skipped -122, +122 lines =@@ - - //// [APISample_jsdoc.js] - "use strict"; --/* -- * Note: This test is a public API sample. The original sources can be found -- * at: https://github.com/YousefED/typescript-json-schema -- * https://github.com/vega/ts-json-schema-generator -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ +@@= skipped -129, +129 lines =@@ + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); -var ts = require("typescript"); +const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_linter.js b/testdata/baselines/reference/submodule/compiler/APISample_linter.js index 81cba71e70..be5ae7c4e5 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_linter.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_linter.js @@ -74,6 +74,11 @@ fileNames.forEach(fileName => { //// [APISample_linter.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); exports.delint = delint; const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_linter.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_linter.js.diff index 2f9b2b9e1f..5bc028be72 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_linter.js.diff +++ b/testdata/baselines/reference/submodule/compiler/APISample_linter.js.diff @@ -1,14 +1,7 @@ --- old.APISample_linter.js +++ new.APISample_linter.js -@@= skipped -73, +73 lines =@@ - - //// [APISample_linter.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ +@@= skipped -80, +80 lines =@@ + */ Object.defineProperty(exports, "__esModule", { value: true }); exports.delint = delint; -var ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js b/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js index 2d4cb20590..4359a0c275 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js @@ -46,6 +46,11 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string): //// [APISample_parseConfig.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); exports.createProgram = createProgram; const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js.diff index aa2225246a..417f4c229e 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js.diff +++ b/testdata/baselines/reference/submodule/compiler/APISample_parseConfig.js.diff @@ -1,14 +1,7 @@ --- old.APISample_parseConfig.js +++ new.APISample_parseConfig.js -@@= skipped -45, +45 lines =@@ - - //// [APISample_parseConfig.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ +@@= skipped -52, +52 lines =@@ + */ Object.defineProperty(exports, "__esModule", { value: true }); exports.createProgram = createProgram; -var ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_transform.js b/testdata/baselines/reference/submodule/compiler/APISample_transform.js index c462a864e7..8f1b028cad 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_transform.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_transform.js @@ -26,6 +26,11 @@ console.log(JSON.stringify(result)); //// [APISample_transform.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); const source = "let x: string = 'string'"; diff --git a/testdata/baselines/reference/submodule/compiler/APISample_transform.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_transform.js.diff index 62ddcd3067..353eeba78c 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_transform.js.diff +++ b/testdata/baselines/reference/submodule/compiler/APISample_transform.js.diff @@ -1,14 +1,8 @@ --- old.APISample_transform.js +++ new.APISample_transform.js -@@= skipped -25, +25 lines =@@ - - //// [APISample_transform.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ +@@= skipped -31, +31 lines =@@ + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); -var ts = require("typescript"); +const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/APISample_watcher.js b/testdata/baselines/reference/submodule/compiler/APISample_watcher.js index 0b04a6309e..4b2a3906c9 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_watcher.js +++ b/testdata/baselines/reference/submodule/compiler/APISample_watcher.js @@ -121,6 +121,11 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); //// [APISample_watcher.js] "use strict"; +/* + * Note: This test is a public API sample. The sample sources can be found + * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); const ts = require("typescript"); function watch(rootFileNames, options) { diff --git a/testdata/baselines/reference/submodule/compiler/APISample_watcher.js.diff b/testdata/baselines/reference/submodule/compiler/APISample_watcher.js.diff index 7872ebf267..9b572eae42 100644 --- a/testdata/baselines/reference/submodule/compiler/APISample_watcher.js.diff +++ b/testdata/baselines/reference/submodule/compiler/APISample_watcher.js.diff @@ -1,14 +1,8 @@ --- old.APISample_watcher.js +++ new.APISample_watcher.js -@@= skipped -120, +120 lines =@@ - - //// [APISample_watcher.js] - "use strict"; --/* -- * Note: This test is a public API sample. The sample sources can be found -- * at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services -- * Please log a "breaking change" issue for any API breaking change affecting this issue -- */ +@@= skipped -126, +126 lines =@@ + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ Object.defineProperty(exports, "__esModule", { value: true }); -var ts = require("typescript"); +const ts = require("typescript"); diff --git a/testdata/baselines/reference/submodule/compiler/abstractClassInLocalScopeIsAbstract.types b/testdata/baselines/reference/submodule/compiler/abstractClassInLocalScopeIsAbstract.types index afc238dd4c..41f28f004c 100644 --- a/testdata/baselines/reference/submodule/compiler/abstractClassInLocalScopeIsAbstract.types +++ b/testdata/baselines/reference/submodule/compiler/abstractClassInLocalScopeIsAbstract.types @@ -14,7 +14,7 @@ >A : A new A(); ->new A() : any +>new A() : A >A : typeof A new B(); diff --git a/testdata/baselines/reference/submodule/compiler/abstractClassInLocalScopeIsAbstract.types.diff b/testdata/baselines/reference/submodule/compiler/abstractClassInLocalScopeIsAbstract.types.diff new file mode 100644 index 0000000000..0b33e3aff5 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/abstractClassInLocalScopeIsAbstract.types.diff @@ -0,0 +1,11 @@ +--- old.abstractClassInLocalScopeIsAbstract.types ++++ new.abstractClassInLocalScopeIsAbstract.types +@@= skipped -13, +13 lines =@@ + >A : A + + new A(); +->new A() : any ++>new A() : A + >A : typeof A + + new B(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js b/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js index 6632073318..88a35b31b6 100644 --- a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js +++ b/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js @@ -29,6 +29,7 @@ class RegularClass { } //// [accessorInAmbientContextES5.js] +// Should allow accessor in ambient contexts even when targeting ES5 // Regular class should still error when targeting ES5 class RegularClass { accessor shouldError; // Should still error diff --git a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js.diff b/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js.diff index 5a989ff971..e1bf7b98fc 100644 --- a/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js.diff +++ b/testdata/baselines/reference/submodule/compiler/accessorInAmbientContextES5.js.diff @@ -1,10 +1,9 @@ --- old.accessorInAmbientContextES5.js +++ new.accessorInAmbientContextES5.js -@@= skipped -28, +28 lines =@@ - } +@@= skipped -29, +29 lines =@@ //// [accessorInAmbientContextES5.js] --// Should allow accessor in ambient contexts even when targeting ES5 + // Should allow accessor in ambient contexts even when targeting ES5 -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); diff --git a/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js b/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js index 3b810f99c3..177eee9290 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js +++ b/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js @@ -36,6 +36,7 @@ let check3: test3 = "y"; //// [aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js] +// the type printback for every `test` below should be "y" let check = "y"; let check1 = "y"; let check2 = "y"; diff --git a/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js.diff b/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js.diff index 5f3c71a237..bfdda90285 100644 --- a/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js.diff +++ b/testdata/baselines/reference/submodule/compiler/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js.diff @@ -5,7 +5,6 @@ //// [aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js] -"use strict"; --// the type printback for every `test` below should be "y" + // the type printback for every `test` below should be "y" let check = "y"; - let check1 = "y"; - let check2 = "y"; \ No newline at end of file + let check1 = "y"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js b/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js index c84dcda198..e12e847485 100644 --- a/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js +++ b/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js @@ -8,7 +8,7 @@ m1.f(); //// [amdDependencyComment1.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const m1 = require("m2"); m1.f(); diff --git a/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js.diff b/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js.diff index 848a44ccbb..de0a9033ec 100644 --- a/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/amdDependencyComment1.js.diff @@ -1,12 +1,9 @@ --- old.amdDependencyComment1.js +++ new.amdDependencyComment1.js -@@= skipped -7, +7 lines =@@ - - //// [amdDependencyComment1.js] +@@= skipped -9, +9 lines =@@ "use strict"; --/// + /// Object.defineProperty(exports, "__esModule", { value: true }); -var m1 = require("m2"); -+/// +const m1 = require("m2"); m1.f(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js b/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js index e57a4276fe..7538bd86ee 100644 --- a/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js +++ b/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js @@ -8,7 +8,7 @@ m1.f(); //// [amdDependencyCommentName1.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const m1 = require("m2"); m1.f(); diff --git a/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js.diff b/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js.diff index 71ca61c44d..98845f5611 100644 --- a/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/amdDependencyCommentName1.js.diff @@ -1,12 +1,9 @@ --- old.amdDependencyCommentName1.js +++ new.amdDependencyCommentName1.js -@@= skipped -7, +7 lines =@@ - - //// [amdDependencyCommentName1.js] +@@= skipped -9, +9 lines =@@ "use strict"; --/// + /// Object.defineProperty(exports, "__esModule", { value: true }); -var m1 = require("m2"); -+/// +const m1 = require("m2"); m1.f(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrayFrom.js b/testdata/baselines/reference/submodule/compiler/arrayFrom.js index fc8159f804..477082fedc 100644 --- a/testdata/baselines/reference/submodule/compiler/arrayFrom.js +++ b/testdata/baselines/reference/submodule/compiler/arrayFrom.js @@ -39,6 +39,8 @@ function getEither (in1: Iterable, in2: ArrayLike) { //// [arrayFrom.js] +// Tests fix for #20432, ensures Array.from accepts all valid inputs +// Also tests for #19682 const inputA = []; const inputB = []; const inputALike = { length: 0 }; diff --git a/testdata/baselines/reference/submodule/compiler/arrayFrom.js.diff b/testdata/baselines/reference/submodule/compiler/arrayFrom.js.diff deleted file mode 100644 index 9386f60d71..0000000000 --- a/testdata/baselines/reference/submodule/compiler/arrayFrom.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.arrayFrom.js -+++ new.arrayFrom.js -@@= skipped -38, +38 lines =@@ - - - //// [arrayFrom.js] --// Tests fix for #20432, ensures Array.from accepts all valid inputs --// Also tests for #19682 - const inputA = []; - const inputB = []; - const inputALike = { length: 0 }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js index 46abecf4fc..96bae1d84f 100644 --- a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js +++ b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js @@ -33,6 +33,7 @@ fn(a => { }); //// [assignmentCompatability_checking-apply-member-off-of-function-interface.js] +// 3.8.4 Assignment Compatibility var x; // Should fail x = ''; diff --git a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js.diff b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js.diff deleted file mode 100644 index 1f469916de..0000000000 --- a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.assignmentCompatability_checking-apply-member-off-of-function-interface.js -+++ new.assignmentCompatability_checking-apply-member-off-of-function-interface.js -@@= skipped -32, +32 lines =@@ - - - //// [assignmentCompatability_checking-apply-member-off-of-function-interface.js] --// 3.8.4 Assignment Compatibility - var x; - // Should fail - x = ''; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js index 42551f45cb..f4d2de50fc 100644 --- a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js +++ b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js @@ -33,6 +33,7 @@ fn(a => { }); //// [assignmentCompatability_checking-call-member-off-of-function-interface.js] +// 3.8.4 Assignment Compatibility var x; // Should fail x = ''; diff --git a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js.diff b/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js.diff deleted file mode 100644 index d61f6de7b5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.assignmentCompatability_checking-call-member-off-of-function-interface.js -+++ new.assignmentCompatability_checking-call-member-off-of-function-interface.js -@@= skipped -32, +32 lines =@@ - - - //// [assignmentCompatability_checking-call-member-off-of-function-interface.js] --// 3.8.4 Assignment Compatibility - var x; - // Should fail - x = ''; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js b/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js index ac1a06dee4..c652c79aa7 100644 --- a/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js +++ b/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js @@ -26,6 +26,7 @@ function g(x) { } //// [assignmentToReferenceTypes.js] +// Should all be allowed M = null; class C { } diff --git a/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js.diff b/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js.diff deleted file mode 100644 index 569d50de4a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/assignmentToReferenceTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.assignmentToReferenceTypes.js -+++ new.assignmentToReferenceTypes.js -@@= skipped -25, +25 lines =@@ - } - - //// [assignmentToReferenceTypes.js] --// Should all be allowed - M = null; - class C { - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js b/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js index 2668ace0b0..45c06fe734 100644 --- a/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js +++ b/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js @@ -6,6 +6,7 @@ async ({ foo, bar, ...rest }) => bar(await foo); //// [asyncFunctionTempVariableScoping.js] +// https://github.com/Microsoft/TypeScript/issues/19187 var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) @@ -17,7 +18,6 @@ var __rest = (this && this.__rest) || function (s, e) { } return t; }; -// https://github.com/Microsoft/TypeScript/issues/19187 async (_a) => { var { foo, bar } = _a, rest = __rest(_a, ["foo", "bar"]); return bar(await foo); diff --git a/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js.diff b/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js.diff index c50a92ee97..8e68b6a276 100644 --- a/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js.diff +++ b/testdata/baselines/reference/submodule/compiler/asyncFunctionTempVariableScoping.js.diff @@ -1,10 +1,9 @@ --- old.asyncFunctionTempVariableScoping.js +++ new.asyncFunctionTempVariableScoping.js -@@= skipped -5, +5 lines =@@ - async ({ foo, bar, ...rest }) => bar(await foo); +@@= skipped -6, +6 lines =@@ //// [asyncFunctionTempVariableScoping.js] --// https://github.com/Microsoft/TypeScript/issues/19187 + // https://github.com/Microsoft/TypeScript/issues/19187 -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { @@ -17,12 +16,11 @@ var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) -@@= skipped -21, +11 lines =@@ +@@= skipped -20, +11 lines =@@ } return t; }; -(_a) => __awaiter(this, void 0, void 0, function* () { -+// https://github.com/Microsoft/TypeScript/issues/19187 +async (_a) => { var { foo, bar } = _a, rest = __rest(_a, ["foo", "bar"]); - return bar(yield foo); diff --git a/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js b/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js index 0ada4a51d6..0d3698bb39 100644 --- a/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js +++ b/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js @@ -36,6 +36,7 @@ interface i4 { //import i4 = require(''); // error //// [augmentedTypesInterface.js] +// interface then interface class i2 { bar() { return 1; diff --git a/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js.diff b/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js.diff deleted file mode 100644 index cae881d4fe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/augmentedTypesInterface.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.augmentedTypesInterface.js -+++ new.augmentedTypesInterface.js -@@= skipped -35, +35 lines =@@ - //import i4 = require(''); // error - - //// [augmentedTypesInterface.js] --// interface then interface - class i2 { - bar() { - return 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js b/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js index f59d46d642..ef3170d82a 100644 --- a/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js +++ b/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js @@ -26,6 +26,7 @@ goofus((a: string) => ({ dog: function() { return a; } })); //// [badInferenceLowerPriorityThanGoodInference.js] +// Repro from #13118 const result = canYouInferThis(() => ({ a: { BLAH: 33 }, b: x => { } diff --git a/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js.diff b/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js.diff deleted file mode 100644 index c2f7f0e6f4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/badInferenceLowerPriorityThanGoodInference.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.badInferenceLowerPriorityThanGoodInference.js -+++ new.badInferenceLowerPriorityThanGoodInference.js -@@= skipped -25, +25 lines =@@ - - - //// [badInferenceLowerPriorityThanGoodInference.js] --// Repro from #13118 - const result = canYouInferThis(() => ({ - a: { BLAH: 33 }, - b: x => { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js b/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js index 378671931c..c15c8506ae 100644 --- a/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js +++ b/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js @@ -26,6 +26,7 @@ createInstance(MenuWorkbenchToolBar, { //// [cachedContextualTypes.js] "use strict"; +// Repro from #52198 Object.defineProperty(exports, "__esModule", { value: true }); class MenuWorkbenchToolBar { constructor(options) { } diff --git a/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js.diff b/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js.diff deleted file mode 100644 index 6236676ccd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/cachedContextualTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.cachedContextualTypes.js -+++ new.cachedContextualTypes.js -@@= skipped -25, +25 lines =@@ - - //// [cachedContextualTypes.js] - "use strict"; --// Repro from #52198 - Object.defineProperty(exports, "__esModule", { value: true }); - class MenuWorkbenchToolBar { - constructor(options) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js index 9d5385bd49..d54c2d7666 100644 --- a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js +++ b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js @@ -20,6 +20,8 @@ values = values2; //// [checkInfiniteExpansionTermination.js] +// Regression test for #1002 +// Before fix this code would cause infinite loop var values; var values2; values = values2; diff --git a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js.diff b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js.diff deleted file mode 100644 index a144218a54..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.checkInfiniteExpansionTermination.js -+++ new.checkInfiniteExpansionTermination.js -@@= skipped -19, +19 lines =@@ - - - //// [checkInfiniteExpansionTermination.js] --// Regression test for #1002 --// Before fix this code would cause infinite loop - var values; - var values2; - values = values2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js index c442b12a44..9726e78404 100644 --- a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js +++ b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js @@ -20,6 +20,8 @@ function fn() { //// [checkInfiniteExpansionTermination2.js] +// Regression test for #1002 +// Before fix this code would cause infinite loop function fn() { var values = []; // Hang when using , but not diff --git a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js.diff b/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js.diff deleted file mode 100644 index 77a7641e48..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkInfiniteExpansionTermination2.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.checkInfiniteExpansionTermination2.js -+++ new.checkInfiniteExpansionTermination2.js -@@= skipped -19, +19 lines =@@ - - - //// [checkInfiniteExpansionTermination2.js] --// Regression test for #1002 --// Before fix this code would cause infinite loop - function fn() { - var values = []; - // Hang when using , but not \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js index 0a413dc368..6bf89996a4 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js @@ -20,12 +20,12 @@ a; //// [checkJsdocTypeTagOnExportAssignment1.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {boolean} a * @property {boolean} b */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = { c: false }; //// [b.js] diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js.diff index cb001a666b..962b43db5d 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.js.diff @@ -1,18 +1,6 @@ --- old.checkJsdocTypeTagOnExportAssignment1.js +++ new.checkJsdocTypeTagOnExportAssignment1.js -@@= skipped -19, +19 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment1.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {boolean} a - * @property {boolean} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = { c: false }; +@@= skipped -30, +30 lines =@@ //// [b.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js index 6bf97fedfe..6205b8fe2e 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js @@ -22,12 +22,12 @@ a; //// [checkJsdocTypeTagOnExportAssignment3.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {boolean} a * @property {boolean} b */ +Object.defineProperty(exports, "__esModule", { value: true }); const bar = { c: 1 }; /** @type {Foo} */ exports.default = bar; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js.diff index fc0499aae9..df954aac94 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js.diff +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.js.diff @@ -1,19 +1,6 @@ --- old.checkJsdocTypeTagOnExportAssignment3.js +++ new.checkJsdocTypeTagOnExportAssignment3.js -@@= skipped -21, +21 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment3.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {boolean} a - * @property {boolean} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - const bar = { c: 1 }; - /** @type {Foo} */ - exports.default = bar; +@@= skipped -33, +33 lines =@@ //// [b.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js index a4067800e7..3e280248f4 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js @@ -15,9 +15,9 @@ export default ""; //// [checkJsdocTypeTagOnExportAssignment4.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {number} Foo */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = ""; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js.diff deleted file mode 100644 index aa2903966c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment4.js -+++ new.checkJsdocTypeTagOnExportAssignment4.js -@@= skipped -14, +14 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment4.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {number} Foo - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = ""; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js index bd15e36ff4..25a7b3dae7 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js @@ -20,12 +20,12 @@ a; //// [checkJsdocTypeTagOnExportAssignment5.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {number} a * @property {number} b */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = { a: 1, b: 1 }; //// [b.js] diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js.diff index 280223a9e8..b7331afe3b 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js.diff +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.js.diff @@ -1,18 +1,6 @@ --- old.checkJsdocTypeTagOnExportAssignment5.js +++ new.checkJsdocTypeTagOnExportAssignment5.js -@@= skipped -19, +19 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment5.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {number} a - * @property {number} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = { a: 1, b: 1 }; +@@= skipped -30, +30 lines =@@ //// [b.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js index e2b514d833..7dce488e36 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js @@ -20,12 +20,12 @@ a; //// [checkJsdocTypeTagOnExportAssignment6.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {number} a * @property {number} b */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = { a: 1, b: 1, c: 1 }; //// [b.js] diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js.diff index 57ee0893a0..93ac1ae858 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js.diff +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.js.diff @@ -1,18 +1,6 @@ --- old.checkJsdocTypeTagOnExportAssignment6.js +++ new.checkJsdocTypeTagOnExportAssignment6.js -@@= skipped -19, +19 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment6.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {number} a - * @property {number} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = { a: 1, b: 1, c: 1 }; +@@= skipped -30, +30 lines =@@ //// [b.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js index 481aeef891..2c00033c88 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js @@ -22,12 +22,12 @@ a; //// [checkJsdocTypeTagOnExportAssignment7.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef {Object} Foo * @property {number} a * @property {number} b */ +Object.defineProperty(exports, "__esModule", { value: true }); const abc = { a: 1, b: 1, c: 1 }; /** @type {Foo} */ exports.default = abc; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js.diff index d61e82ff4d..852115e2a2 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js.diff +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.js.diff @@ -1,19 +1,6 @@ --- old.checkJsdocTypeTagOnExportAssignment7.js +++ new.checkJsdocTypeTagOnExportAssignment7.js -@@= skipped -21, +21 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment7.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef {Object} Foo - * @property {number} a - * @property {number} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - const abc = { a: 1, b: 1, c: 1 }; - /** @type {Foo} */ - exports.default = abc; +@@= skipped -33, +33 lines =@@ //// [b.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js index a13517d674..b63560b276 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js @@ -19,12 +19,12 @@ export default { //// [checkJsdocTypeTagOnExportAssignment8.js] //// [a.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef Foo * @property {string} a * @property {'b'} b */ +Object.defineProperty(exports, "__esModule", { value: true }); /** @type {Foo} */ exports.default = { a: 'a', diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js.diff b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js.diff deleted file mode 100644 index f6124fcb3a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.js.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment8.js -+++ new.checkJsdocTypeTagOnExportAssignment8.js -@@= skipped -18, +18 lines =@@ - //// [checkJsdocTypeTagOnExportAssignment8.js] - //// [a.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef Foo - * @property {string} a - * @property {'b'} b - */ --Object.defineProperty(exports, "__esModule", { value: true }); - /** @type {Foo} */ - exports.default = { - a: 'a', \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js b/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js index 32ab8f146f..e0eb73f9c1 100644 --- a/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js +++ b/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js @@ -20,6 +20,7 @@ interface Y extends X { //// [circularBaseTypes.js] +// Repro from #38098 ; // Error function f(m) { return m.value; diff --git a/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js.diff b/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js.diff index f11e8e382f..91342e2fd8 100644 --- a/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/circularBaseTypes.js.diff @@ -5,7 +5,6 @@ //// [circularBaseTypes.js] -"use strict"; --// Repro from #38098 + // Repro from #38098 ; // Error - function f(m) { - return m.value; \ No newline at end of file + function f(m) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt b/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt index d7fdcefcfd..2629296c6b 100644 --- a/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt @@ -1,7 +1,8 @@ circularModuleImports.ts(5,5): error TS2303: Circular definition of import alias 'A'. +circularModuleImports.ts(7,5): error TS2303: Circular definition of import alias 'B'. -==== circularModuleImports.ts (1 errors) ==== +==== circularModuleImports.ts (2 errors) ==== module M { @@ -11,6 +12,8 @@ circularModuleImports.ts(5,5): error TS2303: Circular definition of import alias !!! error TS2303: Circular definition of import alias 'A'. import B = A; + ~~~~~~~~~~~~~ +!!! error TS2303: Circular definition of import alias 'B'. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt.diff new file mode 100644 index 0000000000..dd48f7b787 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.circularModuleImports.errors.txt ++++ new.circularModuleImports.errors.txt +@@= skipped -0, +0 lines =@@ + circularModuleImports.ts(5,5): error TS2303: Circular definition of import alias 'A'. +- +- +-==== circularModuleImports.ts (1 errors) ==== ++circularModuleImports.ts(7,5): error TS2303: Circular definition of import alias 'B'. ++ ++ ++==== circularModuleImports.ts (2 errors) ==== + module M + + { +@@= skipped -10, +11 lines =@@ + !!! error TS2303: Circular definition of import alias 'A'. + + import B = A; ++ ~~~~~~~~~~~~~ ++!!! error TS2303: Circular definition of import alias 'B'. + + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js index 6b54aece8e..192219fc76 100644 --- a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js +++ b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js @@ -22,6 +22,7 @@ class Foo { //// [classVarianceResolveCircularity2.js] "use strict"; +// Issue #52813 Object.defineProperty(exports, "__esModule", { value: true }); class Bar { num; diff --git a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js.diff b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js.diff index 46edd29106..5d873414fc 100644 --- a/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/classVarianceResolveCircularity2.js.diff @@ -1,10 +1,7 @@ --- old.classVarianceResolveCircularity2.js +++ new.classVarianceResolveCircularity2.js -@@= skipped -21, +21 lines =@@ - - //// [classVarianceResolveCircularity2.js] - "use strict"; --// Issue #52813 +@@= skipped -24, +24 lines =@@ + // Issue #52813 Object.defineProperty(exports, "__esModule", { value: true }); class Bar { - constructor() { diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js index 4733da1abc..9837da4c37 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js @@ -20,5 +20,9 @@ declare class E extends C { } //// [a.js] +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js.diff deleted file mode 100644 index 87a1fe8499..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientClass1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnAmbientClass1.js -+++ new.commentOnAmbientClass1.js -@@= skipped -19, +19 lines =@@ - } - - //// [a.js] --/*!========= -- Keep this pinned comment -- ========= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js index c95f0fc511..f6c9d92ebf 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js @@ -23,5 +23,9 @@ declare enum E { } //// [a.js] +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js.diff deleted file mode 100644 index 8f095b3b11..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientEnum.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnAmbientEnum.js -+++ new.commentOnAmbientEnum.js -@@= skipped -22, +22 lines =@@ - } - - //// [a.js] --/*!========= -- Keep this pinned comment -- ========= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js index 921318e96a..2d43b502f2 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js @@ -25,5 +25,9 @@ declare module E { } //// [a.js] +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js.diff deleted file mode 100644 index 8b147b4f4a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientModule.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnAmbientModule.js -+++ new.commentOnAmbientModule.js -@@= skipped -24, +24 lines =@@ - } - - //// [a.js] --/*!========= -- Keep this pinned comment -- ========= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js index 493a0cb7e8..5220f0f1b0 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js @@ -13,3 +13,7 @@ declare var v: number; declare var y: number; //// [commentOnAmbientVariable1.js] +/*!========= + Keep this pinned comment + ========= +*/ diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js.diff deleted file mode 100644 index acf7a59f1e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientVariable1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.commentOnAmbientVariable1.js -+++ new.commentOnAmbientVariable1.js -@@= skipped -12, +12 lines =@@ - declare var y: number; - - //// [commentOnAmbientVariable1.js] --/*!========= -- Keep this pinned comment -- ========= --*/ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js b/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js index 52a825d649..2261323694 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js @@ -17,5 +17,9 @@ declare function bar(); declare function foobar(a: typeof foo): typeof bar; //// [a.js] +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js.diff deleted file mode 100644 index 55a2349f41..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnAmbientfunction.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnAmbientfunction.js -+++ new.commentOnAmbientfunction.js -@@= skipped -16, +16 lines =@@ - declare function foobar(a: typeof foo): typeof bar; - - //// [a.js] --/*!========= -- Keep this pinned comment -- ========= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js b/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js index 3b7d9b4daf..72585e6a9e 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js @@ -20,5 +20,9 @@ module ElidedModule3 { } //// [a.js] +/*!================= + Keep this pinned + ================= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js.diff deleted file mode 100644 index 861acd202b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnElidedModule1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnElidedModule1.js -+++ new.commentOnElidedModule1.js -@@= skipped -19, +19 lines =@@ - } - - //// [a.js] --/*!================= -- Keep this pinned -- ================= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js index 6968403a0a..96d1f097e3 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js @@ -8,4 +8,5 @@ import foo = require('./foo'); //// [commentOnImportStatement3.js] "use strict"; +/* copyright */ Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js.diff deleted file mode 100644 index 1dcd831942..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnImportStatement3.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.commentOnImportStatement3.js -+++ new.commentOnImportStatement3.js -@@= skipped -7, +7 lines =@@ - - //// [commentOnImportStatement3.js] - "use strict"; --/* copyright */ - Object.defineProperty(exports, "__esModule", { value: true }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js b/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js index c80760d1e9..c51658e2df 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js @@ -20,5 +20,9 @@ interface I3 { } //// [a.js] +/*!================= + Keep this pinned + ================= +*/ //// [b.js] /// diff --git a/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js.diff deleted file mode 100644 index 44a1d8f99c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnInterface1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.commentOnInterface1.js -+++ new.commentOnInterface1.js -@@= skipped -19, +19 lines =@@ - } - - //// [a.js] --/*!================= -- Keep this pinned -- ================= --*/ - //// [b.js] - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js b/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js index 63845a5bd0..637e3b25b9 100644 --- a/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js +++ b/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js @@ -38,6 +38,10 @@ function foo2(a: any): void { } //// [a.js] +/*!================= + Keep this pinned + ================= +*/ function foo(a) { } class c { diff --git a/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js.diff b/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js.diff deleted file mode 100644 index bb4c48fea0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentOnSignature1.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.commentOnSignature1.js -+++ new.commentOnSignature1.js -@@= skipped -37, +37 lines =@@ - } - - //// [a.js] --/*!================= -- Keep this pinned -- ================= --*/ - function foo(a) { - } - class c { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js b/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js index 7c8e9a8c04..a19ad80982 100644 --- a/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js +++ b/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js @@ -10,9 +10,9 @@ export class SomeAutoGeneratedThing {} //// [commentWithUnreasonableIndentationLevel01.js] "use strict"; +// Repro from #41223 Object.defineProperty(exports, "__esModule", { value: true }); exports.SomeAutoGeneratedThing = void 0; -// Repro from #41223 /** * This is a comment with dumb indentation for some auto-generated thing. */ diff --git a/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js.diff b/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js.diff deleted file mode 100644 index 0392624fbc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/commentWithUnreasonableIndentationLevel01.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.commentWithUnreasonableIndentationLevel01.js -+++ new.commentWithUnreasonableIndentationLevel01.js -@@= skipped -9, +9 lines =@@ - - //// [commentWithUnreasonableIndentationLevel01.js] - "use strict"; --// Repro from #41223 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.SomeAutoGeneratedThing = void 0; -+// Repro from #41223 - /** - * This is a comment with dumb indentation for some auto-generated thing. - */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js b/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js index 4bfa399af9..a6142ff0ec 100644 --- a/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js +++ b/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js @@ -563,9 +563,9 @@ export function viewFactory_AppComponent0(viewUtils:any,parentInjector:any,decla //// [complexNarrowingWithAny.js] "use strict"; +// Repro from #10869 Object.defineProperty(exports, "__esModule", { value: true }); exports.viewFactory_AppComponent0 = viewFactory_AppComponent0; -// Repro from #10869 /** * This file is generated by the Angular 2 template compiler. * Do not edit. diff --git a/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js.diff b/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js.diff index 07df85e517..62ebb990bc 100644 --- a/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js.diff +++ b/testdata/baselines/reference/submodule/compiler/complexNarrowingWithAny.js.diff @@ -1,17 +1,6 @@ --- old.complexNarrowingWithAny.js +++ new.complexNarrowingWithAny.js -@@= skipped -562, +562 lines =@@ - - //// [complexNarrowingWithAny.js] - "use strict"; --// Repro from #10869 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.viewFactory_AppComponent0 = viewFactory_AppComponent0; -+// Repro from #10869 - /** - * This file is generated by the Angular 2 template compiler. - * Do not edit. -@@= skipped -130, +130 lines =@@ +@@= skipped -692, +692 lines =@@ import51.ControlContainer = ControlContainer; })(import51 || (import51 = {})); class _View_AppComponent0 { diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js b/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js index 5bc77ce228..6afd67dd25 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js @@ -10,3 +10,4 @@ type WithSpec = T type R = WithSpec // should not error //// [conditionalTypeAnyUnion.js] +// repro from #52568 diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js.diff deleted file mode 100644 index 77c26d5e6a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeAnyUnion.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.conditionalTypeAnyUnion.js -+++ new.conditionalTypeAnyUnion.js -@@= skipped -9, +9 lines =@@ - type R = WithSpec // should not error - - //// [conditionalTypeAnyUnion.js] --// repro from #52568 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js b/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js index 5a1a9a3a72..7bd8d8ae64 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js @@ -121,9 +121,9 @@ export enum PubSubRecordIsStoredInRedisAsA { const PubSubRecordType = buildPubSubRecordType({}); //// [conditionalTypeDoesntSpinForever.js] -export { PubSubRecordIsStoredInRedisAsA }; // A *self-contained* demonstration of the problem follows... // Test this by running `tsc --target es6` on the command-line, rather than through another build tool such as Gulp, Webpack, etc. +export { PubSubRecordIsStoredInRedisAsA }; var PubSubRecordIsStoredInRedisAsA; (function (PubSubRecordIsStoredInRedisAsA) { PubSubRecordIsStoredInRedisAsA["redisHash"] = "redisHash"; diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js.diff index be33872f0c..849909b8f9 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js.diff +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypeDoesntSpinForever.js.diff @@ -1,13 +1,11 @@ --- old.conditionalTypeDoesntSpinForever.js +++ new.conditionalTypeDoesntSpinForever.js -@@= skipped -120, +120 lines =@@ - const PubSubRecordType = buildPubSubRecordType({}); - +@@= skipped -122, +122 lines =@@ //// [conditionalTypeDoesntSpinForever.js] -+export { PubSubRecordIsStoredInRedisAsA }; // A *self-contained* demonstration of the problem follows... // Test this by running `tsc --target es6` on the command-line, rather than through another build tool such as Gulp, Webpack, etc. -export var PubSubRecordIsStoredInRedisAsA; ++export { PubSubRecordIsStoredInRedisAsA }; +var PubSubRecordIsStoredInRedisAsA; (function (PubSubRecordIsStoredInRedisAsA) { PubSubRecordIsStoredInRedisAsA["redisHash"] = "redisHash"; diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js b/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js index 0b6beefa7d..611917d268 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js @@ -14,3 +14,4 @@ interface AnySchemaType, V> extends AbstractS //// [conditionalTypeSimplification.js] +// Repro from #30794 diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js.diff deleted file mode 100644 index ff19785ecc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypeSimplification.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.conditionalTypeSimplification.js -+++ new.conditionalTypeSimplification.js -@@= skipped -13, +13 lines =@@ - - - //// [conditionalTypeSimplification.js] --// Repro from #30794 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js b/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js index bd47ca6308..cc958056c2 100644 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js +++ b/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js @@ -10,6 +10,7 @@ interface JSONSchema4 { //// [conditionalTypesASI.js] +// Repro from #21637 //// [conditionalTypesASI.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js.diff b/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js.diff deleted file mode 100644 index 51579daebe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/conditionalTypesASI.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.conditionalTypesASI.js -+++ new.conditionalTypesASI.js -@@= skipped -9, +9 lines =@@ - - - //// [conditionalTypesASI.js] --// Repro from #21637 - - - //// [conditionalTypesASI.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js b/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js index 92c53c8d92..f511bb55b1 100644 --- a/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js +++ b/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js @@ -38,9 +38,9 @@ class Item extends BaseClass { //// [conflictingTypeParameterSymbolTransfer.js] "use strict"; +// @strict Object.defineProperty(exports, "__esModule", { value: true }); exports.C2 = void 0; -// @strict // Via #56620 class Base { } diff --git a/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js.diff b/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js.diff index a9203fd8cd..81a3b724a3 100644 --- a/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js.diff +++ b/testdata/baselines/reference/submodule/compiler/conflictingTypeParameterSymbolTransfer.js.diff @@ -1,14 +1,6 @@ --- old.conflictingTypeParameterSymbolTransfer.js +++ new.conflictingTypeParameterSymbolTransfer.js -@@= skipped -37, +37 lines =@@ - - //// [conflictingTypeParameterSymbolTransfer.js] - "use strict"; --// @strict - Object.defineProperty(exports, "__esModule", { value: true }); - exports.C2 = void 0; -+// @strict - // Via #56620 +@@= skipped -44, +44 lines =@@ class Base { } class C2 extends Base { @@ -16,7 +8,7 @@ constructor(T) { super(); // Should not error -@@= skipped -20, +21 lines =@@ +@@= skipped -13, +14 lines =@@ class Leg { } class Foo extends Leg { diff --git a/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js b/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js index f23204a27f..9e3fd4f274 100644 --- a/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js +++ b/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js @@ -43,6 +43,9 @@ function mixed4(x: Record<'a', T>, y: Record2) { //// [consistentAliasVsNonAliasRecordBehavior.js] +// TODO: FIXME: All the below cases labeled `no error` _should be an error_, and are only prevented from so being +// by incorrect variance-based relationships +// Ref: https://github.com/Microsoft/TypeScript/issues/29698 function defaultRecord(x, y) { x = y; // no error, but error expected. } diff --git a/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js.diff b/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js.diff deleted file mode 100644 index 58122a9e9e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/consistentAliasVsNonAliasRecordBehavior.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.consistentAliasVsNonAliasRecordBehavior.js -+++ new.consistentAliasVsNonAliasRecordBehavior.js -@@= skipped -42, +42 lines =@@ - - - //// [consistentAliasVsNonAliasRecordBehavior.js] --// TODO: FIXME: All the below cases labeled `no error` _should be an error_, and are only prevented from so being --// by incorrect variance-based relationships --// Ref: https://github.com/Microsoft/TypeScript/issues/29698 - function defaultRecord(x, y) { - x = y; // no error, but error expected. - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constWithNonNull.js b/testdata/baselines/reference/submodule/compiler/constWithNonNull.js index d8c2c37962..6cf38ad519 100644 --- a/testdata/baselines/reference/submodule/compiler/constWithNonNull.js +++ b/testdata/baselines/reference/submodule/compiler/constWithNonNull.js @@ -8,4 +8,5 @@ x!++; //// [constWithNonNull.js] +// Fixes #21848 x++; diff --git a/testdata/baselines/reference/submodule/compiler/constWithNonNull.js.diff b/testdata/baselines/reference/submodule/compiler/constWithNonNull.js.diff deleted file mode 100644 index 5cfb298b89..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constWithNonNull.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.constWithNonNull.js -+++ new.constWithNonNull.js -@@= skipped -7, +7 lines =@@ - - - //// [constWithNonNull.js] --// Fixes #21848 - x++; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js b/testdata/baselines/reference/submodule/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js index 434ab25a15..d7c43c002a 100644 --- a/testdata/baselines/reference/submodule/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js +++ b/testdata/baselines/reference/submodule/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js @@ -25,4 +25,5 @@ export interface IImmutableMap2> extends Map(v: V) => void>() { //// [constraintReferencingTypeParameterFromSameTypeParameterList.js] +// used to be valid, now an error to do this function f() { } function foo() { diff --git a/testdata/baselines/reference/submodule/compiler/constraintReferencingTypeParameterFromSameTypeParameterList.js.diff b/testdata/baselines/reference/submodule/compiler/constraintReferencingTypeParameterFromSameTypeParameterList.js.diff deleted file mode 100644 index b0ad009519..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constraintReferencingTypeParameterFromSameTypeParameterList.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.constraintReferencingTypeParameterFromSameTypeParameterList.js -+++ new.constraintReferencingTypeParameterFromSameTypeParameterList.js -@@= skipped -26, +26 lines =@@ - - - //// [constraintReferencingTypeParameterFromSameTypeParameterList.js] --// used to be valid, now an error to do this - function f() { - } - function foo() { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js b/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js index 418ea01336..359b24a27d 100644 --- a/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js +++ b/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js @@ -60,6 +60,7 @@ test( //// [contextSensitiveReturnTypeInference.js] +// Repro from #34849 const DEPS = { foo: 1 }; diff --git a/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js.diff b/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js.diff index e92610a536..440bae3f6c 100644 --- a/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js.diff +++ b/testdata/baselines/reference/submodule/compiler/contextSensitiveReturnTypeInference.js.diff @@ -5,7 +5,6 @@ //// [contextSensitiveReturnTypeInference.js] -"use strict"; --// Repro from #34849 + // Repro from #34849 const DEPS = { - foo: 1 - }; \ No newline at end of file + foo: 1 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js b/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js index 73c02a4083..1c6a523b6e 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js +++ b/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js @@ -8,4 +8,5 @@ f({ data: 0 }, { data(value, key) {} }); //// [contextualPropertyOfGenericMappedType.js] +// Repro for #24694 f({ data: 0 }, { data(value, key) { } }); diff --git a/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js.diff b/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js.diff deleted file mode 100644 index b79e469d24..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contextualPropertyOfGenericMappedType.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.contextualPropertyOfGenericMappedType.js -+++ new.contextualPropertyOfGenericMappedType.js -@@= skipped -7, +7 lines =@@ - - - //// [contextualPropertyOfGenericMappedType.js] --// Repro for #24694 - f({ data: 0 }, { data(value, key) { } }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js b/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js index a52165a583..3cd8546ba0 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js +++ b/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js @@ -22,6 +22,7 @@ const banana5 = fruitFactory5(Banana) // Banana<"foo"> //// [contextualSignatureInstantiation4.js] +// Repros from #32976 const banana1 = fruitFactory1(Banana); // Banana const banana2 = fruitFactory2(Banana); // Banana const banana3 = fruitFactory3(Banana); // Banana<"foo"> diff --git a/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js.diff b/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js.diff index be8fb6e1e8..ad3e9202f3 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js.diff +++ b/testdata/baselines/reference/submodule/compiler/contextualSignatureInstantiation4.js.diff @@ -5,7 +5,6 @@ //// [contextualSignatureInstantiation4.js] -"use strict"; --// Repros from #32976 + // Repros from #32976 const banana1 = fruitFactory1(Banana); // Banana - const banana2 = fruitFactory2(Banana); // Banana - const banana3 = fruitFactory3(Banana); // Banana<"foo"> \ No newline at end of file + const banana2 = fruitFactory2(Banana); // Banana \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js b/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js index 496cc2c0d8..9d496e8aef 100644 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js +++ b/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js @@ -30,6 +30,7 @@ const x: Observable = observable(false); //// [contextuallyTypedBooleanLiterals.js] +// Repro from #48363 const bn1 = box(0); // Box const bn2 = box(0); // Ok const bb1 = box(false); // Box diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js.diff b/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js.diff index 65bad0af4d..82fa29fe9f 100644 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js.diff +++ b/testdata/baselines/reference/submodule/compiler/contextuallyTypedBooleanLiterals.js.diff @@ -5,7 +5,6 @@ //// [contextuallyTypedBooleanLiterals.js] -"use strict"; --// Repro from #48363 + // Repro from #48363 const bn1 = box(0); // Box - const bn2 = box(0); // Ok - const bb1 = box(false); // Box \ No newline at end of file + const bn2 = box(0); // Ok \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js index 6c3d9fe7d5..9bcb86269a 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js @@ -25,6 +25,7 @@ function foo(things: Val[]): void { } //// [controlFlowDestructuringLoop.js] +// Repro from #28758 function isNumVal(x) { return typeof x.val === 'number'; } diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js.diff index 69009d6440..a919bc0a4d 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js.diff +++ b/testdata/baselines/reference/submodule/compiler/controlFlowDestructuringLoop.js.diff @@ -5,7 +5,6 @@ //// [controlFlowDestructuringLoop.js] -"use strict"; --// Repro from #28758 + // Repro from #28758 function isNumVal(x) { - return typeof x.val === 'number'; - } \ No newline at end of file + return typeof x.val === 'number'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js b/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js index 0c2e32cb74..af657b632d 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js @@ -152,6 +152,7 @@ export class StyleParser { //// [controlFlowPropertyDeclarations.js] "use strict"; +// Repro from ##8913 Object.defineProperty(exports, "__esModule", { value: true }); exports.StyleParser = exports.HTMLtoJSX = void 0; var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig'); diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js.diff index c0f009b46e..3efc353dd3 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js.diff +++ b/testdata/baselines/reference/submodule/compiler/controlFlowPropertyDeclarations.js.diff @@ -1,14 +1,6 @@ --- old.controlFlowPropertyDeclarations.js +++ new.controlFlowPropertyDeclarations.js -@@= skipped -151, +151 lines =@@ - - //// [controlFlowPropertyDeclarations.js] - "use strict"; --// Repro from ##8913 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.StyleParser = exports.HTMLtoJSX = void 0; - var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig'); -@@= skipped -87, +86 lines =@@ +@@= skipped -238, +238 lines =@@ return /^\d+px$/.test(value); } class HTMLtoJSX { diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js b/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js index 70cf0436ee..ff82e5c972 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js @@ -124,8 +124,8 @@ function getObject(id: string | number) { //// [controlFlowSelfReferentialLoop.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // Repro from #12319 +Object.defineProperty(exports, "__esModule", { value: true }); function md5(string) { function FF(a, b, c, d, x, s, ac) { return 0; diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js.diff deleted file mode 100644 index 4015bfc679..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowSelfReferentialLoop.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.controlFlowSelfReferentialLoop.js -+++ new.controlFlowSelfReferentialLoop.js -@@= skipped -123, +123 lines =@@ - - //// [controlFlowSelfReferentialLoop.js] - "use strict"; --// Repro from #12319 - Object.defineProperty(exports, "__esModule", { value: true }); -+// Repro from #12319 - function md5(string) { - function FF(a, b, c, d, x, s, ac) { - return 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js b/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js index de53bab39f..5c75c3407e 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js +++ b/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js @@ -30,6 +30,7 @@ function foo2() { } //// [controlFlowWithIncompleteTypes.js] +// Repro from #11000 function foo1() { let x = 0; while (cond) { diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js.diff b/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js.diff deleted file mode 100644 index 6e1c290db9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/controlFlowWithIncompleteTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.controlFlowWithIncompleteTypes.js -+++ new.controlFlowWithIncompleteTypes.js -@@= skipped -29, +29 lines =@@ - } - - //// [controlFlowWithIncompleteTypes.js] --// Repro from #11000 - function foo1() { - let x = 0; - while (cond) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/correlatedUnions.js b/testdata/baselines/reference/submodule/compiler/correlatedUnions.js index f28acd85d2..60b89f2fb3 100644 --- a/testdata/baselines/reference/submodule/compiler/correlatedUnions.js +++ b/testdata/baselines/reference/submodule/compiler/correlatedUnions.js @@ -304,6 +304,7 @@ function getValueConcrete( //// [correlatedUnions.js] +// Various repros from #30581 function processRecord(rec) { rec.f(rec.v); } diff --git a/testdata/baselines/reference/submodule/compiler/correlatedUnions.js.diff b/testdata/baselines/reference/submodule/compiler/correlatedUnions.js.diff index 8e046ca39f..6e2c376340 100644 --- a/testdata/baselines/reference/submodule/compiler/correlatedUnions.js.diff +++ b/testdata/baselines/reference/submodule/compiler/correlatedUnions.js.diff @@ -5,11 +5,10 @@ //// [correlatedUnions.js] -"use strict"; --// Various repros from #30581 + // Various repros from #30581 function processRecord(rec) { rec.f(rec.v); - } -@@= skipped -214, +212 lines =@@ +@@= skipped -214, +213 lines =@@ declare function createEventListener({ name, once, callback }: Ev): Ev; declare const clickEvent: { readonly name: "click"; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js index f731d32e3b..66ac428f74 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js @@ -42,6 +42,9 @@ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(somet //// [input.d.ts] +/** + * @typedef {{ } & { name?: string }} P + */ export type P = {} & { name?: string; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js.diff index 3ce20e95ee..66f8165e97 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).js.diff @@ -5,6 +5,9 @@ //// [input.d.ts] -export function fn(p?: P): void; ++/** ++ * @typedef {{ } & { name?: string }} P ++ */ +export type P = {} & { + name?: string; +}; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js index 9e50d3792c..f2e51184e5 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js @@ -42,6 +42,9 @@ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(somet //// [input.d.ts] +/** + * @typedef {{ } & { name?: string }} P + */ export type P = {} & { name?: string; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js.diff index ae201f753b..db186c93e4 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).js.diff @@ -5,6 +5,9 @@ //// [input.d.ts] -export function fn(p?: P): void; ++/** ++ * @typedef {{ } & { name?: string }} P ++ */ +export type P = {} & { + name?: string; +}; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js b/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js index 345ebd102f..9a3ef3a146 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js @@ -82,14 +82,32 @@ C.B = B; export declare class Foo { } //// [index1.d.ts] -export default function Example(): void; +declare function Example(): void; +export default Example; +declare namespace Example { + var Foo: typeof import("./foo").Foo; +} //// [index2.d.ts] import { Foo } from './foo'; export { Foo }; -export default function Example(): void; +declare function Example(): void; +export default Example; +declare namespace Example { + var Foo: typeof import("./foo").Foo; +} //// [index3.d.ts] export declare class Bar { } -export default function Example(): void; +declare function Example(): void; +export default Example; +declare namespace Example { + var Bar: typeof import("./index3").Bar; +} //// [index4.d.ts] export declare function C(): any; +export declare namespace C { + var A: () => void; +} +export declare namespace C { + var B: () => void; +} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js.diff index ff4abd456f..552d88daf0 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js.diff @@ -18,37 +18,38 @@ Object.defineProperty(exports, "Foo", { enumerable: true, get: function () { return foo_1.Foo; } }); function Example() { } Example.Foo = foo_1.Foo; -@@= skipped -31, +31 lines =@@ - export declare class Foo { +@@= skipped -32, +32 lines =@@ } //// [index1.d.ts] --declare function Example(): void; --declare namespace Example { -- var Foo: typeof import("./foo").Foo; --} + declare function Example(): void; ++export default Example; + declare namespace Example { + var Foo: typeof import("./foo").Foo; + } -export default Example; -+export default function Example(): void; //// [index2.d.ts] import { Foo } from './foo'; export { Foo }; --declare function Example(): void; --declare namespace Example { -- var Foo: typeof import("./foo").Foo; --} + declare function Example(): void; ++export default Example; + declare namespace Example { + var Foo: typeof import("./foo").Foo; + } -export default Example; -+export default function Example(): void; //// [index3.d.ts] export declare class Bar { } --declare function Example(): void; --declare namespace Example { -- var Bar: typeof import("./index3").Bar; --} + declare function Example(): void; ++export default Example; + declare namespace Example { + var Bar: typeof import("./index3").Bar; + } -export default Example; -+export default function Example(): void; //// [index4.d.ts] export declare function C(): any; --export declare namespace C { -- var A: () => void; -- var B: () => void; --} \ No newline at end of file + export declare namespace C { + var A: () => void; ++} ++export declare namespace C { + var B: () => void; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js b/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js index d44b34946b..0c6b49eb4a 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js @@ -32,6 +32,7 @@ class Hola { //// [test1.js] +/*! Copyright 2015 MyCompany Inc. */ class Hello { } //// [test2.js] @@ -43,6 +44,7 @@ class Hola { //// [test1.d.ts] +/*! Copyright 2015 MyCompany Inc. */ declare class Hello { } //// [test2.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js.diff deleted file mode 100644 index 702fedbaa6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitDetachedComment2.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.declarationEmitDetachedComment2.js -+++ new.declarationEmitDetachedComment2.js -@@= skipped -31, +31 lines =@@ - - - //// [test1.js] --/*! Copyright 2015 MyCompany Inc. */ - class Hello { - } - //// [test2.js] -@@= skipped -12, +11 lines =@@ - - - //// [test1.d.ts] --/*! Copyright 2015 MyCompany Inc. */ - declare class Hello { - } - //// [test2.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.errors.txt new file mode 100644 index 0000000000..1ed386c351 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.errors.txt @@ -0,0 +1,14 @@ +b.ts(4,1): error TS4032: Property 'val' of exported interface has or is using name 'I' from private module '"a"'. + + +==== a.ts (0 errors) ==== + interface I {} + export function f(): I { return null as I; } +==== b.ts (1 errors) ==== + import {f} from "./a"; + + export function q() {} + q.val = f(); + ~~~~~~~~~~~ +!!! error TS4032: Property 'val' of exported interface has or is using name 'I' from private module '"a"'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.errors.txt.diff index fc2ba7171a..e5704b00b0 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.errors.txt.diff @@ -1,18 +1,10 @@ --- old.declarationEmitExpandoPropertyPrivateName.errors.txt +++ new.declarationEmitExpandoPropertyPrivateName.errors.txt -@@= skipped -0, +0 lines =@@ --b.ts(4,1): error TS4032: Property 'val' of exported interface has or is using name 'I' from private module '"a"'. -- -- --==== a.ts (0 errors) ==== -- interface I {} -- export function f(): I { return null as I; } --==== b.ts (1 errors) ==== -- import {f} from "./a"; -- -- export function q() {} -- q.val = f(); +@@= skipped -8, +8 lines =@@ + + export function q() {} + q.val = f(); - ~~~~~ --!!! error TS4032: Property 'val' of exported interface has or is using name 'I' from private module '"a"'. -- -+ \ No newline at end of file ++ ~~~~~~~~~~~ + !!! error TS4032: Property 'val' of exported interface has or is using name 'I' from private module '"a"'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js index 4b994cff3c..62611a4b50 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js @@ -31,3 +31,6 @@ export declare function f(): I; export {}; //// [b.d.ts] export declare function q(): void; +export declare namespace q { + var val: I; +} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js.diff index e97c240744..1a0346d4ab 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoPropertyPrivateName.js.diff @@ -14,4 +14,7 @@ export declare function f(): I; export {}; +//// [b.d.ts] -+export declare function q(): void; \ No newline at end of file ++export declare function q(): void; ++export declare namespace q { ++ var val: I; ++} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js index 02c1beb29a..cf2922f110 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js @@ -36,8 +36,8 @@ export interface Rect

{ readonly a: p; readonly b: p; } -export declare const Point: { - (x: number, y: number): Point; - zero: () => Point; -}; +export declare function Point(x: number, y: number): Point; export declare const Rect:

(a: p, b: p) => Rect

; +export declare namespace Point { + var zero: () => Point; +} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js.diff index 6b591946c6..eca527388e 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitExpandoWithGenericConstraint.js.diff @@ -1,10 +1,15 @@ --- old.declarationEmitExpandoWithGenericConstraint.js +++ new.declarationEmitExpandoWithGenericConstraint.js -@@= skipped -37, +37 lines =@@ +@@= skipped -35, +35 lines =@@ + readonly a: p; + readonly b: p; } - export declare const Point: { - (x: number, y: number): Point; +-export declare const Point: { +- (x: number, y: number): Point; - zero(): Point; -+ zero: () => Point; - }; - export declare const Rect:

(a: p, b: p) => Rect

; \ No newline at end of file +-}; ++export declare function Point(x: number, y: number): Point; + export declare const Rect:

(a: p, b: p) => Rect

; ++export declare namespace Point { ++ var zero: () => Point; ++} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitFunctionKeywordProp.js b/testdata/baselines/reference/submodule/compiler/declarationEmitFunctionKeywordProp.js index f5ce29f90a..0c8480ef02 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitFunctionKeywordProp.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitFunctionKeywordProp.js @@ -25,5 +25,22 @@ baz.normal = false; //// [declarationEmitFunctionKeywordProp.d.ts] declare function foo(): void; +declare namespace foo { + var _a: boolean; + export { _a as null }; +} declare function bar(): void; +declare namespace bar { + var async: boolean; +} +declare namespace bar { + var normal: boolean; +} declare function baz(): void; +declare namespace baz { + var _b: boolean; + export { _b as class }; +} +declare namespace baz { + var normal: boolean; +} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitFunctionKeywordProp.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitFunctionKeywordProp.js.diff index 5628351b23..06133cdc84 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitFunctionKeywordProp.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitFunctionKeywordProp.js.diff @@ -1,21 +1,21 @@ --- old.declarationEmitFunctionKeywordProp.js +++ new.declarationEmitFunctionKeywordProp.js -@@= skipped -24, +24 lines =@@ - - //// [declarationEmitFunctionKeywordProp.d.ts] - declare function foo(): void; --declare namespace foo { -- var _a: boolean; -- export { _a as null }; --} +@@= skipped -31, +31 lines =@@ declare function bar(): void; --declare namespace bar { -- var async: boolean; -- var normal: boolean; --} + declare namespace bar { + var async: boolean; ++} ++declare namespace bar { + var normal: boolean; + } declare function baz(): void; --declare namespace baz { + declare namespace baz { - var _a: boolean; - export var normal: boolean; - export { _a as class }; --} \ No newline at end of file ++ var _b: boolean; ++ export { _b as class }; ++} ++declare namespace baz { ++ var normal: boolean; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js b/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js index 2fe741d288..cdfdfdad11 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js @@ -7,9 +7,9 @@ export let b = [{ foo: 0, m() {} }, { bar: 1 }]; //// [declarationEmitInferredUndefinedPropFromFunctionInArray.js] "use strict"; +// repro from https://github.com/microsoft/TypeScript/issues/53914 Object.defineProperty(exports, "__esModule", { value: true }); exports.b = void 0; -// repro from https://github.com/microsoft/TypeScript/issues/53914 exports.b = [{ foo: 0, m() { } }, { bar: 1 }]; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js.diff deleted file mode 100644 index 7d4aec176a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitInferredUndefinedPropFromFunctionInArray.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.declarationEmitInferredUndefinedPropFromFunctionInArray.js -+++ new.declarationEmitInferredUndefinedPropFromFunctionInArray.js -@@= skipped -6, +6 lines =@@ - - //// [declarationEmitInferredUndefinedPropFromFunctionInArray.js] - "use strict"; --// repro from https://github.com/microsoft/TypeScript/issues/53914 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.b = void 0; -+// repro from https://github.com/microsoft/TypeScript/issues/53914 - exports.b = [{ foo: 0, m() { } }, { bar: 1 }]; - diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js b/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js index 3079c4ba18..45192f5a18 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js @@ -68,87 +68,14 @@ exports.publicProcedure = trpc.procedure; //// [index.d.ts] -export declare const middleware: >(fn: import("@trpc/server").MiddlewareFunction<{ - _config: import("@trpc/server").RootConfig<{ - errorShape: import("@trpc/server").ErrorFormatterShape; +export declare const middleware: >(fn: import("@trpc/server/middleware").MiddlewareFunction<{ + _config: import("@trpc/server/internals/config").RootConfig<{ + errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape; }>; -}, TNewParams>) => import("@trpc/server").MiddlewareBuilder<{ - _config: import("@trpc/server").RootConfig<{ - errorShape: import("@trpc/server").ErrorFormatterShape; +}, TNewParams>) => import("@trpc/server/middleware").MiddlewareBuilder<{ + _config: import("@trpc/server/internals/config").RootConfig<{ + errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape; }>; }, TNewParams>; export declare const router: {}; export declare const publicProcedure: {}; - - -//// [DtsFileErrors] - - -index.d.ts(1,102): error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareFunction'. -index.d.ts(5,43): error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareBuilder'. - - -==== node_modules/@trpc/server/internals/config.d.ts (0 errors) ==== - export interface RootConfig { - prop: T; - } -==== node_modules/@trpc/server/internals/utils.d.ts (0 errors) ==== - export interface ErrorFormatterShape { - prop: T; - } - export type PickFirstDefined = undefined extends TType - ? undefined extends TPick - ? never - : TPick - : TType; - export interface ErrorFormatter { - prop: [T, U]; - } - export interface DefaultErrorShape { - prop: T; - } -==== node_modules/@trpc/server/middleware.d.ts (0 errors) ==== - export interface MiddlewareFunction { - prop: [T, U]; - } - export interface MiddlewareBuilder { - prop: [T, U]; - } -==== node_modules/@trpc/server/index.d.ts (0 errors) ==== - import { RootConfig } from './internals/config'; - import { ErrorFormatterShape, PickFirstDefined, ErrorFormatter, DefaultErrorShape } from './internals/utils'; - declare class TRPCBuilder { - create>(): { - procedure: {}; - middleware: >(fn: import("./middleware").MiddlewareFunction<{ - _config: RootConfig<{ - errorShape: ErrorFormatterShape>>; - }>; - }, TNewParams>) => import("./middleware").MiddlewareBuilder<{ - _config: RootConfig<{ - errorShape: ErrorFormatterShape>>; - }>; - }, TNewParams>; - router: {}; - }; - } - - export declare const initTRPC: TRPCBuilder; - export {}; -==== index.d.ts (2 errors) ==== - export declare const middleware: >(fn: import("@trpc/server").MiddlewareFunction<{ - ~~~~~~~~~~~~~~~~~~ -!!! error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareFunction'. - _config: import("@trpc/server").RootConfig<{ - errorShape: import("@trpc/server").ErrorFormatterShape; - }>; - }, TNewParams>) => import("@trpc/server").MiddlewareBuilder<{ - ~~~~~~~~~~~~~~~~~ -!!! error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareBuilder'. - _config: import("@trpc/server").RootConfig<{ - errorShape: import("@trpc/server").ErrorFormatterShape; - }>; - }, TNewParams>; - export declare const router: {}; - export declare const publicProcedure: {}; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js.diff index acd616e574..d4735170cf 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitIsolatedDeclarationErrorNotEmittedForNonEmittedFile.js.diff @@ -13,87 +13,14 @@ + + +//// [index.d.ts] -+export declare const middleware: >(fn: import("@trpc/server").MiddlewareFunction<{ -+ _config: import("@trpc/server").RootConfig<{ -+ errorShape: import("@trpc/server").ErrorFormatterShape; ++export declare const middleware: >(fn: import("@trpc/server/middleware").MiddlewareFunction<{ ++ _config: import("@trpc/server/internals/config").RootConfig<{ ++ errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape; + }>; -+}, TNewParams>) => import("@trpc/server").MiddlewareBuilder<{ -+ _config: import("@trpc/server").RootConfig<{ -+ errorShape: import("@trpc/server").ErrorFormatterShape; ++}, TNewParams>) => import("@trpc/server/middleware").MiddlewareBuilder<{ ++ _config: import("@trpc/server/internals/config").RootConfig<{ ++ errorShape: import("@trpc/server/internals/utils").ErrorFormatterShape; + }>; +}, TNewParams>; +export declare const router: {}; -+export declare const publicProcedure: {}; -+ -+ -+//// [DtsFileErrors] -+ -+ -+index.d.ts(1,102): error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareFunction'. -+index.d.ts(5,43): error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareBuilder'. -+ -+ -+==== node_modules/@trpc/server/internals/config.d.ts (0 errors) ==== -+ export interface RootConfig { -+ prop: T; -+ } -+==== node_modules/@trpc/server/internals/utils.d.ts (0 errors) ==== -+ export interface ErrorFormatterShape { -+ prop: T; -+ } -+ export type PickFirstDefined = undefined extends TType -+ ? undefined extends TPick -+ ? never -+ : TPick -+ : TType; -+ export interface ErrorFormatter { -+ prop: [T, U]; -+ } -+ export interface DefaultErrorShape { -+ prop: T; -+ } -+==== node_modules/@trpc/server/middleware.d.ts (0 errors) ==== -+ export interface MiddlewareFunction { -+ prop: [T, U]; -+ } -+ export interface MiddlewareBuilder { -+ prop: [T, U]; -+ } -+==== node_modules/@trpc/server/index.d.ts (0 errors) ==== -+ import { RootConfig } from './internals/config'; -+ import { ErrorFormatterShape, PickFirstDefined, ErrorFormatter, DefaultErrorShape } from './internals/utils'; -+ declare class TRPCBuilder { -+ create>(): { -+ procedure: {}; -+ middleware: >(fn: import("./middleware").MiddlewareFunction<{ -+ _config: RootConfig<{ -+ errorShape: ErrorFormatterShape>>; -+ }>; -+ }, TNewParams>) => import("./middleware").MiddlewareBuilder<{ -+ _config: RootConfig<{ -+ errorShape: ErrorFormatterShape>>; -+ }>; -+ }, TNewParams>; -+ router: {}; -+ }; -+ } -+ -+ export declare const initTRPC: TRPCBuilder; -+ export {}; -+==== index.d.ts (2 errors) ==== -+ export declare const middleware: >(fn: import("@trpc/server").MiddlewareFunction<{ -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareFunction'. -+ _config: import("@trpc/server").RootConfig<{ -+ errorShape: import("@trpc/server").ErrorFormatterShape; -+ }>; -+ }, TNewParams>) => import("@trpc/server").MiddlewareBuilder<{ -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS2694: Namespace '"node_modules/@trpc/server/index"' has no exported member 'MiddlewareBuilder'. -+ _config: import("@trpc/server").RootConfig<{ -+ errorShape: import("@trpc/server").ErrorFormatterShape; -+ }>; -+ }, TNewParams>; -+ export declare const router: {}; -+ export declare const publicProcedure: {}; -+ \ No newline at end of file ++export declare const publicProcedure: {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments.js b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments.js index fc844a9af6..9d36f2464b 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments.js @@ -36,3 +36,9 @@ const a = foo[dashStrMem]; //// [declarationEmitLateBoundAssignments.d.ts] export declare function foo(): void; +export declare namespace foo { + var bar: number; +} +export declare namespace foo { + var strMemName: string; +} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments.js.diff index 9b5edc4ae8..e6fc1de8ea 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments.js.diff @@ -1,10 +1,10 @@ --- old.declarationEmitLateBoundAssignments.js +++ new.declarationEmitLateBoundAssignments.js -@@= skipped -35, +35 lines =@@ - - //// [declarationEmitLateBoundAssignments.d.ts] +@@= skipped -37, +37 lines =@@ export declare function foo(): void; --export declare namespace foo { -- var bar: number; -- var strMemName: string; --} \ No newline at end of file + export declare namespace foo { + var bar: number; ++} ++export declare namespace foo { + var strMemName: string; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.js b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.js index dbace19f24..370aaf1b30 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.js @@ -121,7 +121,13 @@ arrow10[emoji] = 0; //// [declarationEmitLateBoundAssignments2.d.ts] export declare function decl(): void; +export declare namespace decl { + var B: string; +} export declare function decl2(): void; +export declare namespace decl2 { + var C: number; +} export declare function decl3(): void; export declare function decl4(): void; export declare function decl5(): void; @@ -130,14 +136,14 @@ export declare function decl7(): void; export declare function decl8(): void; export declare function decl9(): void; export declare function decl10(): void; -export declare const arrow: { - (): void; - B: string; -}; -export declare const arrow2: { - (): void; - C: number; -}; +export declare function arrow(): void; +export declare namespace arrow { + var B: string; +} +export declare function arrow2(): void; +export declare namespace arrow2 { + var C: number; +} export declare const arrow3: { (): void; 77: number; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.js.diff index 7b63352120..d2275bb556 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundAssignments2.js.diff @@ -1,16 +1,8 @@ --- old.declarationEmitLateBoundAssignments2.js +++ new.declarationEmitLateBoundAssignments2.js -@@= skipped -120, +120 lines =@@ - - //// [declarationEmitLateBoundAssignments2.d.ts] - export declare function decl(): void; --export declare namespace decl { -- var B: string; --} - export declare function decl2(): void; --export declare namespace decl2 { -- var C: number; --} +@@= skipped -128, +128 lines =@@ + var C: number; + } export declare function decl3(): void; -export declare namespace decl3 { } export declare function decl4(): void; @@ -27,6 +19,22 @@ -export declare namespace decl9 { } export declare function decl10(): void; -export declare namespace decl10 { } - export declare const arrow: { +-export declare const arrow: { +- (): void; +- B: string; +-}; +-export declare const arrow2: { +- (): void; +- C: number; +-}; ++export declare function arrow(): void; ++export declare namespace arrow { ++ var B: string; ++} ++export declare function arrow2(): void; ++export declare namespace arrow2 { ++ var C: number; ++} + export declare const arrow3: { (): void; - B: string; \ No newline at end of file + 77: number; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.js b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.js index b3e5b3073c..c807097433 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.js @@ -26,3 +26,9 @@ const a = foo[dashStrMem]; //// [file.d.ts] export declare function foo(): void; +export declare namespace foo { + var bar: number; +} +export declare namespace foo { + var strMemName: string; +} diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.js.diff index 62c383b58d..3f66ad50ff 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.js.diff @@ -8,5 +8,10 @@ -export namespace foo { - let bar: number; - let strMemName: string; --} -+export declare function foo(): void; \ No newline at end of file ++export declare function foo(): void; ++export declare namespace foo { ++ var bar: number; ++} ++export declare namespace foo { ++ var strMemName: string; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js index 43466056a4..3d0bd7dd79 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js @@ -62,6 +62,7 @@ export const entriesOf = (o: o) => //// [declarationEmitMappedTypePreservesTypeParameterConstraint.js] "use strict"; +// repro from https://github.com/microsoft/TypeScript/issues/54560 Object.defineProperty(exports, "__esModule", { value: true }); exports.entriesOf = exports.buildSchema = void 0; const buildSchema = (version) => (({})); diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js.diff index 90819e98d3..6e0f495e0e 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePreservesTypeParameterConstraint.js.diff @@ -1,10 +1,7 @@ --- old.declarationEmitMappedTypePreservesTypeParameterConstraint.js +++ new.declarationEmitMappedTypePreservesTypeParameterConstraint.js -@@= skipped -61, +61 lines =@@ - - //// [declarationEmitMappedTypePreservesTypeParameterConstraint.js] - "use strict"; --// repro from https://github.com/microsoft/TypeScript/issues/54560 +@@= skipped -64, +64 lines =@@ + // repro from https://github.com/microsoft/TypeScript/issues/54560 Object.defineProperty(exports, "__esModule", { value: true }); exports.entriesOf = exports.buildSchema = void 0; -const buildSchema = (version) => ({}); @@ -12,7 +9,7 @@ exports.buildSchema = buildSchema; const entriesOf = (o) => Object.entries(o); exports.entriesOf = entriesOf; -@@= skipped -31, +30 lines =@@ +@@= skipped -28, +28 lines =@@ export declare type ZodRawShape = { [k: string]: ZodTypeAny; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js index cf17422ad6..f429d2e37c 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js @@ -12,5 +12,5 @@ exports.f = ((arg) => arg)({ '0': 0 }); // Original prop uses string syntax //// [declarationEmitMappedTypePropertyFromNumericStringKey.d.ts] export declare const f: { - "0": string | number; + '0': string | number; }; diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js.diff deleted file mode 100644 index 3d865db89d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.declarationEmitMappedTypePropertyFromNumericStringKey.js -+++ new.declarationEmitMappedTypePropertyFromNumericStringKey.js -@@= skipped -11, +11 lines =@@ - - //// [declarationEmitMappedTypePropertyFromNumericStringKey.d.ts] - export declare const f: { -- '0': string | number; -+ "0": string | number; - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types index 84bf1f59bd..04705c37ee 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types @@ -2,13 +2,13 @@ === declarationEmitMappedTypePropertyFromNumericStringKey.ts === export const f = ((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}); // Original prop uses string syntax ->f : { "0": string | number; } ->((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { "0": string | number; } +>f : { '0': string | number; } +>((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { '0': string | number; } >((arg: {[K in keyof T]: T[K] | string}) => arg) : (arg: { [K in keyof T]: string | T[K]; }) => { [K in keyof T]: string | T[K]; } >(arg: {[K in keyof T]: T[K] | string}) => arg : (arg: { [K in keyof T]: string | T[K]; }) => { [K in keyof T]: string | T[K]; } >arg : { [K in keyof T]: string | T[K]; } >arg : { [K in keyof T]: string | T[K]; } ->{'0': 0} : { "0": number; } +>{'0': 0} : { '0': number; } >'0' : number >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types.diff index 0023a8b4b6..a26d381f10 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitMappedTypePropertyFromNumericStringKey.types.diff @@ -1,22 +1,13 @@ --- old.declarationEmitMappedTypePropertyFromNumericStringKey.types +++ new.declarationEmitMappedTypePropertyFromNumericStringKey.types -@@= skipped -1, +1 lines =@@ - - === declarationEmitMappedTypePropertyFromNumericStringKey.ts === +@@= skipped -3, +3 lines =@@ export const f = ((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}); // Original prop uses string syntax -->f : { '0': string | number; } -->((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { '0': string | number; } + >f : { '0': string | number; } + >((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { '0': string | number; } ->((arg: {[K in keyof T]: T[K] | string}) => arg) : (arg: { [K in keyof T]: T[K] | string; }) => { [K in keyof T]: string | T[K]; } ->(arg: {[K in keyof T]: T[K] | string}) => arg : (arg: { [K in keyof T]: T[K] | string; }) => { [K in keyof T]: string | T[K]; } -->arg : { [K in keyof T]: string | T[K]; } -->arg : { [K in keyof T]: string | T[K]; } -->{'0': 0} : { '0': number; } -+>f : { "0": string | number; } -+>((arg: {[K in keyof T]: T[K] | string}) => arg)({'0': 0}) : { "0": string | number; } +>((arg: {[K in keyof T]: T[K] | string}) => arg) : (arg: { [K in keyof T]: string | T[K]; }) => { [K in keyof T]: string | T[K]; } +>(arg: {[K in keyof T]: T[K] | string}) => arg : (arg: { [K in keyof T]: string | T[K]; }) => { [K in keyof T]: string | T[K]; } -+>arg : { [K in keyof T]: string | T[K]; } -+>arg : { [K in keyof T]: string | T[K]; } -+>{'0': 0} : { "0": number; } - >'0' : number - >0 : 0 + >arg : { [K in keyof T]: string | T[K]; } + >arg : { [K in keyof T]: string | T[K]; } + >{'0': 0} : { '0': number; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt index ffde8f5e80..1826289e03 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt @@ -1,9 +1,10 @@ declarationEmitUnknownImport.ts(1,1): error TS2303: Circular definition of import alias 'Foo'. declarationEmitUnknownImport.ts(1,14): error TS2304: Cannot find name 'SomeNonExistingName'. declarationEmitUnknownImport.ts(1,14): error TS2503: Cannot find namespace 'SomeNonExistingName'. +declarationEmitUnknownImport.ts(2,9): error TS2303: Circular definition of import alias 'Foo'. -==== declarationEmitUnknownImport.ts (3 errors) ==== +==== declarationEmitUnknownImport.ts (4 errors) ==== import Foo = SomeNonExistingName ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2303: Circular definition of import alias 'Foo'. @@ -11,4 +12,6 @@ declarationEmitUnknownImport.ts(1,14): error TS2503: Cannot find namespace 'Some !!! error TS2304: Cannot find name 'SomeNonExistingName'. ~~~~~~~~~~~~~~~~~~~ !!! error TS2503: Cannot find namespace 'SomeNonExistingName'. - export {Foo} \ No newline at end of file + export {Foo} + ~~~ +!!! error TS2303: Circular definition of import alias 'Foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt.diff new file mode 100644 index 0000000000..486c3ff82d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.declarationEmitUnknownImport.errors.txt ++++ new.declarationEmitUnknownImport.errors.txt +@@= skipped -0, +0 lines =@@ + declarationEmitUnknownImport.ts(1,1): error TS2303: Circular definition of import alias 'Foo'. + declarationEmitUnknownImport.ts(1,14): error TS2304: Cannot find name 'SomeNonExistingName'. + declarationEmitUnknownImport.ts(1,14): error TS2503: Cannot find namespace 'SomeNonExistingName'. +- +- +-==== declarationEmitUnknownImport.ts (3 errors) ==== ++declarationEmitUnknownImport.ts(2,9): error TS2303: Circular definition of import alias 'Foo'. ++ ++ ++==== declarationEmitUnknownImport.ts (4 errors) ==== + import Foo = SomeNonExistingName + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2303: Circular definition of import alias 'Foo'. +@@= skipped -11, +12 lines =@@ + ~~~~~~~~~~~~~~~~~~~ + !!! error TS2503: Cannot find namespace 'SomeNonExistingName'. + export {Foo} ++ ~~~ ++!!! error TS2303: Circular definition of import alias 'Foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt index 37d7841f4b..f52b6fd9af 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt @@ -3,9 +3,10 @@ declarationEmitUnknownImport2.ts(1,12): error TS1005: '=' expected. declarationEmitUnknownImport2.ts(1,12): error TS2304: Cannot find name 'From'. declarationEmitUnknownImport2.ts(1,12): error TS2503: Cannot find namespace 'From'. declarationEmitUnknownImport2.ts(1,17): error TS1005: ';' expected. +declarationEmitUnknownImport2.ts(2,1): error TS2303: Circular definition of import alias 'Foo'. -==== declarationEmitUnknownImport2.ts (5 errors) ==== +==== declarationEmitUnknownImport2.ts (6 errors) ==== import Foo From './Foo'; // Syntax error ~~~~~~~~~~~~~~~ !!! error TS2303: Circular definition of import alias 'Foo'. @@ -17,4 +18,6 @@ declarationEmitUnknownImport2.ts(1,17): error TS1005: ';' expected. !!! error TS2503: Cannot find namespace 'From'. ~~~~~~~ !!! error TS1005: ';' expected. - export default Foo \ No newline at end of file + export default Foo + ~~~~~~~~~~~~~~~~~~ +!!! error TS2303: Circular definition of import alias 'Foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt.diff new file mode 100644 index 0000000000..00d4874583 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.declarationEmitUnknownImport2.errors.txt ++++ new.declarationEmitUnknownImport2.errors.txt +@@= skipped -2, +2 lines =@@ + declarationEmitUnknownImport2.ts(1,12): error TS2304: Cannot find name 'From'. + declarationEmitUnknownImport2.ts(1,12): error TS2503: Cannot find namespace 'From'. + declarationEmitUnknownImport2.ts(1,17): error TS1005: ';' expected. +- +- +-==== declarationEmitUnknownImport2.ts (5 errors) ==== ++declarationEmitUnknownImport2.ts(2,1): error TS2303: Circular definition of import alias 'Foo'. ++ ++ ++==== declarationEmitUnknownImport2.ts (6 errors) ==== + import Foo From './Foo'; // Syntax error + ~~~~~~~~~~~~~~~ + !!! error TS2303: Circular definition of import alias 'Foo'. +@@= skipped -15, +16 lines =@@ + ~~~~~~~ + !!! error TS1005: ';' expected. + export default Foo ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS2303: Circular definition of import alias 'Foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js b/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js index 916a7548c9..37a14c819a 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js +++ b/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js @@ -29,30 +29,4 @@ exports.MyComp = Ctor.extends({ foo: "bar" }); //// [index.d.ts] import * as ns from "mod"; -export declare const MyComp: import("mod").ExtendedCtor; - - -//// [DtsFileErrors] - - -index.d.ts(2,44): error TS2694: Namespace '"node_modules/mod/index"' has no exported member 'ExtendedCtor'. - - -==== node_modules/mod/ctor.d.ts (0 errors) ==== - export interface Ctor { - x: number; - } - export type ExtendedCtor = {x: number, ext: T}; - export interface CtorConstructor { - extends(x: T): ExtendedCtor; - } - export const Ctor: CtorConstructor; -==== node_modules/mod/index.d.ts (0 errors) ==== - import { Ctor } from "./ctor"; - export default Ctor; -==== index.d.ts (1 errors) ==== - import * as ns from "mod"; - export declare const MyComp: import("mod").ExtendedCtor; - ~~~~~~~~~~~~ -!!! error TS2694: Namespace '"node_modules/mod/index"' has no exported member 'ExtendedCtor'. - \ No newline at end of file +export declare const MyComp: import("mod/ctor").ExtendedCtor; diff --git a/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js.diff b/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js.diff index c460ba5131..0d1946d9ee 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationsIndirectGeneratedAliasReference.js.diff @@ -8,35 +8,3 @@ +const ns = require("mod"); const Ctor = ns.default; exports.MyComp = Ctor.extends({ foo: "bar" }); - - - //// [index.d.ts] - import * as ns from "mod"; --export declare const MyComp: import("mod/ctor").ExtendedCtor; -+export declare const MyComp: import("mod").ExtendedCtor; -+ -+ -+//// [DtsFileErrors] -+ -+ -+index.d.ts(2,44): error TS2694: Namespace '"node_modules/mod/index"' has no exported member 'ExtendedCtor'. -+ -+ -+==== node_modules/mod/ctor.d.ts (0 errors) ==== -+ export interface Ctor { -+ x: number; -+ } -+ export type ExtendedCtor = {x: number, ext: T}; -+ export interface CtorConstructor { -+ extends(x: T): ExtendedCtor; -+ } -+ export const Ctor: CtorConstructor; -+==== node_modules/mod/index.d.ts (0 errors) ==== -+ import { Ctor } from "./ctor"; -+ export default Ctor; -+==== index.d.ts (1 errors) ==== -+ import * as ns from "mod"; -+ export declare const MyComp: import("mod").ExtendedCtor; -+ ~~~~~~~~~~~~ -+!!! error TS2694: Namespace '"node_modules/mod/index"' has no exported member 'ExtendedCtor'. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js b/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js index bf75d38e5a..618990a5f9 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js +++ b/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js @@ -44,6 +44,8 @@ void p3.result.three; //// [declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js] "use strict"; +// Note that both of the following have an `any` in their return type from where we bottom out the type printout +// for having too many instances of the same symbol nesting. var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { diff --git a/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js.diff b/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js.diff deleted file mode 100644 index 936f834eeb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js -+++ new.declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js -@@= skipped -43, +43 lines =@@ - - //// [declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js] - "use strict"; --// Note that both of the following have an `any` in their return type from where we bottom out the type printout --// for having too many instances of the same symbol nesting. - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js b/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js index 5b71459dcb..44abeb067c 100644 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js +++ b/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js @@ -57,6 +57,7 @@ const a2: string[][][][][][][][][][] = [[[[[[[[[[42]]]]]]]]]]; //// [deeplyNestedCheck.js] +// Repro from #14794 const x = { b: [ { diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js.diff b/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js.diff index 28297b816c..7ed38e2061 100644 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js.diff +++ b/testdata/baselines/reference/submodule/compiler/deeplyNestedCheck.js.diff @@ -1,14 +1,6 @@ --- old.deeplyNestedCheck.js +++ new.deeplyNestedCheck.js -@@= skipped -56, +56 lines =@@ - - - //// [deeplyNestedCheck.js] --// Repro from #14794 - const x = { - b: [ - { -@@= skipped -13, +12 lines =@@ +@@= skipped -69, +69 lines =@@ { g: { h: [ diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js b/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js index a8e4d07c86..34078a0951 100644 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js @@ -15,6 +15,7 @@ class BufferPool> { //// [deeplyNestedConstraints.js] +// Repro from #41931 class BufferPool { setArray2(_, array) { array.length; // Requires exploration of >5 levels of constraints diff --git a/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js.diff index aa5c1605a1..8c82df9c5c 100644 --- a/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js.diff +++ b/testdata/baselines/reference/submodule/compiler/deeplyNestedConstraints.js.diff @@ -5,7 +5,6 @@ //// [deeplyNestedConstraints.js] -"use strict"; --// Repro from #41931 + // Repro from #41931 class BufferPool { - setArray2(_, array) { - array.length; // Requires exploration of >5 levels of constraints \ No newline at end of file + setArray2(_, array) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js index 8edd173c99..274f717191 100644 --- a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js +++ b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js @@ -29,6 +29,7 @@ function f3(x: 'a' | 'b') { //// [deferredLookupTypeResolution.js] +// Repro from #17456 function f2(a) { return f1(a, 'x'); } diff --git a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js.diff b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js.diff index 4d447e3693..477a00692a 100644 --- a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js.diff +++ b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution.js.diff @@ -5,7 +5,6 @@ //// [deferredLookupTypeResolution.js] -"use strict"; --// Repro from #17456 + // Repro from #17456 function f2(a) { - return f1(a, 'x'); - } \ No newline at end of file + return f1(a, 'x'); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js index 791854dd9a..50f3bff36d 100644 --- a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js +++ b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js @@ -25,6 +25,7 @@ type DeepOK = { true: 'true', otherwise: 'false' }[Juxtapose]; //// [deferredLookupTypeResolution2.js] +// Repro from #17456 //// [deferredLookupTypeResolution2.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js.diff b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js.diff index 7401b3875d..437c24328f 100644 --- a/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/deferredLookupTypeResolution2.js.diff @@ -5,7 +5,5 @@ //// [deferredLookupTypeResolution2.js] -"use strict"; --// Repro from #17456 + // Repro from #17456 - - //// [deferredLookupTypeResolution2.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js b/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js index 0d9113f0c0..dada973102 100644 --- a/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js +++ b/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js @@ -14,6 +14,7 @@ function foo

(props: Readonly

) { //// [destructuringWithConstraint.js] +// Repro from #22823 function foo(props) { let { foo = false } = props; if (foo === true) { } diff --git a/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js.diff b/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js.diff index 7fc47b688a..6c6c57ce24 100644 --- a/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js.diff +++ b/testdata/baselines/reference/submodule/compiler/destructuringWithConstraint.js.diff @@ -5,7 +5,6 @@ //// [destructuringWithConstraint.js] -"use strict"; --// Repro from #22823 + // Repro from #22823 function foo(props) { - let { foo = false } = props; - if (foo === true) { } \ No newline at end of file + let { foo = false } = props; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js b/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js index 86bcb2df27..404d7e797c 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js +++ b/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js @@ -42,6 +42,7 @@ f({ //// [discriminantPropertyInference.js] +// Repro from #41759 // simple inference f({ disc: true, diff --git a/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js.diff b/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js.diff deleted file mode 100644 index 002fbe8bab..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminantPropertyInference.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminantPropertyInference.js -+++ new.discriminantPropertyInference.js -@@= skipped -41, +41 lines =@@ - - - //// [discriminantPropertyInference.js] --// Repro from #41759 - // simple inference - f({ - disc: true, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js b/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js index e2bba7fed0..5dbe68cd7c 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js +++ b/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js @@ -26,6 +26,7 @@ if (c !== undefined) { } //// [discriminantsAndNullOrUndefined.js] +// Repro from #10228 function never(_) { throw new Error(); } diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js.diff b/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js.diff deleted file mode 100644 index 9d2a710e34..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndNullOrUndefined.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminantsAndNullOrUndefined.js -+++ new.discriminantsAndNullOrUndefined.js -@@= skipped -25, +25 lines =@@ - } - - //// [discriminantsAndNullOrUndefined.js] --// Repro from #10228 - function never(_) { - throw new Error(); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js b/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js index 0e7a9e50b6..db43dd7836 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js +++ b/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js @@ -83,6 +83,7 @@ else { //// [discriminantsAndPrimitives.js] +// Repro from #10257 plus other tests function f1(x) { if (typeof x !== 'string') { switch (x.kind) { diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js.diff b/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js.diff deleted file mode 100644 index f9f7e9b017..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndPrimitives.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminantsAndPrimitives.js -+++ new.discriminantsAndPrimitives.js -@@= skipped -82, +82 lines =@@ - - - //// [discriminantsAndPrimitives.js] --// Repro from #10257 plus other tests - function f1(x) { - if (typeof x !== 'string') { - switch (x.kind) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js b/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js index 305b5a0a9f..123d88e4b6 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js +++ b/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js @@ -34,6 +34,7 @@ function foo2(x: A | B): any { } //// [discriminantsAndTypePredicates.js] +// Repro from #10145 function isA(x) { return x.type === 'A'; } function isB(x) { return x.type === 'B'; } function foo1(x) { diff --git a/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js.diff b/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js.diff deleted file mode 100644 index e2266b751b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/discriminantsAndTypePredicates.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.discriminantsAndTypePredicates.js -+++ new.discriminantsAndTypePredicates.js -@@= skipped -33, +33 lines =@@ - } - - //// [discriminantsAndTypePredicates.js] --// Repro from #10145 - function isA(x) { return x.type === 'A'; } - function isB(x) { return x.type === 'B'; } - function foo1(x) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js b/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js index 28b2bd20f1..3bcffa3516 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js +++ b/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js @@ -25,6 +25,7 @@ function ListItem(_data: IListItemData) { //// [discriminatedUnionJsxElement.jsx] +// Repro from #46021 function Menu(data) { var _a; const listItemVariant = (_a = data.menuItemsVariant) !== null && _a !== void 0 ? _a : ListItemVariant.OneLine; diff --git a/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js.diff b/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js.diff index ad545cf227..761ad11f9c 100644 --- a/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js.diff +++ b/testdata/baselines/reference/submodule/compiler/discriminatedUnionJsxElement.js.diff @@ -5,7 +5,6 @@ //// [discriminatedUnionJsxElement.jsx] -"use strict"; --// Repro from #46021 + // Repro from #46021 function Menu(data) { - var _a; - const listItemVariant = (_a = data.menuItemsVariant) !== null && _a !== void 0 ? _a : ListItemVariant.OneLine; \ No newline at end of file + var _a; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js index 67ad695067..6ba104adb8 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js @@ -23,5 +23,5 @@ export {}; //// [file2.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff index ce53729873..76baf49462 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff @@ -7,6 +7,4 @@ -//// [file1.js] //// [file2.js] "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); -+/// \ No newline at end of file + /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js index 634eac5395..5ca112f999 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js @@ -35,5 +35,5 @@ export {}; //// [file2.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff index 9009fe87ce..a3b62bf462 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff +++ b/testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff @@ -7,6 +7,4 @@ -//// [file1.js] //// [file2.js] "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); -+/// \ No newline at end of file + /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js index 39046d4eca..52f49c2d7e 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js +++ b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js @@ -347,6 +347,8 @@ export var tests: TestRunner = (function () { //// [duplicateLocalVariable1.js] "use strict"; +//import FileManager = require('filemanager'); +//import App = require('app'); Object.defineProperty(exports, "__esModule", { value: true }); exports.tests = exports.TestRunner = exports.TestCase = void 0; var TestFileDir = ".\\TempTestFiles"; diff --git a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js.diff b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js.diff index 62371627fa..a7227754cb 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/duplicateLocalVariable1.js.diff @@ -1,12 +1,6 @@ --- old.duplicateLocalVariable1.js +++ new.duplicateLocalVariable1.js -@@= skipped -346, +346 lines =@@ - - //// [duplicateLocalVariable1.js] - "use strict"; --//import FileManager = require('filemanager'); --//import App = require('app'); - Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -352, +352 lines =@@ exports.tests = exports.TestRunner = exports.TestCase = void 0; var TestFileDir = ".\\TempTestFiles"; class TestCase { @@ -16,7 +10,7 @@ constructor(name, test, errorMessageRegEx) { this.name = name; this.test = test; -@@= skipped -14, +15 lines =@@ +@@= skipped -8, +11 lines =@@ } exports.TestCase = TestCase; class TestRunner { diff --git a/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js b/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js index 4c61b7d7ba..3999d213aa 100644 --- a/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js +++ b/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js @@ -16,9 +16,9 @@ export const c = { //// [emitMethodCalledNew.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/55075 Object.defineProperty(exports, "__esModule", { value: true }); exports.c = exports.b = exports.a = void 0; -// https://github.com/microsoft/TypeScript/issues/55075 exports.a = { new(x) { return x + 1; } }; diff --git a/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js.diff b/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js.diff deleted file mode 100644 index 3acf938c2e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.emitMethodCalledNew.js -+++ new.emitMethodCalledNew.js -@@= skipped -15, +15 lines =@@ - - //// [emitMethodCalledNew.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/55075 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.c = exports.b = exports.a = void 0; -+// https://github.com/microsoft/TypeScript/issues/55075 - exports.a = { - new(x) { return x + 1; } - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js b/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js index ca9a87b245..d50c8fc1c4 100644 --- a/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js +++ b/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js @@ -10,4 +10,9 @@ var x = 10; //// [emitPinnedCommentsOnTopOfFile.js] +/*! + + multi line + comment +*/ var x = 10; diff --git a/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js.diff b/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js.diff deleted file mode 100644 index 268a95d541..0000000000 --- a/testdata/baselines/reference/submodule/compiler/emitPinnedCommentsOnTopOfFile.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.emitPinnedCommentsOnTopOfFile.js -+++ new.emitPinnedCommentsOnTopOfFile.js -@@= skipped -9, +9 lines =@@ - var x = 10; - - //// [emitPinnedCommentsOnTopOfFile.js] --/*! -- -- multi line -- comment --*/ - var x = 10; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js index fcc80bef33..60e41c7655 100644 --- a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js +++ b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js @@ -52,7 +52,7 @@ export declare enum MouseButton { NO_BUTTON = 0 } export declare const DOMMouseButton: { - "-1": MouseButton; + '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; diff --git a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js.diff b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js.diff deleted file mode 100644 index 99e39a42d8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js -+++ new.enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js -@@= skipped -51, +51 lines =@@ - NO_BUTTON = 0 - } - export declare const DOMMouseButton: { -- '-1': MouseButton; -+ "-1": MouseButton; - "0": MouseButton; - "1": MouseButton; - "2": MouseButton; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types index 9071fcc7d4..336591545f 100644 --- a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types +++ b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types @@ -30,8 +30,8 @@ export enum MouseButton { } export const DOMMouseButton = { ->DOMMouseButton : { "-1": MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } ->{ '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BUTTON, "3": MouseButton.XBUTTON1_BUTTON, "4": MouseButton.XBUTTON2_BUTTON,} : { "-1": MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } +>DOMMouseButton : { '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } +>{ '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BUTTON, "3": MouseButton.XBUTTON1_BUTTON, "4": MouseButton.XBUTTON2_BUTTON,} : { '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } '-1': MouseButton.NO_BUTTON, >'-1' : MouseButton diff --git a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types.diff b/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types.diff deleted file mode 100644 index 7eca3bcfab..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types -+++ new.enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types -@@= skipped -29, +29 lines =@@ - } - - export const DOMMouseButton = { -->DOMMouseButton : { '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } -->{ '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BUTTON, "3": MouseButton.XBUTTON1_BUTTON, "4": MouseButton.XBUTTON2_BUTTON,} : { '-1': MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } -+>DOMMouseButton : { "-1": MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } -+>{ '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BUTTON, "3": MouseButton.XBUTTON1_BUTTON, "4": MouseButton.XBUTTON2_BUTTON,} : { "-1": MouseButton; "0": MouseButton; "1": MouseButton; "2": MouseButton; "3": MouseButton; "4": MouseButton; } - - '-1': MouseButton.NO_BUTTON, - >'-1' : MouseButton \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/errorElaboration.js b/testdata/baselines/reference/submodule/compiler/errorElaboration.js index 2665c3b3fe..01bb02177c 100644 --- a/testdata/baselines/reference/submodule/compiler/errorElaboration.js +++ b/testdata/baselines/reference/submodule/compiler/errorElaboration.js @@ -27,6 +27,7 @@ const x = ({ [foo.bar]: c }) => undefined; //// [errorElaboration.js] +// Repro for #5712 let a; foo(a); // Repro for #25498 diff --git a/testdata/baselines/reference/submodule/compiler/errorElaboration.js.diff b/testdata/baselines/reference/submodule/compiler/errorElaboration.js.diff deleted file mode 100644 index fea4b6e979..0000000000 --- a/testdata/baselines/reference/submodule/compiler/errorElaboration.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.errorElaboration.js -+++ new.errorElaboration.js -@@= skipped -26, +26 lines =@@ - - - //// [errorElaboration.js] --// Repro for #5712 - let a; - foo(a); - // Repro for #25498 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js b/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js index 63ec409b0b..81595327fa 100644 --- a/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js +++ b/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js @@ -18,4 +18,6 @@ let Foo = { Bar() { } }; let Baz = () => { }; -let x = React.createElement(Foo.Bar, null, "Hello let y = ", React.createElement(Baz, null, "Hello")); +let x = React.createElement(Foo.Bar, null, + "Hello let y = ", + React.createElement(Baz, null, "Hello")); diff --git a/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js.diff b/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js.diff deleted file mode 100644 index d071260647..0000000000 --- a/testdata/baselines/reference/submodule/compiler/errorSpanForUnclosedJsxTag.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.errorSpanForUnclosedJsxTag.js -+++ new.errorSpanForUnclosedJsxTag.js -@@= skipped -17, +17 lines =@@ - Bar() { } - }; - let Baz = () => { }; --let x = React.createElement(Foo.Bar, null, -- "Hello let y = ", -- React.createElement(Baz, null, "Hello")); -+let x = React.createElement(Foo.Bar, null, "Hello let y = ", React.createElement(Baz, null, "Hello")); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.errors.txt.diff deleted file mode 100644 index 8120ad3982..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.errors.txt.diff +++ /dev/null @@ -1,74 +0,0 @@ ---- old.es6ExportEqualsInterop.errors.txt -+++ new.es6ExportEqualsInterop.errors.txt -@@= skipped -0, +0 lines =@@ - main.ts(15,1): error TS2693: 'z1' only refers to a type, but is being used as a value here. - main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'. - main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'. --main.ts(27,8): error TS1259: Module '"interface"' can only be default-imported using the 'esModuleInterop' flag --main.ts(28,8): error TS1259: Module '"variable"' can only be default-imported using the 'esModuleInterop' flag --main.ts(29,8): error TS1259: Module '"interface-variable"' can only be default-imported using the 'esModuleInterop' flag --main.ts(30,8): error TS1259: Module '"module"' can only be default-imported using the 'esModuleInterop' flag --main.ts(31,8): error TS1259: Module '"interface-module"' can only be default-imported using the 'esModuleInterop' flag --main.ts(32,8): error TS1259: Module '"variable-module"' can only be default-imported using the 'esModuleInterop' flag --main.ts(33,8): error TS1259: Module '"function"' can only be default-imported using the 'esModuleInterop' flag --main.ts(34,8): error TS1259: Module '"function-module"' can only be default-imported using the 'esModuleInterop' flag --main.ts(35,8): error TS1259: Module '"class"' can only be default-imported using the 'esModuleInterop' flag --main.ts(36,8): error TS1259: Module '"class-module"' can only be default-imported using the 'esModuleInterop' flag - main.ts(39,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. - main.ts(45,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. - main.ts(47,21): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. -@@= skipped -40, +30 lines =@@ - main.ts(106,15): error TS2498: Module '"class-module"' uses 'export =' and cannot be used with 'export *'. - - --==== main.ts (41 errors) ==== -+==== main.ts (31 errors) ==== - /// - - // import-equals -@@= skipped -34, +34 lines =@@ - - // default import - import x1 from "interface"; -- ~~ --!!! error TS1259: Module '"interface"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:6:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x2 from "variable"; -- ~~ --!!! error TS1259: Module '"variable"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:14:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x3 from "interface-variable"; -- ~~ --!!! error TS1259: Module '"interface-variable"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:26:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x4 from "module"; -- ~~ --!!! error TS1259: Module '"module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:34:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x5 from "interface-module"; -- ~~ --!!! error TS1259: Module '"interface-module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:46:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x6 from "variable-module"; -- ~~ --!!! error TS1259: Module '"variable-module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:60:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x7 from "function"; -- ~~ --!!! error TS1259: Module '"function"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:65:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x8 from "function-module"; -- ~~ --!!! error TS1259: Module '"function-module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:74:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x9 from "class"; -- ~~ --!!! error TS1259: Module '"class"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:82:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - import x0 from "class-module"; -- ~~ --!!! error TS1259: Module '"class-module"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 modules.d.ts:94:5: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. - - // namespace import - import * as y1 from "interface"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js index 71125ca7fe..30831ecb96 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js +++ b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js @@ -208,6 +208,7 @@ export * from "class-module"; //// [main.js] "use strict"; +/// var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js.diff b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js.diff index ae73ab1233..032ba1bf0d 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js.diff +++ b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.js.diff @@ -1,14 +1,6 @@ --- old.es6ExportEqualsInterop.js +++ new.es6ExportEqualsInterop.js -@@= skipped -207, +207 lines =@@ - - //// [main.js] - "use strict"; --/// - var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); -@@= skipped -17, +16 lines =@@ +@@= skipped -224, +224 lines =@@ }; Object.defineProperty(exports, "__esModule", { value: true }); exports.a0 = exports.a9 = exports.a8 = exports.a7 = exports.a6 = exports.a5 = exports.a4 = exports.a3 = exports.a2 = exports.a1 = void 0; diff --git a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types.diff b/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types.diff deleted file mode 100644 index d79de05db2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ExportEqualsInterop.types.diff +++ /dev/null @@ -1,43 +0,0 @@ ---- old.es6ExportEqualsInterop.types -+++ new.es6ExportEqualsInterop.types -@@= skipped -88, +88 lines =@@ - >x1 : any - - import x2 from "variable"; -->x2 : any -+>x2 : { a: number; b: number; } - - import x3 from "interface-variable"; -->x3 : any -+>x3 : { a: number; b: number; } - - import x4 from "module"; -->x4 : any -+>x4 : typeof z4 - - import x5 from "interface-module"; -->x5 : any -+>x5 : typeof z5 - - import x6 from "variable-module"; -->x6 : any -+>x6 : { a: number; b: number; } - - import x7 from "function"; -->x7 : any -+>x7 : () => any - - import x8 from "function-module"; -->x8 : any -+>x8 : typeof z8 - - import x9 from "class"; -->x9 : any -+>x9 : typeof z9 - - import x0 from "class-module"; -->x0 : any -+>x0 : typeof z0 - - // namespace import - import * as y1 from "interface"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.errors.txt.diff deleted file mode 100644 index 2e5b58dc1b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.es6ImportDefaultBindingInEs5.errors.txt -+++ new.es6ImportDefaultBindingInEs5.errors.txt -@@= skipped -0, +0 lines =@@ --es6ImportDefaultBindingInEs5_1.ts(1,8): error TS1259: Module '"es6ImportDefaultBindingInEs5_0"' can only be default-imported using the 'esModuleInterop' flag -- -- --==== es6ImportDefaultBindingInEs5_0.ts (0 errors) ==== -- var a = 10; -- export = a; -- --==== es6ImportDefaultBindingInEs5_1.ts (1 errors) ==== -- import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; -- ~~~~~~~~~~~~~~ --!!! error TS1259: Module '"es6ImportDefaultBindingInEs5_0"' can only be default-imported using the 'esModuleInterop' flag --!!! related TS2594 es6ImportDefaultBindingInEs5_0.ts:2:1: This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.types.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.types.diff deleted file mode 100644 index 2ba3f20ec6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingInEs5.types.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.es6ImportDefaultBindingInEs5.types -+++ new.es6ImportDefaultBindingInEs5.types -@@= skipped -9, +9 lines =@@ - - === es6ImportDefaultBindingInEs5_1.ts === - import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; -->defaultBinding : any -+>defaultBinding : number diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js index a81be3a2ca..7c0a7f2eda 100644 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js +++ b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js @@ -144,6 +144,7 @@ const attributes2: Attribute2 = { //// [excessPropertyCheckWithMultipleDiscriminants.js] "use strict"; +// Repro from #32657 Object.defineProperty(exports, "__esModule", { value: true }); const foo = { type: "number", diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js.diff b/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js.diff deleted file mode 100644 index 9f32319ccc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyCheckWithMultipleDiscriminants.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.excessPropertyCheckWithMultipleDiscriminants.js -+++ new.excessPropertyCheckWithMultipleDiscriminants.js -@@= skipped -143, +143 lines =@@ - - //// [excessPropertyCheckWithMultipleDiscriminants.js] - "use strict"; --// Repro from #32657 - Object.defineProperty(exports, "__esModule", { value: true }); - const foo = { - type: "number", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js b/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js index 2da41c0e26..1d1a6bde39 100644 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js +++ b/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js @@ -75,6 +75,7 @@ test = { foo: true, bar: { foo: true, bar: true, boo: true } } //// [excessPropertyChecksWithNestedIntersections.js] "use strict"; +// https://github.com/Microsoft/TypeScript/issues/13813 Object.defineProperty(exports, "__esModule", { value: true }); exports.myInstance = exports.photo = exports.obj = void 0; let a = { a: { x: 'hello' } }; // ok diff --git a/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js.diff b/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js.diff deleted file mode 100644 index f87d79cdcf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessPropertyChecksWithNestedIntersections.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.excessPropertyChecksWithNestedIntersections.js -+++ new.excessPropertyChecksWithNestedIntersections.js -@@= skipped -74, +74 lines =@@ - - //// [excessPropertyChecksWithNestedIntersections.js] - "use strict"; --// https://github.com/Microsoft/TypeScript/issues/13813 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.myInstance = exports.photo = exports.obj = void 0; - let a = { a: { x: 'hello' } }; // ok \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js b/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js index b6e2180083..13fd6616f4 100644 --- a/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js +++ b/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js @@ -48,6 +48,8 @@ configureStore({ }); const Component = () => { const categories = ['Fruit', 'Vegetables']; - return (React.createElement("ul", null, React.createElement("li", null, "All"), categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only - )))); + return (React.createElement("ul", null, + React.createElement("li", null, "All"), + categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only + )))); }; diff --git a/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js.diff b/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js.diff deleted file mode 100644 index 0fd96a87b2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessiveStackDepthFlatArray.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.excessiveStackDepthFlatArray.js -+++ new.excessiveStackDepthFlatArray.js -@@= skipped -47, +47 lines =@@ - }); - const Component = () => { - const categories = ['Fruit', 'Vegetables']; -- return (React.createElement("ul", null, -- React.createElement("li", null, "All"), -- categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only -- )))); -+ return (React.createElement("ul", null, React.createElement("li", null, "All"), categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only -+ )))); - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js b/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js index 5f3c2cb38a..eb963d74e4 100644 --- a/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js +++ b/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js @@ -42,6 +42,7 @@ const a14 = [...a13, ...a13] as const; // 2^14 > 10,000 //// [excessivelyLargeTupleSpread.js] +// #41771 const a0 = [0]; const a1 = [...a0, ...a0]; const a2 = [...a1, ...a1]; diff --git a/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js.diff b/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js.diff deleted file mode 100644 index 92979b3175..0000000000 --- a/testdata/baselines/reference/submodule/compiler/excessivelyLargeTupleSpread.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.excessivelyLargeTupleSpread.js -+++ new.excessivelyLargeTupleSpread.js -@@= skipped -41, +41 lines =@@ - - - //// [excessivelyLargeTupleSpread.js] --// #41771 - const a0 = [0]; - const a1 = [...a0, ...a0]; - const a2 = [...a1, ...a1]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js b/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js index e92726d1c4..ec7240b8bf 100644 --- a/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js +++ b/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js @@ -40,6 +40,7 @@ function functionC(): void { //// [exhaustiveSwitchCheckCircularity.js] +// Repro from #47539 function f() { let foo = "aaa"; while (true) { diff --git a/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js.diff b/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js.diff index 993390a5ce..6f44da6b5b 100644 --- a/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exhaustiveSwitchCheckCircularity.js.diff @@ -5,7 +5,6 @@ //// [exhaustiveSwitchCheckCircularity.js] -"use strict"; --// Repro from #47539 + // Repro from #47539 function f() { - let foo = "aaa"; - while (true) { \ No newline at end of file + let foo = "aaa"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js b/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js index a5f9b593d5..dfa5893abe 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js @@ -22,10 +22,10 @@ if (Math.random()) { //// [expandoFunctionBlockShadowing.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/56538 Object.defineProperty(exports, "__esModule", { value: true }); exports.X = X; exports.Y = Y; -// https://github.com/microsoft/TypeScript/issues/56538 function X() { } if (Math.random()) { const X = {}; @@ -45,3 +45,6 @@ if (Math.random()) { //// [expandoFunctionBlockShadowing.d.ts] export declare function X(): void; export declare function Y(): void; +export declare namespace Y { + var test: string; +} diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js.diff deleted file mode 100644 index fa0b90a7ec..0000000000 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionBlockShadowing.js.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.expandoFunctionBlockShadowing.js -+++ new.expandoFunctionBlockShadowing.js -@@= skipped -21, +21 lines =@@ - - //// [expandoFunctionBlockShadowing.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/56538 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.X = X; - exports.Y = Y; -+// https://github.com/microsoft/TypeScript/issues/56538 - function X() { } - if (Math.random()) { - const X = {}; -@@= skipped -23, +23 lines =@@ - //// [expandoFunctionBlockShadowing.d.ts] - export declare function X(): void; - export declare function Y(): void; --export declare namespace Y { -- var test: string; --} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js b/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js index 984cc06333..da77799946 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js @@ -14,9 +14,9 @@ expr2[s] = 0 //// [expandoFunctionExpressionsWithDynamicNames.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/54809 Object.defineProperty(exports, "__esModule", { value: true }); exports.expr2 = exports.expr = void 0; -// https://github.com/microsoft/TypeScript/issues/54809 const s = "X"; const expr = () => { }; exports.expr = expr; @@ -27,11 +27,11 @@ exports.expr2[s] = 0; //// [expandoFunctionExpressionsWithDynamicNames.d.ts] -export declare const expr: { - (): void; - X: number; -}; -export declare const expr2: { - (): void; - X: number; -}; +export declare function expr(): void; +export declare namespace expr { + var X: number; +} +export declare function expr2(): void; +export declare namespace expr2 { + var X: number; +} diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js.diff index 91ce438ddd..bc387e9ed0 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js.diff +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionExpressionsWithDynamicNames.js.diff @@ -1,13 +1,22 @@ --- old.expandoFunctionExpressionsWithDynamicNames.js +++ new.expandoFunctionExpressionsWithDynamicNames.js -@@= skipped -13, +13 lines =@@ +@@= skipped -26, +26 lines =@@ - //// [expandoFunctionExpressionsWithDynamicNames.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/54809 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.expr2 = exports.expr = void 0; -+// https://github.com/microsoft/TypeScript/issues/54809 - const s = "X"; - const expr = () => { }; - exports.expr = expr; \ No newline at end of file + + //// [expandoFunctionExpressionsWithDynamicNames.d.ts] +-export declare const expr: { +- (): void; +- X: number; +-}; +-export declare const expr2: { +- (): void; +- X: number; +-}; ++export declare function expr(): void; ++export declare namespace expr { ++ var X: number; ++} ++export declare function expr2(): void; ++export declare namespace expr2 { ++ var X: number; ++} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js b/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js index eaa83e486c..cd98400344 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js @@ -38,6 +38,7 @@ export function testUndefined(): TestUndefined { //// [expandoFunctionNullishProperty.js] +// mentioned in https://github.com/microsoft/TypeScript/issues/54220 export function testNull() { function inner() { } inner.prop = null; diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js.diff deleted file mode 100644 index f5d6dc439b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionNullishProperty.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.expandoFunctionNullishProperty.js -+++ new.expandoFunctionNullishProperty.js -@@= skipped -37, +37 lines =@@ - - - //// [expandoFunctionNullishProperty.js] --// mentioned in https://github.com/microsoft/TypeScript/issues/54220 - export function testNull() { - function inner() { } - inner.prop = null; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt b/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt index 4b08c73606..0008df30a8 100644 --- a/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt @@ -1,9 +1,12 @@ +/a.d.ts(2,1): error TS2303: Circular definition of import alias 'N'. /a.d.ts(3,1): error TS2303: Circular definition of import alias 'N'. -==== /a.d.ts (1 errors) ==== +==== /a.d.ts (2 errors) ==== declare global { namespace N {} } export = N; + ~~~~~~~~~~~ +!!! error TS2303: Circular definition of import alias 'N'. export as namespace N; ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2303: Circular definition of import alias 'N'. diff --git a/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt.diff new file mode 100644 index 0000000000..78e304bf69 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.exportAsNamespaceConflict.errors.txt ++++ new.exportAsNamespaceConflict.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.d.ts(2,1): error TS2303: Circular definition of import alias 'N'. + /a.d.ts(3,1): error TS2303: Circular definition of import alias 'N'. + + +-==== /a.d.ts (1 errors) ==== ++==== /a.d.ts (2 errors) ==== + declare global { namespace N {} } + export = N; ++ ~~~~~~~~~~~ ++!!! error TS2303: Circular definition of import alias 'N'. + export as namespace N; + ~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2303: Circular definition of import alias 'N'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt b/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt index 4d54d16ef5..7a53980c7f 100644 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt @@ -1,6 +1,6 @@ -/index.ts(7,7): error TS2322: Type '{ default: { configs: { "stage-0": PluginConfig; }; }; configs: { "stage-0": PluginConfig; }; }' is not assignable to type 'Plugin'. +/index.ts(7,7): error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'. Types of property 'configs' are incompatible. - Type '{ "stage-0": PluginConfig; }' is not assignable to type 'Record'. + Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record'. Property ''stage-0'' is incompatible with index signature. Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'. Types of property 'parser' are incompatible. @@ -43,9 +43,9 @@ const p: Plugin = pluginImportX; ~ -!!! error TS2322: Type '{ default: { configs: { "stage-0": PluginConfig; }; }; configs: { "stage-0": PluginConfig; }; }' is not assignable to type 'Plugin'. +!!! error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'. !!! error TS2322: Types of property 'configs' are incompatible. -!!! error TS2322: Type '{ "stage-0": PluginConfig; }' is not assignable to type 'Record'. +!!! error TS2322: Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record'. !!! error TS2322: Property ''stage-0'' is incompatible with index signature. !!! error TS2322: Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'. !!! error TS2322: Types of property 'parser' are incompatible. diff --git a/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt.diff deleted file mode 100644 index aa4d5bb0b8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportAssignmentExpressionIsExpressionNode.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.exportAssignmentExpressionIsExpressionNode.errors.txt -+++ new.exportAssignmentExpressionIsExpressionNode.errors.txt -@@= skipped -0, +0 lines =@@ --/index.ts(7,7): error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'. -+/index.ts(7,7): error TS2322: Type '{ default: { configs: { "stage-0": PluginConfig; }; }; configs: { "stage-0": PluginConfig; }; }' is not assignable to type 'Plugin'. - Types of property 'configs' are incompatible. -- Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record'. -+ Type '{ "stage-0": PluginConfig; }' is not assignable to type 'Record'. - Property ''stage-0'' is incompatible with index signature. - Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'. - Types of property 'parser' are incompatible. -@@= skipped -42, +42 lines =@@ - - const p: Plugin = pluginImportX; - ~ --!!! error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'. -+!!! error TS2322: Type '{ default: { configs: { "stage-0": PluginConfig; }; }; configs: { "stage-0": PluginConfig; }; }' is not assignable to type 'Plugin'. - !!! error TS2322: Types of property 'configs' are incompatible. --!!! error TS2322: Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record'. -+!!! error TS2322: Type '{ "stage-0": PluginConfig; }' is not assignable to type 'Record'. - !!! error TS2322: Property ''stage-0'' is incompatible with index signature. - !!! error TS2322: Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'. - !!! error TS2322: Types of property 'parser' are incompatible. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js b/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js index 56044df4b6..e8fe3f601b 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js +++ b/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js @@ -18,9 +18,9 @@ export { B } //// [exportDeclarationForModuleOrEnumWithMemberOfSameName.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/55038 Object.defineProperty(exports, "__esModule", { value: true }); exports.B = exports.A = void 0; -// https://github.com/microsoft/TypeScript/issues/55038 var A; (function (A_1) { A_1.A = 0; diff --git a/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js.diff b/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js.diff deleted file mode 100644 index 9675ac592a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js -+++ new.exportDeclarationForModuleOrEnumWithMemberOfSameName(module=commonjs).js -@@= skipped -17, +17 lines =@@ - - //// [exportDeclarationForModuleOrEnumWithMemberOfSameName.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/55038 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.B = exports.A = void 0; -+// https://github.com/microsoft/TypeScript/issues/55038 - var A; - (function (A_1) { - A_1.A = 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js b/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js index 30f165ebe4..077ffd357f 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js @@ -10,10 +10,10 @@ export { aa as default } from './hi' //// [exportDefaultDuplicateCrash.js] "use strict"; +// #38214 Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; exports.default = default_1; -// #38214 function default_1() { } const hi_1 = require("./hi"); Object.defineProperty(exports, "default", { enumerable: true, get: function () { return hi_1.default; } }); diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js.diff index 9fc17e9cc4..d457f0ef4e 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js.diff +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultDuplicateCrash.js.diff @@ -1,14 +1,8 @@ --- old.exportDefaultDuplicateCrash.js +++ new.exportDefaultDuplicateCrash.js -@@= skipped -9, +9 lines =@@ - - //// [exportDefaultDuplicateCrash.js] - "use strict"; --// #38214 - Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -14, +14 lines =@@ exports.default = void 0; exports.default = default_1; -+// #38214 function default_1() { } -var hi_1 = require("./hi"); +const hi_1 = require("./hi"); diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js b/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js index a75a467ba1..ed42c5818e 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js @@ -11,3 +11,4 @@ declare module 'module' { //// [exportDefaultVariable.js] +// Regression test for #3018 diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js.diff b/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js.diff deleted file mode 100644 index fb2dddfa33..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultVariable.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.exportDefaultVariable.js -+++ new.exportDefaultVariable.js -@@= skipped -10, +10 lines =@@ - - - //// [exportDefaultVariable.js] --// Regression test for #3018 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.errors.txt.diff deleted file mode 100644 index 3c2bc80adf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.exportEqualsDefaultProperty.errors.txt -+++ new.exportEqualsDefaultProperty.errors.txt -@@= skipped -0, +0 lines =@@ -- -+imp.ts(2,5): error TS2339: Property 'toExponential' does not exist on type '{ greeting: string; default: number; }'. -+ -+ -+==== exp.ts (0 errors) ==== -+ var x = { -+ "greeting": "hello, world", -+ "default": 42 -+ }; -+ -+ export = x -+ -+==== imp.ts (1 errors) ==== -+ import foo from "./exp"; -+ foo.toExponential(2); -+ ~~~~~~~~~~~~~ -+!!! error TS2339: Property 'toExponential' does not exist on type '{ greeting: string; default: number; }'. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.symbols.diff b/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.symbols.diff deleted file mode 100644 index 35de9ce474..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.symbols.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.exportEqualsDefaultProperty.symbols -+++ new.exportEqualsDefaultProperty.symbols -@@= skipped -19, +19 lines =@@ - >foo : Symbol(foo, Decl(imp.ts, 0, 6)) - - foo.toExponential(2); -->foo.toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --)) - >foo : Symbol(foo, Decl(imp.ts, 0, 6)) -->toExponential : Symbol(Number.toExponential, Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.types.diff b/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.types.diff deleted file mode 100644 index 6b7846da27..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportEqualsDefaultProperty.types.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.exportEqualsDefaultProperty.types -+++ new.exportEqualsDefaultProperty.types -@@= skipped -19, +19 lines =@@ - - === imp.ts === - import foo from "./exp"; -->foo : number -+>foo : { greeting: string; default: number; } - - foo.toExponential(2); -->foo.toExponential(2) : string -->foo.toExponential : (fractionDigits?: number) => string -->foo : number -->toExponential : (fractionDigits?: number) => string -+>foo.toExponential(2) : any -+>foo.toExponential : any -+>foo : { greeting: string; default: number; } -+>toExponential : any - >2 : 2 diff --git a/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js b/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js index 34286aaf03..42f1f7cf4a 100644 --- a/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js +++ b/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js @@ -25,6 +25,7 @@ function f(x: FlatArray, y: FlatArray) //// [flatArrayNoExcessiveStackDepth.js] +// Repro from #43493 const bar = foo.flatMap(bar => bar); // Repros from comments in #43249 const repro_43249 = (value) => { diff --git a/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js.diff b/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js.diff index de12ee2d61..c9bcb682b0 100644 --- a/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js.diff +++ b/testdata/baselines/reference/submodule/compiler/flatArrayNoExcessiveStackDepth.js.diff @@ -5,7 +5,6 @@ //// [flatArrayNoExcessiveStackDepth.js] -"use strict"; --// Repro from #43493 + // Repro from #43493 const bar = foo.flatMap(bar => bar); - // Repros from comments in #43249 - const repro_43249 = (value) => { \ No newline at end of file + // Repros from comments in #43249 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js b/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js index 18ffbc6d0c..d0d355ef63 100644 --- a/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js +++ b/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js @@ -9,5 +9,6 @@ q("x"); //// [freshLiteralTypesInIntersections.js] +// Repro from #19657 const q = func("x", ["x"]); q("x"); diff --git a/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js.diff b/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js.diff index 1a4ac6adf4..2186d4d734 100644 --- a/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js.diff +++ b/testdata/baselines/reference/submodule/compiler/freshLiteralTypesInIntersections.js.diff @@ -5,6 +5,6 @@ //// [freshLiteralTypesInIntersections.js] -"use strict"; --// Repro from #19657 + // Repro from #19657 const q = func("x", ["x"]); q("x"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js b/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js index e26a0c62a4..ad55053719 100644 --- a/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js +++ b/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js @@ -23,6 +23,7 @@ function callN(p: T) { } //// [functionCallOnConstrainedTypeVariable.js] +// Repro from #20196 function call0(p) { p.a("s"); // Error } diff --git a/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js.diff b/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js.diff index 6b5920b987..89ac39c155 100644 --- a/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js.diff +++ b/testdata/baselines/reference/submodule/compiler/functionCallOnConstrainedTypeVariable.js.diff @@ -5,7 +5,6 @@ //// [functionCallOnConstrainedTypeVariable.js] -"use strict"; --// Repro from #20196 + // Repro from #20196 function call0(p) { - p.a("s"); // Error - } \ No newline at end of file + p.a("s"); // Error \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js b/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js index eac4f5f8e0..cbb72e8ab1 100644 --- a/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js +++ b/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js @@ -34,6 +34,7 @@ enhancer4.onChange(null); //// [genericFunctionInference2.js] +// Repro from #30685 const myReducer1 = combineReducers({ combined: combineReducers({ foo }), }); diff --git a/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js.diff b/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js.diff deleted file mode 100644 index 57fccd601a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericFunctionInference2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.genericFunctionInference2.js -+++ new.genericFunctionInference2.js -@@= skipped -33, +33 lines =@@ - - - //// [genericFunctionInference2.js] --// Repro from #30685 - const myReducer1 = combineReducers({ - combined: combineReducers({ foo }), - }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js index b630ace2fd..404e6a0271 100644 --- a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js +++ b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js @@ -16,6 +16,7 @@ f1<"b">(event => { }); //// [genericInferenceDefaultTypeParameter.js] +// Repro from #50858 f1(event => { }); f1(event => { }); f1(event => { }); diff --git a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js.diff b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js.diff index 58907b3091..4c3d1313c7 100644 --- a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js.diff +++ b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameter.js.diff @@ -5,7 +5,6 @@ //// [genericInferenceDefaultTypeParameter.js] -"use strict"; --// Repro from #50858 - f1(event => { }); + // Repro from #50858 f1(event => { }); f1(event => { }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js index 5dc0a47dea..7c9d1c4b98 100644 --- a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js +++ b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js @@ -18,11 +18,11 @@ const v1 = e.preventDefault()} />; //// [genericInferenceDefaultTypeParameterJsxReact.js] "use strict"; +/// var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -/// // Repro from #50858 const react_1 = __importDefault(require("react")); function Component(props) { diff --git a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js.diff b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js.diff index fb30d959fd..7cd137b7da 100644 --- a/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js.diff +++ b/testdata/baselines/reference/submodule/compiler/genericInferenceDefaultTypeParameterJsxReact.js.diff @@ -1,15 +1,8 @@ --- old.genericInferenceDefaultTypeParameterJsxReact.js +++ new.genericInferenceDefaultTypeParameterJsxReact.js -@@= skipped -17, +17 lines =@@ - - //// [genericInferenceDefaultTypeParameterJsxReact.js] - "use strict"; --/// - var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; +@@= skipped -23, +23 lines =@@ }; Object.defineProperty(exports, "__esModule", { value: true }); -+/// // Repro from #50858 -var react_1 = __importDefault(require("react")); +const react_1 = __importDefault(require("react")); diff --git a/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js b/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js index 64a67ccc66..c4f2c68476 100644 --- a/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js +++ b/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js @@ -13,6 +13,7 @@ let o2: { b: string, x: number } = test(o1); //// [genericIsNeverEmptyObject.js] +// Repro from #29067 var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -35,7 +36,6 @@ var __rest = (this && this.__rest) || function (s, e) { } return t; }; -// Repro from #29067 function test(obj) { let { a } = obj, rest = __rest(obj, ["a"]); return __assign(__assign({}, rest), { b: a }); diff --git a/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js.diff b/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js.diff index f4c36261ad..4d67e47082 100644 --- a/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js.diff +++ b/testdata/baselines/reference/submodule/compiler/genericIsNeverEmptyObject.js.diff @@ -5,15 +5,6 @@ //// [genericIsNeverEmptyObject.js] -"use strict"; --// Repro from #29067 + // Repro from #29067 var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -24, +22 lines =@@ - } - return t; - }; -+// Repro from #29067 - function test(obj) { - let { a } = obj, rest = __rest(obj, ["a"]); - return __assign(__assign({}, rest), { b: a }); \ No newline at end of file + __assign = Object.assign || function(t) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/genericRestTypes.js b/testdata/baselines/reference/submodule/compiler/genericRestTypes.js index 3440eff575..cc93397822 100644 --- a/testdata/baselines/reference/submodule/compiler/genericRestTypes.js +++ b/testdata/baselines/reference/submodule/compiler/genericRestTypes.js @@ -30,6 +30,7 @@ function assignmentWithComplexRest3() { } //// [genericRestTypes.js] +// Repro from #25793 function assignmentWithComplexRest() { const fn1 = (x, ..._) => x; const fn2 = fn1; diff --git a/testdata/baselines/reference/submodule/compiler/genericRestTypes.js.diff b/testdata/baselines/reference/submodule/compiler/genericRestTypes.js.diff index 327b439fef..865211326a 100644 --- a/testdata/baselines/reference/submodule/compiler/genericRestTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/genericRestTypes.js.diff @@ -5,7 +5,6 @@ //// [genericRestTypes.js] -"use strict"; --// Repro from #25793 + // Repro from #25793 function assignmentWithComplexRest() { - const fn1 = (x, ..._) => x; - const fn2 = fn1; \ No newline at end of file + const fn1 = (x, ..._) => x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js b/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js index 81379d9a8e..20d85a7956 100644 --- a/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js +++ b/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js @@ -13,4 +13,5 @@ cases(fn(opts => { })); //// [getParameterNameAtPosition.js] +// Repro from #30171 cases(fn(opts => { })); diff --git a/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js.diff b/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js.diff index 6faee97c2a..3377b2d600 100644 --- a/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js.diff +++ b/testdata/baselines/reference/submodule/compiler/getParameterNameAtPosition.js.diff @@ -5,5 +5,5 @@ //// [getParameterNameAtPosition.js] -"use strict"; --// Repro from #30171 + // Repro from #30171 cases(fn(opts => { })); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js b/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js index 3a97a865d2..3756895cc1 100644 --- a/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js +++ b/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js @@ -21,6 +21,7 @@ function f1(state: State<{ foo: number }>) { //// [identityRelationNeverTypes.js] +// Repro from #47996 function f1(state) { if (state.matches('a') && state.matches('a.b')) { state; // never diff --git a/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js.diff b/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js.diff index a3fc586d45..9d389e331e 100644 --- a/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/identityRelationNeverTypes.js.diff @@ -5,7 +5,6 @@ //// [identityRelationNeverTypes.js] -"use strict"; --// Repro from #47996 + // Repro from #47996 function f1(state) { - if (state.matches('a') && state.matches('a.b')) { - state; // never \ No newline at end of file + if (state.matches('a') && state.matches('a.b')) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js b/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js index e4eea244b9..f2d8c25c70 100644 --- a/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js +++ b/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js @@ -25,8 +25,8 @@ let x2 = ; // Error //// [ignoredJsxAttributes.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); // Repro from #44797 const React = require("react"); let props = { diff --git a/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js.diff b/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js.diff index 39292a7044..1dc2a3e2ff 100644 --- a/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/ignoredJsxAttributes.js.diff @@ -1,12 +1,8 @@ --- old.ignoredJsxAttributes.js +++ new.ignoredJsxAttributes.js -@@= skipped -24, +24 lines =@@ - - //// [ignoredJsxAttributes.js] - "use strict"; --/// +@@= skipped -27, +27 lines =@@ + /// Object.defineProperty(exports, "__esModule", { value: true }); -+/// // Repro from #44797 -var React = require("react"); +const React = require("react"); diff --git a/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js b/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js index a336436e99..c0a40a48ca 100644 --- a/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js +++ b/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js @@ -23,6 +23,8 @@ class C2 implements IFoo2 { // error } //// [implementGenericWithMismatchedTypes.js] +// no errors because in the derived types the best common type for T's value is Object +// and that matches the original signature for assignability since we treat its T's as Object class C { foo(x) { return null; diff --git a/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js.diff b/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js.diff deleted file mode 100644 index 62094db9bf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/implementGenericWithMismatchedTypes.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.implementGenericWithMismatchedTypes.js -+++ new.implementGenericWithMismatchedTypes.js -@@= skipped -22, +22 lines =@@ - } - - //// [implementGenericWithMismatchedTypes.js] --// no errors because in the derived types the best common type for T's value is Object --// and that matches the original signature for assignability since we treat its T's as Object - class C { - foo(x) { - return null; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js b/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js index 51b4c2f889..7a7aed1ed6 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js @@ -24,6 +24,7 @@ function f2(mymap: MyMap, k: keyof M, z: { x: number }) { //// [indexedAccessNormalization.js] +// Repro from from #43152 function f1(mymap, k) { const elemofM = mymap[k]; g(elemofM); diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js.diff b/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js.diff index 5595f810a2..d3057e5365 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js.diff +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessNormalization.js.diff @@ -5,7 +5,6 @@ //// [indexedAccessNormalization.js] -"use strict"; --// Repro from from #43152 + // Repro from from #43152 function f1(mymap, k) { - const elemofM = mymap[k]; - g(elemofM); \ No newline at end of file + const elemofM = mymap[k]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js b/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js index ccdebbb66a..0a52abf84e 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js @@ -23,8 +23,8 @@ class Comp extends Component> //// [indexedAccessRelation.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // Repro from #14723 +Object.defineProperty(exports, "__esModule", { value: true }); class Component { setState(state) { } } diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js.diff b/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js.diff deleted file mode 100644 index 2f676bbe24..0000000000 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessRelation.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.indexedAccessRelation.js -+++ new.indexedAccessRelation.js -@@= skipped -22, +22 lines =@@ - - //// [indexedAccessRelation.js] - "use strict"; --// Repro from #14723 - Object.defineProperty(exports, "__esModule", { value: true }); -+// Repro from #14723 - class Component { - setState(state) { } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js b/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js index aa3ef89972..85888552d7 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js @@ -39,6 +39,7 @@ function foo(x: C, y: T['content']) { //// [indexedAccessTypeConstraints.js] "use strict"; +// Repro from #14557 Object.defineProperty(exports, "__esModule", { value: true }); exports.Bar = exports.Foo = void 0; class Parent { diff --git a/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js.diff index 1fcf56ce47..7812071eaa 100644 --- a/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js.diff +++ b/testdata/baselines/reference/submodule/compiler/indexedAccessTypeConstraints.js.diff @@ -1,10 +1,6 @@ --- old.indexedAccessTypeConstraints.js +++ new.indexedAccessTypeConstraints.js -@@= skipped -38, +38 lines =@@ - - //// [indexedAccessTypeConstraints.js] - "use strict"; --// Repro from #14557 +@@= skipped -42, +42 lines =@@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Bar = exports.Foo = void 0; class Parent { diff --git a/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js b/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js index 2049f4d25b..4e66f0faa5 100644 --- a/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js +++ b/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js @@ -33,6 +33,7 @@ let n: number = f(2).a; //// [indirectTypeParameterReferences.js] +// Repro from #19043 const flowtypes = (b) => { const combined = (fn) => null; const literal = (fn) => null; diff --git a/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js.diff b/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js.diff deleted file mode 100644 index aaa080d08a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/indirectTypeParameterReferences.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.indirectTypeParameterReferences.js -+++ new.indirectTypeParameterReferences.js -@@= skipped -32, +32 lines =@@ - - - //// [indirectTypeParameterReferences.js] --// Repro from #19043 - const flowtypes = (b) => { - const combined = (fn) => null; - const literal = (fn) => null; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js b/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js index 3584a8132a..fd0f6080ea 100644 --- a/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js +++ b/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js @@ -12,6 +12,7 @@ b.m("test", function (bug) { }); //// [inferSecondaryParameter.js] +// type inference on 'bug' should give 'any' var b = { m: function (test, fn) { } }; b.m("test", function (bug) { var a = bug; diff --git a/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js.diff b/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js.diff deleted file mode 100644 index 01cb15dbb6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferSecondaryParameter.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferSecondaryParameter.js -+++ new.inferSecondaryParameter.js -@@= skipped -11, +11 lines =@@ - }); - - //// [inferSecondaryParameter.js] --// type inference on 'bug' should give 'any' - var b = { m: function (test, fn) { } }; - b.m("test", function (bug) { - var a = bug; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js b/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js index f038359b08..7b99077c69 100644 --- a/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js @@ -41,6 +41,7 @@ m.child; // ok //// [inferTypeParameterConstraints.js] +// Repro from #42636 // https://github.com/microsoft/TypeScript/issues/57286#issuecomment-1927920336 class BaseClass { fake() { diff --git a/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js.diff index 4d4403e0ed..5b15a9e6b9 100644 --- a/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js.diff +++ b/testdata/baselines/reference/submodule/compiler/inferTypeParameterConstraints.js.diff @@ -5,11 +5,10 @@ //// [inferTypeParameterConstraints.js] -"use strict"; --// Repro from #42636 + // Repro from #42636 // https://github.com/microsoft/TypeScript/issues/57286#issuecomment-1927920336 class BaseClass { - fake() { -@@= skipped -9, +7 lines =@@ +@@= skipped -9, +8 lines =@@ } } class Klass extends BaseClass { diff --git a/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js b/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js index 3ba422ef3f..c630f363f7 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js @@ -33,6 +33,7 @@ const res3 = test({ //// [inferenceAndSelfReferentialConstraint.js] +// @strict function test(arg) { return arg; } diff --git a/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js.diff deleted file mode 100644 index 97cadbab15..0000000000 --- a/testdata/baselines/reference/submodule/compiler/inferenceAndSelfReferentialConstraint.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.inferenceAndSelfReferentialConstraint.js -+++ new.inferenceAndSelfReferentialConstraint.js -@@= skipped -32, +32 lines =@@ - - - //// [inferenceAndSelfReferentialConstraint.js] --// @strict - function test(arg) { - return arg; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js b/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js index 7349cb195d..556e627a49 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js @@ -56,6 +56,7 @@ type T2 = GetT1; // number //// [inferenceErasedSignatures.js] +// Repro from #37163 class SomeAbstractClass extends SomeBaseClass { foo; bar; diff --git a/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js.diff index fad7f0a963..90e89856c6 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js.diff +++ b/testdata/baselines/reference/submodule/compiler/inferenceErasedSignatures.js.diff @@ -5,7 +5,7 @@ //// [inferenceErasedSignatures.js] -"use strict"; --// Repro from #37163 + // Repro from #37163 -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { diff --git a/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js b/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js index a5fd40279b..b2e7c48bd7 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js +++ b/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js @@ -15,4 +15,5 @@ Component({items: [{name:' string'}], itemKey: 'name' }); //// [inferenceFromIncompleteSource.js] +// Repro from #42030 Component({ items: [{ name: ' string' }], itemKey: 'name' }); diff --git a/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js.diff b/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js.diff index 165491bb7d..6abf1807cb 100644 --- a/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js.diff +++ b/testdata/baselines/reference/submodule/compiler/inferenceFromIncompleteSource.js.diff @@ -5,5 +5,5 @@ //// [inferenceFromIncompleteSource.js] -"use strict"; --// Repro from #42030 + // Repro from #42030 Component({ items: [{ name: ' string' }], itemKey: 'name' }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js b/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js index 791ffb843a..e3dff9c7a2 100644 --- a/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js @@ -53,6 +53,7 @@ type Conv = //// [infiniteConstraints.js] "use strict"; +// Both of the following types trigger the recursion limiter in getImmediateBaseConstraint Object.defineProperty(exports, "__esModule", { value: true }); const out = myBug({ obj1: { a: "test" } }); const noError = ensureNoDuplicates({ main: value("test"), alternate: value("test2") }); diff --git a/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js.diff deleted file mode 100644 index bccf326f67..0000000000 --- a/testdata/baselines/reference/submodule/compiler/infiniteConstraints.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.infiniteConstraints.js -+++ new.infiniteConstraints.js -@@= skipped -52, +52 lines =@@ - - //// [infiniteConstraints.js] - "use strict"; --// Both of the following types trigger the recursion limiter in getImmediateBaseConstraint - Object.defineProperty(exports, "__esModule", { value: true }); - const out = myBug({ obj1: { a: "test" } }); - const noError = ensureNoDuplicates({ main: value("test"), alternate: value("test2") }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js b/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js index 86091a4dc7..a2d3a00181 100644 --- a/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js +++ b/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js @@ -187,6 +187,7 @@ assignPartial(obj, { foo(...args) {} }); // args has type [string] //// [instantiateContextualTypes.js] +// #6611 function fn(values, value) { } fn(handlers, value => alert(value)); diff --git a/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js.diff b/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js.diff index b1446de5ba..845ea67434 100644 --- a/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/instantiateContextualTypes.js.diff @@ -1,14 +1,6 @@ --- old.instantiateContextualTypes.js +++ new.instantiateContextualTypes.js -@@= skipped -186, +186 lines =@@ - - - //// [instantiateContextualTypes.js] --// #6611 - function fn(values, value) { - } - fn(handlers, value => alert(value)); -@@= skipped -22, +21 lines =@@ +@@= skipped -208, +208 lines =@@ })(N1 || (N1 = {})); passContentsToFunc(outerBoxOfString, box => box.value); class Interesting { diff --git a/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js b/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js index a282da3696..32452f4acf 100644 --- a/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js +++ b/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js @@ -18,6 +18,7 @@ const x1 = f1(); // Z const x2 = f2({}, {}, {}, {}); // Z<{}, string[]> //// [instantiatedTypeAliasDisplay.js] +// Repros from #12066 const x1 = f1(); // Z const x2 = f2({}, {}, {}, {}); // Z<{}, string[]> diff --git a/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js.diff b/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js.diff deleted file mode 100644 index d53a7d7398..0000000000 --- a/testdata/baselines/reference/submodule/compiler/instantiatedTypeAliasDisplay.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.instantiatedTypeAliasDisplay.js -+++ new.instantiatedTypeAliasDisplay.js -@@= skipped -17, +17 lines =@@ - const x2 = f2({}, {}, {}, {}); // Z<{}, string[]> - - //// [instantiatedTypeAliasDisplay.js] --// Repros from #12066 - const x1 = f1(); // Z - const x2 = f2({}, {}, {}, {}); // Z<{}, string[]> diff --git a/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js b/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js index 3c9c6d1b6b..e68f399703 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js @@ -8,4 +8,5 @@ new x(); //// [intersectionOfMixinConstructorTypeAndNonConstructorType.js] +// Repro for #17388 new x(); diff --git a/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js.diff deleted file mode 100644 index 186b4c63d0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionOfMixinConstructorTypeAndNonConstructorType.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.intersectionOfMixinConstructorTypeAndNonConstructorType.js -+++ new.intersectionOfMixinConstructorTypeAndNonConstructorType.js -@@= skipped -7, +7 lines =@@ - - - //// [intersectionOfMixinConstructorTypeAndNonConstructorType.js] --// Repro for #17388 - new x(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js b/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js index 961b7c1037..23ed81694f 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js @@ -12,9 +12,9 @@ export const Form3 = brokenFunction(parameterFn)({store: "hello"}) //// [intersectionTypeInference1.js] "use strict"; +// Repro from #8801 Object.defineProperty(exports, "__esModule", { value: true }); exports.Form3 = void 0; -// Repro from #8801 function alert(s) { } const parameterFn = (props) => alert(props.store); const brokenFunction = (f) => (o) => o; diff --git a/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js.diff deleted file mode 100644 index 56f35b8476..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionTypeInference1.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.intersectionTypeInference1.js -+++ new.intersectionTypeInference1.js -@@= skipped -11, +11 lines =@@ - - //// [intersectionTypeInference1.js] - "use strict"; --// Repro from #8801 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Form3 = void 0; -+// Repro from #8801 - function alert(s) { } - const parameterFn = (props) => alert(props.store); - const brokenFunction = (f) => (o) => o; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js index 8a09619e08..6e682816f3 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js @@ -30,11 +30,11 @@ export function assertNodeProperty< //// [intersectionsOfLargeUnions.js] "use strict"; +// Repro from #23977 Object.defineProperty(exports, "__esModule", { value: true }); exports.assertIsElement = assertIsElement; exports.assertNodeTagName = assertNodeTagName; exports.assertNodeProperty = assertNodeProperty; -// Repro from #23977 function assertIsElement(node) { let nodeType = node === null ? null : node.nodeType; return nodeType === 1; diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js.diff deleted file mode 100644 index 1552e303e5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.intersectionsOfLargeUnions.js -+++ new.intersectionsOfLargeUnions.js -@@= skipped -29, +29 lines =@@ - - //// [intersectionsOfLargeUnions.js] - "use strict"; --// Repro from #23977 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.assertIsElement = assertIsElement; - exports.assertNodeTagName = assertNodeTagName; - exports.assertNodeProperty = assertNodeProperty; -+// Repro from #23977 - function assertIsElement(node) { - let nodeType = node === null ? null : node.nodeType; - return nodeType === 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js index d61b378eec..4fdc0f80b9 100644 --- a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js +++ b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js @@ -40,6 +40,7 @@ export function assertNodeProperty< //// [intersectionsOfLargeUnions2.js] "use strict"; +// Repro from #24233 Object.defineProperty(exports, "__esModule", { value: true }); exports.assertIsElement = assertIsElement; exports.assertNodeTagName = assertNodeTagName; diff --git a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js.diff b/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js.diff deleted file mode 100644 index 7468281772..0000000000 --- a/testdata/baselines/reference/submodule/compiler/intersectionsOfLargeUnions2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.intersectionsOfLargeUnions2.js -+++ new.intersectionsOfLargeUnions2.js -@@= skipped -39, +39 lines =@@ - - //// [intersectionsOfLargeUnions2.js] - "use strict"; --// Repro from #24233 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.assertIsElement = assertIsElement; - exports.assertNodeTagName = assertNodeTagName; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js index f373f20796..64ad2de25b 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js @@ -12,6 +12,7 @@ export const foo3 = (type: Unresolved): void => {}; //// [isolatedDeclarationErrorTypes1.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/60192 Object.defineProperty(exports, "__esModule", { value: true }); exports.foo3 = exports.foo2 = exports.foo1 = void 0; const foo1 = (type) => { }; diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js.diff index bec6aaca54..4134efb25c 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorTypes1.js.diff @@ -1,14 +1,6 @@ --- old.isolatedDeclarationErrorTypes1.js +++ new.isolatedDeclarationErrorTypes1.js -@@= skipped -11, +11 lines =@@ - - //// [isolatedDeclarationErrorTypes1.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/60192 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.foo3 = exports.foo2 = exports.foo1 = void 0; - const foo1 = (type) => { }; -@@= skipped -12, +11 lines =@@ +@@= skipped -23, +23 lines =@@ //// [isolatedDeclarationErrorTypes1.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrors.js b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrors.js index 8f211bd237..6616dff493 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrors.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrors.js @@ -22,11 +22,14 @@ errorOnMissingReturn.a = ""; //// [isolatedDeclarationErrors.d.ts] declare function errorOnAssignmentBelowDecl(): void; -declare const errorOnAssignmentBelow: { - (): void; - a: string; -}; -declare const errorOnMissingReturn: { - (): void; - a: string; -}; +declare namespace errorOnAssignmentBelowDecl { + var a: string; +} +declare function errorOnAssignmentBelow(): void; +declare namespace errorOnAssignmentBelow { + var a: string; +} +declare function errorOnMissingReturn(): void; +declare namespace errorOnMissingReturn { + var a: string; +} diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrors.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrors.js.diff index a2e2b81506..47bb029ded 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrors.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrors.js.diff @@ -8,11 +8,14 @@ + +//// [isolatedDeclarationErrors.d.ts] +declare function errorOnAssignmentBelowDecl(): void; -+declare const errorOnAssignmentBelow: { -+ (): void; -+ a: string; -+}; -+declare const errorOnMissingReturn: { -+ (): void; -+ a: string; -+}; \ No newline at end of file ++declare namespace errorOnAssignmentBelowDecl { ++ var a: string; ++} ++declare function errorOnAssignmentBelow(): void; ++declare namespace errorOnAssignmentBelow { ++ var a: string; ++} ++declare function errorOnMissingReturn(): void; ++declare namespace errorOnMissingReturn { ++ var a: string; ++} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsExpandoFunctions.js b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsExpandoFunctions.js index 52f0d4f7c5..32cbc8903c 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsExpandoFunctions.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsExpandoFunctions.js @@ -25,3 +25,24 @@ foo.length = 10; //// [isolatedDeclarationErrorsExpandoFunctions.d.ts] export declare function foo(): void; +export declare namespace foo { + var apply: () => void; +} +export declare namespace foo { + var call: () => void; +} +export declare namespace foo { + var bind: () => void; +} +export declare namespace foo { + var caller: () => void; +} +export declare namespace foo { + var toString: () => void; +} +export declare namespace foo { + var length: number; +} +export declare namespace foo { + var length: number; +} diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsExpandoFunctions.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsExpandoFunctions.js.diff index ea6e1338aa..158cd2ae6c 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsExpandoFunctions.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsExpandoFunctions.js.diff @@ -7,4 +7,25 @@ + + +//// [isolatedDeclarationErrorsExpandoFunctions.d.ts] -+export declare function foo(): void; \ No newline at end of file ++export declare function foo(): void; ++export declare namespace foo { ++ var apply: () => void; ++} ++export declare namespace foo { ++ var call: () => void; ++} ++export declare namespace foo { ++ var bind: () => void; ++} ++export declare namespace foo { ++ var caller: () => void; ++} ++export declare namespace foo { ++ var toString: () => void; ++} ++export declare namespace foo { ++ var length: number; ++} ++export declare namespace foo { ++ var length: number; ++} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js index ead291b262..32bc756193 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js @@ -28,12 +28,12 @@ export function test3(x?: Unresolved): void {} //// [isolatedDeclarationsAddUndefined2.js] "use strict"; +// https://github.com/microsoft/TypeScript/issues/60123 Object.defineProperty(exports, "__esModule", { value: true }); exports.Bar4 = exports.Bar3 = exports.Bar2 = exports.Bar = void 0; exports.test1 = test1; exports.test2 = test2; exports.test3 = test3; -// https://github.com/microsoft/TypeScript/issues/60123 class Bar { x; constructor(x) { diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js.diff index b9c92a668b..1a37f56f75 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationsAddUndefined2.js.diff @@ -1,16 +1,8 @@ --- old.isolatedDeclarationsAddUndefined2.js +++ new.isolatedDeclarationsAddUndefined2.js -@@= skipped -27, +27 lines =@@ - - //// [isolatedDeclarationsAddUndefined2.js] - "use strict"; --// https://github.com/microsoft/TypeScript/issues/60123 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.Bar4 = exports.Bar3 = exports.Bar2 = exports.Bar = void 0; - exports.test1 = test1; +@@= skipped -34, +34 lines =@@ exports.test2 = test2; exports.test3 = test3; -+// https://github.com/microsoft/TypeScript/issues/60123 class Bar { + x; constructor(x) { diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js index bf182d3b0a..225ab69c4c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js @@ -14,11 +14,11 @@ module.exports = function loader(options) {} //// [index.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef Options * @property {string} opt */ +Object.defineProperty(exports, "__esModule", { value: true }); /** * @param {Options} options */ @@ -34,6 +34,10 @@ module.exports = function loader(options) { }; //// [index.d.ts] +/** + * @typedef Options + * @property {string} opt + */ export type Options = { opt: string; }; diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff index b9cfac184e..05ce65400f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js.diff @@ -1,22 +1,22 @@ --- old.jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js +++ new.jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js -@@= skipped -13, +13 lines =@@ - - //// [index.js] - "use strict"; +@@= skipped -17, +17 lines =@@ + * @typedef Options + * @property {string} opt + */ +Object.defineProperty(exports, "__esModule", { value: true }); +/** -+ * @typedef Options -+ * @property {string} opt -+ */ -+/** + * @param {Options} options + */ +export = function loader(options) { }; ++/** ++ * @typedef Options ++ * @property {string} opt ++ */ /** - * @typedef Options - * @property {string} opt -@@= skipped -11, +20 lines =@@ + * @param {Options} options + */ +@@= skipped -7, +16 lines =@@ //// [index.d.ts] @@ -26,6 +26,10 @@ -declare function _exports(options: Options): void; -export = _exports; -type Options = { ++/** ++ * @typedef Options ++ * @property {string} opt ++ */ +export type Options = { opt: string; }; diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.js b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.js index 9d4cfaead5..8e4843d111 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.js +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.js @@ -19,11 +19,11 @@ SomeConstructor3.staticMember = "str"; //// [file.d.ts] declare const SomeConstructor: () => void; -declare const SomeConstructor2: { - (): void; - staticMember: string; -}; -declare const SomeConstructor3: { - (): void; - staticMember: string; -}; +declare function SomeConstructor2(): void; +declare namespace SomeConstructor2 { + var staticMember: string; +} +declare function SomeConstructor3(): void; +declare namespace SomeConstructor3 { + var staticMember: string; +} diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.js.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.js.diff index 171c3332a5..d115dfd622 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunction.js.diff @@ -8,24 +8,18 @@ -declare class SomeConstructor { - x: number; -} --declare function SomeConstructor2(): void; --declare namespace SomeConstructor2 { ++declare const SomeConstructor: () => void; + declare function SomeConstructor2(): void; + declare namespace SomeConstructor2 { - let staticMember: string; --} --declare function SomeConstructor3(): void; --declare namespace SomeConstructor3 { ++ var staticMember: string; + } + declare function SomeConstructor3(): void; + declare namespace SomeConstructor3 { - let staticMember_1: string; - export { staticMember_1 as staticMember }; -} -declare class SomeConstructor3 { - x: number; --} -+declare const SomeConstructor: () => void; -+declare const SomeConstructor2: { -+ (): void; -+ staticMember: string; -+}; -+declare const SomeConstructor3: { -+ (): void; -+ staticMember: string; -+}; \ No newline at end of file ++ var staticMember: string; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.js b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.js index b4b7986cec..4b6b926338 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.js +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.js @@ -25,15 +25,15 @@ SelfReference.staticMember = "str"; //// [file.d.ts] declare const SomeConstructor: () => void; -declare const SomeConstructor2: { - (): void; - staticMember: string; -}; -declare const SomeConstructor3: { - (): void; - staticMember: string; -}; -declare const SelfReference: { - (): any; - staticMember: string; -}; +declare function SomeConstructor2(): void; +declare namespace SomeConstructor2 { + var staticMember: string; +} +declare function SomeConstructor3(): void; +declare namespace SomeConstructor3 { + var staticMember: string; +} +declare function SelfReference(): any; +declare namespace SelfReference { + var staticMember: string; +} diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.js.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.js.diff index 3b57bcf92d..74d665ccee 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsGlobalFileConstFunctionNamed.js.diff @@ -8,12 +8,14 @@ -declare class SomeConstructor { - x: number; -} --declare function SomeConstructor2(): void; --declare namespace SomeConstructor2 { ++declare const SomeConstructor: () => void; + declare function SomeConstructor2(): void; + declare namespace SomeConstructor2 { - let staticMember: string; --} --declare function SomeConstructor3(): void; --declare namespace SomeConstructor3 { ++ var staticMember: string; + } + declare function SomeConstructor3(): void; + declare namespace SomeConstructor3 { - let staticMember_1: string; - export { staticMember_1 as staticMember }; -} @@ -21,23 +23,14 @@ - x: number; -} -declare function SelfReference(): SelfReference; --declare namespace SelfReference { ++ var staticMember: string; ++} ++declare function SelfReference(): any; + declare namespace SelfReference { - let staticMember_2: string; - export { staticMember_2 as staticMember }; -} -declare class SelfReference { - x: number; --} -+declare const SomeConstructor: () => void; -+declare const SomeConstructor2: { -+ (): void; -+ staticMember: string; -+}; -+declare const SomeConstructor3: { -+ (): void; -+ staticMember: string; -+}; -+declare const SelfReference: { -+ (): any; -+ staticMember: string; -+}; \ No newline at end of file ++ var staticMember: string; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js index efd479b20b..27af38aea1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js @@ -36,6 +36,10 @@ class C3 extends C1 { //// [a.d.ts] +/** + * @typedef A + * @property {string} a + */ export type A = { a: string; }; diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js.diff index 0847a31c50..b9410f80a6 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.js.diff @@ -1,13 +1,9 @@ --- old.jsDeclarationsInheritedTypes.js +++ new.jsDeclarationsInheritedTypes.js -@@= skipped -35, +35 lines =@@ - - - //// [a.d.ts] --/** -- * @typedef A -- * @property {string} a -- */ +@@= skipped -39, +39 lines =@@ + * @typedef A + * @property {string} a + */ -/** - * @typedef B - * @property {number} b diff --git a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js index 236608d9bd..0bb4e6f499 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js +++ b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js @@ -47,10 +47,10 @@ NewAjax.prototype.case6_unexpectedlyResolvesPathToNodeModules; //// [index.d.ts] -export type LionRequestInit = import('@lion/ajax').LionRequestInit; /** * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit */ +export type LionRequestInit = import('@lion/ajax').LionRequestInit; export declare class NewAjax { /** * @param {LionRequestInit} [init] diff --git a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js.diff b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js.diff index 7a5027b638..18975a2a3f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js.diff @@ -1,14 +1,11 @@ --- old.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js +++ new.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.js -@@= skipped -46, +46 lines =@@ - - - //// [index.d.ts] -+export type LionRequestInit = import('@lion/ajax').LionRequestInit; +@@= skipped -49, +49 lines =@@ /** * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit */ -export class NewAjax { ++export type LionRequestInit = import('@lion/ajax').LionRequestInit; +export declare class NewAjax { /** * @param {LionRequestInit} [init] diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt index 3be4b9a200..8636c15447 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt @@ -1,3 +1,4 @@ +enumDef.js(14,21): error TS1003: Identifier expected. enumDef.js(16,18): error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. index.js(4,17): error TS2503: Cannot find namespace 'Host'. index.js(8,21): error TS2304: Cannot find name 'Host'. @@ -5,7 +6,7 @@ index.js(13,11): error TS2503: Cannot find namespace 'Host'. index.js(18,11): error TS2503: Cannot find namespace 'Host'. -==== enumDef.js (1 errors) ==== +==== enumDef.js (2 errors) ==== var Host = {}; Host.UserMetrics = {}; /** @enum {number} */ @@ -20,7 +21,10 @@ index.js(18,11): error TS2503: Cannot find namespace 'Host'. */ /** * @typedef {string} + */ + +!!! error TS1003: Identifier expected. Host.UserMetrics.Blah = { ~~~~ !!! error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js index 30fd9c4e05..6a374721cf 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js @@ -56,10 +56,10 @@ const example3 = { //// [jsFileAlternativeUseOfOverloadTag.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // These are a few examples of existing alternative uses of @overload tag. // They will not work as expected with our implementation, but we are // trying to make sure that our changes do not result in any crashes here. +Object.defineProperty(exports, "__esModule", { value: true }); const example1 = { /** * @overload Example1(value) diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff index 72bb7b12fe..8dae32a238 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff @@ -5,10 +5,13 @@ //// [jsFileAlternativeUseOfOverloadTag.js] +"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); // These are a few examples of existing alternative uses of @overload tag. // They will not work as expected with our implementation, but we are // trying to make sure that our changes do not result in any crashes here. ++Object.defineProperty(exports, "__esModule", { value: true }); + const example1 = { + /** + * @overload Example1(value) @@= skipped -51, +53 lines =@@ diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt index 4147bce1d5..f3bf77a415 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt @@ -1,9 +1,12 @@ /a.js(1,13): error TS1098: Type parameter list cannot be empty. +/a.js(1,14): error TS1139: Type parameter declaration expected. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** @param {<} x */ ~~ !!! error TS1098: Type parameter list cannot be empty. + ~ +!!! error TS1139: Type parameter declaration expected. function f(x) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt index 1b0b2a8cd2..e7e5e429a5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt @@ -1,12 +1,15 @@ example.js(3,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +example.js(3,19): error TS1005: '}' expected. -==== example.js (1 errors) ==== +==== example.js (2 errors) ==== // @ts-check /** * @type {function(@foo)} ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~ +!!! error TS1005: '}' expected. */ let x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js b/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js index 7444e18d4a..c537ca89a1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js +++ b/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js @@ -11,4 +11,5 @@ declare var React: any; //// [jsxAttributeWithoutExpressionReact.js] -React.createElement(View, null, React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); +React.createElement(View, null, + React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); diff --git a/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js.diff b/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js.diff deleted file mode 100644 index d422561af4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxAttributeWithoutExpressionReact.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.jsxAttributeWithoutExpressionReact.js -+++ new.jsxAttributeWithoutExpressionReact.js -@@= skipped -10, +10 lines =@@ - - - //// [jsxAttributeWithoutExpressionReact.js] --React.createElement(View, null, -- React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); -+React.createElement(View, null, React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true })); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js b/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js index 089e12841d..4f197298a1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js +++ b/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js @@ -17,9 +17,9 @@ export const Hoc = ( //// [jsxCallElaborationCheckNoCrash1.js] "use strict"; +/// Object.defineProperty(exports, "__esModule", { value: true }); exports.Hoc = void 0; -/// const React = require("react"); const Hoc = (TagElement) => { const Component = () => React.createElement(TagElement, null); diff --git a/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js.diff b/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js.diff index c1dbfd53f8..8e4a0e5e02 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxCallElaborationCheckNoCrash1.js.diff @@ -1,14 +1,10 @@ --- old.jsxCallElaborationCheckNoCrash1.js +++ new.jsxCallElaborationCheckNoCrash1.js -@@= skipped -16, +16 lines =@@ - - //// [jsxCallElaborationCheckNoCrash1.js] - "use strict"; --/// +@@= skipped -19, +19 lines =@@ + /// Object.defineProperty(exports, "__esModule", { value: true }); exports.Hoc = void 0; -var React = require("react"); -+/// +const React = require("react"); const Hoc = (TagElement) => { const Component = () => React.createElement(TagElement, null); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js b/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js index e98f1efae1..d434ef7198 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js @@ -15,4 +15,6 @@ const a = ( //// [index.js] /// /// -const a = (React.createElement("main", null, (React.createElement("div", null)), React.createElement("span", null))); +const a = (React.createElement("main", null, + (React.createElement("div", null)), + React.createElement("span", null))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js.diff index 60fa1c536d..df3d91292e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxChildWrongType.js.diff @@ -7,7 +7,4 @@ -"use strict"; /// /// --const a = (React.createElement("main", null, -- (React.createElement("div", null)), -- React.createElement("span", null))); -+const a = (React.createElement("main", null, (React.createElement("div", null)), React.createElement("span", null))); \ No newline at end of file + const a = (React.createElement("main", null, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js b/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js index 3c3753387f..a01e4ceeae 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js @@ -20,4 +20,6 @@ const b = ( //// [index.js] /// /// -const b = (React.createElement(Foo, null, React.createElement("div", null), "aa")); +const b = (React.createElement(Foo, null, + React.createElement("div", null), + "aa")); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js.diff index 0f17e08fc4..d2845cf221 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenArrayWrongType.js.diff @@ -7,7 +7,4 @@ -"use strict"; /// /// --const b = (React.createElement(Foo, null, -- React.createElement("div", null), -- "aa")); -+const b = (React.createElement(Foo, null, React.createElement("div", null), "aa")); \ No newline at end of file + const b = (React.createElement(Foo, null, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js b/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js index 0570331206..9d0abff513 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js @@ -94,7 +94,9 @@ var a = React.createElement(Blah, null, x => x); // Blah components don't accept text as child elements var a = React.createElement(Blah, null, "Hello unexpected text!"); // Blah components don't accept multiple children. -var a = React.createElement(Blah, null, x => "" + x, x => "" + x); +var a = React.createElement(Blah, null, + x => "" + x, + x => "" + x); function Blah2(props) { return React.createElement(React.Fragment, null); } @@ -103,7 +105,9 @@ var a = React.createElement(Blah2, null, x => x); // Blah2 components don't accept text as child elements var a = React.createElement(Blah2, null, "Hello unexpected text!"); // Blah2 components don't accept multiple children of the wrong type. -var a = React.createElement(Blah2, null, x => x, x => x); +var a = React.createElement(Blah2, null, + x => x, + x => x); function Blah3(props) { return React.createElement(React.Fragment, null); } @@ -112,4 +116,6 @@ var a = React.createElement(Blah3, null, x => x); // Blah3 components don't accept text as child elements var a = React.createElement(Blah3, null, "Hello unexpected text!"); // Blah3 components don't accept multiple children of the wrong type. -var a = React.createElement(Blah3, null, x => x, x => x); +var a = React.createElement(Blah3, null, + x => x, + x => x); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js.diff index 9240c8544f..cb4108a499 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenIndividualErrorElaborations.js.diff @@ -8,34 +8,4 @@ +const React = require("react"); function Blah(props) { return React.createElement(React.Fragment, null); - } -@@= skipped -9, +9 lines =@@ - // Blah components don't accept text as child elements - var a = React.createElement(Blah, null, "Hello unexpected text!"); - // Blah components don't accept multiple children. --var a = React.createElement(Blah, null, -- x => "" + x, -- x => "" + x); -+var a = React.createElement(Blah, null, x => "" + x, x => "" + x); - function Blah2(props) { - return React.createElement(React.Fragment, null); - } -@@= skipped -11, +9 lines =@@ - // Blah2 components don't accept text as child elements - var a = React.createElement(Blah2, null, "Hello unexpected text!"); - // Blah2 components don't accept multiple children of the wrong type. --var a = React.createElement(Blah2, null, -- x => x, -- x => x); -+var a = React.createElement(Blah2, null, x => x, x => x); - function Blah3(props) { - return React.createElement(React.Fragment, null); - } -@@= skipped -11, +9 lines =@@ - // Blah3 components don't accept text as child elements - var a = React.createElement(Blah3, null, "Hello unexpected text!"); - // Blah3 components don't accept multiple children of the wrong type. --var a = React.createElement(Blah3, null, -- x => x, -- x => x); -+var a = React.createElement(Blah3, null, x => x, x => x); \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js b/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js index 354a537461..0730e084b9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js @@ -28,9 +28,9 @@ export class App extends React.Component<{}> { //// [jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js] "use strict"; +/// Object.defineProperty(exports, "__esModule", { value: true }); exports.App = void 0; -/// const React = require("react"); function TabLayout(props) { return React.createElement("div", null); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js.diff index 4f2d8d312a..9a6bac24b2 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js.diff @@ -1,14 +1,10 @@ --- old.jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js +++ new.jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js -@@= skipped -27, +27 lines =@@ - - //// [jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.js] - "use strict"; --/// +@@= skipped -30, +30 lines =@@ + /// Object.defineProperty(exports, "__esModule", { value: true }); exports.App = void 0; -var React = require("react"); -+/// +const React = require("react"); function TabLayout(props) { return React.createElement("div", null); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js b/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js index a4dc7e7d0d..4ae637d1c4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js @@ -19,4 +19,6 @@ const b = ( //// [other.js] /// /// -const b = (React.createElement(Foo, null, React.createElement("div", null), "aa")); +const b = (React.createElement(Foo, null, + React.createElement("div", null), + "aa")); diff --git a/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js.diff b/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js.diff index a6b8208467..130688bec5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxChildrenWrongType.js.diff @@ -7,7 +7,4 @@ -"use strict"; /// /// --const b = (React.createElement(Foo, null, -- React.createElement("div", null), -- "aa")); -+const b = (React.createElement(Foo, null, React.createElement("div", null), "aa")); \ No newline at end of file + const b = (React.createElement(Foo, null, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.errors.txt b/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.errors.txt index c8e84730f2..384c3e74b4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.errors.txt @@ -14,7 +14,7 @@ file.tsx(2,19): error TS2322: Type '{}' is not assignable to type 'IntrinsicClas "name": "@types/react", "version": "0.0.1", "main": "", - "types": "index.d.ts", + "types": "index.d.ts" } ==== node_modules/@types/react/index.d.ts (0 errors) ==== interface IntrinsicClassAttributesAlias { diff --git a/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.js b/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.js index 0b71ffe9f6..474c490d7e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.js +++ b/testdata/baselines/reference/submodule/compiler/jsxClassAttributeResolution.js @@ -8,7 +8,7 @@ export const a = ; "name": "@types/react", "version": "0.0.1", "main": "", - "types": "index.d.ts", + "types": "index.d.ts" } //// [index.d.ts] interface IntrinsicClassAttributesAlias { diff --git a/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js b/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js index ee76f869af..b425a88ebd 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js +++ b/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js @@ -612,6 +612,7 @@ export interface ReactSelectProps extends React.Props var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -625,7 +626,6 @@ var __assign = (this && this.__assign) || function () { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createReactSingleSelect = createReactSingleSelect; -/// const React = require("react"); function createReactSingleSelect(WrappedComponent) { return (props) => { diff --git a/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js.diff b/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js.diff index 1a21218483..0cd38d4a45 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxComplexSignatureHasApplicabilityError.js.diff @@ -1,19 +1,10 @@ --- old.jsxComplexSignatureHasApplicabilityError.js +++ new.jsxComplexSignatureHasApplicabilityError.js -@@= skipped -611, +611 lines =@@ - - //// [jsxComplexSignatureHasApplicabilityError.js] - "use strict"; --/// - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -14, +13 lines =@@ +@@= skipped -625, +625 lines =@@ }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createReactSingleSelect = createReactSingleSelect; -var React = require("react"); -+/// +const React = require("react"); function createReactSingleSelect(WrappedComponent) { return (props) => { diff --git a/testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.js b/testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.js index d3a96f6c16..cede538469 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.js +++ b/testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.js @@ -26,7 +26,18 @@ export default Foo; //// [jsxDeclarationsWithEsModuleInteropNoCrash.d.ts] /// +import PropTypes from 'prop-types'; declare function Foo({ bar }: { bar: any; }): JSX.Element; +declare namespace Foo { + var propTypes: { + bar: PropTypes.Requireable; + }; +} +declare namespace Foo { + var defaultProps: { + bar: boolean; + }; +} export default Foo; diff --git a/testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.js.diff b/testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.js.diff index 1b8d5ca439..282833a6e0 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxDeclarationsWithEsModuleInteropNoCrash.js.diff @@ -5,10 +5,11 @@ //// [jsxDeclarationsWithEsModuleInteropNoCrash.d.ts] /// -export default Foo; ++import PropTypes from 'prop-types'; declare function Foo({ bar }: { bar: any; }): JSX.Element; --declare namespace Foo { + declare namespace Foo { - export { propTypes }; - export { defaultProps }; -} @@ -20,4 +21,13 @@ - export { bar_1 as bar }; -} -import PropTypes from 'prop-types'; ++ var propTypes: { ++ bar: PropTypes.Requireable; ++ }; ++} ++declare namespace Foo { ++ var defaultProps: { ++ bar: boolean; ++ }; ++} +export default Foo; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js index 9961ba8b5a..6272ca29c6 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js +++ b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js @@ -27,4 +27,5 @@ const React = require("react"); function Wrapper(props) { return React.createElement("div", null, props.children); } -const element = (React.createElement(Wrapper, null, React.createElement("div", null, "Hello"))); +const element = (React.createElement(Wrapper, null, + React.createElement("div", null, "Hello"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js.diff b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js.diff index e75b72d689..f92e43abf4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxEmptyExpressionNotCountedAsChild(jsx=react).js.diff @@ -8,7 +8,4 @@ +const React = require("react"); function Wrapper(props) { return React.createElement("div", null, props.children); - } --const element = (React.createElement(Wrapper, null, -- React.createElement("div", null, "Hello"))); -+const element = (React.createElement(Wrapper, null, React.createElement("div", null, "Hello"))); \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js b/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js index cbd2b8fb00..37a0f7edfd 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js +++ b/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js @@ -20,6 +20,7 @@ const myHoc = ( //// [jsxExcessPropsAndAssignability.js] "use strict"; +/// var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -32,7 +33,6 @@ var __assign = (this && this.__assign) || function () { return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); -/// const React = require("react"); const myHoc = (ComposedComponent) => { const WrapperComponent = null; diff --git a/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js.diff b/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js.diff index 961aefabfb..ab464f6bd5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxExcessPropsAndAssignability.js.diff @@ -1,19 +1,10 @@ --- old.jsxExcessPropsAndAssignability.js +++ new.jsxExcessPropsAndAssignability.js -@@= skipped -19, +19 lines =@@ - - //// [jsxExcessPropsAndAssignability.js] - "use strict"; --/// - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -13, +12 lines =@@ +@@= skipped -32, +32 lines =@@ return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); -var React = require("react"); -+/// +const React = require("react"); const myHoc = (ComposedComponent) => { const WrapperComponent = null; diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js index faba591900..18800eb73b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js @@ -9,4 +9,8 @@ declare var Frag: any; //// [jsxFactoryAndJsxFragmentFactory.js] h(Frag, null); -h(Frag, null, h("span", null, "1"), h(Frag, null, h("span", null, "2.1"), h("span", null, "2.2"))); +h(Frag, null, + h("span", null, "1"), + h(Frag, null, + h("span", null, "2.1"), + h("span", null, "2.2"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js.diff deleted file mode 100644 index 7b47493d91..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactory.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.jsxFactoryAndJsxFragmentFactory.js -+++ new.jsxFactoryAndJsxFragmentFactory.js -@@= skipped -8, +8 lines =@@ - - //// [jsxFactoryAndJsxFragmentFactory.js] - h(Frag, null); --h(Frag, null, -- h("span", null, "1"), -- h(Frag, null, -- h("span", null, "2.1"), -- h("span", null, "2.2"))); -+h(Frag, null, h("span", null, "1"), h(Frag, null, h("span", null, "2.1"), h("span", null, "2.2"))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js index a724406b71..b6882ec8ec 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js @@ -8,4 +8,8 @@ declare var h: any; //// [jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js] h(React.Fragment, null); -h(React.Fragment, null, h("span", null, "1"), h(React.Fragment, null, h("span", null, "2.1"), h("span", null, "2.2"))); +h(React.Fragment, null, + h("span", null, "1"), + h(React.Fragment, null, + h("span", null, "2.1"), + h("span", null, "2.2"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js.diff deleted file mode 100644 index 77b56ccfe3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js -+++ new.jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js -@@= skipped -7, +7 lines =@@ - - //// [jsxFactoryAndJsxFragmentFactoryErrorNotIdentifier.js] - h(React.Fragment, null); --h(React.Fragment, null, -- h("span", null, "1"), -- h(React.Fragment, null, -- h("span", null, "2.1"), -- h("span", null, "2.2"))); -+h(React.Fragment, null, h("span", null, "1"), h(React.Fragment, null, h("span", null, "2.1"), h("span", null, "2.2"))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js index a9d22fd0db..83b4e2ee67 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js @@ -8,4 +8,8 @@ declare var h: any; //// [jsxFactoryAndJsxFragmentFactoryNull.js] h(null, null); -h(null, null, h("span", null, "1"), h(null, null, h("span", null, "2.1"), h("span", null, "2.2"))); +h(null, null, + h("span", null, "1"), + h(null, null, + h("span", null, "2.1"), + h("span", null, "2.2"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js.diff deleted file mode 100644 index 4069a9e30f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.jsxFactoryAndJsxFragmentFactoryNull.js -+++ new.jsxFactoryAndJsxFragmentFactoryNull.js -@@= skipped -7, +7 lines =@@ - - //// [jsxFactoryAndJsxFragmentFactoryNull.js] - h(null, null); --h(null, null, -- h("span", null, "1"), -- h(null, null, -- h("span", null, "2.1"), -- h("span", null, "2.2"))); -+h(null, null, h("span", null, "1"), h(null, null, h("span", null, "2.1"), h("span", null, "2.2"))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js b/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js index de9f387250..a62a05ca0b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js @@ -8,4 +8,8 @@ declare var h: any; //// [jsxFactoryButNoJsxFragmentFactory.js] h(React.Fragment, null); -h(React.Fragment, null, h("span", null, "1"), h(React.Fragment, null, h("span", null, "2.1"), h("span", null, "2.2"))); +h(React.Fragment, null, + h("span", null, "1"), + h(React.Fragment, null, + h("span", null, "2.1"), + h("span", null, "2.2"))); diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js.diff deleted file mode 100644 index 4456fecc25..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryButNoJsxFragmentFactory.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.jsxFactoryButNoJsxFragmentFactory.js -+++ new.jsxFactoryButNoJsxFragmentFactory.js -@@= skipped -7, +7 lines =@@ - - //// [jsxFactoryButNoJsxFragmentFactory.js] - h(React.Fragment, null); --h(React.Fragment, null, -- h("span", null, "1"), -- h(React.Fragment, null, -- h("span", null, "2.1"), -- h("span", null, "2.2"))); -+h(React.Fragment, null, h("span", null, "1"), h(React.Fragment, null, h("span", null, "2.1"), h("span", null, "2.2"))); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js index 72870d3a61..56a90bc5f3 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js @@ -24,5 +24,7 @@ exports.Counter = Counter; const react_1 = require("react"); function Counter({ count = 0 }) { const [cnt, setCnt] = null; - return (0, react_1.createElement)(react_1.Fragment, null, (0, react_1.createElement)("p", null, cnt), (0, react_1.createElement)("button", { onClick: () => setCnt((prev) => prev + 1), type: "button" }, "Update")); + return (0, react_1.createElement)(react_1.Fragment, null, + (0, react_1.createElement)("p", null, cnt), + (0, react_1.createElement)("button", { onClick: () => setCnt((prev) => prev + 1), type: "button" }, "Update")); } diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js.diff index c831aea953..48fafba0da 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryNoUnusedLocals.js.diff @@ -8,8 +8,4 @@ +const react_1 = require("react"); function Counter({ count = 0 }) { const [cnt, setCnt] = null; -- return (0, react_1.createElement)(react_1.Fragment, null, -- (0, react_1.createElement)("p", null, cnt), -- (0, react_1.createElement)("button", { onClick: () => setCnt((prev) => prev + 1), type: "button" }, "Update")); -+ return (0, react_1.createElement)(react_1.Fragment, null, (0, react_1.createElement)("p", null, cnt), (0, react_1.createElement)("button", { onClick: () => setCnt((prev) => prev + 1), type: "button" }, "Update")); - } \ No newline at end of file + return (0, react_1.createElement)(react_1.Fragment, null, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js index 912b0e85c5..95beb17270 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js +++ b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js @@ -12,8 +12,8 @@ const tag = {"Title"}; //// [jsxIntrinsicUnions.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); const El = Math.random() ? 'h1' : 'h2'; const tag = React.createElement(El, { className: "ok", key: "key" }, "Title"); diff --git a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js.diff b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js.diff index 3ca0818f87..b0b95f3946 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxIntrinsicUnions.js.diff @@ -1,13 +1,10 @@ --- old.jsxIntrinsicUnions.js +++ new.jsxIntrinsicUnions.js -@@= skipped -11, +11 lines =@@ - - //// [jsxIntrinsicUnions.js] +@@= skipped -13, +13 lines =@@ "use strict"; --/// + /// Object.defineProperty(exports, "__esModule", { value: true }); -var React = require("react"); -+/// +const React = require("react"); const El = Math.random() ? 'h1' : 'h2'; const tag = React.createElement(El, { className: "ok", key: "key" }, "Title"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js b/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js index 1c70ee3d23..d6cfb6507f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js +++ b/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js @@ -28,8 +28,8 @@ const d = ; // Technically OK, but probably //// [jsxIssuesErrorWhenTagExpectsTooManyArguments.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); function MyComp4(props, context, bad, verybad) { return React.createElement("div", null); diff --git a/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js.diff b/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js.diff index 3125094b86..6b15ca0dec 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxIssuesErrorWhenTagExpectsTooManyArguments.js.diff @@ -1,13 +1,10 @@ --- old.jsxIssuesErrorWhenTagExpectsTooManyArguments.js +++ new.jsxIssuesErrorWhenTagExpectsTooManyArguments.js -@@= skipped -27, +27 lines =@@ - - //// [jsxIssuesErrorWhenTagExpectsTooManyArguments.js] +@@= skipped -29, +29 lines =@@ "use strict"; --/// + /// Object.defineProperty(exports, "__esModule", { value: true }); -var React = require("react"); -+/// +const React = require("react"); function MyComp4(props, context, bad, verybad) { return React.createElement("div", null); diff --git a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react).js b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react).js index 314be06f5a..4caa67cbbc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react).js +++ b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react).js @@ -43,7 +43,8 @@ exports.selfClosing = exports.frag = exports.HelloWorld = void 0; const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; -exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); +exports.frag = React.createElement(React.Fragment, null, + React.createElement("div", null)); exports.selfClosing = React.createElement("img", { src: "./image.png" }); //// [two.js] "use strict"; @@ -78,7 +79,8 @@ exports.selfClosing = exports.frag = exports.HelloWorld = void 0; const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; -exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); +exports.frag = React.createElement(React.Fragment, null, + React.createElement("div", null)); exports.selfClosing = React.createElement("img", { src: "./image.png" }); //// [index.js] "use strict"; diff --git a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react).js.diff b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react).js.diff index 856c8d095f..69d7992f5e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react).js.diff @@ -8,11 +8,8 @@ +const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; --exports.frag = React.createElement(React.Fragment, null, -- React.createElement("div", null)); -+exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); - exports.selfClosing = React.createElement("img", { src: "./image.png" }); - //// [two.js] + exports.frag = React.createElement(React.Fragment, null, +@@= skipped -10, +10 lines =@@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.selfClosing = exports.frag = exports.HelloWorld = void 0; @@ -46,7 +43,7 @@ //// [four.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -@@= skipped -36, +35 lines =@@ +@@= skipped -26, +26 lines =@@ /// /* @jsxRuntime automatic */ /* @jsxRuntime classic */ @@ -54,9 +51,4 @@ +const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; --exports.frag = React.createElement(React.Fragment, null, -- React.createElement("div", null)); -+exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); - exports.selfClosing = React.createElement("img", { src: "./image.png" }); - //// [index.js] - "use strict"; \ No newline at end of file + exports.frag = React.createElement(React.Fragment, null, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsx).js b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsx).js index 314be06f5a..4caa67cbbc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsx).js +++ b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsx).js @@ -43,7 +43,8 @@ exports.selfClosing = exports.frag = exports.HelloWorld = void 0; const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; -exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); +exports.frag = React.createElement(React.Fragment, null, + React.createElement("div", null)); exports.selfClosing = React.createElement("img", { src: "./image.png" }); //// [two.js] "use strict"; @@ -78,7 +79,8 @@ exports.selfClosing = exports.frag = exports.HelloWorld = void 0; const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; -exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); +exports.frag = React.createElement(React.Fragment, null, + React.createElement("div", null)); exports.selfClosing = React.createElement("img", { src: "./image.png" }); //// [index.js] "use strict"; diff --git a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsx).js.diff b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsx).js.diff index 613dd4f759..d267f42d42 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsx).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsx).js.diff @@ -8,11 +8,8 @@ +const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; --exports.frag = React.createElement(React.Fragment, null, -- React.createElement("div", null)); -+exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); - exports.selfClosing = React.createElement("img", { src: "./image.png" }); - //// [two.js] + exports.frag = React.createElement(React.Fragment, null, +@@= skipped -10, +10 lines =@@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.selfClosing = exports.frag = exports.HelloWorld = void 0; @@ -46,7 +43,7 @@ //// [four.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -@@= skipped -36, +35 lines =@@ +@@= skipped -26, +26 lines =@@ /// /* @jsxRuntime automatic */ /* @jsxRuntime classic */ @@ -54,9 +51,4 @@ +const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; --exports.frag = React.createElement(React.Fragment, null, -- React.createElement("div", null)); -+exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); - exports.selfClosing = React.createElement("img", { src: "./image.png" }); - //// [index.js] - "use strict"; \ No newline at end of file + exports.frag = React.createElement(React.Fragment, null, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsxdev).js b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsxdev).js index a0409f1a58..a7b5fb849c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsxdev).js +++ b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsxdev).js @@ -43,7 +43,8 @@ exports.selfClosing = exports.frag = exports.HelloWorld = void 0; const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; -exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); +exports.frag = React.createElement(React.Fragment, null, + React.createElement("div", null)); exports.selfClosing = React.createElement("img", { src: "./image.png" }); //// [two.js] "use strict"; @@ -78,7 +79,8 @@ exports.selfClosing = exports.frag = exports.HelloWorld = void 0; const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; -exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); +exports.frag = React.createElement(React.Fragment, null, + React.createElement("div", null)); exports.selfClosing = React.createElement("img", { src: "./image.png" }); //// [index.js] "use strict"; diff --git a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsxdev).js.diff b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsxdev).js.diff index 5f21695144..20bf9be5a4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsxdev).js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxRuntimePragma(jsx=react-jsxdev).js.diff @@ -8,11 +8,8 @@ +const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; --exports.frag = React.createElement(React.Fragment, null, -- React.createElement("div", null)); -+exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); - exports.selfClosing = React.createElement("img", { src: "./image.png" }); - //// [two.js] + exports.frag = React.createElement(React.Fragment, null, +@@= skipped -10, +10 lines =@@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.selfClosing = exports.frag = exports.HelloWorld = void 0; @@ -48,7 +45,7 @@ //// [four.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -@@= skipped -38, +35 lines =@@ +@@= skipped -28, +26 lines =@@ /// /* @jsxRuntime automatic */ /* @jsxRuntime classic */ @@ -56,9 +53,4 @@ +const React = require("react"); const HelloWorld = () => React.createElement("h1", null, "Hello world"); exports.HelloWorld = HelloWorld; --exports.frag = React.createElement(React.Fragment, null, -- React.createElement("div", null)); -+exports.frag = React.createElement(React.Fragment, null, React.createElement("div", null)); - exports.selfClosing = React.createElement("img", { src: "./image.png" }); - //// [index.js] - "use strict"; \ No newline at end of file + exports.frag = React.createElement(React.Fragment, null, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/lateBoundFunctionMemberAssignmentDeclarations.js b/testdata/baselines/reference/submodule/compiler/lateBoundFunctionMemberAssignmentDeclarations.js index 328d1a72ea..05ce6daa8c 100644 --- a/testdata/baselines/reference/submodule/compiler/lateBoundFunctionMemberAssignmentDeclarations.js +++ b/testdata/baselines/reference/submodule/compiler/lateBoundFunctionMemberAssignmentDeclarations.js @@ -19,3 +19,6 @@ const x = foo[_private]; //// [index.d.ts] export declare function foo(): void; +export declare namespace foo { + var bar: number; +} diff --git a/testdata/baselines/reference/submodule/compiler/lateBoundFunctionMemberAssignmentDeclarations.js.diff b/testdata/baselines/reference/submodule/compiler/lateBoundFunctionMemberAssignmentDeclarations.js.diff deleted file mode 100644 index 9b1699fd25..0000000000 --- a/testdata/baselines/reference/submodule/compiler/lateBoundFunctionMemberAssignmentDeclarations.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.lateBoundFunctionMemberAssignmentDeclarations.js -+++ new.lateBoundFunctionMemberAssignmentDeclarations.js -@@= skipped -18, +18 lines =@@ - - //// [index.d.ts] - export declare function foo(): void; --export declare namespace foo { -- var bar: number; --} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/limitDeepInstantiations.js b/testdata/baselines/reference/submodule/compiler/limitDeepInstantiations.js index d00023c9ca..3d4a46835e 100644 --- a/testdata/baselines/reference/submodule/compiler/limitDeepInstantiations.js +++ b/testdata/baselines/reference/submodule/compiler/limitDeepInstantiations.js @@ -9,5 +9,6 @@ let f2: Foo<"false", {}>; //// [limitDeepInstantiations.js] +// Repro from #14837 let f1; let f2; diff --git a/testdata/baselines/reference/submodule/compiler/limitDeepInstantiations.js.diff b/testdata/baselines/reference/submodule/compiler/limitDeepInstantiations.js.diff deleted file mode 100644 index 9ad270affc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/limitDeepInstantiations.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.limitDeepInstantiations.js -+++ new.limitDeepInstantiations.js -@@= skipped -8, +8 lines =@@ - - - //// [limitDeepInstantiations.js] --// Repro from #14837 - let f1; - let f2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js b/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js index d3de3ec29e..e0cb4c8339 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js @@ -47,6 +47,7 @@ const onSomeEvent = (p: P) => //// [mappedTypeGenericIndexedAccess.js] +// Repro from #49242 class Test { entries; constructor() { diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js.diff b/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js.diff index f9adfbcda2..e231cfa770 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js.diff +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js.diff @@ -5,13 +5,13 @@ //// [mappedTypeGenericIndexedAccess.js] -"use strict"; --// Repro from #49242 + // Repro from #49242 class Test { + entries; constructor() { this.entries = {}; } -@@= skipped -18, +17 lines =@@ +@@= skipped -18, +18 lines =@@ [0]: (p) => console.log(p.foo), [1]: (p) => console.log(p.a), }; diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccess.js b/testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccess.js index 12d26ef41b..5db211fd58 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccess.js +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccess.js @@ -31,6 +31,7 @@ let pair2: Pairs[keyof FooBar] = { //// [mappedTypeIndexedAccess.js] +// Repro from #15756 // Error expected here let pair1 = { key: "foo", diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccess.js.diff b/testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccess.js.diff index 78ebf16833..a78abeae77 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccess.js.diff +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeIndexedAccess.js.diff @@ -5,7 +5,6 @@ //// [mappedTypeIndexedAccess.js] -"use strict"; --// Repro from #15756 + // Repro from #15756 // Error expected here - let pair1 = { - key: "foo", \ No newline at end of file + let pair1 = { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeInferenceCircularity.js b/testdata/baselines/reference/submodule/compiler/mappedTypeInferenceCircularity.js index 9dc10b5e36..9559d67856 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeInferenceCircularity.js +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeInferenceCircularity.js @@ -10,4 +10,5 @@ declare var h: HTML; h.div(h); //// [mappedTypeInferenceCircularity.js] +// Repro from #12511 h.div(h); diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeInferenceCircularity.js.diff b/testdata/baselines/reference/submodule/compiler/mappedTypeInferenceCircularity.js.diff deleted file mode 100644 index 42d3272a0b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeInferenceCircularity.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.mappedTypeInferenceCircularity.js -+++ new.mappedTypeInferenceCircularity.js -@@= skipped -9, +9 lines =@@ - h.div(h); - - //// [mappedTypeInferenceCircularity.js] --// Repro from #12511 - h.div(h); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeNestedGenericInstantiation.js b/testdata/baselines/reference/submodule/compiler/mappedTypeNestedGenericInstantiation.js index 2be7e110b9..327d9b8d1b 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeNestedGenericInstantiation.js +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeNestedGenericInstantiation.js @@ -16,5 +16,6 @@ const v = chain({a: 1, b: 2}).mapValues(square).value(); //// [mappedTypeNestedGenericInstantiation.js] +// Repro from #13346 const square = (x) => x * x; const v = chain({ a: 1, b: 2 }).mapValues(square).value(); diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeNestedGenericInstantiation.js.diff b/testdata/baselines/reference/submodule/compiler/mappedTypeNestedGenericInstantiation.js.diff deleted file mode 100644 index 5816153056..0000000000 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeNestedGenericInstantiation.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.mappedTypeNestedGenericInstantiation.js -+++ new.mappedTypeNestedGenericInstantiation.js -@@= skipped -15, +15 lines =@@ - - - //// [mappedTypeNestedGenericInstantiation.js] --// Repro from #13346 - const square = (x) => x * x; - const v = chain({ a: 1, b: 2 }).mapValues(square).value(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeParameterConstraint.js b/testdata/baselines/reference/submodule/compiler/mappedTypeParameterConstraint.js index 789c65e064..2573d7a36b 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeParameterConstraint.js +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeParameterConstraint.js @@ -10,6 +10,7 @@ function foo(arg: U): MyMap { //// [mappedTypeParameterConstraint.js] +// Repro for #27596 function foo(arg) { return arg; } diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeParameterConstraint.js.diff b/testdata/baselines/reference/submodule/compiler/mappedTypeParameterConstraint.js.diff deleted file mode 100644 index 6ad2cc4e2a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeParameterConstraint.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.mappedTypeParameterConstraint.js -+++ new.mappedTypeParameterConstraint.js -@@= skipped -9, +9 lines =@@ - - - //// [mappedTypeParameterConstraint.js] --// Repro for #27596 - function foo(arg) { - return arg; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypePartialConstraints.js b/testdata/baselines/reference/submodule/compiler/mappedTypePartialConstraints.js index 535d8ce788..c4ba242b78 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypePartialConstraints.js +++ b/testdata/baselines/reference/submodule/compiler/mappedTypePartialConstraints.js @@ -19,6 +19,7 @@ fn(MySubClass); //// [mappedTypePartialConstraints.js] +// Repro from #16985 class MyClass { doIt(data) { } } diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypePartialConstraints.js.diff b/testdata/baselines/reference/submodule/compiler/mappedTypePartialConstraints.js.diff deleted file mode 100644 index 349a969b2d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/mappedTypePartialConstraints.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.mappedTypePartialConstraints.js -+++ new.mappedTypePartialConstraints.js -@@= skipped -18, +18 lines =@@ - - - //// [mappedTypePartialConstraints.js] --// Repro from #16985 - class MyClass { - doIt(data) { } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeWithCombinedTypeMappers.js b/testdata/baselines/reference/submodule/compiler/mappedTypeWithCombinedTypeMappers.js index 75b4ca83db..3ed298c154 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeWithCombinedTypeMappers.js +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeWithCombinedTypeMappers.js @@ -22,4 +22,5 @@ const shouldFail: { important: boolean } = output.x.children; //// [mappedTypeWithCombinedTypeMappers.js] +// Repro from #13351 const shouldFail = output.x.children; diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeWithCombinedTypeMappers.js.diff b/testdata/baselines/reference/submodule/compiler/mappedTypeWithCombinedTypeMappers.js.diff deleted file mode 100644 index 5f380fbc01..0000000000 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeWithCombinedTypeMappers.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.mappedTypeWithCombinedTypeMappers.js -+++ new.mappedTypeWithCombinedTypeMappers.js -@@= skipped -21, +21 lines =@@ - - - //// [mappedTypeWithCombinedTypeMappers.js] --// Repro from #13351 - const shouldFail = output.x.children; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mixinPrivateAndProtected.js b/testdata/baselines/reference/submodule/compiler/mixinPrivateAndProtected.js index c7763285d2..0b12977d87 100644 --- a/testdata/baselines/reference/submodule/compiler/mixinPrivateAndProtected.js +++ b/testdata/baselines/reference/submodule/compiler/mixinPrivateAndProtected.js @@ -92,6 +92,7 @@ class Customer extends PersonMixin(Person) { //// [mixinPrivateAndProtected.js] +// Repro from #13830 class A { pb = 2; ptd = 1; diff --git a/testdata/baselines/reference/submodule/compiler/mixinPrivateAndProtected.js.diff b/testdata/baselines/reference/submodule/compiler/mixinPrivateAndProtected.js.diff index c9cd276f69..6756cce609 100644 --- a/testdata/baselines/reference/submodule/compiler/mixinPrivateAndProtected.js.diff +++ b/testdata/baselines/reference/submodule/compiler/mixinPrivateAndProtected.js.diff @@ -1,10 +1,8 @@ --- old.mixinPrivateAndProtected.js +++ new.mixinPrivateAndProtected.js -@@= skipped -91, +91 lines =@@ - - +@@= skipped -93, +93 lines =@@ //// [mixinPrivateAndProtected.js] --// Repro from #13830 + // Repro from #13830 class A { - constructor() { - this.pb = 2; @@ -48,7 +46,7 @@ }; } const AB2C = mixC(AB2), ABC = mixC(AB); -@@= skipped -51, +39 lines =@@ +@@= skipped -49, +38 lines =@@ ab2c.pvt.toFixed(); // Error // Repro from #13924 class Person { diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js b/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js index 1de091ed9e..145596af3b 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js @@ -36,4 +36,5 @@ import moment = require("moment-timezone"); //// [idx.test.js] "use strict"; +/// Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff b/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff index 74cfebc2a4..75ddb861bb 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff @@ -9,5 +9,4 @@ -Object.defineProperty(exports, "__esModule", { value: true }); //// [idx.test.js] "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); \ No newline at end of file + /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule1.js b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule1.js index b1196c299a..310ddede4b 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule1.js +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule1.js @@ -28,6 +28,7 @@ x.foo().x; //// [main.js] "use strict"; +/// Object.defineProperty(exports, "__esModule", { value: true }); let x; x.foo().x; diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule1.js.diff b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule1.js.diff deleted file mode 100644 index d8f590916e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.moduleAugmentationInAmbientModule1.js -+++ new.moduleAugmentationInAmbientModule1.js -@@= skipped -27, +27 lines =@@ - - //// [main.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); - let x; - x.foo().x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule2.js b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule2.js index f02b2a39a2..1f270b9f81 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule2.js +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule2.js @@ -29,6 +29,7 @@ x.foo().x; //// [main.js] "use strict"; +/// Object.defineProperty(exports, "__esModule", { value: true }); require("Map"); let x; diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule2.js.diff b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule2.js.diff index 5bb4aef0ec..d95b87e65e 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule2.js.diff @@ -1,11 +1,6 @@ --- old.moduleAugmentationInAmbientModule2.js +++ new.moduleAugmentationInAmbientModule2.js -@@= skipped -28, +28 lines =@@ - - //// [main.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -33, +33 lines =@@ require("Map"); let x; x.foo().x; diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule3.js b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule3.js index 4dc2ba18b4..dda27d1c9f 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule3.js +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule3.js @@ -39,6 +39,7 @@ x.foo2().x2; //// [main.js] "use strict"; +/// Object.defineProperty(exports, "__esModule", { value: true }); require("Map"); let x; diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule3.js.diff b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule3.js.diff index f9bab0626d..a7764856f2 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule3.js.diff +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule3.js.diff @@ -1,12 +1,6 @@ --- old.moduleAugmentationInAmbientModule3.js +++ new.moduleAugmentationInAmbientModule3.js -@@= skipped -38, +38 lines =@@ - - //// [main.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); - require("Map"); +@@= skipped -44, +44 lines =@@ let x; x.foo().x; x.foo2().x2; diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule4.js b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule4.js index 7a452c7a49..68039aeea6 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule4.js +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule4.js @@ -41,6 +41,8 @@ x.foo2().x2; //// [main.js] "use strict"; +/// +/// Object.defineProperty(exports, "__esModule", { value: true }); require("Map"); let x; diff --git a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule4.js.diff b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule4.js.diff index b88382915e..f2d1c8beab 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule4.js.diff +++ b/testdata/baselines/reference/submodule/compiler/moduleAugmentationInAmbientModule4.js.diff @@ -1,13 +1,6 @@ --- old.moduleAugmentationInAmbientModule4.js +++ new.moduleAugmentationInAmbientModule4.js -@@= skipped -40, +40 lines =@@ - - //// [main.js] - "use strict"; --/// --/// - Object.defineProperty(exports, "__esModule", { value: true }); - require("Map"); +@@= skipped -47, +47 lines =@@ let x; x.foo().x; x.foo2().x2; diff --git a/testdata/baselines/reference/submodule/compiler/moduleElementsInWrongContext.types.diff b/testdata/baselines/reference/submodule/compiler/moduleElementsInWrongContext.types.diff deleted file mode 100644 index 9e70d381f4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/moduleElementsInWrongContext.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.moduleElementsInWrongContext.types -+++ new.moduleElementsInWrongContext.types -@@= skipped -50, +50 lines =@@ - >Foo : typeof Foo - - import bar from "ambient"; -->bar : any -+>bar : typeof Foo - - import { baz } from "ambient"; - >baz : any \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.types b/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.types index 6d0c234077..20c96e38f6 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.types +++ b/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.types @@ -2,8 +2,8 @@ === eslint.config.js === const eslintReact = require('./eslint-plugin-react.js'); ->eslintReact : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; }; } ->require('./eslint-plugin-react.js') : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; }; } +>eslintReact : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; }; } +>require('./eslint-plugin-react.js') : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; }; } >require : any >'./eslint-plugin-react.js' : "./eslint-plugin-react.js" @@ -18,7 +18,7 @@ tseslint.config(eslintReact) >tseslint.config : (...configs: import("typescript-eslint").Config[]) => void >tseslint : { config: (...configs: import("typescript-eslint").Config[]) => void; } >config : (...configs: import("typescript-eslint").Config[]) => void ->eslintReact : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; }; } +>eslintReact : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; }; } === eslint-plugin-react.js === const deprecatedRules = { @@ -31,8 +31,8 @@ const deprecatedRules = { } const allRules = { ->allRules : { "no-unsafe": boolean; } ->{ 'no-unsafe': true} : { "no-unsafe": boolean; } +>allRules : { 'no-unsafe': boolean; } +>{ 'no-unsafe': true} : { 'no-unsafe': boolean; } 'no-unsafe': true >'no-unsafe' : boolean @@ -40,26 +40,26 @@ const allRules = { } module.exports = { ->module.exports = { plugins: { react: { deprecatedRules, rules: allRules, }, },} : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; }; } ->module.exports : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; }; } ->module : { "export=": { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; }; }; } ->exports : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; }; } ->{ plugins: { react: { deprecatedRules, rules: allRules, }, },} : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; }; } +>module.exports = { plugins: { react: { deprecatedRules, rules: allRules, }, },} : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; }; } +>module.exports : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; }; } +>module : { "export=": { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; }; }; } +>exports : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; }; } +>{ plugins: { react: { deprecatedRules, rules: allRules, }, },} : { plugins: { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; }; } plugins: { ->plugins : { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; } ->{ react: { deprecatedRules, rules: allRules, }, } : { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; }; } +>plugins : { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; } +>{ react: { deprecatedRules, rules: allRules, }, } : { react: { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; }; } react: { ->react : { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; } ->{ deprecatedRules, rules: allRules, } : { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { "no-unsafe": boolean; }; } +>react : { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; } +>{ deprecatedRules, rules: allRules, } : { deprecatedRules: { "jsx-sort-default-props": boolean; }; rules: { 'no-unsafe': boolean; }; } deprecatedRules, >deprecatedRules : { "jsx-sort-default-props": boolean; } rules: allRules, ->rules : { "no-unsafe": boolean; } ->allRules : { "no-unsafe": boolean; } +>rules : { 'no-unsafe': boolean; } +>allRules : { 'no-unsafe': boolean; } }, }, diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_empty.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_empty.errors.txt.diff new file mode 100644 index 0000000000..2f2399daf6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_empty.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.moduleResolutionWithSuffixes_empty.errors.txt ++++ new.moduleResolutionWithSuffixes_empty.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": [] +- } +- } +-==== /index.ts (0 errors) ==== +- import { base } from "./foo"; +-==== /foo.ts (0 errors) ==== +- export function base() {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_notSpecified.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_notSpecified.errors.txt.diff new file mode 100644 index 0000000000..2f26d2d13f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_notSpecified.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.moduleResolutionWithSuffixes_notSpecified.errors.txt ++++ new.moduleResolutionWithSuffixes_notSpecified.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- } +- } +-==== /index.ts (0 errors) ==== +- import { base } from "./foo"; +-==== /foo.ts (0 errors) ==== +- export function base() {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one.errors.txt.diff new file mode 100644 index 0000000000..7965155fa6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.moduleResolutionWithSuffixes_one.errors.txt ++++ new.moduleResolutionWithSuffixes_one.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": [".ios"] +- } +- } +- +-==== /index.ts (0 errors) ==== +- import { ios } from "./foo"; +-==== /foo.ios.ts (0 errors) ==== +- export function ios() {} +-==== /foo.ts (0 errors) ==== +- export function base() {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_oneBlank.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_oneBlank.errors.txt.diff new file mode 100644 index 0000000000..b4268cd42f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_oneBlank.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.moduleResolutionWithSuffixes_oneBlank.errors.txt ++++ new.moduleResolutionWithSuffixes_oneBlank.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": [""] +- } +- } +- +-==== /index.ts (0 errors) ==== +- import { base } from "./foo"; +-==== /foo.ts (0 errors) ==== +- export function base() {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_oneNotFound.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_oneNotFound.errors.txt.diff new file mode 100644 index 0000000000..779eeea7dd --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_oneNotFound.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.moduleResolutionWithSuffixes_oneNotFound.errors.txt ++++ new.moduleResolutionWithSuffixes_oneNotFound.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. + /index.ts(1,21): error TS2307: Cannot find module './foo' or its corresponding type declarations. + + +-==== /tsconfig.json (1 errors) ==== ++==== /tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. + "traceResolution": true, + "moduleSuffixes": [".ios"] + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_dirModuleWithIndex.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_dirModuleWithIndex.errors.txt.diff new file mode 100644 index 0000000000..69ab38bf7a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_dirModuleWithIndex.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.moduleResolutionWithSuffixes_one_dirModuleWithIndex.errors.txt ++++ new.moduleResolutionWithSuffixes_one_dirModuleWithIndex.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": [".ios"] +- } +- } +- +-==== /index.ts (0 errors) ==== +- import { ios } from "./foo"; +-==== /foo/index.ios.ts (0 errors) ==== +- export function ios() {} +-==== /foo/index.ts (0 errors) ==== +- export function base() {} ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_externalModule.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_externalModule.errors.txt.diff new file mode 100644 index 0000000000..e85122c087 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_externalModule.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.moduleResolutionWithSuffixes_one_externalModule.errors.txt ++++ new.moduleResolutionWithSuffixes_one_externalModule.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(6,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "allowJs": true, +- "checkJs": false, +- "outDir": "bin", +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": [".ios"] +- } +- } +- +-==== /index.ts (0 errors) ==== +- import { ios } from "some-library"; +- +-==== /node_modules/some-library/index.ios.js (0 errors) ==== +- "use strict"; +- exports.__esModule = true; +- function ios() {} +- exports.ios = ios; +-==== /node_modules/some-library/index.ios.d.ts (0 errors) ==== +- export declare function ios(): void; +-==== /node_modules/some-library/index.js (0 errors) ==== +- "use strict"; +- exports.__esModule = true; +- function base() {} +- exports.base = base; +-==== /node_modules/some-library/index.d.ts (0 errors) ==== +- export declare function base(): void; +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_externalModulePath.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_externalModulePath.errors.txt.diff new file mode 100644 index 0000000000..c3459b508b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_externalModulePath.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.moduleResolutionWithSuffixes_one_externalModulePath.errors.txt ++++ new.moduleResolutionWithSuffixes_one_externalModulePath.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(6,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "allowJs": true, +- "checkJs": false, +- "outDir": "bin", +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": [".ios"] +- } +- } +- +-==== /index.ts (0 errors) ==== +- import { iosfoo } from "some-library/foo"; +- +-==== /node_modules/some-library/foo.ios.js (0 errors) ==== +- "use strict"; +- exports.__esModule = true; +- function iosfoo() {} +- exports.iosfoo = iosfoo; +-==== /node_modules/some-library/foo.ios.d.ts (0 errors) ==== +- export declare function iosfoo(): void; +-==== /node_modules/some-library/foo.js (0 errors) ==== +- "use strict"; +- exports.__esModule = true; +- function basefoo() {} +- exports.basefoo = basefoo; +-==== /node_modules/some-library/foo.d.ts (0 errors) ==== +- export declare function basefoo(): void; +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_externalTSModule.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_externalTSModule.errors.txt.diff new file mode 100644 index 0000000000..156fb025fd --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_externalTSModule.errors.txt.diff @@ -0,0 +1,26 @@ +--- old.moduleResolutionWithSuffixes_one_externalTSModule.errors.txt ++++ new.moduleResolutionWithSuffixes_one_externalTSModule.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(4,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "outDir": "bin", +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": [".ios"] +- } +- } +- +-==== /test.ts (0 errors) ==== +- import { ios } from "some-library"; +- +-==== /node_modules/some-library/index.ios.ts (0 errors) ==== +- export function ios() {} +-==== /node_modules/some-library/index.ts (0 errors) ==== +- export function base() {} ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_jsonModule.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_jsonModule.errors.txt.diff new file mode 100644 index 0000000000..cada164092 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_one_jsonModule.errors.txt.diff @@ -0,0 +1,33 @@ +--- old.moduleResolutionWithSuffixes_one_jsonModule.errors.txt ++++ new.moduleResolutionWithSuffixes_one_jsonModule.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(6,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "esModuleInterop": true, +- "resolveJsonModule": true, +- "outDir": "bin", +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": [".ios"] +- } +- } +- +-==== /index.ts (0 errors) ==== +- import foo from "./foo.json"; +- console.log(foo.ios); +-==== /foo.ios.json (0 errors) ==== +- { +- "ios": "platform ios" +- } +-==== /foo.json (0 errors) ==== +- { +- "base": "platform base" +- } +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank1.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank1.errors.txt.diff new file mode 100644 index 0000000000..35f61639d6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank1.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.moduleResolutionWithSuffixes_threeLastIsBlank1.errors.txt ++++ new.moduleResolutionWithSuffixes_threeLastIsBlank1.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": ["-ios", "__native", ""] +- } +- } +- +-==== /index.ts (0 errors) ==== +- import { ios } from "./foo"; +-==== /foo-ios.ts (0 errors) ==== +- export function ios() {} +-==== /foo__native.ts (0 errors) ==== +- export function native() {} +-==== /foo.ts (0 errors) ==== +- export function base() {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank2.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank2.errors.txt.diff new file mode 100644 index 0000000000..978953794a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank2.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.moduleResolutionWithSuffixes_threeLastIsBlank2.errors.txt ++++ new.moduleResolutionWithSuffixes_threeLastIsBlank2.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": ["-ios", "__native", ""] +- } +- } +- +-==== /index.ts (0 errors) ==== +- import { native } from "./foo"; +-==== /foo__native.ts (0 errors) ==== +- export function native() {} +-==== /foo.ts (0 errors) ==== +- export function base() {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank3.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank3.errors.txt.diff new file mode 100644 index 0000000000..1672bb7aa0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank3.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.moduleResolutionWithSuffixes_threeLastIsBlank3.errors.txt ++++ new.moduleResolutionWithSuffixes_threeLastIsBlank3.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-==== /tsconfig.json (1 errors) ==== +- { +- "compilerOptions": { +- "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- "traceResolution": true, +- "moduleSuffixes": ["-ios", "__native", ""] +- } +- } +- +-==== /index.ts (0 errors) ==== +- import { base } from "./foo"; +-==== /foo.ts (0 errors) ==== +- export function base() {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank4.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank4.errors.txt.diff new file mode 100644 index 0000000000..79da8b925c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSuffixes_threeLastIsBlank4.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.moduleResolutionWithSuffixes_threeLastIsBlank4.errors.txt ++++ new.moduleResolutionWithSuffixes_threeLastIsBlank4.errors.txt +@@= skipped -0, +0 lines =@@ +-/tsconfig.json(3,23): error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. + /index.ts(1,22): error TS2307: Cannot find module './foo' or its corresponding type declarations. + + +-==== /tsconfig.json (1 errors) ==== ++==== /tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "moduleResolution": "node", +- ~~~~~~ +-!!! error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. + "traceResolution": true, + "moduleSuffixes": ["-ios", "__native", ""] + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSymlinks_preserveSymlinks.js b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSymlinks_preserveSymlinks.js index de63c70176..31cdc9ec06 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSymlinks_preserveSymlinks.js +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSymlinks_preserveSymlinks.js @@ -21,9 +21,9 @@ x = new C2(); //// [app.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // We shouldn't resolve symlinks for references either. See the trace. /// +Object.defineProperty(exports, "__esModule", { value: true }); const linked_1 = require("linked"); const linked2_1 = require("linked2"); let x = new linked_1.C(); diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSymlinks_preserveSymlinks.js.diff b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSymlinks_preserveSymlinks.js.diff index 01db587117..eef0d9a16b 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSymlinks_preserveSymlinks.js.diff +++ b/testdata/baselines/reference/submodule/compiler/moduleResolutionWithSymlinks_preserveSymlinks.js.diff @@ -1,13 +1,9 @@ --- old.moduleResolutionWithSymlinks_preserveSymlinks.js +++ new.moduleResolutionWithSymlinks_preserveSymlinks.js -@@= skipped -20, +20 lines =@@ - - //// [app.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -23, +23 lines =@@ // We shouldn't resolve symlinks for references either. See the trace. /// --Object.defineProperty(exports, "__esModule", { value: true }); + Object.defineProperty(exports, "__esModule", { value: true }); -var linked_1 = require("linked"); -var linked2_1 = require("linked2"); +const linked_1 = require("linked"); diff --git a/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.js b/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.js index 98c93b07b7..727cbed30c 100644 --- a/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.js +++ b/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.js @@ -1,8 +1,42 @@ //// [tests/cases/compiler/module_augmentUninstantiatedModule2.ts] //// -//// [module_augmentUninstantiatedModule2.ts] -declare var ng: ng.IAngularStatic; declare module ng { export interface IModule { name: string; } export interface IAngularStatic { module: (s: string) => IModule; } } export = ng; +//// [app.ts] +import ng = require("angular"); +import "./moduleAugmentation"; + +var x: number = ng.getNumber(); -//// [module_augmentUninstantiatedModule2.js] +//// [moduleAugmentation.ts] +import * as ng from "angular" +declare module "angular" { + export interface IAngularStatic { + getNumber: () => number; + } +} + +//// [index.d.ts] +declare var ng: ng.IAngularStatic; + +declare module ng { + export interface IModule { + name: string; + } + + export interface IAngularStatic { + module: (s: string) => IModule; + } +} + +export = ng; + + + +//// [moduleAugmentation.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [app.js] "use strict"; -module.exports = ng; +Object.defineProperty(exports, "__esModule", { value: true }); +const ng = require("angular"); +require("./moduleAugmentation"); +var x = ng.getNumber(); diff --git a/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.js.diff b/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.js.diff new file mode 100644 index 0000000000..314247865d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.js.diff @@ -0,0 +1,10 @@ +--- old.module_augmentUninstantiatedModule2.js ++++ new.module_augmentUninstantiatedModule2.js +@@= skipped -36, +36 lines =@@ + //// [app.js] + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); +-var ng = require("angular"); ++const ng = require("angular"); + require("./moduleAugmentation"); + var x = ng.getNumber(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.symbols b/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.symbols index d8a3779193..17c284df01 100644 --- a/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.symbols +++ b/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.symbols @@ -1,32 +1,59 @@ //// [tests/cases/compiler/module_augmentUninstantiatedModule2.ts] //// -=== module_augmentUninstantiatedModule2.ts === +=== app.ts === +import ng = require("angular"); +>ng : Symbol(ng, Decl(app.ts, 0, 0)) + +import "./moduleAugmentation"; + +var x: number = ng.getNumber(); +>x : Symbol(x, Decl(app.ts, 3, 3)) +>ng.getNumber : Symbol(ng.IAngularStatic.getNumber, Decl(moduleAugmentation.ts, 2, 37)) +>ng : Symbol(ng, Decl(app.ts, 0, 0)) +>getNumber : Symbol(ng.IAngularStatic.getNumber, Decl(moduleAugmentation.ts, 2, 37)) + +=== moduleAugmentation.ts === +import * as ng from "angular" +>ng : Symbol(ng, Decl(moduleAugmentation.ts, 0, 6)) + +declare module "angular" { +>"angular" : Symbol(ng, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 34), Decl(moduleAugmentation.ts, 0, 29)) + + export interface IAngularStatic { +>IAngularStatic : Symbol(IAngularStatic, Decl(index.d.ts, 5, 4), Decl(moduleAugmentation.ts, 1, 26)) + + getNumber: () => number; +>getNumber : Symbol(IAngularStatic.getNumber, Decl(moduleAugmentation.ts, 2, 37)) + } +} + +=== node_modules/angular/index.d.ts === declare var ng: ng.IAngularStatic; ->ng : Symbol(ng, Decl(module_augmentUninstantiatedModule2.ts, 0, 11), Decl(module_augmentUninstantiatedModule2.ts, 0, 34)) ->ng : Symbol(ng, Decl(module_augmentUninstantiatedModule2.ts, 0, 11), Decl(module_augmentUninstantiatedModule2.ts, 0, 34)) ->IAngularStatic : Symbol(ng.IAngularStatic, Decl(module_augmentUninstantiatedModule2.ts, 5, 4)) +>ng : Symbol(ng, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 34), Decl(moduleAugmentation.ts, 0, 29)) +>ng : Symbol(ng, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 34), Decl(moduleAugmentation.ts, 0, 29)) +>IAngularStatic : Symbol(ng.IAngularStatic, Decl(index.d.ts, 5, 4), Decl(moduleAugmentation.ts, 1, 26)) declare module ng { ->ng : Symbol(ng, Decl(module_augmentUninstantiatedModule2.ts, 0, 11), Decl(module_augmentUninstantiatedModule2.ts, 0, 34)) +>ng : Symbol(ng, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 34), Decl(moduleAugmentation.ts, 0, 29)) export interface IModule { ->IModule : Symbol(IModule, Decl(module_augmentUninstantiatedModule2.ts, 2, 19)) +>IModule : Symbol(IModule, Decl(index.d.ts, 2, 19)) name: string; ->name : Symbol(IModule.name, Decl(module_augmentUninstantiatedModule2.ts, 3, 29)) +>name : Symbol(IModule.name, Decl(index.d.ts, 3, 29)) } export interface IAngularStatic { ->IAngularStatic : Symbol(IAngularStatic, Decl(module_augmentUninstantiatedModule2.ts, 5, 4)) +>IAngularStatic : Symbol(IAngularStatic, Decl(index.d.ts, 5, 4), Decl(moduleAugmentation.ts, 1, 26)) module: (s: string) => IModule; ->module : Symbol(IAngularStatic.module, Decl(module_augmentUninstantiatedModule2.ts, 7, 36)) ->s : Symbol(s, Decl(module_augmentUninstantiatedModule2.ts, 8, 16)) ->IModule : Symbol(IModule, Decl(module_augmentUninstantiatedModule2.ts, 2, 19)) +>module : Symbol(IAngularStatic.module, Decl(index.d.ts, 7, 36)) +>s : Symbol(s, Decl(index.d.ts, 8, 16)) +>IModule : Symbol(IModule, Decl(index.d.ts, 2, 19)) } } export = ng; ->ng : Symbol(ng, Decl(module_augmentUninstantiatedModule2.ts, 0, 11), Decl(module_augmentUninstantiatedModule2.ts, 0, 34)) +>ng : Symbol(ng, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 34), Decl(moduleAugmentation.ts, 0, 29)) diff --git a/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.types b/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.types index 4256b711e0..c4feae8337 100644 --- a/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.types +++ b/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.types @@ -1,8 +1,34 @@ //// [tests/cases/compiler/module_augmentUninstantiatedModule2.ts] //// -=== module_augmentUninstantiatedModule2.ts === +=== app.ts === +import ng = require("angular"); +>ng : ng.IAngularStatic + +import "./moduleAugmentation"; + +var x: number = ng.getNumber(); +>x : number +>ng.getNumber() : number +>ng.getNumber : () => number +>ng : ng.IAngularStatic +>getNumber : () => number + +=== moduleAugmentation.ts === +import * as ng from "angular" +>ng : ng.IAngularStatic + +declare module "angular" { +>"angular" : IAngularStatic + + export interface IAngularStatic { + getNumber: () => number; +>getNumber : () => number + } +} + +=== node_modules/angular/index.d.ts === declare var ng: ng.IAngularStatic; ->ng : import("module_augmentUninstantiatedModule2").IAngularStatic +>ng : import("node_modules/angular/index.d.ts").IAngularStatic >ng : any declare module ng { @@ -19,6 +45,6 @@ declare module ng { } export = ng; ->ng : import("module_augmentUninstantiatedModule2").IAngularStatic +>ng : import("node_modules/angular/index.d.ts").IAngularStatic diff --git a/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.types.diff b/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.types.diff deleted file mode 100644 index 2f98d353d6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/module_augmentUninstantiatedModule2.types.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.module_augmentUninstantiatedModule2.types -+++ new.module_augmentUninstantiatedModule2.types -@@= skipped -1, +1 lines =@@ - - === module_augmentUninstantiatedModule2.ts === - declare var ng: ng.IAngularStatic; -->ng : ng.IAngularStatic -+>ng : import("module_augmentUninstantiatedModule2").IAngularStatic - >ng : any - - declare module ng { -@@= skipped -17, +17 lines =@@ - } - - export = ng; -->ng : ng.IAngularStatic -+>ng : import("module_augmentUninstantiatedModule2").IAngularStatic - diff --git a/testdata/baselines/reference/submodule/compiler/mutuallyRecursiveCallbacks.js b/testdata/baselines/reference/submodule/compiler/mutuallyRecursiveCallbacks.js index 1293db402c..29786c4222 100644 --- a/testdata/baselines/reference/submodule/compiler/mutuallyRecursiveCallbacks.js +++ b/testdata/baselines/reference/submodule/compiler/mutuallyRecursiveCallbacks.js @@ -11,5 +11,6 @@ bar = foo; //// [mutuallyRecursiveCallbacks.js] +// Repro from #18277 ; bar = foo; diff --git a/testdata/baselines/reference/submodule/compiler/mutuallyRecursiveCallbacks.js.diff b/testdata/baselines/reference/submodule/compiler/mutuallyRecursiveCallbacks.js.diff deleted file mode 100644 index 514e00850f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/mutuallyRecursiveCallbacks.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.mutuallyRecursiveCallbacks.js -+++ new.mutuallyRecursiveCallbacks.js -@@= skipped -10, +10 lines =@@ - - - //// [mutuallyRecursiveCallbacks.js] --// Repro from #18277 - ; - bar = foo; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/narrowingAssignmentReadonlyRespectsAssertion.js b/testdata/baselines/reference/submodule/compiler/narrowingAssignmentReadonlyRespectsAssertion.js index 1883857f77..d8c5dac351 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingAssignmentReadonlyRespectsAssertion.js +++ b/testdata/baselines/reference/submodule/compiler/narrowingAssignmentReadonlyRespectsAssertion.js @@ -43,6 +43,7 @@ testFunc(); //// [narrowingAssignmentReadonlyRespectsAssertion.js] +// https://github.com/microsoft/TypeScript/issues/41984 function subDataFunc() { return [ { val1: "a", val2: ["a", "b", "c"] }, diff --git a/testdata/baselines/reference/submodule/compiler/narrowingAssignmentReadonlyRespectsAssertion.js.diff b/testdata/baselines/reference/submodule/compiler/narrowingAssignmentReadonlyRespectsAssertion.js.diff deleted file mode 100644 index ee0de41a3e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/narrowingAssignmentReadonlyRespectsAssertion.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.narrowingAssignmentReadonlyRespectsAssertion.js -+++ new.narrowingAssignmentReadonlyRespectsAssertion.js -@@= skipped -42, +42 lines =@@ - - - //// [narrowingAssignmentReadonlyRespectsAssertion.js] --// https://github.com/microsoft/TypeScript/issues/41984 - function subDataFunc() { - return [ - { val1: "a", val2: ["a", "b", "c"] }, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/narrowingByDiscriminantInLoop.js b/testdata/baselines/reference/submodule/compiler/narrowingByDiscriminantInLoop.js index 6f72b882e0..c0e686f486 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingByDiscriminantInLoop.js +++ b/testdata/baselines/reference/submodule/compiler/narrowingByDiscriminantInLoop.js @@ -88,6 +88,7 @@ function f2(x: A | B) { } //// [narrowingByDiscriminantInLoop.js] +// Repro from #9977 function insertInterface(callbackType) { for (const memberType of callbackType.members) { if (memberType.type === "const") { diff --git a/testdata/baselines/reference/submodule/compiler/narrowingByDiscriminantInLoop.js.diff b/testdata/baselines/reference/submodule/compiler/narrowingByDiscriminantInLoop.js.diff deleted file mode 100644 index 4b13749fc3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/narrowingByDiscriminantInLoop.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.narrowingByDiscriminantInLoop.js -+++ new.narrowingByDiscriminantInLoop.js -@@= skipped -87, +87 lines =@@ - } - - //// [narrowingByDiscriminantInLoop.js] --// Repro from #9977 - function insertInterface(callbackType) { - for (const memberType of callbackType.members) { - if (memberType.type === "const") { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/narrowingConstrainedTypeParameter.js b/testdata/baselines/reference/submodule/compiler/narrowingConstrainedTypeParameter.js index f430b1633d..9b76ba2a7a 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingConstrainedTypeParameter.js +++ b/testdata/baselines/reference/submodule/compiler/narrowingConstrainedTypeParameter.js @@ -20,6 +20,7 @@ export function speak(pet: TPet, voice: (pet: TPet) => string) //// [narrowingConstrainedTypeParameter.js] "use strict"; +// Repro from #10811 Object.defineProperty(exports, "__esModule", { value: true }); exports.speak = speak; function isPet(pet) { diff --git a/testdata/baselines/reference/submodule/compiler/narrowingConstrainedTypeParameter.js.diff b/testdata/baselines/reference/submodule/compiler/narrowingConstrainedTypeParameter.js.diff deleted file mode 100644 index a91c8edb73..0000000000 --- a/testdata/baselines/reference/submodule/compiler/narrowingConstrainedTypeParameter.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.narrowingConstrainedTypeParameter.js -+++ new.narrowingConstrainedTypeParameter.js -@@= skipped -19, +19 lines =@@ - - //// [narrowingConstrainedTypeParameter.js] - "use strict"; --// Repro from #10811 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.speak = speak; - function isPet(pet) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/narrowingMutualSubtypes.js b/testdata/baselines/reference/submodule/compiler/narrowingMutualSubtypes.js index 63c8c4a840..dcbd8a4ba2 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingMutualSubtypes.js +++ b/testdata/baselines/reference/submodule/compiler/narrowingMutualSubtypes.js @@ -145,6 +145,7 @@ function checksArrayOrObject2(obj: Record | Record[]) //// [narrowingMutualSubtypes.js] +// Check that `any` is a strict supertype of `unknown` const a1a = [ru1, ra1]; // { [x: string]: any }[] const a1b = [ra1, ru1]; // { [x: string]: any }[] const a2a = [ru2, ra2]; // { [x: string]: any }[] diff --git a/testdata/baselines/reference/submodule/compiler/narrowingMutualSubtypes.js.diff b/testdata/baselines/reference/submodule/compiler/narrowingMutualSubtypes.js.diff index da7c361c5c..4d9bdd5433 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingMutualSubtypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/narrowingMutualSubtypes.js.diff @@ -5,7 +5,6 @@ //// [narrowingMutualSubtypes.js] -"use strict"; --// Check that `any` is a strict supertype of `unknown` + // Check that `any` is a strict supertype of `unknown` const a1a = [ru1, ra1]; // { [x: string]: any }[] - const a1b = [ra1, ru1]; // { [x: string]: any }[] - const a2a = [ru2, ra2]; // { [x: string]: any }[] \ No newline at end of file + const a1b = [ra1, ru1]; // { [x: string]: any }[] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/narrowingOfQualifiedNames.js b/testdata/baselines/reference/submodule/compiler/narrowingOfQualifiedNames.js index b2f8305403..9d85e8c2ff 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingOfQualifiedNames.js +++ b/testdata/baselines/reference/submodule/compiler/narrowingOfQualifiedNames.js @@ -89,6 +89,7 @@ function handleDogWorking(pet: Pet) { } //// [narrowingOfQualifiedNames.js] +// Repro from #43411 function init(properties) { if (properties.foo) { properties.foo; // type is { aaa: string; bbb: string; } diff --git a/testdata/baselines/reference/submodule/compiler/narrowingOfQualifiedNames.js.diff b/testdata/baselines/reference/submodule/compiler/narrowingOfQualifiedNames.js.diff index 5ab38260dd..96f14aa958 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingOfQualifiedNames.js.diff +++ b/testdata/baselines/reference/submodule/compiler/narrowingOfQualifiedNames.js.diff @@ -5,7 +5,6 @@ //// [narrowingOfQualifiedNames.js] -"use strict"; --// Repro from #43411 + // Repro from #43411 function init(properties) { - if (properties.foo) { - properties.foo; // type is { aaa: string; bbb: string; } \ No newline at end of file + if (properties.foo) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/newAbstractInstance2.types b/testdata/baselines/reference/submodule/compiler/newAbstractInstance2.types index c5c5964e66..90ac3b1392 100644 --- a/testdata/baselines/reference/submodule/compiler/newAbstractInstance2.types +++ b/testdata/baselines/reference/submodule/compiler/newAbstractInstance2.types @@ -9,6 +9,6 @@ import A from "./a"; >A : typeof A new A(); ->new A() : any +>new A() : A >A : typeof A diff --git a/testdata/baselines/reference/submodule/compiler/newAbstractInstance2.types.diff b/testdata/baselines/reference/submodule/compiler/newAbstractInstance2.types.diff new file mode 100644 index 0000000000..1698e60a8b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/newAbstractInstance2.types.diff @@ -0,0 +1,9 @@ +--- old.newAbstractInstance2.types ++++ new.newAbstractInstance2.types +@@= skipped -8, +8 lines =@@ + >A : typeof A + + new A(); +->new A() : any ++>new A() : A + >A : typeof A diff --git a/testdata/baselines/reference/submodule/compiler/noAsConstNameLookup.js b/testdata/baselines/reference/submodule/compiler/noAsConstNameLookup.js index c90a2a17f6..85d56a02ee 100644 --- a/testdata/baselines/reference/submodule/compiler/noAsConstNameLookup.js +++ b/testdata/baselines/reference/submodule/compiler/noAsConstNameLookup.js @@ -33,6 +33,7 @@ new C().f(); //// [noAsConstNameLookup.js] +// Repros from #44292 export class FeatureRunner { cleaners = []; async runFeature() { diff --git a/testdata/baselines/reference/submodule/compiler/noAsConstNameLookup.js.diff b/testdata/baselines/reference/submodule/compiler/noAsConstNameLookup.js.diff index 6082f9529f..44f88e019b 100644 --- a/testdata/baselines/reference/submodule/compiler/noAsConstNameLookup.js.diff +++ b/testdata/baselines/reference/submodule/compiler/noAsConstNameLookup.js.diff @@ -1,10 +1,9 @@ --- old.noAsConstNameLookup.js +++ new.noAsConstNameLookup.js -@@= skipped -32, +32 lines =@@ - +@@= skipped -33, +33 lines =@@ //// [noAsConstNameLookup.js] --// Repros from #44292 + // Repros from #44292 -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { diff --git a/testdata/baselines/reference/submodule/compiler/noCrashOnMixin.types b/testdata/baselines/reference/submodule/compiler/noCrashOnMixin.types index f7b437d648..4ee44ae946 100644 --- a/testdata/baselines/reference/submodule/compiler/noCrashOnMixin.types +++ b/testdata/baselines/reference/submodule/compiler/noCrashOnMixin.types @@ -42,7 +42,7 @@ class CrashTrigger extends Mixin(Empty) { >trigger : () => void new Concrete(); ->new Concrete() : any +>new Concrete() : Concrete >Concrete : typeof Concrete } } diff --git a/testdata/baselines/reference/submodule/compiler/noCrashOnMixin.types.diff b/testdata/baselines/reference/submodule/compiler/noCrashOnMixin.types.diff index c2a5832969..e6805f89ec 100644 --- a/testdata/baselines/reference/submodule/compiler/noCrashOnMixin.types.diff +++ b/testdata/baselines/reference/submodule/compiler/noCrashOnMixin.types.diff @@ -24,4 +24,12 @@ +>Mixin : >(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Mixin.(Anonymous class); } & TBase >Empty : typeof Empty - public trigger() { \ No newline at end of file + public trigger() { + >trigger : () => void + + new Concrete(); +->new Concrete() : any ++>new Concrete() : Concrete + >Concrete : typeof Concrete + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/noErrorTruncation.js b/testdata/baselines/reference/submodule/compiler/noErrorTruncation.js index f55016cf9e..57885ddc12 100644 --- a/testdata/baselines/reference/submodule/compiler/noErrorTruncation.js +++ b/testdata/baselines/reference/submodule/compiler/noErrorTruncation.js @@ -19,4 +19,5 @@ const x: SomeLongOptionA //// [noErrorTruncation.js] +// @noErrorTruncation const x = 42; diff --git a/testdata/baselines/reference/submodule/compiler/noErrorTruncation.js.diff b/testdata/baselines/reference/submodule/compiler/noErrorTruncation.js.diff deleted file mode 100644 index f66891b2e7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/noErrorTruncation.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.noErrorTruncation.js -+++ new.noErrorTruncation.js -@@= skipped -18, +18 lines =@@ - - - //// [noErrorTruncation.js] --// @noErrorTruncation - const x = 42; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/noExcessiveStackDepthError.js b/testdata/baselines/reference/submodule/compiler/noExcessiveStackDepthError.js index 650edc17d6..ef673963b3 100644 --- a/testdata/baselines/reference/submodule/compiler/noExcessiveStackDepthError.js +++ b/testdata/baselines/reference/submodule/compiler/noExcessiveStackDepthError.js @@ -18,6 +18,7 @@ function foo() { //// [noExcessiveStackDepthError.js] +// Repro from #46631 function foo() { var x; var x; // Excessive stack depth error not expected here diff --git a/testdata/baselines/reference/submodule/compiler/noExcessiveStackDepthError.js.diff b/testdata/baselines/reference/submodule/compiler/noExcessiveStackDepthError.js.diff index c6ce643aa2..8cf54fc688 100644 --- a/testdata/baselines/reference/submodule/compiler/noExcessiveStackDepthError.js.diff +++ b/testdata/baselines/reference/submodule/compiler/noExcessiveStackDepthError.js.diff @@ -5,7 +5,6 @@ //// [noExcessiveStackDepthError.js] -"use strict"; --// Repro from #46631 + // Repro from #46631 function foo() { - var x; - var x; // Excessive stack depth error not expected here \ No newline at end of file + var x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.js b/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.js index bed03832af..564f12939c 100644 --- a/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.js +++ b/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.js @@ -18,6 +18,7 @@ interface IFoo { ({ c: null }); //// [noImplicitAnyInCastExpression.js] +// verify no noImplictAny errors reported with cast expression // Expr type not assignable to target type (({ a: null })); // Expr type assignable to target type diff --git a/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.js.diff b/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.js.diff index 6bb1eb9514..6b86be5482 100644 --- a/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.js.diff +++ b/testdata/baselines/reference/submodule/compiler/noImplicitAnyInCastExpression.js.diff @@ -1,10 +1,8 @@ --- old.noImplicitAnyInCastExpression.js +++ new.noImplicitAnyInCastExpression.js -@@= skipped -17, +17 lines =@@ - ({ c: null }); - +@@= skipped -19, +19 lines =@@ //// [noImplicitAnyInCastExpression.js] --// verify no noImplictAny errors reported with cast expression + // verify no noImplictAny errors reported with cast expression // Expr type not assignable to target type -({ a: null }); +(({ a: null })); diff --git a/testdata/baselines/reference/submodule/compiler/noImplicitAnyStringIndexerOnObject.types b/testdata/baselines/reference/submodule/compiler/noImplicitAnyStringIndexerOnObject.types index c0ccc1bce4..72f6540b64 100644 --- a/testdata/baselines/reference/submodule/compiler/noImplicitAnyStringIndexerOnObject.types +++ b/testdata/baselines/reference/submodule/compiler/noImplicitAnyStringIndexerOnObject.types @@ -10,7 +10,7 @@ var a = {}["hello"]; var b: string = { '': 'foo' }['']; >b : string >{ '': 'foo' }[''] : string ->{ '': 'foo' } : { "": string; } +>{ '': 'foo' } : { '': string; } >'' : string >'foo' : "foo" >'' : "" diff --git a/testdata/baselines/reference/submodule/compiler/noImplicitAnyStringIndexerOnObject.types.diff b/testdata/baselines/reference/submodule/compiler/noImplicitAnyStringIndexerOnObject.types.diff deleted file mode 100644 index 53719baf04..0000000000 --- a/testdata/baselines/reference/submodule/compiler/noImplicitAnyStringIndexerOnObject.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.noImplicitAnyStringIndexerOnObject.types -+++ new.noImplicitAnyStringIndexerOnObject.types -@@= skipped -9, +9 lines =@@ - var b: string = { '': 'foo' }['']; - >b : string - >{ '': 'foo' }[''] : string -->{ '': 'foo' } : { '': string; } -+>{ '': 'foo' } : { "": string; } - >'' : string - >'foo' : "foo" - >'' : "" \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeModuleReexportFromDottedPath.js b/testdata/baselines/reference/submodule/compiler/nodeModuleReexportFromDottedPath.js index 8e6036fddd..4959a62228 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeModuleReexportFromDottedPath.js +++ b/testdata/baselines/reference/submodule/compiler/nodeModuleReexportFromDottedPath.js @@ -29,32 +29,5 @@ exports.default = new EnhancedPrisma(); //// [index.d.ts] import { PrismaClient } from "@prisma/client"; -declare const _default: PrismaClient; +declare const _default: PrismaClient; export default _default; - - -//// [DtsFileErrors] - - -/index.d.ts(2,45): error TS2307: Cannot find module '.prisma' or its corresponding type declarations. - - -==== /node_modules/.prisma/client/index.d.ts (0 errors) ==== - export interface PrismaClientOptions { - rejectOnNotFound?: any; - } - - export class PrismaClient { - private fetcher; - } - -==== /node_modules/@prisma/client/index.d.ts (0 errors) ==== - export * from ".prisma/client"; - -==== /index.d.ts (1 errors) ==== - import { PrismaClient } from "@prisma/client"; - declare const _default: PrismaClient; - ~~~~~~~~~ -!!! error TS2307: Cannot find module '.prisma' or its corresponding type declarations. - export default _default; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeModuleReexportFromDottedPath.js.diff b/testdata/baselines/reference/submodule/compiler/nodeModuleReexportFromDottedPath.js.diff index ce61505671..24451f8b04 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeModuleReexportFromDottedPath.js.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeModuleReexportFromDottedPath.js.diff @@ -8,37 +8,3 @@ +const client_1 = require("@prisma/client"); const EnhancedPrisma = enhancePrisma(client_1.PrismaClient); exports.default = new EnhancedPrisma(); - - - //// [index.d.ts] - import { PrismaClient } from "@prisma/client"; --declare const _default: PrismaClient; -+declare const _default: PrismaClient; - export default _default; -+ -+ -+//// [DtsFileErrors] -+ -+ -+/index.d.ts(2,45): error TS2307: Cannot find module '.prisma' or its corresponding type declarations. -+ -+ -+==== /node_modules/.prisma/client/index.d.ts (0 errors) ==== -+ export interface PrismaClientOptions { -+ rejectOnNotFound?: any; -+ } -+ -+ export class PrismaClient { -+ private fetcher; -+ } -+ -+==== /node_modules/@prisma/client/index.d.ts (0 errors) ==== -+ export * from ".prisma/client"; -+ -+==== /index.d.ts (1 errors) ==== -+ import { PrismaClient } from "@prisma/client"; -+ declare const _default: PrismaClient; -+ ~~~~~~~~~ -+!!! error TS2307: Cannot find module '.prisma' or its corresponding type declarations. -+ export default _default; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=false).js b/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=false).js index 9ee99aa2ad..cc81c52b2d 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=false).js +++ b/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=false).js @@ -20,3 +20,4 @@ type TestOld = NonNullableOld; //// [nonNullableAndObjectIntersections.js] +// These should all resolve to never diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=false).js.diff b/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=false).js.diff deleted file mode 100644 index 2d6395f613..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=false).js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.nonNullableAndObjectIntersections(strict=false).js -+++ new.nonNullableAndObjectIntersections(strict=false).js -@@= skipped -19, +19 lines =@@ - - - //// [nonNullableAndObjectIntersections.js] --// These should all resolve to never \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=true).js b/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=true).js index 9ee99aa2ad..cc81c52b2d 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=true).js +++ b/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=true).js @@ -20,3 +20,4 @@ type TestOld = NonNullableOld; //// [nonNullableAndObjectIntersections.js] +// These should all resolve to never diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=true).js.diff b/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=true).js.diff index 1ff55a894a..900254fa63 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=true).js.diff +++ b/testdata/baselines/reference/submodule/compiler/nonNullableAndObjectIntersections(strict=true).js.diff @@ -5,4 +5,4 @@ //// [nonNullableAndObjectIntersections.js] -"use strict"; --// These should all resolve to never \ No newline at end of file + // These should all resolve to never \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js b/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js index 7bcb5236cc..f86e844830 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js +++ b/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js @@ -21,6 +21,7 @@ function f2(x: T | U) { //// [nonNullableReduction.js] +// Repros from #43425 function test(f1, f2) { f1 === null || f1 === void 0 ? void 0 : f1("hello"); f2 === null || f2 === void 0 ? void 0 : f2("hello"); diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js.diff b/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js.diff index 764ced1140..3e74c451a1 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js.diff +++ b/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js.diff @@ -5,7 +5,6 @@ //// [nonNullableReduction.js] -"use strict"; --// Repros from #43425 + // Repros from #43425 function test(f1, f2) { - f1 === null || f1 === void 0 ? void 0 : f1("hello"); - f2 === null || f2 === void 0 ? void 0 : f2("hello"); \ No newline at end of file + f1 === null || f1 === void 0 ? void 0 : f1("hello"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js b/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js index 4bec3fee12..21567dfc36 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js +++ b/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js @@ -21,6 +21,7 @@ function f2(x: T | U) { //// [nonNullableReductionNonStrict.js] +// Repros from #43425 function test(f1, f2) { f1 === null || f1 === void 0 ? void 0 : f1("hello"); f2 === null || f2 === void 0 ? void 0 : f2("hello"); diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js.diff b/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js.diff deleted file mode 100644 index 4dc8446649..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.nonNullableReductionNonStrict.js -+++ new.nonNullableReductionNonStrict.js -@@= skipped -20, +20 lines =@@ - - - //// [nonNullableReductionNonStrict.js] --// Repros from #43425 - function test(f1, f2) { - f1 === null || f1 === void 0 ? void 0 : f1("hello"); - f2 === null || f2 === void 0 ? void 0 : f2("hello"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/normalizedIntersectionTooComplex.js b/testdata/baselines/reference/submodule/compiler/normalizedIntersectionTooComplex.js index 3e390e8835..2311c833d4 100644 --- a/testdata/baselines/reference/submodule/compiler/normalizedIntersectionTooComplex.js +++ b/testdata/baselines/reference/submodule/compiler/normalizedIntersectionTooComplex.js @@ -40,5 +40,6 @@ const comp = ctor({ common: "ok", ref: x => console.log(x) }); //// [normalizedIntersectionTooComplex.js] +// Repro from #30050 const ctor = getCtor(all); const comp = ctor({ common: "ok", ref: x => console.log(x) }); diff --git a/testdata/baselines/reference/submodule/compiler/normalizedIntersectionTooComplex.js.diff b/testdata/baselines/reference/submodule/compiler/normalizedIntersectionTooComplex.js.diff index 051b1d5c7b..7a16b5202b 100644 --- a/testdata/baselines/reference/submodule/compiler/normalizedIntersectionTooComplex.js.diff +++ b/testdata/baselines/reference/submodule/compiler/normalizedIntersectionTooComplex.js.diff @@ -5,6 +5,6 @@ //// [normalizedIntersectionTooComplex.js] -"use strict"; --// Repro from #30050 + // Repro from #30050 const ctor = getCtor(all); const comp = ctor({ common: "ok", ref: x => console.log(x) }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/objectInstantiationFromUnionSpread.js b/testdata/baselines/reference/submodule/compiler/objectInstantiationFromUnionSpread.js index e2c3fab75f..6f130b2f07 100644 --- a/testdata/baselines/reference/submodule/compiler/objectInstantiationFromUnionSpread.js +++ b/testdata/baselines/reference/submodule/compiler/objectInstantiationFromUnionSpread.js @@ -23,6 +23,7 @@ function f2(a: Item[]) { //// [objectInstantiationFromUnionSpread.js] +// #40995 var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { diff --git a/testdata/baselines/reference/submodule/compiler/objectInstantiationFromUnionSpread.js.diff b/testdata/baselines/reference/submodule/compiler/objectInstantiationFromUnionSpread.js.diff deleted file mode 100644 index 687778aa18..0000000000 --- a/testdata/baselines/reference/submodule/compiler/objectInstantiationFromUnionSpread.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.objectInstantiationFromUnionSpread.js -+++ new.objectInstantiationFromUnionSpread.js -@@= skipped -22, +22 lines =@@ - - - //// [objectInstantiationFromUnionSpread.js] --// #40995 - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types b/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types index 29ba3f1471..b43aa5751a 100644 --- a/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types +++ b/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types @@ -86,7 +86,7 @@ interface Indexed { var b10: Indexed = { 0: { }, '1': { } }; // ok >b10 : Indexed ->{ 0: { }, '1': { } } : { 0: {}; "1": {}; } +>{ 0: { }, '1': { } } : { 0: {}; '1': {}; } >0 : {} >{ } : {} >'1' : {} diff --git a/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types.diff b/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types.diff deleted file mode 100644 index d6f08e5826..0000000000 --- a/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.objectLiteralExcessProperties.types -+++ new.objectLiteralExcessProperties.types -@@= skipped -85, +85 lines =@@ - - var b10: Indexed = { 0: { }, '1': { } }; // ok - >b10 : Indexed -->{ 0: { }, '1': { } } : { 0: {}; '1': {}; } -+>{ 0: { }, '1': { } } : { 0: {}; "1": {}; } - >0 : {} - >{ } : {} - >'1' : {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/observableInferenceCanBeMade.js b/testdata/baselines/reference/submodule/compiler/observableInferenceCanBeMade.js index 7264b96672..164218ef75 100644 --- a/testdata/baselines/reference/submodule/compiler/observableInferenceCanBeMade.js +++ b/testdata/baselines/reference/submodule/compiler/observableInferenceCanBeMade.js @@ -24,6 +24,7 @@ function asObservable(input: string | ObservableInput): Observable; //// [optionalTupleElementsAndUndefined.js] +// Repro from #50753 // Types in the following declarations should be identical var v; var v; diff --git a/testdata/baselines/reference/submodule/compiler/optionalTupleElementsAndUndefined.js.diff b/testdata/baselines/reference/submodule/compiler/optionalTupleElementsAndUndefined.js.diff index bfc6e4e9c1..4f6d46b1af 100644 --- a/testdata/baselines/reference/submodule/compiler/optionalTupleElementsAndUndefined.js.diff +++ b/testdata/baselines/reference/submodule/compiler/optionalTupleElementsAndUndefined.js.diff @@ -5,7 +5,6 @@ //// [optionalTupleElementsAndUndefined.js] -"use strict"; --// Repro from #50753 + // Repro from #50753 // Types in the following declarations should be identical - var v; var v; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/overEagerReturnTypeSpecialization.js b/testdata/baselines/reference/submodule/compiler/overEagerReturnTypeSpecialization.js index 77afe5d4c1..2149a45d3f 100644 --- a/testdata/baselines/reference/submodule/compiler/overEagerReturnTypeSpecialization.js +++ b/testdata/baselines/reference/submodule/compiler/overEagerReturnTypeSpecialization.js @@ -17,6 +17,7 @@ var r2: I1 = v1.func(num => num.toString()) // Correctly returns an I1 num.toString()) // Correctly returns an I1 .func(str => str.length); // should error var r2 = v1.func(num => num.toString()) // Correctly returns an I1 diff --git a/testdata/baselines/reference/submodule/compiler/overEagerReturnTypeSpecialization.js.diff b/testdata/baselines/reference/submodule/compiler/overEagerReturnTypeSpecialization.js.diff deleted file mode 100644 index fd6459403f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/overEagerReturnTypeSpecialization.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.overEagerReturnTypeSpecialization.js -+++ new.overEagerReturnTypeSpecialization.js -@@= skipped -16, +16 lines =@@ - - - //// [overEagerReturnTypeSpecialization.js] --//Note: Below simpler repro - var r1 = v1.func(num => num.toString()) // Correctly returns an I1 - .func(str => str.length); // should error - var r2 = v1.func(num => num.toString()) // Correctly returns an I1 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/overrideBaseIntersectionMethod.js b/testdata/baselines/reference/submodule/compiler/overrideBaseIntersectionMethod.js index b5bbdf7bae..e489e06f7e 100644 --- a/testdata/baselines/reference/submodule/compiler/overrideBaseIntersectionMethod.js +++ b/testdata/baselines/reference/submodule/compiler/overrideBaseIntersectionMethod.js @@ -33,6 +33,7 @@ class Foo extends WithLocation(Point) { //// [overrideBaseIntersectionMethod.js] +// Repro from #14615 const WithLocation = (Base) => class extends Base { getLocation() { const [x, y] = super.getLocation(); diff --git a/testdata/baselines/reference/submodule/compiler/overrideBaseIntersectionMethod.js.diff b/testdata/baselines/reference/submodule/compiler/overrideBaseIntersectionMethod.js.diff index b118e12b91..a0f6970bcd 100644 --- a/testdata/baselines/reference/submodule/compiler/overrideBaseIntersectionMethod.js.diff +++ b/testdata/baselines/reference/submodule/compiler/overrideBaseIntersectionMethod.js.diff @@ -5,11 +5,10 @@ //// [overrideBaseIntersectionMethod.js] -"use strict"; --// Repro from #14615 + // Repro from #14615 const WithLocation = (Base) => class extends Base { getLocation() { - const [x, y] = super.getLocation(); -@@= skipped -9, +7 lines =@@ +@@= skipped -9, +8 lines =@@ } }; class Point { diff --git a/testdata/baselines/reference/submodule/compiler/partiallyDiscriminantedUnions.js b/testdata/baselines/reference/submodule/compiler/partiallyDiscriminantedUnions.js index 9d4a79077a..d12035cbfc 100644 --- a/testdata/baselines/reference/submodule/compiler/partiallyDiscriminantedUnions.js +++ b/testdata/baselines/reference/submodule/compiler/partiallyDiscriminantedUnions.js @@ -49,6 +49,7 @@ function fail(s: Shapes) { } //// [partiallyDiscriminantedUnions.js] +// Repro from #10586 const ab = {}; if (ab.type === 'a') { if (ab.subtype === 2) { diff --git a/testdata/baselines/reference/submodule/compiler/partiallyDiscriminantedUnions.js.diff b/testdata/baselines/reference/submodule/compiler/partiallyDiscriminantedUnions.js.diff index d58efbc512..38fb47a0ff 100644 --- a/testdata/baselines/reference/submodule/compiler/partiallyDiscriminantedUnions.js.diff +++ b/testdata/baselines/reference/submodule/compiler/partiallyDiscriminantedUnions.js.diff @@ -1,14 +1,6 @@ --- old.partiallyDiscriminantedUnions.js +++ new.partiallyDiscriminantedUnions.js -@@= skipped -48, +48 lines =@@ - } - - //// [partiallyDiscriminantedUnions.js] --// Repro from #10586 - const ab = {}; - if (ab.type === 'a') { - if (ab.subtype === 2) { -@@= skipped -9, +8 lines =@@ +@@= skipped -57, +57 lines =@@ } // Repro from #11185 class Square { diff --git a/testdata/baselines/reference/submodule/compiler/pinnedComments1.js b/testdata/baselines/reference/submodule/compiler/pinnedComments1.js index 3ed3f3a3de..ece697b096 100644 --- a/testdata/baselines/reference/submodule/compiler/pinnedComments1.js +++ b/testdata/baselines/reference/submodule/compiler/pinnedComments1.js @@ -12,5 +12,9 @@ class C { } //// [pinnedComments1.js] +/*!========= + Keep this pinned comment + ========= +*/ class C { } diff --git a/testdata/baselines/reference/submodule/compiler/pinnedComments1.js.diff b/testdata/baselines/reference/submodule/compiler/pinnedComments1.js.diff deleted file mode 100644 index 3ad1398649..0000000000 --- a/testdata/baselines/reference/submodule/compiler/pinnedComments1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.pinnedComments1.js -+++ new.pinnedComments1.js -@@= skipped -11, +11 lines =@@ - } - - //// [pinnedComments1.js] --/*!========= -- Keep this pinned comment -- ========= --*/ - class C { - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/primitiveUnionDetection.js b/testdata/baselines/reference/submodule/compiler/primitiveUnionDetection.js index dde8372257..427974daad 100644 --- a/testdata/baselines/reference/submodule/compiler/primitiveUnionDetection.js +++ b/testdata/baselines/reference/submodule/compiler/primitiveUnionDetection.js @@ -11,6 +11,7 @@ const result = getInterfaceFromString({ type: 'two' }); //// [primitiveUnionDetection.js] +// Repro from #46624 const result = getInterfaceFromString({ type: 'two' }); diff --git a/testdata/baselines/reference/submodule/compiler/primitiveUnionDetection.js.diff b/testdata/baselines/reference/submodule/compiler/primitiveUnionDetection.js.diff index aeca5c77dd..7beb348355 100644 --- a/testdata/baselines/reference/submodule/compiler/primitiveUnionDetection.js.diff +++ b/testdata/baselines/reference/submodule/compiler/primitiveUnionDetection.js.diff @@ -5,6 +5,5 @@ //// [primitiveUnionDetection.js] -"use strict"; --// Repro from #46624 + // Repro from #46624 const result = getInterfaceFromString({ type: 'two' }); - diff --git a/testdata/baselines/reference/submodule/compiler/privatePropertyInUnion.js b/testdata/baselines/reference/submodule/compiler/privatePropertyInUnion.js index 18aaae481f..349c9d265f 100644 --- a/testdata/baselines/reference/submodule/compiler/privatePropertyInUnion.js +++ b/testdata/baselines/reference/submodule/compiler/privatePropertyInUnion.js @@ -17,6 +17,7 @@ type __ValueDescriptorType = T extends ISyncableObjec //// [privatePropertyInUnion.js] +// Repro from #38236 class SyncableObject { foo; } diff --git a/testdata/baselines/reference/submodule/compiler/privatePropertyInUnion.js.diff b/testdata/baselines/reference/submodule/compiler/privatePropertyInUnion.js.diff index c63b589247..72a48f34b7 100644 --- a/testdata/baselines/reference/submodule/compiler/privatePropertyInUnion.js.diff +++ b/testdata/baselines/reference/submodule/compiler/privatePropertyInUnion.js.diff @@ -5,7 +5,7 @@ //// [privatePropertyInUnion.js] -"use strict"; --// Repro from #38236 + // Repro from #38236 class SyncableObject { + foo; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/promisePermutations2.js b/testdata/baselines/reference/submodule/compiler/promisePermutations2.js index d09a581506..7918ffb468 100644 --- a/testdata/baselines/reference/submodule/compiler/promisePermutations2.js +++ b/testdata/baselines/reference/submodule/compiler/promisePermutations2.js @@ -169,6 +169,7 @@ var s12b = s12.then(testFunction12P, testFunction12P, testFunction12P); // ok var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok //// [promisePermutations2.js] +// same as promisePermutations but without the same overloads in Promise var r1; var r1a = r1.then(testFunction, testFunction, testFunction); var r1b = r1.then(testFunction, testFunction, testFunction).then(testFunction, testFunction, testFunction); diff --git a/testdata/baselines/reference/submodule/compiler/promisePermutations2.js.diff b/testdata/baselines/reference/submodule/compiler/promisePermutations2.js.diff deleted file mode 100644 index 2cddc5a770..0000000000 --- a/testdata/baselines/reference/submodule/compiler/promisePermutations2.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.promisePermutations2.js -+++ new.promisePermutations2.js -@@= skipped -168, +168 lines =@@ - var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok - - //// [promisePermutations2.js] --// same as promisePermutations but without the same overloads in Promise - var r1; - var r1a = r1.then(testFunction, testFunction, testFunction); - var r1b = r1.then(testFunction, testFunction, testFunction).then(testFunction, testFunction, testFunction); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/promisePermutations3.js b/testdata/baselines/reference/submodule/compiler/promisePermutations3.js index a76a406dc2..d752ccddfd 100644 --- a/testdata/baselines/reference/submodule/compiler/promisePermutations3.js +++ b/testdata/baselines/reference/submodule/compiler/promisePermutations3.js @@ -169,6 +169,7 @@ var s12b = s12.then(testFunction12P, testFunction12P, testFunction12P); // ok var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok //// [promisePermutations3.js] +// same as promisePermutations but without the same overloads in IPromise var r1; var r1a = r1.then(testFunction, testFunction, testFunction); var r1b = r1.then(testFunction, testFunction, testFunction).then(testFunction, testFunction, testFunction); diff --git a/testdata/baselines/reference/submodule/compiler/promisePermutations3.js.diff b/testdata/baselines/reference/submodule/compiler/promisePermutations3.js.diff deleted file mode 100644 index 6a42aa7cf3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/promisePermutations3.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.promisePermutations3.js -+++ new.promisePermutations3.js -@@= skipped -168, +168 lines =@@ - var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok - - //// [promisePermutations3.js] --// same as promisePermutations but without the same overloads in IPromise - var r1; - var r1a = r1.then(testFunction, testFunction, testFunction); - var r1b = r1.then(testFunction, testFunction, testFunction).then(testFunction, testFunction, testFunction); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/ramdaToolsNoInfinite2.types b/testdata/baselines/reference/submodule/compiler/ramdaToolsNoInfinite2.types index 0bc7f43feb..987b07e6bc 100644 --- a/testdata/baselines/reference/submodule/compiler/ramdaToolsNoInfinite2.types +++ b/testdata/baselines/reference/submodule/compiler/ramdaToolsNoInfinite2.types @@ -425,7 +425,7 @@ declare module "Number/_Internal" { >Numbers : Numbers 'string': { ->'string' : { all: "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9" | "0" | "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9"; "+": "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9"; "-": "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9"; "0": "0"; } +>'string' : { all: "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9" | "0" | "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9"; '+': "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9"; '-': "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9"; '0': "0"; } 'all': Format; >'all' : "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9" | "0" | "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9" @@ -441,7 +441,7 @@ declare module "Number/_Internal" { }; 'number': { ->'number' : { all: -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40; "+": 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40; "-": -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1; "0": 0; } +>'number' : { all: -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40; '+': 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40; '-': -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1; '0': 0; } 'all': Format; >'all' : -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 diff --git a/testdata/baselines/reference/submodule/compiler/ramdaToolsNoInfinite2.types.diff b/testdata/baselines/reference/submodule/compiler/ramdaToolsNoInfinite2.types.diff index fad96e62f9..48b45e143c 100644 --- a/testdata/baselines/reference/submodule/compiler/ramdaToolsNoInfinite2.types.diff +++ b/testdata/baselines/reference/submodule/compiler/ramdaToolsNoInfinite2.types.diff @@ -5,7 +5,7 @@ 'string': { ->'string' : { all: Format; '+': Format; '-': Format; '0': Format; } -+>'string' : { all: "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9" | "0" | "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9"; "+": "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9"; "-": "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9"; "0": "0"; } ++>'string' : { all: "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9" | "0" | "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9"; '+': "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9"; '-': "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9"; '0': "0"; } 'all': Format; >'all' : "-1" | "-10" | "-11" | "-12" | "-13" | "-14" | "-15" | "-16" | "-17" | "-18" | "-19" | "-2" | "-20" | "-21" | "-22" | "-23" | "-24" | "-25" | "-26" | "-27" | "-28" | "-29" | "-3" | "-30" | "-31" | "-32" | "-33" | "-34" | "-35" | "-36" | "-37" | "-38" | "-39" | "-4" | "-40" | "-5" | "-6" | "-7" | "-8" | "-9" | "0" | "1" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "2" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "3" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "4" | "40" | "5" | "6" | "7" | "8" | "9" @@ -14,7 +14,7 @@ }; 'number': { ->'number' : { all: Format; '+': Format; '-': Format; '0': Format; } -+>'number' : { all: -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40; "+": 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40; "-": -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1; "0": 0; } ++>'number' : { all: -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40; '+': 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40; '-': -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1; '0': 0; } 'all': Format; >'all' : -40 | -39 | -38 | -37 | -36 | -35 | -34 | -33 | -32 | -31 | -30 | -29 | -28 | -27 | -26 | -25 | -24 | -23 | -22 | -21 | -20 | -19 | -18 | -17 | -16 | -15 | -14 | -13 | -12 | -11 | -10 | -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/reactDefaultPropsInferenceSuccess.js b/testdata/baselines/reference/submodule/compiler/reactDefaultPropsInferenceSuccess.js index ef4cb2f788..72a4c4084d 100644 --- a/testdata/baselines/reference/submodule/compiler/reactDefaultPropsInferenceSuccess.js +++ b/testdata/baselines/reference/submodule/compiler/reactDefaultPropsInferenceSuccess.js @@ -72,11 +72,11 @@ const Test5 = () => ; //// [reactDefaultPropsInferenceSuccess.js] "use strict"; +/// var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -/// const react_1 = __importDefault(require("react")); class FieldFeedback extends react_1.default.Component { static defaultProps = { diff --git a/testdata/baselines/reference/submodule/compiler/reactDefaultPropsInferenceSuccess.js.diff b/testdata/baselines/reference/submodule/compiler/reactDefaultPropsInferenceSuccess.js.diff index f18ce8f09c..c556e5e7d2 100644 --- a/testdata/baselines/reference/submodule/compiler/reactDefaultPropsInferenceSuccess.js.diff +++ b/testdata/baselines/reference/submodule/compiler/reactDefaultPropsInferenceSuccess.js.diff @@ -1,11 +1,6 @@ --- old.reactDefaultPropsInferenceSuccess.js +++ new.reactDefaultPropsInferenceSuccess.js -@@= skipped -71, +71 lines =@@ - - //// [reactDefaultPropsInferenceSuccess.js] - "use strict"; --/// - var __importDefault = (this && this.__importDefault) || function (mod) { +@@= skipped -76, +76 lines =@@ return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); @@ -17,7 +12,6 @@ - } - } - FieldFeedback.defaultProps = { -+/// +const react_1 = __importDefault(require("react")); +class FieldFeedback extends react_1.default.Component { + static defaultProps = { diff --git a/testdata/baselines/reference/submodule/compiler/reactSFCAndFunctionResolvable.js b/testdata/baselines/reference/submodule/compiler/reactSFCAndFunctionResolvable.js index 348085d966..366d48ac9a 100644 --- a/testdata/baselines/reference/submodule/compiler/reactSFCAndFunctionResolvable.js +++ b/testdata/baselines/reference/submodule/compiler/reactSFCAndFunctionResolvable.js @@ -29,8 +29,8 @@ const RandomComponent: React.SFC = () => { //// [reactSFCAndFunctionResolvable.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); const RandomComponent = () => { const Component = condition1 diff --git a/testdata/baselines/reference/submodule/compiler/reactSFCAndFunctionResolvable.js.diff b/testdata/baselines/reference/submodule/compiler/reactSFCAndFunctionResolvable.js.diff index e0547d01bf..6d6fd84e25 100644 --- a/testdata/baselines/reference/submodule/compiler/reactSFCAndFunctionResolvable.js.diff +++ b/testdata/baselines/reference/submodule/compiler/reactSFCAndFunctionResolvable.js.diff @@ -1,13 +1,10 @@ --- old.reactSFCAndFunctionResolvable.js +++ new.reactSFCAndFunctionResolvable.js -@@= skipped -28, +28 lines =@@ - - //// [reactSFCAndFunctionResolvable.js] +@@= skipped -30, +30 lines =@@ "use strict"; --/// + /// Object.defineProperty(exports, "__esModule", { value: true }); -var React = require("react"); -+/// +const React = require("react"); const RandomComponent = () => { const Component = condition1 diff --git a/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM.js b/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM.js index c7411537fb..07eb8f5ce7 100644 --- a/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM.js +++ b/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM.js @@ -15,6 +15,7 @@ const children: any[] = []; //// [reactTagNameComponentWithPropsNoOOM.js] "use strict"; +/// var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -27,7 +28,6 @@ var __assign = (this && this.__assign) || function () { return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); -/// const React = require("react"); const classes = ""; const rest = {}; diff --git a/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM.js.diff b/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM.js.diff index 6f68ebc762..95bdd6f6ec 100644 --- a/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM.js.diff +++ b/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM.js.diff @@ -1,19 +1,10 @@ --- old.reactTagNameComponentWithPropsNoOOM.js +++ new.reactTagNameComponentWithPropsNoOOM.js -@@= skipped -14, +14 lines =@@ - - //// [reactTagNameComponentWithPropsNoOOM.js] - "use strict"; --/// - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -13, +12 lines =@@ +@@= skipped -27, +27 lines =@@ return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); -var React = require("react"); -+/// +const React = require("react"); const classes = ""; const rest = {}; diff --git a/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM2.js b/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM2.js index 39837e0ce6..f7ab3ffc65 100644 --- a/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM2.js +++ b/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM2.js @@ -15,6 +15,7 @@ const children: any[] = []; //// [reactTagNameComponentWithPropsNoOOM2.js] "use strict"; +/// var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -27,7 +28,6 @@ var __assign = (this && this.__assign) || function () { return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); -/// const React = require("react"); const classes = ""; const rest = {}; diff --git a/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM2.js.diff b/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM2.js.diff index b3845ebbe9..ccc77b4289 100644 --- a/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/reactTagNameComponentWithPropsNoOOM2.js.diff @@ -1,19 +1,10 @@ --- old.reactTagNameComponentWithPropsNoOOM2.js +++ new.reactTagNameComponentWithPropsNoOOM2.js -@@= skipped -14, +14 lines =@@ - - //// [reactTagNameComponentWithPropsNoOOM2.js] - "use strict"; --/// - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -13, +12 lines =@@ +@@= skipped -27, +27 lines =@@ return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); -var React = require("react"); -+/// +const React = require("react"); const classes = ""; const rest = {}; diff --git a/testdata/baselines/reference/submodule/compiler/recursiveClassBaseType.js b/testdata/baselines/reference/submodule/compiler/recursiveClassBaseType.js index 7543db73ac..30721da2df 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveClassBaseType.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveClassBaseType.js @@ -24,6 +24,7 @@ class Derived1 extends class extends Base1 { //// [recursiveClassBaseType.js] +// Repro from #44281 class C extends Base({ x: p(() => []) }) { } // Repro from #44359 diff --git a/testdata/baselines/reference/submodule/compiler/recursiveClassBaseType.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveClassBaseType.js.diff index bc446c4de3..4dd8f82a35 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveClassBaseType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/recursiveClassBaseType.js.diff @@ -5,7 +5,6 @@ //// [recursiveClassBaseType.js] -"use strict"; --// Repro from #44281 + // Repro from #44281 class C extends Base({ x: p(() => []) }) { - } - // Repro from #44359 \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js index 4efd88da4f..10f5f4901e 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js @@ -105,6 +105,8 @@ module Sample.Thing.Languages.PlainText { //// [recursiveClassReferenceTest.js] +// Scenario 1: Test reqursive function call with "this" parameter +// Scenario 2: Test recursive function call with cast and "this" parameter var Sample; (function (Sample) { let Actions; diff --git a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.diff index f84a83dbf4..1e6a1cb30c 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.diff +++ b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.diff @@ -1,11 +1,7 @@ --- old.recursiveClassReferenceTest.js +++ new.recursiveClassReferenceTest.js -@@= skipped -104, +104 lines =@@ - - - //// [recursiveClassReferenceTest.js] --// Scenario 1: Test reqursive function call with "this" parameter --// Scenario 2: Test recursive function call with cast and "this" parameter +@@= skipped -108, +108 lines =@@ + // Scenario 2: Test recursive function call with cast and "this" parameter var Sample; (function (Sample) { - var Actions; @@ -19,7 +15,7 @@ (function (Find) { class StartFindAction { getId() { return "yo"; } -@@= skipped -22, +20 lines =@@ +@@= skipped -18, +18 lines =@@ })(Actions = Sample.Actions || (Sample.Actions = {})); })(Sample || (Sample = {})); (function (Sample) { diff --git a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.map b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.map index b9bf4e1da0..c31f8b7c9d 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.map +++ b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.map @@ -1,3 +1,3 @@ //// [recursiveClassReferenceTest.js.map] -{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AA+BA,IAAO,MAUN;AAVD,WAAO,MAAM,EA1Bb;IA0Bc,IAAA,OAUb;IAVa,WAAA,OAAO,EA1BrB;QA0BsB,IAAA,KAUrB;QAVqB,WAAA,OAAK,EA1B3B;YA0B4B,IAAA,IAU3B;YAV2B,WAAA,IAAI,EAAC;gBAChC,MAAa,eAAe;oBAEpB,KAAK,GAAG,EAAE,OAAO,IAAI,CAAC,CAAA,CAAE;oBAExB,GAAG,CAAC,KAA6B,EAAU;wBAEjD,OAAO,IAAI,CAAC;oBAAA,CACZ;iBACD;gBARY,KAAA,eAAe,kBAQ3B,CAAA;YAAA,CACD,EAV2B,IAAI,GAAJ,QAAA,IAAI,KAAJ,QAAA,IAAI,QAU/B;QADC,CACF,AAzCA,EA+BsB,KAAK,GAAL,QAAA,KAAK,KAAL,QAAA,KAAK,QAU1B;IADC,CACF,AAzCA,EA+Bc,OAAO,GAAP,OAAA,OAAO,KAAP,OAAA,OAAO,QAUpB;AADC,CACF,AAzCA,EA+BO,MAAM,KAAN,MAAM,QAUZ;AAED,WAAO,MAAM,EAtCb;IAsCc,IAAA,KAoBb;IApBa,WAAA,KAAK,EAtCnB;QAsCoB,IAAA,OAoBnB;QApBmB,WAAA,OAAO,EAAC;YAC3B,MAAa,UAAU;gBAKF,SAAS;gBAHtB,GAAG,CAAC,MAAyC,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;oBAAA,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;gBAAA,CAAC,CAAA,CAAC;gBAEjF,OAAO,GAAO,IAAI,CAAC;gBAC3B,YAAoB,SAAkC,EAAE;qCAApC,SAAS;oBACzB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAAA,CAC1C;gBAEM,UAAU,GAAG;oBACnB,OAAO,OAAO,CAAC;gBAAA,CACf;gBAEM,OAAO,GAAG;gBAAC,CAEjB;aAED;YAlBY,QAAA,UAAU,aAkBtB,CAAA;QAAA,CACD,EApBmB,OAAO,GAAP,MAAA,OAAO,KAAP,MAAA,OAAO,QAoB1B;IADC,CACF,AA/DA,EA2Cc,KAAK,GAAL,OAAA,KAAK,KAAL,OAAA,KAAK,QAoBlB;AADC,CACF,AA/DA,EA2CO,MAAM,KAAN,MAAM,QAoBZ;AAGD,MAAM,YAAY;IAA2B,eAAe,GAAW,EAAE,OAAO,IAAI,CAAC,CAAA,CAAC;CAAE;AASxF,WAAO,MAAM,EAtEb;IAsEc,IAAA,KAwBb;IAxBa,WAAA,KAAK,EAtEnB;QAsEoB,IAAA,SAwBnB;QAxBmB,WAAA,SAAS,EAtE7B;YAsE8B,IAAA,SAwB7B;YAxB6B,WAAA,SAAS,EAAC;gBAEvC,MAAa,KAAK;oBACS,IAAI;oBAAxB,YAAoB,IAAW,EAAE;oCAAb,IAAI;oBAAU,CAAE;oBACnC,KAAK,GAAU;wBACrB,OAAO,IAAI,CAAC;oBAAA,CACZ;oBAEM,MAAM,CAAC,KAAY,EAAU;wBACnC,OAAO,IAAI,KAAK,KAAK,CAAC;oBAAA,CACtB;oBAEM,OAAO,GAAU,EAAE,OAAO,IAAI,CAAC,CAAA,CAAE;iBACxC;gBAXY,UAAA,KAAK,QAWjB,CAAA;gBAED,MAAa,IAAK,SAAQ,YAAY;oBAErC,aAAa;oBACN,eAAe,GAAW;wBAChC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBAAA,CACvB;iBAGD;gBARY,UAAA,IAAI,OAQhB,CAAA;YAAA,CACD,EAxB6B,SAAS,GAAT,UAAA,SAAS,KAAT,UAAA,SAAS,QAwBtC;QADC,CACF,AAnGA,EA2EoB,SAAS,GAAT,MAAA,SAAS,KAAT,MAAA,SAAS,QAwB5B;IADC,CACF,AAnGA,EA2Ec,KAAK,GAAL,OAAA,KAAK,KAAL,OAAA,KAAK,QAwBlB;AADC,CACF,AAnGA,EA2EO,MAAM,KAAN,MAAM,QAwBZ"} -//// https://sokra.github.io/source-map-visualization#base64,dmFyIFNhbXBsZTsNCihmdW5jdGlvbiAoU2FtcGxlKSB7DQogICAgbGV0IEFjdGlvbnM7DQogICAgKGZ1bmN0aW9uIChBY3Rpb25zKSB7DQogICAgICAgIGxldCBUaGluZzsNCiAgICAgICAgKGZ1bmN0aW9uIChUaGluZ18xKSB7DQogICAgICAgICAgICBsZXQgRmluZDsNCiAgICAgICAgICAgIChmdW5jdGlvbiAoRmluZCkgew0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YXJ0RmluZEFjdGlvbiB7DQogICAgICAgICAgICAgICAgICAgIGdldElkKCkgeyByZXR1cm4gInlvIjsgfQ0KICAgICAgICAgICAgICAgICAgICBydW4oVGhpbmcpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIEZpbmQuU3RhcnRGaW5kQWN0aW9uID0gU3RhcnRGaW5kQWN0aW9uOw0KICAgICAgICAgICAgfSkoRmluZCA9IFRoaW5nXzEuRmluZCB8fCAoVGhpbmdfMS5GaW5kID0ge30pKTsNCiAgICAgICAgfSkoVGhpbmcgPSBBY3Rpb25zLlRoaW5nIHx8IChBY3Rpb25zLlRoaW5nID0ge30pKTsNCiAgICB9KShBY3Rpb25zID0gU2FtcGxlLkFjdGlvbnMgfHwgKFNhbXBsZS5BY3Rpb25zID0ge30pKTsNCn0pKFNhbXBsZSB8fCAoU2FtcGxlID0ge30pKTsNCihmdW5jdGlvbiAoU2FtcGxlKSB7DQogICAgbGV0IFRoaW5nOw0KICAgIChmdW5jdGlvbiAoVGhpbmcpIHsNCiAgICAgICAgbGV0IFdpZGdldHM7DQogICAgICAgIChmdW5jdGlvbiAoV2lkZ2V0cykgew0KICAgICAgICAgICAgY2xhc3MgRmluZFdpZGdldCB7DQogICAgICAgICAgICAgICAgY29kZVRoaW5nOw0KICAgICAgICAgICAgICAgIGdhcihydW5uZXIpIHsgaWYgKHRydWUpIHsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJ1bm5lcih0aGlzKTsNCiAgICAgICAgICAgICAgICB9IH0NCiAgICAgICAgICAgICAgICBkb21Ob2RlID0gbnVsbDsNCiAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihjb2RlVGhpbmcpIHsNCiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2RlVGhpbmcgPSBjb2RlVGhpbmc7DQogICAgICAgICAgICAgICAgICAgIC8vIHNjZW5hcmlvIDENCiAgICAgICAgICAgICAgICAgICAgY29kZVRoaW5nLmFkZFdpZGdldCgiYWRkV2lkZ2V0IiwgdGhpcyk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGdldERvbU5vZGUoKSB7DQogICAgICAgICAgICAgICAgICAgIHJldHVybiBkb21Ob2RlOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBkZXN0cm95KCkgew0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIFdpZGdldHMuRmluZFdpZGdldCA9IEZpbmRXaWRnZXQ7DQogICAgICAgIH0pKFdpZGdldHMgPSBUaGluZy5XaWRnZXRzIHx8IChUaGluZy5XaWRnZXRzID0ge30pKTsNCiAgICB9KShUaGluZyA9IFNhbXBsZS5UaGluZyB8fCAoU2FtcGxlLlRoaW5nID0ge30pKTsNCn0pKFNhbXBsZSB8fCAoU2FtcGxlID0ge30pKTsNCmNsYXNzIEFic3RyYWN0TW9kZSB7DQogICAgZ2V0SW5pdGlhbFN0YXRlKCkgeyByZXR1cm4gbnVsbDsgfQ0KfQ0KKGZ1bmN0aW9uIChTYW1wbGUpIHsNCiAgICBsZXQgVGhpbmc7DQogICAgKGZ1bmN0aW9uIChUaGluZykgew0KICAgICAgICBsZXQgTGFuZ3VhZ2VzOw0KICAgICAgICAoZnVuY3Rpb24gKExhbmd1YWdlcykgew0KICAgICAgICAgICAgbGV0IFBsYWluVGV4dDsNCiAgICAgICAgICAgIChmdW5jdGlvbiAoUGxhaW5UZXh0KSB7DQogICAgICAgICAgICAgICAgY2xhc3MgU3RhdGUgew0KICAgICAgICAgICAgICAgICAgICBtb2RlOw0KICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtb2RlKSB7DQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vZGUgPSBtb2RlOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIGNsb25lKCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgZXF1YWxzKG90aGVyKSB7DQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcyA9PT0gb3RoZXI7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgZ2V0TW9kZSgpIHsgcmV0dXJuIG1vZGU7IH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgUGxhaW5UZXh0LlN0YXRlID0gU3RhdGU7DQogICAgICAgICAgICAgICAgY2xhc3MgTW9kZSBleHRlbmRzIEFic3RyYWN0TW9kZSB7DQogICAgICAgICAgICAgICAgICAgIC8vIHNjZW5hcmlvIDINCiAgICAgICAgICAgICAgICAgICAgZ2V0SW5pdGlhbFN0YXRlKCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdGF0ZShzZWxmKTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBQbGFpblRleHQuTW9kZSA9IE1vZGU7DQogICAgICAgICAgICB9KShQbGFpblRleHQgPSBMYW5ndWFnZXMuUGxhaW5UZXh0IHx8IChMYW5ndWFnZXMuUGxhaW5UZXh0ID0ge30pKTsNCiAgICAgICAgfSkoTGFuZ3VhZ2VzID0gVGhpbmcuTGFuZ3VhZ2VzIHx8IChUaGluZy5MYW5ndWFnZXMgPSB7fSkpOw0KICAgIH0pKFRoaW5nID0gU2FtcGxlLlRoaW5nIHx8IChTYW1wbGUuVGhpbmcgPSB7fSkpOw0KfSkoU2FtcGxlIHx8IChTYW1wbGUgPSB7fSkpOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9cmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LmpzLm1hcA==,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQStCQSxJQUFPLE1BVU47QUFWRCxXQUFPLE1BQU0sRUExQmI7SUEwQmMsSUFBQSxPQVViO0lBVmEsV0FBQSxPQUFPLEVBMUJyQjtRQTBCc0IsSUFBQSxLQVVyQjtRQVZxQixXQUFBLE9BQUssRUExQjNCO1lBMEI0QixJQUFBLElBVTNCO1lBVjJCLFdBQUEsSUFBSSxFQUFDO2dCQUNoQyxNQUFhLGVBQWU7b0JBRXBCLEtBQUssR0FBRyxFQUFFLE9BQU8sSUFBSSxDQUFDLENBQUEsQ0FBRTtvQkFFeEIsR0FBRyxDQUFDLEtBQTZCLEVBQVU7d0JBRWpELE9BQU8sSUFBSSxDQUFDO29CQUFBLENBQ1o7aUJBQ0Q7Z0JBUlksS0FBQSxlQUFlLGtCQVEzQixDQUFBO1lBQUEsQ0FDRCxFQVYyQixJQUFJLEdBQUosUUFBQSxJQUFJLEtBQUosUUFBQSxJQUFJLFFBVS9CO1FBREMsQ0FDRixBQXpDQSxFQStCc0IsS0FBSyxHQUFMLFFBQUEsS0FBSyxLQUFMLFFBQUEsS0FBSyxRQVUxQjtJQURDLENBQ0YsQUF6Q0EsRUErQmMsT0FBTyxHQUFQLE9BQUEsT0FBTyxLQUFQLE9BQUEsT0FBTyxRQVVwQjtBQURDLENBQ0YsQUF6Q0EsRUErQk8sTUFBTSxLQUFOLE1BQU0sUUFVWjtBQUVELFdBQU8sTUFBTSxFQXRDYjtJQXNDYyxJQUFBLEtBb0JiO0lBcEJhLFdBQUEsS0FBSyxFQXRDbkI7UUFzQ29CLElBQUEsT0FvQm5CO1FBcEJtQixXQUFBLE9BQU8sRUFBQztZQUMzQixNQUFhLFVBQVU7Z0JBS0YsU0FBUztnQkFIdEIsR0FBRyxDQUFDLE1BQXlDLEVBQUUsRUFBRSxJQUFJLElBQUksRUFBRSxDQUFDO29CQUFBLE9BQU8sTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO2dCQUFBLENBQUMsQ0FBQSxDQUFDO2dCQUVqRixPQUFPLEdBQU8sSUFBSSxDQUFDO2dCQUMzQixZQUFvQixTQUFrQyxFQUFFO3FDQUFwQyxTQUFTO29CQUN6QixhQUFhO29CQUNiLFNBQVMsQ0FBQyxTQUFTLENBQUMsV0FBVyxFQUFFLElBQUksQ0FBQyxDQUFDO2dCQUFBLENBQzFDO2dCQUVNLFVBQVUsR0FBRztvQkFDbkIsT0FBTyxPQUFPLENBQUM7Z0JBQUEsQ0FDZjtnQkFFTSxPQUFPLEdBQUc7Z0JBQUMsQ0FFakI7YUFFRDtZQWxCWSxRQUFBLFVBQVUsYUFrQnRCLENBQUE7UUFBQSxDQUNELEVBcEJtQixPQUFPLEdBQVAsTUFBQSxPQUFPLEtBQVAsTUFBQSxPQUFPLFFBb0IxQjtJQURDLENBQ0YsQUEvREEsRUEyQ2MsS0FBSyxHQUFMLE9BQUEsS0FBSyxLQUFMLE9BQUEsS0FBSyxRQW9CbEI7QUFEQyxDQUNGLEFBL0RBLEVBMkNPLE1BQU0sS0FBTixNQUFNLFFBb0JaO0FBR0QsTUFBTSxZQUFZO0lBQTJCLGVBQWUsR0FBVyxFQUFFLE9BQU8sSUFBSSxDQUFDLENBQUEsQ0FBQztDQUFFO0FBU3hGLFdBQU8sTUFBTSxFQXRFYjtJQXNFYyxJQUFBLEtBd0JiO0lBeEJhLFdBQUEsS0FBSyxFQXRFbkI7UUFzRW9CLElBQUEsU0F3Qm5CO1FBeEJtQixXQUFBLFNBQVMsRUF0RTdCO1lBc0U4QixJQUFBLFNBd0I3QjtZQXhCNkIsV0FBQSxTQUFTLEVBQUM7Z0JBRXZDLE1BQWEsS0FBSztvQkFDUyxJQUFJO29CQUF4QixZQUFvQixJQUFXLEVBQUU7b0NBQWIsSUFBSTtvQkFBVSxDQUFFO29CQUNuQyxLQUFLLEdBQVU7d0JBQ3JCLE9BQU8sSUFBSSxDQUFDO29CQUFBLENBQ1o7b0JBRU0sTUFBTSxDQUFDLEtBQVksRUFBVTt3QkFDbkMsT0FBTyxJQUFJLEtBQUssS0FBSyxDQUFDO29CQUFBLENBQ3RCO29CQUVNLE9BQU8sR0FBVSxFQUFFLE9BQU8sSUFBSSxDQUFDLENBQUEsQ0FBRTtpQkFDeEM7Z0JBWFksVUFBQSxLQUFLLFFBV2pCLENBQUE7Z0JBRUQsTUFBYSxJQUFLLFNBQVEsWUFBWTtvQkFFckMsYUFBYTtvQkFDTixlQUFlLEdBQVc7d0JBQ2hDLE9BQU8sSUFBSSxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7b0JBQUEsQ0FDdkI7aUJBR0Q7Z0JBUlksVUFBQSxJQUFJLE9BUWhCLENBQUE7WUFBQSxDQUNELEVBeEI2QixTQUFTLEdBQVQsVUFBQSxTQUFTLEtBQVQsVUFBQSxTQUFTLFFBd0J0QztRQURDLENBQ0YsQUFuR0EsRUEyRW9CLFNBQVMsR0FBVCxNQUFBLFNBQVMsS0FBVCxNQUFBLFNBQVMsUUF3QjVCO0lBREMsQ0FDRixBQW5HQSxFQTJFYyxLQUFLLEdBQUwsT0FBQSxLQUFLLEtBQUwsT0FBQSxLQUFLLFFBd0JsQjtBQURDLENBQ0YsQUFuR0EsRUEyRU8sTUFBTSxLQUFOLE1BQU0sUUF3QloifQ==,Ly8gU2NlbmFyaW8gMTogVGVzdCByZXF1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoICJ0aGlzIiBwYXJhbWV0ZXIKLy8gU2NlbmFyaW8gMjogVGVzdCByZWN1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoIGNhc3QgYW5kICJ0aGlzIiBwYXJhbWV0ZXIKCgoKZGVjbGFyZSBtb2R1bGUgU2FtcGxlLlRoaW5nIHsKCglleHBvcnQgaW50ZXJmYWNlIElXaWRnZXQgewoJCWdldERvbU5vZGUoKTogYW55OwoJCWRlc3Ryb3koKTsKCQlnYXIocnVubmVyOih3aWRnZXQ6U2FtcGxlLlRoaW5nLklXaWRnZXQpPT5hbnkpOmFueTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElDb2RlVGhpbmcgewogIAogIAkJZ2V0RG9tTm9kZSgpOiBFbGVtZW50OwoJCQoJCWFkZFdpZGdldCh3aWRnZXRJZDpzdHJpbmcsIHdpZGdldDpJV2lkZ2V0KTsKCgkJCgkJZm9jdXMoKTsgCgkJCgkJLy9hZGRXaWRnZXQod2lkZ2V0OiBTYW1wbGUuVGhpbmcuV2lkZ2V0cy5JV2lkZ2V0KTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElBY3Rpb24gewoJCXJ1bihUaGluZzpJQ29kZVRoaW5nKTpib29sZWFuOwoJCWdldElkKCk6c3RyaW5nOwoJfQkKfQoKbW9kdWxlIFNhbXBsZS5BY3Rpb25zLlRoaW5nLkZpbmQgewoJZXhwb3J0IGNsYXNzIFN0YXJ0RmluZEFjdGlvbiBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JQWN0aW9uIHsKCQkKCQlwdWJsaWMgZ2V0SWQoKSB7IHJldHVybiAieW8iOyB9CgkJCgkJcHVibGljIHJ1bihUaGluZzpTYW1wbGUuVGhpbmcuSUNvZGVUaGluZyk6Ym9vbGVhbiB7CgoJCQlyZXR1cm4gdHJ1ZTsKCQl9Cgl9Cn0KCm1vZHVsZSBTYW1wbGUuVGhpbmcuV2lkZ2V0cyB7CglleHBvcnQgY2xhc3MgRmluZFdpZGdldCBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JV2lkZ2V0IHsKCgkJcHVibGljIGdhcihydW5uZXI6KHdpZGdldDpTYW1wbGUuVGhpbmcuSVdpZGdldCk9PmFueSkgeyBpZiAodHJ1ZSkge3JldHVybiBydW5uZXIodGhpcyk7fX0KCQkJCgkJcHJpdmF0ZSBkb21Ob2RlOmFueSA9IG51bGw7CgkJY29uc3RydWN0b3IocHJpdmF0ZSBjb2RlVGhpbmc6IFNhbXBsZS5UaGluZy5JQ29kZVRoaW5nKSB7CgkJICAgIC8vIHNjZW5hcmlvIDEKCQkgICAgY29kZVRoaW5nLmFkZFdpZGdldCgiYWRkV2lkZ2V0IiwgdGhpcyk7CgkJfQoJCQoJCXB1YmxpYyBnZXREb21Ob2RlKCkgewoJCQlyZXR1cm4gZG9tTm9kZTsKCQl9CgkJCgkJcHVibGljIGRlc3Ryb3koKSB7CgoJCX0KCgl9Cn0KCmludGVyZmFjZSBJTW9kZSB7IGdldEluaXRpYWxTdGF0ZSgpOiBJU3RhdGU7fSAKY2xhc3MgQWJzdHJhY3RNb2RlIGltcGxlbWVudHMgSU1vZGUgeyBwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7IHJldHVybiBudWxsO30gfQoKaW50ZXJmYWNlIElTdGF0ZSB7fQoKaW50ZXJmYWNlIFdpbmRvdyB7CiAgICBvcGVuZXI6IFdpbmRvdzsKfQpkZWNsYXJlIHZhciBzZWxmOiBXaW5kb3c7Cgptb2R1bGUgU2FtcGxlLlRoaW5nLkxhbmd1YWdlcy5QbGFpblRleHQgewoJCglleHBvcnQgY2xhc3MgU3RhdGUgaW1wbGVtZW50cyBJU3RhdGUgewkJCiAgICAgICAgY29uc3RydWN0b3IocHJpdmF0ZSBtb2RlOiBJTW9kZSkgeyB9CgkJcHVibGljIGNsb25lKCk6SVN0YXRlIHsKCQkJcmV0dXJuIHRoaXM7CgkJfQoKCQlwdWJsaWMgZXF1YWxzKG90aGVyOklTdGF0ZSk6Ym9vbGVhbiB7CgkJCXJldHVybiB0aGlzID09PSBvdGhlcjsKCQl9CgkJCgkJcHVibGljIGdldE1vZGUoKTogSU1vZGUgeyByZXR1cm4gbW9kZTsgfQoJfQoJCglleHBvcnQgY2xhc3MgTW9kZSBleHRlbmRzIEFic3RyYWN0TW9kZSB7CgoJCS8vIHNjZW5hcmlvIDIKCQlwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7CgkJCXJldHVybiBuZXcgU3RhdGUoc2VsZik7CgkJfQoKCgl9Cn0KCg== +{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;AA8B1E,IAAO,MAUN;AAVD,WAAO,MAAM,EA1Bb;IA0Bc,IAAA,OAUb;IAVa,WAAA,OAAO,EA1BrB;QA0BsB,IAAA,KAUrB;QAVqB,WAAA,OAAK,EA1B3B;YA0B4B,IAAA,IAU3B;YAV2B,WAAA,IAAI,EAAC;gBAChC,MAAa,eAAe;oBAEpB,KAAK,GAAG,EAAE,OAAO,IAAI,CAAC,CAAA,CAAE;oBAExB,GAAG,CAAC,KAA6B,EAAU;wBAEjD,OAAO,IAAI,CAAC;oBAAA,CACZ;iBACD;gBARY,KAAA,eAAe,kBAQ3B,CAAA;YAAA,CACD,EAV2B,IAAI,GAAJ,QAAA,IAAI,KAAJ,QAAA,IAAI,QAU/B;QADC,CACF,AAzCA,EA+BsB,KAAK,GAAL,QAAA,KAAK,KAAL,QAAA,KAAK,QAU1B;IADC,CACF,AAzCA,EA+Bc,OAAO,GAAP,OAAA,OAAO,KAAP,OAAA,OAAO,QAUpB;AADC,CACF,AAzCA,EA+BO,MAAM,KAAN,MAAM,QAUZ;AAED,WAAO,MAAM,EAtCb;IAsCc,IAAA,KAoBb;IApBa,WAAA,KAAK,EAtCnB;QAsCoB,IAAA,OAoBnB;QApBmB,WAAA,OAAO,EAAC;YAC3B,MAAa,UAAU;gBAKF,SAAS;gBAHtB,GAAG,CAAC,MAAyC,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;oBAAA,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;gBAAA,CAAC,CAAA,CAAC;gBAEjF,OAAO,GAAO,IAAI,CAAC;gBAC3B,YAAoB,SAAkC,EAAE;qCAApC,SAAS;oBACzB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAAA,CAC1C;gBAEM,UAAU,GAAG;oBACnB,OAAO,OAAO,CAAC;gBAAA,CACf;gBAEM,OAAO,GAAG;gBAAC,CAEjB;aAED;YAlBY,QAAA,UAAU,aAkBtB,CAAA;QAAA,CACD,EApBmB,OAAO,GAAP,MAAA,OAAO,KAAP,MAAA,OAAO,QAoB1B;IADC,CACF,AA/DA,EA2Cc,KAAK,GAAL,OAAA,KAAK,KAAL,OAAA,KAAK,QAoBlB;AADC,CACF,AA/DA,EA2CO,MAAM,KAAN,MAAM,QAoBZ;AAGD,MAAM,YAAY;IAA2B,eAAe,GAAW,EAAE,OAAO,IAAI,CAAC,CAAA,CAAC;CAAE;AASxF,WAAO,MAAM,EAtEb;IAsEc,IAAA,KAwBb;IAxBa,WAAA,KAAK,EAtEnB;QAsEoB,IAAA,SAwBnB;QAxBmB,WAAA,SAAS,EAtE7B;YAsE8B,IAAA,SAwB7B;YAxB6B,WAAA,SAAS,EAAC;gBAEvC,MAAa,KAAK;oBACS,IAAI;oBAAxB,YAAoB,IAAW,EAAE;oCAAb,IAAI;oBAAU,CAAE;oBACnC,KAAK,GAAU;wBACrB,OAAO,IAAI,CAAC;oBAAA,CACZ;oBAEM,MAAM,CAAC,KAAY,EAAU;wBACnC,OAAO,IAAI,KAAK,KAAK,CAAC;oBAAA,CACtB;oBAEM,OAAO,GAAU,EAAE,OAAO,IAAI,CAAC,CAAA,CAAE;iBACxC;gBAXY,UAAA,KAAK,QAWjB,CAAA;gBAED,MAAa,IAAK,SAAQ,YAAY;oBAErC,aAAa;oBACN,eAAe,GAAW;wBAChC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBAAA,CACvB;iBAGD;gBARY,UAAA,IAAI,OAQhB,CAAA;YAAA,CACD,EAxB6B,SAAS,GAAT,UAAA,SAAS,KAAT,UAAA,SAAS,QAwBtC;QADC,CACF,AAnGA,EA2EoB,SAAS,GAAT,MAAA,SAAS,KAAT,MAAA,SAAS,QAwB5B;IADC,CACF,AAnGA,EA2Ec,KAAK,GAAL,OAAA,KAAK,KAAL,OAAA,KAAK,QAwBlB;AADC,CACF,AAnGA,EA2EO,MAAM,KAAN,MAAM,QAwBZ"} +//// https://sokra.github.io/source-map-visualization#base64,Ly8gU2NlbmFyaW8gMTogVGVzdCByZXF1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoICJ0aGlzIiBwYXJhbWV0ZXINCi8vIFNjZW5hcmlvIDI6IFRlc3QgcmVjdXJzaXZlIGZ1bmN0aW9uIGNhbGwgd2l0aCBjYXN0IGFuZCAidGhpcyIgcGFyYW1ldGVyDQp2YXIgU2FtcGxlOw0KKGZ1bmN0aW9uIChTYW1wbGUpIHsNCiAgICBsZXQgQWN0aW9uczsNCiAgICAoZnVuY3Rpb24gKEFjdGlvbnMpIHsNCiAgICAgICAgbGV0IFRoaW5nOw0KICAgICAgICAoZnVuY3Rpb24gKFRoaW5nXzEpIHsNCiAgICAgICAgICAgIGxldCBGaW5kOw0KICAgICAgICAgICAgKGZ1bmN0aW9uIChGaW5kKSB7DQogICAgICAgICAgICAgICAgY2xhc3MgU3RhcnRGaW5kQWN0aW9uIHsNCiAgICAgICAgICAgICAgICAgICAgZ2V0SWQoKSB7IHJldHVybiAieW8iOyB9DQogICAgICAgICAgICAgICAgICAgIHJ1bihUaGluZykgew0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgRmluZC5TdGFydEZpbmRBY3Rpb24gPSBTdGFydEZpbmRBY3Rpb247DQogICAgICAgICAgICB9KShGaW5kID0gVGhpbmdfMS5GaW5kIHx8IChUaGluZ18xLkZpbmQgPSB7fSkpOw0KICAgICAgICB9KShUaGluZyA9IEFjdGlvbnMuVGhpbmcgfHwgKEFjdGlvbnMuVGhpbmcgPSB7fSkpOw0KICAgIH0pKEFjdGlvbnMgPSBTYW1wbGUuQWN0aW9ucyB8fCAoU2FtcGxlLkFjdGlvbnMgPSB7fSkpOw0KfSkoU2FtcGxlIHx8IChTYW1wbGUgPSB7fSkpOw0KKGZ1bmN0aW9uIChTYW1wbGUpIHsNCiAgICBsZXQgVGhpbmc7DQogICAgKGZ1bmN0aW9uIChUaGluZykgew0KICAgICAgICBsZXQgV2lkZ2V0czsNCiAgICAgICAgKGZ1bmN0aW9uIChXaWRnZXRzKSB7DQogICAgICAgICAgICBjbGFzcyBGaW5kV2lkZ2V0IHsNCiAgICAgICAgICAgICAgICBjb2RlVGhpbmc7DQogICAgICAgICAgICAgICAgZ2FyKHJ1bm5lcikgeyBpZiAodHJ1ZSkgew0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gcnVubmVyKHRoaXMpOw0KICAgICAgICAgICAgICAgIH0gfQ0KICAgICAgICAgICAgICAgIGRvbU5vZGUgPSBudWxsOw0KICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNvZGVUaGluZykgew0KICAgICAgICAgICAgICAgICAgICB0aGlzLmNvZGVUaGluZyA9IGNvZGVUaGluZzsNCiAgICAgICAgICAgICAgICAgICAgLy8gc2NlbmFyaW8gMQ0KICAgICAgICAgICAgICAgICAgICBjb2RlVGhpbmcuYWRkV2lkZ2V0KCJhZGRXaWRnZXQiLCB0aGlzKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgZ2V0RG9tTm9kZSgpIHsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRvbU5vZGU7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgV2lkZ2V0cy5GaW5kV2lkZ2V0ID0gRmluZFdpZGdldDsNCiAgICAgICAgfSkoV2lkZ2V0cyA9IFRoaW5nLldpZGdldHMgfHwgKFRoaW5nLldpZGdldHMgPSB7fSkpOw0KICAgIH0pKFRoaW5nID0gU2FtcGxlLlRoaW5nIHx8IChTYW1wbGUuVGhpbmcgPSB7fSkpOw0KfSkoU2FtcGxlIHx8IChTYW1wbGUgPSB7fSkpOw0KY2xhc3MgQWJzdHJhY3RNb2RlIHsNCiAgICBnZXRJbml0aWFsU3RhdGUoKSB7IHJldHVybiBudWxsOyB9DQp9DQooZnVuY3Rpb24gKFNhbXBsZSkgew0KICAgIGxldCBUaGluZzsNCiAgICAoZnVuY3Rpb24gKFRoaW5nKSB7DQogICAgICAgIGxldCBMYW5ndWFnZXM7DQogICAgICAgIChmdW5jdGlvbiAoTGFuZ3VhZ2VzKSB7DQogICAgICAgICAgICBsZXQgUGxhaW5UZXh0Ow0KICAgICAgICAgICAgKGZ1bmN0aW9uIChQbGFpblRleHQpIHsNCiAgICAgICAgICAgICAgICBjbGFzcyBTdGF0ZSB7DQogICAgICAgICAgICAgICAgICAgIG1vZGU7DQogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1vZGUpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW9kZSA9IG1vZGU7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgY2xvbmUoKSB7DQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpczsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBlcXVhbHMob3RoZXIpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzID09PSBvdGhlcjsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBnZXRNb2RlKCkgeyByZXR1cm4gbW9kZTsgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBQbGFpblRleHQuU3RhdGUgPSBTdGF0ZTsNCiAgICAgICAgICAgICAgICBjbGFzcyBNb2RlIGV4dGVuZHMgQWJzdHJhY3RNb2RlIHsNCiAgICAgICAgICAgICAgICAgICAgLy8gc2NlbmFyaW8gMg0KICAgICAgICAgICAgICAgICAgICBnZXRJbml0aWFsU3RhdGUoKSB7DQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFN0YXRlKHNlbGYpOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIFBsYWluVGV4dC5Nb2RlID0gTW9kZTsNCiAgICAgICAgICAgIH0pKFBsYWluVGV4dCA9IExhbmd1YWdlcy5QbGFpblRleHQgfHwgKExhbmd1YWdlcy5QbGFpblRleHQgPSB7fSkpOw0KICAgICAgICB9KShMYW5ndWFnZXMgPSBUaGluZy5MYW5ndWFnZXMgfHwgKFRoaW5nLkxhbmd1YWdlcyA9IHt9KSk7DQogICAgfSkoVGhpbmcgPSBTYW1wbGUuVGhpbmcgfHwgKFNhbXBsZS5UaGluZyA9IHt9KSk7DQp9KShTYW1wbGUgfHwgKFNhbXBsZSA9IHt9KSk7DQovLyMgc291cmNlTWFwcGluZ1VSTD1yZWN1cnNpdmVDbGFzc1JlZmVyZW5jZVRlc3QuanMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGlFQUFpRTtBQUNqRSwwRUFBMEU7QUE4QjFFLElBQU8sTUFVTjtBQVZELFdBQU8sTUFBTSxFQTFCYjtJQTBCYyxJQUFBLE9BVWI7SUFWYSxXQUFBLE9BQU8sRUExQnJCO1FBMEJzQixJQUFBLEtBVXJCO1FBVnFCLFdBQUEsT0FBSyxFQTFCM0I7WUEwQjRCLElBQUEsSUFVM0I7WUFWMkIsV0FBQSxJQUFJLEVBQUM7Z0JBQ2hDLE1BQWEsZUFBZTtvQkFFcEIsS0FBSyxHQUFHLEVBQUUsT0FBTyxJQUFJLENBQUMsQ0FBQSxDQUFFO29CQUV4QixHQUFHLENBQUMsS0FBNkIsRUFBVTt3QkFFakQsT0FBTyxJQUFJLENBQUM7b0JBQUEsQ0FDWjtpQkFDRDtnQkFSWSxLQUFBLGVBQWUsa0JBUTNCLENBQUE7WUFBQSxDQUNELEVBVjJCLElBQUksR0FBSixRQUFBLElBQUksS0FBSixRQUFBLElBQUksUUFVL0I7UUFEQyxDQUNGLEFBekNBLEVBK0JzQixLQUFLLEdBQUwsUUFBQSxLQUFLLEtBQUwsUUFBQSxLQUFLLFFBVTFCO0lBREMsQ0FDRixBQXpDQSxFQStCYyxPQUFPLEdBQVAsT0FBQSxPQUFPLEtBQVAsT0FBQSxPQUFPLFFBVXBCO0FBREMsQ0FDRixBQXpDQSxFQStCTyxNQUFNLEtBQU4sTUFBTSxRQVVaO0FBRUQsV0FBTyxNQUFNLEVBdENiO0lBc0NjLElBQUEsS0FvQmI7SUFwQmEsV0FBQSxLQUFLLEVBdENuQjtRQXNDb0IsSUFBQSxPQW9CbkI7UUFwQm1CLFdBQUEsT0FBTyxFQUFDO1lBQzNCLE1BQWEsVUFBVTtnQkFLRixTQUFTO2dCQUh0QixHQUFHLENBQUMsTUFBeUMsRUFBRSxFQUFFLElBQUksSUFBSSxFQUFFLENBQUM7b0JBQUEsT0FBTyxNQUFNLENBQUMsSUFBSSxDQUFDLENBQUM7Z0JBQUEsQ0FBQyxDQUFBLENBQUM7Z0JBRWpGLE9BQU8sR0FBTyxJQUFJLENBQUM7Z0JBQzNCLFlBQW9CLFNBQWtDLEVBQUU7cUNBQXBDLFNBQVM7b0JBQ3pCLGFBQWE7b0JBQ2IsU0FBUyxDQUFDLFNBQVMsQ0FBQyxXQUFXLEVBQUUsSUFBSSxDQUFDLENBQUM7Z0JBQUEsQ0FDMUM7Z0JBRU0sVUFBVSxHQUFHO29CQUNuQixPQUFPLE9BQU8sQ0FBQztnQkFBQSxDQUNmO2dCQUVNLE9BQU8sR0FBRztnQkFBQyxDQUVqQjthQUVEO1lBbEJZLFFBQUEsVUFBVSxhQWtCdEIsQ0FBQTtRQUFBLENBQ0QsRUFwQm1CLE9BQU8sR0FBUCxNQUFBLE9BQU8sS0FBUCxNQUFBLE9BQU8sUUFvQjFCO0lBREMsQ0FDRixBQS9EQSxFQTJDYyxLQUFLLEdBQUwsT0FBQSxLQUFLLEtBQUwsT0FBQSxLQUFLLFFBb0JsQjtBQURDLENBQ0YsQUEvREEsRUEyQ08sTUFBTSxLQUFOLE1BQU0sUUFvQlo7QUFHRCxNQUFNLFlBQVk7SUFBMkIsZUFBZSxHQUFXLEVBQUUsT0FBTyxJQUFJLENBQUMsQ0FBQSxDQUFDO0NBQUU7QUFTeEYsV0FBTyxNQUFNLEVBdEViO0lBc0VjLElBQUEsS0F3QmI7SUF4QmEsV0FBQSxLQUFLLEVBdEVuQjtRQXNFb0IsSUFBQSxTQXdCbkI7UUF4Qm1CLFdBQUEsU0FBUyxFQXRFN0I7WUFzRThCLElBQUEsU0F3QjdCO1lBeEI2QixXQUFBLFNBQVMsRUFBQztnQkFFdkMsTUFBYSxLQUFLO29CQUNTLElBQUk7b0JBQXhCLFlBQW9CLElBQVcsRUFBRTtvQ0FBYixJQUFJO29CQUFVLENBQUU7b0JBQ25DLEtBQUssR0FBVTt3QkFDckIsT0FBTyxJQUFJLENBQUM7b0JBQUEsQ0FDWjtvQkFFTSxNQUFNLENBQUMsS0FBWSxFQUFVO3dCQUNuQyxPQUFPLElBQUksS0FBSyxLQUFLLENBQUM7b0JBQUEsQ0FDdEI7b0JBRU0sT0FBTyxHQUFVLEVBQUUsT0FBTyxJQUFJLENBQUMsQ0FBQSxDQUFFO2lCQUN4QztnQkFYWSxVQUFBLEtBQUssUUFXakIsQ0FBQTtnQkFFRCxNQUFhLElBQUssU0FBUSxZQUFZO29CQUVyQyxhQUFhO29CQUNOLGVBQWUsR0FBVzt3QkFDaEMsT0FBTyxJQUFJLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQztvQkFBQSxDQUN2QjtpQkFHRDtnQkFSWSxVQUFBLElBQUksT0FRaEIsQ0FBQTtZQUFBLENBQ0QsRUF4QjZCLFNBQVMsR0FBVCxVQUFBLFNBQVMsS0FBVCxVQUFBLFNBQVMsUUF3QnRDO1FBREMsQ0FDRixBQW5HQSxFQTJFb0IsU0FBUyxHQUFULE1BQUEsU0FBUyxLQUFULE1BQUEsU0FBUyxRQXdCNUI7SUFEQyxDQUNGLEFBbkdBLEVBMkVjLEtBQUssR0FBTCxPQUFBLEtBQUssS0FBTCxPQUFBLEtBQUssUUF3QmxCO0FBREMsQ0FDRixBQW5HQSxFQTJFTyxNQUFNLEtBQU4sTUFBTSxRQXdCWiJ9,Ly8gU2NlbmFyaW8gMTogVGVzdCByZXF1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoICJ0aGlzIiBwYXJhbWV0ZXIKLy8gU2NlbmFyaW8gMjogVGVzdCByZWN1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoIGNhc3QgYW5kICJ0aGlzIiBwYXJhbWV0ZXIKCgoKZGVjbGFyZSBtb2R1bGUgU2FtcGxlLlRoaW5nIHsKCglleHBvcnQgaW50ZXJmYWNlIElXaWRnZXQgewoJCWdldERvbU5vZGUoKTogYW55OwoJCWRlc3Ryb3koKTsKCQlnYXIocnVubmVyOih3aWRnZXQ6U2FtcGxlLlRoaW5nLklXaWRnZXQpPT5hbnkpOmFueTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElDb2RlVGhpbmcgewogIAogIAkJZ2V0RG9tTm9kZSgpOiBFbGVtZW50OwoJCQoJCWFkZFdpZGdldCh3aWRnZXRJZDpzdHJpbmcsIHdpZGdldDpJV2lkZ2V0KTsKCgkJCgkJZm9jdXMoKTsgCgkJCgkJLy9hZGRXaWRnZXQod2lkZ2V0OiBTYW1wbGUuVGhpbmcuV2lkZ2V0cy5JV2lkZ2V0KTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElBY3Rpb24gewoJCXJ1bihUaGluZzpJQ29kZVRoaW5nKTpib29sZWFuOwoJCWdldElkKCk6c3RyaW5nOwoJfQkKfQoKbW9kdWxlIFNhbXBsZS5BY3Rpb25zLlRoaW5nLkZpbmQgewoJZXhwb3J0IGNsYXNzIFN0YXJ0RmluZEFjdGlvbiBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JQWN0aW9uIHsKCQkKCQlwdWJsaWMgZ2V0SWQoKSB7IHJldHVybiAieW8iOyB9CgkJCgkJcHVibGljIHJ1bihUaGluZzpTYW1wbGUuVGhpbmcuSUNvZGVUaGluZyk6Ym9vbGVhbiB7CgoJCQlyZXR1cm4gdHJ1ZTsKCQl9Cgl9Cn0KCm1vZHVsZSBTYW1wbGUuVGhpbmcuV2lkZ2V0cyB7CglleHBvcnQgY2xhc3MgRmluZFdpZGdldCBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JV2lkZ2V0IHsKCgkJcHVibGljIGdhcihydW5uZXI6KHdpZGdldDpTYW1wbGUuVGhpbmcuSVdpZGdldCk9PmFueSkgeyBpZiAodHJ1ZSkge3JldHVybiBydW5uZXIodGhpcyk7fX0KCQkJCgkJcHJpdmF0ZSBkb21Ob2RlOmFueSA9IG51bGw7CgkJY29uc3RydWN0b3IocHJpdmF0ZSBjb2RlVGhpbmc6IFNhbXBsZS5UaGluZy5JQ29kZVRoaW5nKSB7CgkJICAgIC8vIHNjZW5hcmlvIDEKCQkgICAgY29kZVRoaW5nLmFkZFdpZGdldCgiYWRkV2lkZ2V0IiwgdGhpcyk7CgkJfQoJCQoJCXB1YmxpYyBnZXREb21Ob2RlKCkgewoJCQlyZXR1cm4gZG9tTm9kZTsKCQl9CgkJCgkJcHVibGljIGRlc3Ryb3koKSB7CgoJCX0KCgl9Cn0KCmludGVyZmFjZSBJTW9kZSB7IGdldEluaXRpYWxTdGF0ZSgpOiBJU3RhdGU7fSAKY2xhc3MgQWJzdHJhY3RNb2RlIGltcGxlbWVudHMgSU1vZGUgeyBwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7IHJldHVybiBudWxsO30gfQoKaW50ZXJmYWNlIElTdGF0ZSB7fQoKaW50ZXJmYWNlIFdpbmRvdyB7CiAgICBvcGVuZXI6IFdpbmRvdzsKfQpkZWNsYXJlIHZhciBzZWxmOiBXaW5kb3c7Cgptb2R1bGUgU2FtcGxlLlRoaW5nLkxhbmd1YWdlcy5QbGFpblRleHQgewoJCglleHBvcnQgY2xhc3MgU3RhdGUgaW1wbGVtZW50cyBJU3RhdGUgewkJCiAgICAgICAgY29uc3RydWN0b3IocHJpdmF0ZSBtb2RlOiBJTW9kZSkgeyB9CgkJcHVibGljIGNsb25lKCk6SVN0YXRlIHsKCQkJcmV0dXJuIHRoaXM7CgkJfQoKCQlwdWJsaWMgZXF1YWxzKG90aGVyOklTdGF0ZSk6Ym9vbGVhbiB7CgkJCXJldHVybiB0aGlzID09PSBvdGhlcjsKCQl9CgkJCgkJcHVibGljIGdldE1vZGUoKTogSU1vZGUgeyByZXR1cm4gbW9kZTsgfQoJfQoJCglleHBvcnQgY2xhc3MgTW9kZSBleHRlbmRzIEFic3RyYWN0TW9kZSB7CgoJCS8vIHNjZW5hcmlvIDIKCQlwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7CgkJCXJldHVybiBuZXcgU3RhdGUoc2VsZik7CgkJfQoKCgl9Cn0KCg== diff --git a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.map.diff b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.map.diff index 3d6581c251..041b9d080b 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.map.diff +++ b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.js.map.diff @@ -4,5 +4,5 @@ //// [recursiveClassReferenceTest.js.map] -{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAAC,IAAA,OAAO,CAUpB;IAVa,WAAA,OAAO;QAAC,IAAA,KAAK,CAU1B;QAVqB,WAAA,OAAK;YAAC,IAAA,IAAI,CAU/B;YAV2B,WAAA,IAAI;gBAC/B,MAAa,eAAe;oBAEpB,KAAK,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;oBAExB,GAAG,CAAC,KAA6B;wBAEvC,OAAO,IAAI,CAAC;oBACb,CAAC;iBACD;gBARY,oBAAe,kBAQ3B,CAAA;YACF,CAAC,EAV2B,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAU/B;QAAD,CAAC,EAVqB,KAAK,GAAL,aAAK,KAAL,aAAK,QAU1B;IAAD,CAAC,EAVa,OAAO,GAAP,cAAO,KAAP,cAAO,QAUpB;AAAD,CAAC,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,WAAO,MAAM;IAAC,IAAA,KAAK,CAoBlB;IApBa,WAAA,KAAK;QAAC,IAAA,OAAO,CAoB1B;QApBmB,WAAA,OAAO;YAC1B,MAAa,UAAU;gBAEf,GAAG,CAAC,MAAyC,IAAI,IAAI,IAAI,EAAE,CAAC;oBAAA,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;gBAAA,CAAC,CAAA,CAAC;gBAGzF,YAAoB,SAAkC;oBAAlC,cAAS,GAAT,SAAS,CAAyB;oBAD9C,YAAO,GAAO,IAAI,CAAC;oBAEvB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAC3C,CAAC;gBAEM,UAAU;oBAChB,OAAO,OAAO,CAAC;gBAChB,CAAC;gBAEM,OAAO;gBAEd,CAAC;aAED;YAlBY,kBAAU,aAkBtB,CAAA;QACF,CAAC,EApBmB,OAAO,GAAP,aAAO,KAAP,aAAO,QAoB1B;IAAD,CAAC,EApBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAoBlB;AAAD,CAAC,EApBM,MAAM,KAAN,MAAM,QAoBZ;AAGD,MAAM,YAAY;IAA2B,eAAe,KAAa,OAAO,IAAI,CAAC,CAAA,CAAC;CAAE;AASxF,WAAO,MAAM;IAAC,IAAA,KAAK,CAwBlB;IAxBa,WAAA,KAAK;QAAC,IAAA,SAAS,CAwB5B;QAxBmB,WAAA,SAAS;YAAC,IAAA,SAAS,CAwBtC;YAxB6B,WAAA,SAAS;gBAEtC,MAAa,KAAK;oBACX,YAAoB,IAAW;wBAAX,SAAI,GAAJ,IAAI,CAAO;oBAAI,CAAC;oBACnC,KAAK;wBACX,OAAO,IAAI,CAAC;oBACb,CAAC;oBAEM,MAAM,CAAC,KAAY;wBACzB,OAAO,IAAI,KAAK,KAAK,CAAC;oBACvB,CAAC;oBAEM,OAAO,KAAY,OAAO,IAAI,CAAC,CAAC,CAAC;iBACxC;gBAXY,eAAK,QAWjB,CAAA;gBAED,MAAa,IAAK,SAAQ,YAAY;oBAErC,aAAa;oBACN,eAAe;wBACrB,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBACxB,CAAC;iBAGD;gBARY,cAAI,OAQhB,CAAA;YACF,CAAC,EAxB6B,SAAS,GAAT,mBAAS,KAAT,mBAAS,QAwBtC;QAAD,CAAC,EAxBmB,SAAS,GAAT,eAAS,KAAT,eAAS,QAwB5B;IAAD,CAAC,EAxBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAwBlB;AAAD,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} -//// https://sokra.github.io/source-map-visualization#base64,Ly8gU2NlbmFyaW8gMTogVGVzdCByZXF1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoICJ0aGlzIiBwYXJhbWV0ZXINCi8vIFNjZW5hcmlvIDI6IFRlc3QgcmVjdXJzaXZlIGZ1bmN0aW9uIGNhbGwgd2l0aCBjYXN0IGFuZCAidGhpcyIgcGFyYW1ldGVyDQp2YXIgU2FtcGxlOw0KKGZ1bmN0aW9uIChTYW1wbGUpIHsNCiAgICB2YXIgQWN0aW9uczsNCiAgICAoZnVuY3Rpb24gKEFjdGlvbnMpIHsNCiAgICAgICAgdmFyIFRoaW5nOw0KICAgICAgICAoZnVuY3Rpb24gKFRoaW5nXzEpIHsNCiAgICAgICAgICAgIHZhciBGaW5kOw0KICAgICAgICAgICAgKGZ1bmN0aW9uIChGaW5kKSB7DQogICAgICAgICAgICAgICAgY2xhc3MgU3RhcnRGaW5kQWN0aW9uIHsNCiAgICAgICAgICAgICAgICAgICAgZ2V0SWQoKSB7IHJldHVybiAieW8iOyB9DQogICAgICAgICAgICAgICAgICAgIHJ1bihUaGluZykgew0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgRmluZC5TdGFydEZpbmRBY3Rpb24gPSBTdGFydEZpbmRBY3Rpb247DQogICAgICAgICAgICB9KShGaW5kID0gVGhpbmdfMS5GaW5kIHx8IChUaGluZ18xLkZpbmQgPSB7fSkpOw0KICAgICAgICB9KShUaGluZyA9IEFjdGlvbnMuVGhpbmcgfHwgKEFjdGlvbnMuVGhpbmcgPSB7fSkpOw0KICAgIH0pKEFjdGlvbnMgPSBTYW1wbGUuQWN0aW9ucyB8fCAoU2FtcGxlLkFjdGlvbnMgPSB7fSkpOw0KfSkoU2FtcGxlIHx8IChTYW1wbGUgPSB7fSkpOw0KKGZ1bmN0aW9uIChTYW1wbGUpIHsNCiAgICB2YXIgVGhpbmc7DQogICAgKGZ1bmN0aW9uIChUaGluZykgew0KICAgICAgICB2YXIgV2lkZ2V0czsNCiAgICAgICAgKGZ1bmN0aW9uIChXaWRnZXRzKSB7DQogICAgICAgICAgICBjbGFzcyBGaW5kV2lkZ2V0IHsNCiAgICAgICAgICAgICAgICBnYXIocnVubmVyKSB7IGlmICh0cnVlKSB7DQogICAgICAgICAgICAgICAgICAgIHJldHVybiBydW5uZXIodGhpcyk7DQogICAgICAgICAgICAgICAgfSB9DQogICAgICAgICAgICAgICAgY29uc3RydWN0b3IoY29kZVRoaW5nKSB7DQogICAgICAgICAgICAgICAgICAgIHRoaXMuY29kZVRoaW5nID0gY29kZVRoaW5nOw0KICAgICAgICAgICAgICAgICAgICB0aGlzLmRvbU5vZGUgPSBudWxsOw0KICAgICAgICAgICAgICAgICAgICAvLyBzY2VuYXJpbyAxDQogICAgICAgICAgICAgICAgICAgIGNvZGVUaGluZy5hZGRXaWRnZXQoImFkZFdpZGdldCIsIHRoaXMpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBnZXREb21Ob2RlKCkgew0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG9tTm9kZTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgZGVzdHJveSgpIHsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICB9DQogICAgICAgICAgICBXaWRnZXRzLkZpbmRXaWRnZXQgPSBGaW5kV2lkZ2V0Ow0KICAgICAgICB9KShXaWRnZXRzID0gVGhpbmcuV2lkZ2V0cyB8fCAoVGhpbmcuV2lkZ2V0cyA9IHt9KSk7DQogICAgfSkoVGhpbmcgPSBTYW1wbGUuVGhpbmcgfHwgKFNhbXBsZS5UaGluZyA9IHt9KSk7DQp9KShTYW1wbGUgfHwgKFNhbXBsZSA9IHt9KSk7DQpjbGFzcyBBYnN0cmFjdE1vZGUgew0KICAgIGdldEluaXRpYWxTdGF0ZSgpIHsgcmV0dXJuIG51bGw7IH0NCn0NCihmdW5jdGlvbiAoU2FtcGxlKSB7DQogICAgdmFyIFRoaW5nOw0KICAgIChmdW5jdGlvbiAoVGhpbmcpIHsNCiAgICAgICAgdmFyIExhbmd1YWdlczsNCiAgICAgICAgKGZ1bmN0aW9uIChMYW5ndWFnZXMpIHsNCiAgICAgICAgICAgIHZhciBQbGFpblRleHQ7DQogICAgICAgICAgICAoZnVuY3Rpb24gKFBsYWluVGV4dCkgew0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YXRlIHsNCiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobW9kZSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb2RlID0gbW9kZTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBjbG9uZSgpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIGVxdWFscyhvdGhlcikgew0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMgPT09IG90aGVyOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIGdldE1vZGUoKSB7IHJldHVybiBtb2RlOyB9DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIFBsYWluVGV4dC5TdGF0ZSA9IFN0YXRlOw0KICAgICAgICAgICAgICAgIGNsYXNzIE1vZGUgZXh0ZW5kcyBBYnN0cmFjdE1vZGUgew0KICAgICAgICAgICAgICAgICAgICAvLyBzY2VuYXJpbyAyDQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxTdGF0ZSgpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgU3RhdGUoc2VsZik7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgUGxhaW5UZXh0Lk1vZGUgPSBNb2RlOw0KICAgICAgICAgICAgfSkoUGxhaW5UZXh0ID0gTGFuZ3VhZ2VzLlBsYWluVGV4dCB8fCAoTGFuZ3VhZ2VzLlBsYWluVGV4dCA9IHt9KSk7DQogICAgICAgIH0pKExhbmd1YWdlcyA9IFRoaW5nLkxhbmd1YWdlcyB8fCAoVGhpbmcuTGFuZ3VhZ2VzID0ge30pKTsNCiAgICB9KShUaGluZyA9IFNhbXBsZS5UaGluZyB8fCAoU2FtcGxlLlRoaW5nID0ge30pKTsNCn0pKFNhbXBsZSB8fCAoU2FtcGxlID0ge30pKTsNCi8vIyBzb3VyY2VNYXBwaW5nVVJMPXJlY3Vyc2l2ZUNsYXNzUmVmZXJlbmNlVGVzdC5qcy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGlFQUFpRTtBQUNqRSwwRUFBMEU7QUE4QjFFLElBQU8sTUFBTSxDQVVaO0FBVkQsV0FBTyxNQUFNO0lBQUMsSUFBQSxPQUFPLENBVXBCO0lBVmEsV0FBQSxPQUFPO1FBQUMsSUFBQSxLQUFLLENBVTFCO1FBVnFCLFdBQUEsT0FBSztZQUFDLElBQUEsSUFBSSxDQVUvQjtZQVYyQixXQUFBLElBQUk7Z0JBQy9CLE1BQWEsZUFBZTtvQkFFcEIsS0FBSyxLQUFLLE9BQU8sSUFBSSxDQUFDLENBQUMsQ0FBQztvQkFFeEIsR0FBRyxDQUFDLEtBQTZCO3dCQUV2QyxPQUFPLElBQUksQ0FBQztvQkFDYixDQUFDO2lCQUNEO2dCQVJZLG9CQUFlLGtCQVEzQixDQUFBO1lBQ0YsQ0FBQyxFQVYyQixJQUFJLEdBQUosWUFBSSxLQUFKLFlBQUksUUFVL0I7UUFBRCxDQUFDLEVBVnFCLEtBQUssR0FBTCxhQUFLLEtBQUwsYUFBSyxRQVUxQjtJQUFELENBQUMsRUFWYSxPQUFPLEdBQVAsY0FBTyxLQUFQLGNBQU8sUUFVcEI7QUFBRCxDQUFDLEVBVk0sTUFBTSxLQUFOLE1BQU0sUUFVWjtBQUVELFdBQU8sTUFBTTtJQUFDLElBQUEsS0FBSyxDQW9CbEI7SUFwQmEsV0FBQSxLQUFLO1FBQUMsSUFBQSxPQUFPLENBb0IxQjtRQXBCbUIsV0FBQSxPQUFPO1lBQzFCLE1BQWEsVUFBVTtnQkFFZixHQUFHLENBQUMsTUFBeUMsSUFBSSxJQUFJLElBQUksRUFBRSxDQUFDO29CQUFBLE9BQU8sTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO2dCQUFBLENBQUMsQ0FBQSxDQUFDO2dCQUd6RixZQUFvQixTQUFrQztvQkFBbEMsY0FBUyxHQUFULFNBQVMsQ0FBeUI7b0JBRDlDLFlBQU8sR0FBTyxJQUFJLENBQUM7b0JBRXZCLGFBQWE7b0JBQ2IsU0FBUyxDQUFDLFNBQVMsQ0FBQyxXQUFXLEVBQUUsSUFBSSxDQUFDLENBQUM7Z0JBQzNDLENBQUM7Z0JBRU0sVUFBVTtvQkFDaEIsT0FBTyxPQUFPLENBQUM7Z0JBQ2hCLENBQUM7Z0JBRU0sT0FBTztnQkFFZCxDQUFDO2FBRUQ7WUFsQlksa0JBQVUsYUFrQnRCLENBQUE7UUFDRixDQUFDLEVBcEJtQixPQUFPLEdBQVAsYUFBTyxLQUFQLGFBQU8sUUFvQjFCO0lBQUQsQ0FBQyxFQXBCYSxLQUFLLEdBQUwsWUFBSyxLQUFMLFlBQUssUUFvQmxCO0FBQUQsQ0FBQyxFQXBCTSxNQUFNLEtBQU4sTUFBTSxRQW9CWjtBQUdELE1BQU0sWUFBWTtJQUEyQixlQUFlLEtBQWEsT0FBTyxJQUFJLENBQUMsQ0FBQSxDQUFDO0NBQUU7QUFTeEYsV0FBTyxNQUFNO0lBQUMsSUFBQSxLQUFLLENBd0JsQjtJQXhCYSxXQUFBLEtBQUs7UUFBQyxJQUFBLFNBQVMsQ0F3QjVCO1FBeEJtQixXQUFBLFNBQVM7WUFBQyxJQUFBLFNBQVMsQ0F3QnRDO1lBeEI2QixXQUFBLFNBQVM7Z0JBRXRDLE1BQWEsS0FBSztvQkFDWCxZQUFvQixJQUFXO3dCQUFYLFNBQUksR0FBSixJQUFJLENBQU87b0JBQUksQ0FBQztvQkFDbkMsS0FBSzt3QkFDWCxPQUFPLElBQUksQ0FBQztvQkFDYixDQUFDO29CQUVNLE1BQU0sQ0FBQyxLQUFZO3dCQUN6QixPQUFPLElBQUksS0FBSyxLQUFLLENBQUM7b0JBQ3ZCLENBQUM7b0JBRU0sT0FBTyxLQUFZLE9BQU8sSUFBSSxDQUFDLENBQUMsQ0FBQztpQkFDeEM7Z0JBWFksZUFBSyxRQVdqQixDQUFBO2dCQUVELE1BQWEsSUFBSyxTQUFRLFlBQVk7b0JBRXJDLGFBQWE7b0JBQ04sZUFBZTt3QkFDckIsT0FBTyxJQUFJLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQztvQkFDeEIsQ0FBQztpQkFHRDtnQkFSWSxjQUFJLE9BUWhCLENBQUE7WUFDRixDQUFDLEVBeEI2QixTQUFTLEdBQVQsbUJBQVMsS0FBVCxtQkFBUyxRQXdCdEM7UUFBRCxDQUFDLEVBeEJtQixTQUFTLEdBQVQsZUFBUyxLQUFULGVBQVMsUUF3QjVCO0lBQUQsQ0FBQyxFQXhCYSxLQUFLLEdBQUwsWUFBSyxLQUFMLFlBQUssUUF3QmxCO0FBQUQsQ0FBQyxFQXhCTSxNQUFNLEtBQU4sTUFBTSxRQXdCWiJ9,Ly8gU2NlbmFyaW8gMTogVGVzdCByZXF1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoICJ0aGlzIiBwYXJhbWV0ZXIKLy8gU2NlbmFyaW8gMjogVGVzdCByZWN1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoIGNhc3QgYW5kICJ0aGlzIiBwYXJhbWV0ZXIKCgoKZGVjbGFyZSBtb2R1bGUgU2FtcGxlLlRoaW5nIHsKCglleHBvcnQgaW50ZXJmYWNlIElXaWRnZXQgewoJCWdldERvbU5vZGUoKTogYW55OwoJCWRlc3Ryb3koKTsKCQlnYXIocnVubmVyOih3aWRnZXQ6U2FtcGxlLlRoaW5nLklXaWRnZXQpPT5hbnkpOmFueTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElDb2RlVGhpbmcgewogIAogIAkJZ2V0RG9tTm9kZSgpOiBFbGVtZW50OwoJCQoJCWFkZFdpZGdldCh3aWRnZXRJZDpzdHJpbmcsIHdpZGdldDpJV2lkZ2V0KTsKCgkJCgkJZm9jdXMoKTsgCgkJCgkJLy9hZGRXaWRnZXQod2lkZ2V0OiBTYW1wbGUuVGhpbmcuV2lkZ2V0cy5JV2lkZ2V0KTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElBY3Rpb24gewoJCXJ1bihUaGluZzpJQ29kZVRoaW5nKTpib29sZWFuOwoJCWdldElkKCk6c3RyaW5nOwoJfQkKfQoKbW9kdWxlIFNhbXBsZS5BY3Rpb25zLlRoaW5nLkZpbmQgewoJZXhwb3J0IGNsYXNzIFN0YXJ0RmluZEFjdGlvbiBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JQWN0aW9uIHsKCQkKCQlwdWJsaWMgZ2V0SWQoKSB7IHJldHVybiAieW8iOyB9CgkJCgkJcHVibGljIHJ1bihUaGluZzpTYW1wbGUuVGhpbmcuSUNvZGVUaGluZyk6Ym9vbGVhbiB7CgoJCQlyZXR1cm4gdHJ1ZTsKCQl9Cgl9Cn0KCm1vZHVsZSBTYW1wbGUuVGhpbmcuV2lkZ2V0cyB7CglleHBvcnQgY2xhc3MgRmluZFdpZGdldCBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JV2lkZ2V0IHsKCgkJcHVibGljIGdhcihydW5uZXI6KHdpZGdldDpTYW1wbGUuVGhpbmcuSVdpZGdldCk9PmFueSkgeyBpZiAodHJ1ZSkge3JldHVybiBydW5uZXIodGhpcyk7fX0KCQkJCgkJcHJpdmF0ZSBkb21Ob2RlOmFueSA9IG51bGw7CgkJY29uc3RydWN0b3IocHJpdmF0ZSBjb2RlVGhpbmc6IFNhbXBsZS5UaGluZy5JQ29kZVRoaW5nKSB7CgkJICAgIC8vIHNjZW5hcmlvIDEKCQkgICAgY29kZVRoaW5nLmFkZFdpZGdldCgiYWRkV2lkZ2V0IiwgdGhpcyk7CgkJfQoJCQoJCXB1YmxpYyBnZXREb21Ob2RlKCkgewoJCQlyZXR1cm4gZG9tTm9kZTsKCQl9CgkJCgkJcHVibGljIGRlc3Ryb3koKSB7CgoJCX0KCgl9Cn0KCmludGVyZmFjZSBJTW9kZSB7IGdldEluaXRpYWxTdGF0ZSgpOiBJU3RhdGU7fSAKY2xhc3MgQWJzdHJhY3RNb2RlIGltcGxlbWVudHMgSU1vZGUgeyBwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7IHJldHVybiBudWxsO30gfQoKaW50ZXJmYWNlIElTdGF0ZSB7fQoKaW50ZXJmYWNlIFdpbmRvdyB7CiAgICBvcGVuZXI6IFdpbmRvdzsKfQpkZWNsYXJlIHZhciBzZWxmOiBXaW5kb3c7Cgptb2R1bGUgU2FtcGxlLlRoaW5nLkxhbmd1YWdlcy5QbGFpblRleHQgewoJCglleHBvcnQgY2xhc3MgU3RhdGUgaW1wbGVtZW50cyBJU3RhdGUgewkJCiAgICAgICAgY29uc3RydWN0b3IocHJpdmF0ZSBtb2RlOiBJTW9kZSkgeyB9CgkJcHVibGljIGNsb25lKCk6SVN0YXRlIHsKCQkJcmV0dXJuIHRoaXM7CgkJfQoKCQlwdWJsaWMgZXF1YWxzKG90aGVyOklTdGF0ZSk6Ym9vbGVhbiB7CgkJCXJldHVybiB0aGlzID09PSBvdGhlcjsKCQl9CgkJCgkJcHVibGljIGdldE1vZGUoKTogSU1vZGUgeyByZXR1cm4gbW9kZTsgfQoJfQoJCglleHBvcnQgY2xhc3MgTW9kZSBleHRlbmRzIEFic3RyYWN0TW9kZSB7CgoJCS8vIHNjZW5hcmlvIDIKCQlwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7CgkJCXJldHVybiBuZXcgU3RhdGUoc2VsZik7CgkJfQoKCgl9Cn0KCg== -+{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AA+BA,IAAO,MAUN;AAVD,WAAO,MAAM,EA1Bb;IA0Bc,IAAA,OAUb;IAVa,WAAA,OAAO,EA1BrB;QA0BsB,IAAA,KAUrB;QAVqB,WAAA,OAAK,EA1B3B;YA0B4B,IAAA,IAU3B;YAV2B,WAAA,IAAI,EAAC;gBAChC,MAAa,eAAe;oBAEpB,KAAK,GAAG,EAAE,OAAO,IAAI,CAAC,CAAA,CAAE;oBAExB,GAAG,CAAC,KAA6B,EAAU;wBAEjD,OAAO,IAAI,CAAC;oBAAA,CACZ;iBACD;gBARY,KAAA,eAAe,kBAQ3B,CAAA;YAAA,CACD,EAV2B,IAAI,GAAJ,QAAA,IAAI,KAAJ,QAAA,IAAI,QAU/B;QADC,CACF,AAzCA,EA+BsB,KAAK,GAAL,QAAA,KAAK,KAAL,QAAA,KAAK,QAU1B;IADC,CACF,AAzCA,EA+Bc,OAAO,GAAP,OAAA,OAAO,KAAP,OAAA,OAAO,QAUpB;AADC,CACF,AAzCA,EA+BO,MAAM,KAAN,MAAM,QAUZ;AAED,WAAO,MAAM,EAtCb;IAsCc,IAAA,KAoBb;IApBa,WAAA,KAAK,EAtCnB;QAsCoB,IAAA,OAoBnB;QApBmB,WAAA,OAAO,EAAC;YAC3B,MAAa,UAAU;gBAKF,SAAS;gBAHtB,GAAG,CAAC,MAAyC,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;oBAAA,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;gBAAA,CAAC,CAAA,CAAC;gBAEjF,OAAO,GAAO,IAAI,CAAC;gBAC3B,YAAoB,SAAkC,EAAE;qCAApC,SAAS;oBACzB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAAA,CAC1C;gBAEM,UAAU,GAAG;oBACnB,OAAO,OAAO,CAAC;gBAAA,CACf;gBAEM,OAAO,GAAG;gBAAC,CAEjB;aAED;YAlBY,QAAA,UAAU,aAkBtB,CAAA;QAAA,CACD,EApBmB,OAAO,GAAP,MAAA,OAAO,KAAP,MAAA,OAAO,QAoB1B;IADC,CACF,AA/DA,EA2Cc,KAAK,GAAL,OAAA,KAAK,KAAL,OAAA,KAAK,QAoBlB;AADC,CACF,AA/DA,EA2CO,MAAM,KAAN,MAAM,QAoBZ;AAGD,MAAM,YAAY;IAA2B,eAAe,GAAW,EAAE,OAAO,IAAI,CAAC,CAAA,CAAC;CAAE;AASxF,WAAO,MAAM,EAtEb;IAsEc,IAAA,KAwBb;IAxBa,WAAA,KAAK,EAtEnB;QAsEoB,IAAA,SAwBnB;QAxBmB,WAAA,SAAS,EAtE7B;YAsE8B,IAAA,SAwB7B;YAxB6B,WAAA,SAAS,EAAC;gBAEvC,MAAa,KAAK;oBACS,IAAI;oBAAxB,YAAoB,IAAW,EAAE;oCAAb,IAAI;oBAAU,CAAE;oBACnC,KAAK,GAAU;wBACrB,OAAO,IAAI,CAAC;oBAAA,CACZ;oBAEM,MAAM,CAAC,KAAY,EAAU;wBACnC,OAAO,IAAI,KAAK,KAAK,CAAC;oBAAA,CACtB;oBAEM,OAAO,GAAU,EAAE,OAAO,IAAI,CAAC,CAAA,CAAE;iBACxC;gBAXY,UAAA,KAAK,QAWjB,CAAA;gBAED,MAAa,IAAK,SAAQ,YAAY;oBAErC,aAAa;oBACN,eAAe,GAAW;wBAChC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBAAA,CACvB;iBAGD;gBARY,UAAA,IAAI,OAQhB,CAAA;YAAA,CACD,EAxB6B,SAAS,GAAT,UAAA,SAAS,KAAT,UAAA,SAAS,QAwBtC;QADC,CACF,AAnGA,EA2EoB,SAAS,GAAT,MAAA,SAAS,KAAT,MAAA,SAAS,QAwB5B;IADC,CACF,AAnGA,EA2Ec,KAAK,GAAL,OAAA,KAAK,KAAL,OAAA,KAAK,QAwBlB;AADC,CACF,AAnGA,EA2EO,MAAM,KAAN,MAAM,QAwBZ"} -+//// https://sokra.github.io/source-map-visualization#base64,dmFyIFNhbXBsZTsNCihmdW5jdGlvbiAoU2FtcGxlKSB7DQogICAgbGV0IEFjdGlvbnM7DQogICAgKGZ1bmN0aW9uIChBY3Rpb25zKSB7DQogICAgICAgIGxldCBUaGluZzsNCiAgICAgICAgKGZ1bmN0aW9uIChUaGluZ18xKSB7DQogICAgICAgICAgICBsZXQgRmluZDsNCiAgICAgICAgICAgIChmdW5jdGlvbiAoRmluZCkgew0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YXJ0RmluZEFjdGlvbiB7DQogICAgICAgICAgICAgICAgICAgIGdldElkKCkgeyByZXR1cm4gInlvIjsgfQ0KICAgICAgICAgICAgICAgICAgICBydW4oVGhpbmcpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIEZpbmQuU3RhcnRGaW5kQWN0aW9uID0gU3RhcnRGaW5kQWN0aW9uOw0KICAgICAgICAgICAgfSkoRmluZCA9IFRoaW5nXzEuRmluZCB8fCAoVGhpbmdfMS5GaW5kID0ge30pKTsNCiAgICAgICAgfSkoVGhpbmcgPSBBY3Rpb25zLlRoaW5nIHx8IChBY3Rpb25zLlRoaW5nID0ge30pKTsNCiAgICB9KShBY3Rpb25zID0gU2FtcGxlLkFjdGlvbnMgfHwgKFNhbXBsZS5BY3Rpb25zID0ge30pKTsNCn0pKFNhbXBsZSB8fCAoU2FtcGxlID0ge30pKTsNCihmdW5jdGlvbiAoU2FtcGxlKSB7DQogICAgbGV0IFRoaW5nOw0KICAgIChmdW5jdGlvbiAoVGhpbmcpIHsNCiAgICAgICAgbGV0IFdpZGdldHM7DQogICAgICAgIChmdW5jdGlvbiAoV2lkZ2V0cykgew0KICAgICAgICAgICAgY2xhc3MgRmluZFdpZGdldCB7DQogICAgICAgICAgICAgICAgY29kZVRoaW5nOw0KICAgICAgICAgICAgICAgIGdhcihydW5uZXIpIHsgaWYgKHRydWUpIHsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJ1bm5lcih0aGlzKTsNCiAgICAgICAgICAgICAgICB9IH0NCiAgICAgICAgICAgICAgICBkb21Ob2RlID0gbnVsbDsNCiAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihjb2RlVGhpbmcpIHsNCiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2RlVGhpbmcgPSBjb2RlVGhpbmc7DQogICAgICAgICAgICAgICAgICAgIC8vIHNjZW5hcmlvIDENCiAgICAgICAgICAgICAgICAgICAgY29kZVRoaW5nLmFkZFdpZGdldCgiYWRkV2lkZ2V0IiwgdGhpcyk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGdldERvbU5vZGUoKSB7DQogICAgICAgICAgICAgICAgICAgIHJldHVybiBkb21Ob2RlOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBkZXN0cm95KCkgew0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIFdpZGdldHMuRmluZFdpZGdldCA9IEZpbmRXaWRnZXQ7DQogICAgICAgIH0pKFdpZGdldHMgPSBUaGluZy5XaWRnZXRzIHx8IChUaGluZy5XaWRnZXRzID0ge30pKTsNCiAgICB9KShUaGluZyA9IFNhbXBsZS5UaGluZyB8fCAoU2FtcGxlLlRoaW5nID0ge30pKTsNCn0pKFNhbXBsZSB8fCAoU2FtcGxlID0ge30pKTsNCmNsYXNzIEFic3RyYWN0TW9kZSB7DQogICAgZ2V0SW5pdGlhbFN0YXRlKCkgeyByZXR1cm4gbnVsbDsgfQ0KfQ0KKGZ1bmN0aW9uIChTYW1wbGUpIHsNCiAgICBsZXQgVGhpbmc7DQogICAgKGZ1bmN0aW9uIChUaGluZykgew0KICAgICAgICBsZXQgTGFuZ3VhZ2VzOw0KICAgICAgICAoZnVuY3Rpb24gKExhbmd1YWdlcykgew0KICAgICAgICAgICAgbGV0IFBsYWluVGV4dDsNCiAgICAgICAgICAgIChmdW5jdGlvbiAoUGxhaW5UZXh0KSB7DQogICAgICAgICAgICAgICAgY2xhc3MgU3RhdGUgew0KICAgICAgICAgICAgICAgICAgICBtb2RlOw0KICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtb2RlKSB7DQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vZGUgPSBtb2RlOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIGNsb25lKCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgZXF1YWxzKG90aGVyKSB7DQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcyA9PT0gb3RoZXI7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgZ2V0TW9kZSgpIHsgcmV0dXJuIG1vZGU7IH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgUGxhaW5UZXh0LlN0YXRlID0gU3RhdGU7DQogICAgICAgICAgICAgICAgY2xhc3MgTW9kZSBleHRlbmRzIEFic3RyYWN0TW9kZSB7DQogICAgICAgICAgICAgICAgICAgIC8vIHNjZW5hcmlvIDINCiAgICAgICAgICAgICAgICAgICAgZ2V0SW5pdGlhbFN0YXRlKCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdGF0ZShzZWxmKTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBQbGFpblRleHQuTW9kZSA9IE1vZGU7DQogICAgICAgICAgICB9KShQbGFpblRleHQgPSBMYW5ndWFnZXMuUGxhaW5UZXh0IHx8IChMYW5ndWFnZXMuUGxhaW5UZXh0ID0ge30pKTsNCiAgICAgICAgfSkoTGFuZ3VhZ2VzID0gVGhpbmcuTGFuZ3VhZ2VzIHx8IChUaGluZy5MYW5ndWFnZXMgPSB7fSkpOw0KICAgIH0pKFRoaW5nID0gU2FtcGxlLlRoaW5nIHx8IChTYW1wbGUuVGhpbmcgPSB7fSkpOw0KfSkoU2FtcGxlIHx8IChTYW1wbGUgPSB7fSkpOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9cmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LmpzLm1hcA==,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQStCQSxJQUFPLE1BVU47QUFWRCxXQUFPLE1BQU0sRUExQmI7SUEwQmMsSUFBQSxPQVViO0lBVmEsV0FBQSxPQUFPLEVBMUJyQjtRQTBCc0IsSUFBQSxLQVVyQjtRQVZxQixXQUFBLE9BQUssRUExQjNCO1lBMEI0QixJQUFBLElBVTNCO1lBVjJCLFdBQUEsSUFBSSxFQUFDO2dCQUNoQyxNQUFhLGVBQWU7b0JBRXBCLEtBQUssR0FBRyxFQUFFLE9BQU8sSUFBSSxDQUFDLENBQUEsQ0FBRTtvQkFFeEIsR0FBRyxDQUFDLEtBQTZCLEVBQVU7d0JBRWpELE9BQU8sSUFBSSxDQUFDO29CQUFBLENBQ1o7aUJBQ0Q7Z0JBUlksS0FBQSxlQUFlLGtCQVEzQixDQUFBO1lBQUEsQ0FDRCxFQVYyQixJQUFJLEdBQUosUUFBQSxJQUFJLEtBQUosUUFBQSxJQUFJLFFBVS9CO1FBREMsQ0FDRixBQXpDQSxFQStCc0IsS0FBSyxHQUFMLFFBQUEsS0FBSyxLQUFMLFFBQUEsS0FBSyxRQVUxQjtJQURDLENBQ0YsQUF6Q0EsRUErQmMsT0FBTyxHQUFQLE9BQUEsT0FBTyxLQUFQLE9BQUEsT0FBTyxRQVVwQjtBQURDLENBQ0YsQUF6Q0EsRUErQk8sTUFBTSxLQUFOLE1BQU0sUUFVWjtBQUVELFdBQU8sTUFBTSxFQXRDYjtJQXNDYyxJQUFBLEtBb0JiO0lBcEJhLFdBQUEsS0FBSyxFQXRDbkI7UUFzQ29CLElBQUEsT0FvQm5CO1FBcEJtQixXQUFBLE9BQU8sRUFBQztZQUMzQixNQUFhLFVBQVU7Z0JBS0YsU0FBUztnQkFIdEIsR0FBRyxDQUFDLE1BQXlDLEVBQUUsRUFBRSxJQUFJLElBQUksRUFBRSxDQUFDO29CQUFBLE9BQU8sTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO2dCQUFBLENBQUMsQ0FBQSxDQUFDO2dCQUVqRixPQUFPLEdBQU8sSUFBSSxDQUFDO2dCQUMzQixZQUFvQixTQUFrQyxFQUFFO3FDQUFwQyxTQUFTO29CQUN6QixhQUFhO29CQUNiLFNBQVMsQ0FBQyxTQUFTLENBQUMsV0FBVyxFQUFFLElBQUksQ0FBQyxDQUFDO2dCQUFBLENBQzFDO2dCQUVNLFVBQVUsR0FBRztvQkFDbkIsT0FBTyxPQUFPLENBQUM7Z0JBQUEsQ0FDZjtnQkFFTSxPQUFPLEdBQUc7Z0JBQUMsQ0FFakI7YUFFRDtZQWxCWSxRQUFBLFVBQVUsYUFrQnRCLENBQUE7UUFBQSxDQUNELEVBcEJtQixPQUFPLEdBQVAsTUFBQSxPQUFPLEtBQVAsTUFBQSxPQUFPLFFBb0IxQjtJQURDLENBQ0YsQUEvREEsRUEyQ2MsS0FBSyxHQUFMLE9BQUEsS0FBSyxLQUFMLE9BQUEsS0FBSyxRQW9CbEI7QUFEQyxDQUNGLEFBL0RBLEVBMkNPLE1BQU0sS0FBTixNQUFNLFFBb0JaO0FBR0QsTUFBTSxZQUFZO0lBQTJCLGVBQWUsR0FBVyxFQUFFLE9BQU8sSUFBSSxDQUFDLENBQUEsQ0FBQztDQUFFO0FBU3hGLFdBQU8sTUFBTSxFQXRFYjtJQXNFYyxJQUFBLEtBd0JiO0lBeEJhLFdBQUEsS0FBSyxFQXRFbkI7UUFzRW9CLElBQUEsU0F3Qm5CO1FBeEJtQixXQUFBLFNBQVMsRUF0RTdCO1lBc0U4QixJQUFBLFNBd0I3QjtZQXhCNkIsV0FBQSxTQUFTLEVBQUM7Z0JBRXZDLE1BQWEsS0FBSztvQkFDUyxJQUFJO29CQUF4QixZQUFvQixJQUFXLEVBQUU7b0NBQWIsSUFBSTtvQkFBVSxDQUFFO29CQUNuQyxLQUFLLEdBQVU7d0JBQ3JCLE9BQU8sSUFBSSxDQUFDO29CQUFBLENBQ1o7b0JBRU0sTUFBTSxDQUFDLEtBQVksRUFBVTt3QkFDbkMsT0FBTyxJQUFJLEtBQUssS0FBSyxDQUFDO29CQUFBLENBQ3RCO29CQUVNLE9BQU8sR0FBVSxFQUFFLE9BQU8sSUFBSSxDQUFDLENBQUEsQ0FBRTtpQkFDeEM7Z0JBWFksVUFBQSxLQUFLLFFBV2pCLENBQUE7Z0JBRUQsTUFBYSxJQUFLLFNBQVEsWUFBWTtvQkFFckMsYUFBYTtvQkFDTixlQUFlLEdBQVc7d0JBQ2hDLE9BQU8sSUFBSSxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7b0JBQUEsQ0FDdkI7aUJBR0Q7Z0JBUlksVUFBQSxJQUFJLE9BUWhCLENBQUE7WUFBQSxDQUNELEVBeEI2QixTQUFTLEdBQVQsVUFBQSxTQUFTLEtBQVQsVUFBQSxTQUFTLFFBd0J0QztRQURDLENBQ0YsQUFuR0EsRUEyRW9CLFNBQVMsR0FBVCxNQUFBLFNBQVMsS0FBVCxNQUFBLFNBQVMsUUF3QjVCO0lBREMsQ0FDRixBQW5HQSxFQTJFYyxLQUFLLEdBQUwsT0FBQSxLQUFLLEtBQUwsT0FBQSxLQUFLLFFBd0JsQjtBQURDLENBQ0YsQUFuR0EsRUEyRU8sTUFBTSxLQUFOLE1BQU0sUUF3QloifQ==,Ly8gU2NlbmFyaW8gMTogVGVzdCByZXF1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoICJ0aGlzIiBwYXJhbWV0ZXIKLy8gU2NlbmFyaW8gMjogVGVzdCByZWN1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoIGNhc3QgYW5kICJ0aGlzIiBwYXJhbWV0ZXIKCgoKZGVjbGFyZSBtb2R1bGUgU2FtcGxlLlRoaW5nIHsKCglleHBvcnQgaW50ZXJmYWNlIElXaWRnZXQgewoJCWdldERvbU5vZGUoKTogYW55OwoJCWRlc3Ryb3koKTsKCQlnYXIocnVubmVyOih3aWRnZXQ6U2FtcGxlLlRoaW5nLklXaWRnZXQpPT5hbnkpOmFueTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElDb2RlVGhpbmcgewogIAogIAkJZ2V0RG9tTm9kZSgpOiBFbGVtZW50OwoJCQoJCWFkZFdpZGdldCh3aWRnZXRJZDpzdHJpbmcsIHdpZGdldDpJV2lkZ2V0KTsKCgkJCgkJZm9jdXMoKTsgCgkJCgkJLy9hZGRXaWRnZXQod2lkZ2V0OiBTYW1wbGUuVGhpbmcuV2lkZ2V0cy5JV2lkZ2V0KTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElBY3Rpb24gewoJCXJ1bihUaGluZzpJQ29kZVRoaW5nKTpib29sZWFuOwoJCWdldElkKCk6c3RyaW5nOwoJfQkKfQoKbW9kdWxlIFNhbXBsZS5BY3Rpb25zLlRoaW5nLkZpbmQgewoJZXhwb3J0IGNsYXNzIFN0YXJ0RmluZEFjdGlvbiBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JQWN0aW9uIHsKCQkKCQlwdWJsaWMgZ2V0SWQoKSB7IHJldHVybiAieW8iOyB9CgkJCgkJcHVibGljIHJ1bihUaGluZzpTYW1wbGUuVGhpbmcuSUNvZGVUaGluZyk6Ym9vbGVhbiB7CgoJCQlyZXR1cm4gdHJ1ZTsKCQl9Cgl9Cn0KCm1vZHVsZSBTYW1wbGUuVGhpbmcuV2lkZ2V0cyB7CglleHBvcnQgY2xhc3MgRmluZFdpZGdldCBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JV2lkZ2V0IHsKCgkJcHVibGljIGdhcihydW5uZXI6KHdpZGdldDpTYW1wbGUuVGhpbmcuSVdpZGdldCk9PmFueSkgeyBpZiAodHJ1ZSkge3JldHVybiBydW5uZXIodGhpcyk7fX0KCQkJCgkJcHJpdmF0ZSBkb21Ob2RlOmFueSA9IG51bGw7CgkJY29uc3RydWN0b3IocHJpdmF0ZSBjb2RlVGhpbmc6IFNhbXBsZS5UaGluZy5JQ29kZVRoaW5nKSB7CgkJICAgIC8vIHNjZW5hcmlvIDEKCQkgICAgY29kZVRoaW5nLmFkZFdpZGdldCgiYWRkV2lkZ2V0IiwgdGhpcyk7CgkJfQoJCQoJCXB1YmxpYyBnZXREb21Ob2RlKCkgewoJCQlyZXR1cm4gZG9tTm9kZTsKCQl9CgkJCgkJcHVibGljIGRlc3Ryb3koKSB7CgoJCX0KCgl9Cn0KCmludGVyZmFjZSBJTW9kZSB7IGdldEluaXRpYWxTdGF0ZSgpOiBJU3RhdGU7fSAKY2xhc3MgQWJzdHJhY3RNb2RlIGltcGxlbWVudHMgSU1vZGUgeyBwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7IHJldHVybiBudWxsO30gfQoKaW50ZXJmYWNlIElTdGF0ZSB7fQoKaW50ZXJmYWNlIFdpbmRvdyB7CiAgICBvcGVuZXI6IFdpbmRvdzsKfQpkZWNsYXJlIHZhciBzZWxmOiBXaW5kb3c7Cgptb2R1bGUgU2FtcGxlLlRoaW5nLkxhbmd1YWdlcy5QbGFpblRleHQgewoJCglleHBvcnQgY2xhc3MgU3RhdGUgaW1wbGVtZW50cyBJU3RhdGUgewkJCiAgICAgICAgY29uc3RydWN0b3IocHJpdmF0ZSBtb2RlOiBJTW9kZSkgeyB9CgkJcHVibGljIGNsb25lKCk6SVN0YXRlIHsKCQkJcmV0dXJuIHRoaXM7CgkJfQoKCQlwdWJsaWMgZXF1YWxzKG90aGVyOklTdGF0ZSk6Ym9vbGVhbiB7CgkJCXJldHVybiB0aGlzID09PSBvdGhlcjsKCQl9CgkJCgkJcHVibGljIGdldE1vZGUoKTogSU1vZGUgeyByZXR1cm4gbW9kZTsgfQoJfQoJCglleHBvcnQgY2xhc3MgTW9kZSBleHRlbmRzIEFic3RyYWN0TW9kZSB7CgoJCS8vIHNjZW5hcmlvIDIKCQlwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7CgkJCXJldHVybiBuZXcgU3RhdGUoc2VsZik7CgkJfQoKCgl9Cn0KCg== \ No newline at end of file ++{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;AA8B1E,IAAO,MAUN;AAVD,WAAO,MAAM,EA1Bb;IA0Bc,IAAA,OAUb;IAVa,WAAA,OAAO,EA1BrB;QA0BsB,IAAA,KAUrB;QAVqB,WAAA,OAAK,EA1B3B;YA0B4B,IAAA,IAU3B;YAV2B,WAAA,IAAI,EAAC;gBAChC,MAAa,eAAe;oBAEpB,KAAK,GAAG,EAAE,OAAO,IAAI,CAAC,CAAA,CAAE;oBAExB,GAAG,CAAC,KAA6B,EAAU;wBAEjD,OAAO,IAAI,CAAC;oBAAA,CACZ;iBACD;gBARY,KAAA,eAAe,kBAQ3B,CAAA;YAAA,CACD,EAV2B,IAAI,GAAJ,QAAA,IAAI,KAAJ,QAAA,IAAI,QAU/B;QADC,CACF,AAzCA,EA+BsB,KAAK,GAAL,QAAA,KAAK,KAAL,QAAA,KAAK,QAU1B;IADC,CACF,AAzCA,EA+Bc,OAAO,GAAP,OAAA,OAAO,KAAP,OAAA,OAAO,QAUpB;AADC,CACF,AAzCA,EA+BO,MAAM,KAAN,MAAM,QAUZ;AAED,WAAO,MAAM,EAtCb;IAsCc,IAAA,KAoBb;IApBa,WAAA,KAAK,EAtCnB;QAsCoB,IAAA,OAoBnB;QApBmB,WAAA,OAAO,EAAC;YAC3B,MAAa,UAAU;gBAKF,SAAS;gBAHtB,GAAG,CAAC,MAAyC,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC;oBAAA,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;gBAAA,CAAC,CAAA,CAAC;gBAEjF,OAAO,GAAO,IAAI,CAAC;gBAC3B,YAAoB,SAAkC,EAAE;qCAApC,SAAS;oBACzB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAAA,CAC1C;gBAEM,UAAU,GAAG;oBACnB,OAAO,OAAO,CAAC;gBAAA,CACf;gBAEM,OAAO,GAAG;gBAAC,CAEjB;aAED;YAlBY,QAAA,UAAU,aAkBtB,CAAA;QAAA,CACD,EApBmB,OAAO,GAAP,MAAA,OAAO,KAAP,MAAA,OAAO,QAoB1B;IADC,CACF,AA/DA,EA2Cc,KAAK,GAAL,OAAA,KAAK,KAAL,OAAA,KAAK,QAoBlB;AADC,CACF,AA/DA,EA2CO,MAAM,KAAN,MAAM,QAoBZ;AAGD,MAAM,YAAY;IAA2B,eAAe,GAAW,EAAE,OAAO,IAAI,CAAC,CAAA,CAAC;CAAE;AASxF,WAAO,MAAM,EAtEb;IAsEc,IAAA,KAwBb;IAxBa,WAAA,KAAK,EAtEnB;QAsEoB,IAAA,SAwBnB;QAxBmB,WAAA,SAAS,EAtE7B;YAsE8B,IAAA,SAwB7B;YAxB6B,WAAA,SAAS,EAAC;gBAEvC,MAAa,KAAK;oBACS,IAAI;oBAAxB,YAAoB,IAAW,EAAE;oCAAb,IAAI;oBAAU,CAAE;oBACnC,KAAK,GAAU;wBACrB,OAAO,IAAI,CAAC;oBAAA,CACZ;oBAEM,MAAM,CAAC,KAAY,EAAU;wBACnC,OAAO,IAAI,KAAK,KAAK,CAAC;oBAAA,CACtB;oBAEM,OAAO,GAAU,EAAE,OAAO,IAAI,CAAC,CAAA,CAAE;iBACxC;gBAXY,UAAA,KAAK,QAWjB,CAAA;gBAED,MAAa,IAAK,SAAQ,YAAY;oBAErC,aAAa;oBACN,eAAe,GAAW;wBAChC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBAAA,CACvB;iBAGD;gBARY,UAAA,IAAI,OAQhB,CAAA;YAAA,CACD,EAxB6B,SAAS,GAAT,UAAA,SAAS,KAAT,UAAA,SAAS,QAwBtC;QADC,CACF,AAnGA,EA2EoB,SAAS,GAAT,MAAA,SAAS,KAAT,MAAA,SAAS,QAwB5B;IADC,CACF,AAnGA,EA2Ec,KAAK,GAAL,OAAA,KAAK,KAAL,OAAA,KAAK,QAwBlB;AADC,CACF,AAnGA,EA2EO,MAAM,KAAN,MAAM,QAwBZ"} ++//// https://sokra.github.io/source-map-visualization#base64,Ly8gU2NlbmFyaW8gMTogVGVzdCByZXF1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoICJ0aGlzIiBwYXJhbWV0ZXINCi8vIFNjZW5hcmlvIDI6IFRlc3QgcmVjdXJzaXZlIGZ1bmN0aW9uIGNhbGwgd2l0aCBjYXN0IGFuZCAidGhpcyIgcGFyYW1ldGVyDQp2YXIgU2FtcGxlOw0KKGZ1bmN0aW9uIChTYW1wbGUpIHsNCiAgICBsZXQgQWN0aW9uczsNCiAgICAoZnVuY3Rpb24gKEFjdGlvbnMpIHsNCiAgICAgICAgbGV0IFRoaW5nOw0KICAgICAgICAoZnVuY3Rpb24gKFRoaW5nXzEpIHsNCiAgICAgICAgICAgIGxldCBGaW5kOw0KICAgICAgICAgICAgKGZ1bmN0aW9uIChGaW5kKSB7DQogICAgICAgICAgICAgICAgY2xhc3MgU3RhcnRGaW5kQWN0aW9uIHsNCiAgICAgICAgICAgICAgICAgICAgZ2V0SWQoKSB7IHJldHVybiAieW8iOyB9DQogICAgICAgICAgICAgICAgICAgIHJ1bihUaGluZykgew0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgRmluZC5TdGFydEZpbmRBY3Rpb24gPSBTdGFydEZpbmRBY3Rpb247DQogICAgICAgICAgICB9KShGaW5kID0gVGhpbmdfMS5GaW5kIHx8IChUaGluZ18xLkZpbmQgPSB7fSkpOw0KICAgICAgICB9KShUaGluZyA9IEFjdGlvbnMuVGhpbmcgfHwgKEFjdGlvbnMuVGhpbmcgPSB7fSkpOw0KICAgIH0pKEFjdGlvbnMgPSBTYW1wbGUuQWN0aW9ucyB8fCAoU2FtcGxlLkFjdGlvbnMgPSB7fSkpOw0KfSkoU2FtcGxlIHx8IChTYW1wbGUgPSB7fSkpOw0KKGZ1bmN0aW9uIChTYW1wbGUpIHsNCiAgICBsZXQgVGhpbmc7DQogICAgKGZ1bmN0aW9uIChUaGluZykgew0KICAgICAgICBsZXQgV2lkZ2V0czsNCiAgICAgICAgKGZ1bmN0aW9uIChXaWRnZXRzKSB7DQogICAgICAgICAgICBjbGFzcyBGaW5kV2lkZ2V0IHsNCiAgICAgICAgICAgICAgICBjb2RlVGhpbmc7DQogICAgICAgICAgICAgICAgZ2FyKHJ1bm5lcikgeyBpZiAodHJ1ZSkgew0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gcnVubmVyKHRoaXMpOw0KICAgICAgICAgICAgICAgIH0gfQ0KICAgICAgICAgICAgICAgIGRvbU5vZGUgPSBudWxsOw0KICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNvZGVUaGluZykgew0KICAgICAgICAgICAgICAgICAgICB0aGlzLmNvZGVUaGluZyA9IGNvZGVUaGluZzsNCiAgICAgICAgICAgICAgICAgICAgLy8gc2NlbmFyaW8gMQ0KICAgICAgICAgICAgICAgICAgICBjb2RlVGhpbmcuYWRkV2lkZ2V0KCJhZGRXaWRnZXQiLCB0aGlzKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgZ2V0RG9tTm9kZSgpIHsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRvbU5vZGU7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgV2lkZ2V0cy5GaW5kV2lkZ2V0ID0gRmluZFdpZGdldDsNCiAgICAgICAgfSkoV2lkZ2V0cyA9IFRoaW5nLldpZGdldHMgfHwgKFRoaW5nLldpZGdldHMgPSB7fSkpOw0KICAgIH0pKFRoaW5nID0gU2FtcGxlLlRoaW5nIHx8IChTYW1wbGUuVGhpbmcgPSB7fSkpOw0KfSkoU2FtcGxlIHx8IChTYW1wbGUgPSB7fSkpOw0KY2xhc3MgQWJzdHJhY3RNb2RlIHsNCiAgICBnZXRJbml0aWFsU3RhdGUoKSB7IHJldHVybiBudWxsOyB9DQp9DQooZnVuY3Rpb24gKFNhbXBsZSkgew0KICAgIGxldCBUaGluZzsNCiAgICAoZnVuY3Rpb24gKFRoaW5nKSB7DQogICAgICAgIGxldCBMYW5ndWFnZXM7DQogICAgICAgIChmdW5jdGlvbiAoTGFuZ3VhZ2VzKSB7DQogICAgICAgICAgICBsZXQgUGxhaW5UZXh0Ow0KICAgICAgICAgICAgKGZ1bmN0aW9uIChQbGFpblRleHQpIHsNCiAgICAgICAgICAgICAgICBjbGFzcyBTdGF0ZSB7DQogICAgICAgICAgICAgICAgICAgIG1vZGU7DQogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1vZGUpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW9kZSA9IG1vZGU7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgY2xvbmUoKSB7DQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpczsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBlcXVhbHMob3RoZXIpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzID09PSBvdGhlcjsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBnZXRNb2RlKCkgeyByZXR1cm4gbW9kZTsgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBQbGFpblRleHQuU3RhdGUgPSBTdGF0ZTsNCiAgICAgICAgICAgICAgICBjbGFzcyBNb2RlIGV4dGVuZHMgQWJzdHJhY3RNb2RlIHsNCiAgICAgICAgICAgICAgICAgICAgLy8gc2NlbmFyaW8gMg0KICAgICAgICAgICAgICAgICAgICBnZXRJbml0aWFsU3RhdGUoKSB7DQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFN0YXRlKHNlbGYpOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIFBsYWluVGV4dC5Nb2RlID0gTW9kZTsNCiAgICAgICAgICAgIH0pKFBsYWluVGV4dCA9IExhbmd1YWdlcy5QbGFpblRleHQgfHwgKExhbmd1YWdlcy5QbGFpblRleHQgPSB7fSkpOw0KICAgICAgICB9KShMYW5ndWFnZXMgPSBUaGluZy5MYW5ndWFnZXMgfHwgKFRoaW5nLkxhbmd1YWdlcyA9IHt9KSk7DQogICAgfSkoVGhpbmcgPSBTYW1wbGUuVGhpbmcgfHwgKFNhbXBsZS5UaGluZyA9IHt9KSk7DQp9KShTYW1wbGUgfHwgKFNhbXBsZSA9IHt9KSk7DQovLyMgc291cmNlTWFwcGluZ1VSTD1yZWN1cnNpdmVDbGFzc1JlZmVyZW5jZVRlc3QuanMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsicmVjdXJzaXZlQ2xhc3NSZWZlcmVuY2VUZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGlFQUFpRTtBQUNqRSwwRUFBMEU7QUE4QjFFLElBQU8sTUFVTjtBQVZELFdBQU8sTUFBTSxFQTFCYjtJQTBCYyxJQUFBLE9BVWI7SUFWYSxXQUFBLE9BQU8sRUExQnJCO1FBMEJzQixJQUFBLEtBVXJCO1FBVnFCLFdBQUEsT0FBSyxFQTFCM0I7WUEwQjRCLElBQUEsSUFVM0I7WUFWMkIsV0FBQSxJQUFJLEVBQUM7Z0JBQ2hDLE1BQWEsZUFBZTtvQkFFcEIsS0FBSyxHQUFHLEVBQUUsT0FBTyxJQUFJLENBQUMsQ0FBQSxDQUFFO29CQUV4QixHQUFHLENBQUMsS0FBNkIsRUFBVTt3QkFFakQsT0FBTyxJQUFJLENBQUM7b0JBQUEsQ0FDWjtpQkFDRDtnQkFSWSxLQUFBLGVBQWUsa0JBUTNCLENBQUE7WUFBQSxDQUNELEVBVjJCLElBQUksR0FBSixRQUFBLElBQUksS0FBSixRQUFBLElBQUksUUFVL0I7UUFEQyxDQUNGLEFBekNBLEVBK0JzQixLQUFLLEdBQUwsUUFBQSxLQUFLLEtBQUwsUUFBQSxLQUFLLFFBVTFCO0lBREMsQ0FDRixBQXpDQSxFQStCYyxPQUFPLEdBQVAsT0FBQSxPQUFPLEtBQVAsT0FBQSxPQUFPLFFBVXBCO0FBREMsQ0FDRixBQXpDQSxFQStCTyxNQUFNLEtBQU4sTUFBTSxRQVVaO0FBRUQsV0FBTyxNQUFNLEVBdENiO0lBc0NjLElBQUEsS0FvQmI7SUFwQmEsV0FBQSxLQUFLLEVBdENuQjtRQXNDb0IsSUFBQSxPQW9CbkI7UUFwQm1CLFdBQUEsT0FBTyxFQUFDO1lBQzNCLE1BQWEsVUFBVTtnQkFLRixTQUFTO2dCQUh0QixHQUFHLENBQUMsTUFBeUMsRUFBRSxFQUFFLElBQUksSUFBSSxFQUFFLENBQUM7b0JBQUEsT0FBTyxNQUFNLENBQUMsSUFBSSxDQUFDLENBQUM7Z0JBQUEsQ0FBQyxDQUFBLENBQUM7Z0JBRWpGLE9BQU8sR0FBTyxJQUFJLENBQUM7Z0JBQzNCLFlBQW9CLFNBQWtDLEVBQUU7cUNBQXBDLFNBQVM7b0JBQ3pCLGFBQWE7b0JBQ2IsU0FBUyxDQUFDLFNBQVMsQ0FBQyxXQUFXLEVBQUUsSUFBSSxDQUFDLENBQUM7Z0JBQUEsQ0FDMUM7Z0JBRU0sVUFBVSxHQUFHO29CQUNuQixPQUFPLE9BQU8sQ0FBQztnQkFBQSxDQUNmO2dCQUVNLE9BQU8sR0FBRztnQkFBQyxDQUVqQjthQUVEO1lBbEJZLFFBQUEsVUFBVSxhQWtCdEIsQ0FBQTtRQUFBLENBQ0QsRUFwQm1CLE9BQU8sR0FBUCxNQUFBLE9BQU8sS0FBUCxNQUFBLE9BQU8sUUFvQjFCO0lBREMsQ0FDRixBQS9EQSxFQTJDYyxLQUFLLEdBQUwsT0FBQSxLQUFLLEtBQUwsT0FBQSxLQUFLLFFBb0JsQjtBQURDLENBQ0YsQUEvREEsRUEyQ08sTUFBTSxLQUFOLE1BQU0sUUFvQlo7QUFHRCxNQUFNLFlBQVk7SUFBMkIsZUFBZSxHQUFXLEVBQUUsT0FBTyxJQUFJLENBQUMsQ0FBQSxDQUFDO0NBQUU7QUFTeEYsV0FBTyxNQUFNLEVBdEViO0lBc0VjLElBQUEsS0F3QmI7SUF4QmEsV0FBQSxLQUFLLEVBdEVuQjtRQXNFb0IsSUFBQSxTQXdCbkI7UUF4Qm1CLFdBQUEsU0FBUyxFQXRFN0I7WUFzRThCLElBQUEsU0F3QjdCO1lBeEI2QixXQUFBLFNBQVMsRUFBQztnQkFFdkMsTUFBYSxLQUFLO29CQUNTLElBQUk7b0JBQXhCLFlBQW9CLElBQVcsRUFBRTtvQ0FBYixJQUFJO29CQUFVLENBQUU7b0JBQ25DLEtBQUssR0FBVTt3QkFDckIsT0FBTyxJQUFJLENBQUM7b0JBQUEsQ0FDWjtvQkFFTSxNQUFNLENBQUMsS0FBWSxFQUFVO3dCQUNuQyxPQUFPLElBQUksS0FBSyxLQUFLLENBQUM7b0JBQUEsQ0FDdEI7b0JBRU0sT0FBTyxHQUFVLEVBQUUsT0FBTyxJQUFJLENBQUMsQ0FBQSxDQUFFO2lCQUN4QztnQkFYWSxVQUFBLEtBQUssUUFXakIsQ0FBQTtnQkFFRCxNQUFhLElBQUssU0FBUSxZQUFZO29CQUVyQyxhQUFhO29CQUNOLGVBQWUsR0FBVzt3QkFDaEMsT0FBTyxJQUFJLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQztvQkFBQSxDQUN2QjtpQkFHRDtnQkFSWSxVQUFBLElBQUksT0FRaEIsQ0FBQTtZQUFBLENBQ0QsRUF4QjZCLFNBQVMsR0FBVCxVQUFBLFNBQVMsS0FBVCxVQUFBLFNBQVMsUUF3QnRDO1FBREMsQ0FDRixBQW5HQSxFQTJFb0IsU0FBUyxHQUFULE1BQUEsU0FBUyxLQUFULE1BQUEsU0FBUyxRQXdCNUI7SUFEQyxDQUNGLEFBbkdBLEVBMkVjLEtBQUssR0FBTCxPQUFBLEtBQUssS0FBTCxPQUFBLEtBQUssUUF3QmxCO0FBREMsQ0FDRixBQW5HQSxFQTJFTyxNQUFNLEtBQU4sTUFBTSxRQXdCWiJ9,Ly8gU2NlbmFyaW8gMTogVGVzdCByZXF1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoICJ0aGlzIiBwYXJhbWV0ZXIKLy8gU2NlbmFyaW8gMjogVGVzdCByZWN1cnNpdmUgZnVuY3Rpb24gY2FsbCB3aXRoIGNhc3QgYW5kICJ0aGlzIiBwYXJhbWV0ZXIKCgoKZGVjbGFyZSBtb2R1bGUgU2FtcGxlLlRoaW5nIHsKCglleHBvcnQgaW50ZXJmYWNlIElXaWRnZXQgewoJCWdldERvbU5vZGUoKTogYW55OwoJCWRlc3Ryb3koKTsKCQlnYXIocnVubmVyOih3aWRnZXQ6U2FtcGxlLlRoaW5nLklXaWRnZXQpPT5hbnkpOmFueTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElDb2RlVGhpbmcgewogIAogIAkJZ2V0RG9tTm9kZSgpOiBFbGVtZW50OwoJCQoJCWFkZFdpZGdldCh3aWRnZXRJZDpzdHJpbmcsIHdpZGdldDpJV2lkZ2V0KTsKCgkJCgkJZm9jdXMoKTsgCgkJCgkJLy9hZGRXaWRnZXQod2lkZ2V0OiBTYW1wbGUuVGhpbmcuV2lkZ2V0cy5JV2lkZ2V0KTsKCX0KCglleHBvcnQgaW50ZXJmYWNlIElBY3Rpb24gewoJCXJ1bihUaGluZzpJQ29kZVRoaW5nKTpib29sZWFuOwoJCWdldElkKCk6c3RyaW5nOwoJfQkKfQoKbW9kdWxlIFNhbXBsZS5BY3Rpb25zLlRoaW5nLkZpbmQgewoJZXhwb3J0IGNsYXNzIFN0YXJ0RmluZEFjdGlvbiBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JQWN0aW9uIHsKCQkKCQlwdWJsaWMgZ2V0SWQoKSB7IHJldHVybiAieW8iOyB9CgkJCgkJcHVibGljIHJ1bihUaGluZzpTYW1wbGUuVGhpbmcuSUNvZGVUaGluZyk6Ym9vbGVhbiB7CgoJCQlyZXR1cm4gdHJ1ZTsKCQl9Cgl9Cn0KCm1vZHVsZSBTYW1wbGUuVGhpbmcuV2lkZ2V0cyB7CglleHBvcnQgY2xhc3MgRmluZFdpZGdldCBpbXBsZW1lbnRzIFNhbXBsZS5UaGluZy5JV2lkZ2V0IHsKCgkJcHVibGljIGdhcihydW5uZXI6KHdpZGdldDpTYW1wbGUuVGhpbmcuSVdpZGdldCk9PmFueSkgeyBpZiAodHJ1ZSkge3JldHVybiBydW5uZXIodGhpcyk7fX0KCQkJCgkJcHJpdmF0ZSBkb21Ob2RlOmFueSA9IG51bGw7CgkJY29uc3RydWN0b3IocHJpdmF0ZSBjb2RlVGhpbmc6IFNhbXBsZS5UaGluZy5JQ29kZVRoaW5nKSB7CgkJICAgIC8vIHNjZW5hcmlvIDEKCQkgICAgY29kZVRoaW5nLmFkZFdpZGdldCgiYWRkV2lkZ2V0IiwgdGhpcyk7CgkJfQoJCQoJCXB1YmxpYyBnZXREb21Ob2RlKCkgewoJCQlyZXR1cm4gZG9tTm9kZTsKCQl9CgkJCgkJcHVibGljIGRlc3Ryb3koKSB7CgoJCX0KCgl9Cn0KCmludGVyZmFjZSBJTW9kZSB7IGdldEluaXRpYWxTdGF0ZSgpOiBJU3RhdGU7fSAKY2xhc3MgQWJzdHJhY3RNb2RlIGltcGxlbWVudHMgSU1vZGUgeyBwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7IHJldHVybiBudWxsO30gfQoKaW50ZXJmYWNlIElTdGF0ZSB7fQoKaW50ZXJmYWNlIFdpbmRvdyB7CiAgICBvcGVuZXI6IFdpbmRvdzsKfQpkZWNsYXJlIHZhciBzZWxmOiBXaW5kb3c7Cgptb2R1bGUgU2FtcGxlLlRoaW5nLkxhbmd1YWdlcy5QbGFpblRleHQgewoJCglleHBvcnQgY2xhc3MgU3RhdGUgaW1wbGVtZW50cyBJU3RhdGUgewkJCiAgICAgICAgY29uc3RydWN0b3IocHJpdmF0ZSBtb2RlOiBJTW9kZSkgeyB9CgkJcHVibGljIGNsb25lKCk6SVN0YXRlIHsKCQkJcmV0dXJuIHRoaXM7CgkJfQoKCQlwdWJsaWMgZXF1YWxzKG90aGVyOklTdGF0ZSk6Ym9vbGVhbiB7CgkJCXJldHVybiB0aGlzID09PSBvdGhlcjsKCQl9CgkJCgkJcHVibGljIGdldE1vZGUoKTogSU1vZGUgeyByZXR1cm4gbW9kZTsgfQoJfQoJCglleHBvcnQgY2xhc3MgTW9kZSBleHRlbmRzIEFic3RyYWN0TW9kZSB7CgoJCS8vIHNjZW5hcmlvIDIKCQlwdWJsaWMgZ2V0SW5pdGlhbFN0YXRlKCk6IElTdGF0ZSB7CgkJCXJldHVybiBuZXcgU3RhdGUoc2VsZik7CgkJfQoKCgl9Cn0KCg== \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.sourcemap.txt b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.sourcemap.txt index 6d5a6d1813..0410811032 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.sourcemap.txt +++ b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.sourcemap.txt @@ -8,13 +8,30 @@ sources: recursiveClassReferenceTest.ts emittedFile:recursiveClassReferenceTest.js sourceFile:recursiveClassReferenceTest.ts ------------------------------------------------------------------- +>>>// Scenario 1: Test reqursive function call with "this" parameter +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^-> +1 > +2 >// Scenario 1: Test reqursive function call with "this" parameter +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 66) Source(1, 66) + SourceIndex(0) +--- +>>>// Scenario 2: Test recursive function call with cast and "this" parameter +1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> + > +2 >// Scenario 2: Test recursive function call with cast and "this" parameter +1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 75) Source(2, 75) + SourceIndex(0) +--- >>>var Sample; 1 > 2 >^^^^ 3 > ^^^^^^ 4 > ^^^^^^^^^^^-> -1 >// Scenario 1: Test reqursive function call with "this" parameter - >// Scenario 2: Test recursive function call with cast and "this" parameter +1 > > > > @@ -57,9 +74,9 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(1, 1) Source(32, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(32, 8) + SourceIndex(0) -3 >Emitted(1, 11) Source(42, 2) + SourceIndex(0) +1 >Emitted(3, 1) Source(32, 1) + SourceIndex(0) +2 >Emitted(3, 5) Source(32, 8) + SourceIndex(0) +3 >Emitted(3, 11) Source(42, 2) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -70,10 +87,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 >module 3 > Sample 4 > -1->Emitted(2, 1) Source(32, 1) + SourceIndex(0) -2 >Emitted(2, 12) Source(32, 8) + SourceIndex(0) -3 >Emitted(2, 18) Source(32, 14) + SourceIndex(0) -4 >Emitted(2, 20) Source(6, 1) + SourceIndex(0) +1->Emitted(4, 1) Source(32, 1) + SourceIndex(0) +2 >Emitted(4, 12) Source(32, 8) + SourceIndex(0) +3 >Emitted(4, 18) Source(32, 14) + SourceIndex(0) +4 >Emitted(4, 20) Source(6, 1) + SourceIndex(0) --- >>> let Actions; 1 >^^^^ @@ -119,9 +136,9 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(3, 5) Source(32, 15) + SourceIndex(0) -2 >Emitted(3, 9) Source(32, 15) + SourceIndex(0) -3 >Emitted(3, 16) Source(42, 2) + SourceIndex(0) +1 >Emitted(5, 5) Source(32, 15) + SourceIndex(0) +2 >Emitted(5, 9) Source(32, 15) + SourceIndex(0) +3 >Emitted(5, 16) Source(42, 2) + SourceIndex(0) --- >>> (function (Actions) { 1->^^^^ @@ -132,10 +149,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > 3 > Actions 4 > -1->Emitted(4, 5) Source(32, 15) + SourceIndex(0) -2 >Emitted(4, 16) Source(32, 15) + SourceIndex(0) -3 >Emitted(4, 23) Source(32, 22) + SourceIndex(0) -4 >Emitted(4, 25) Source(6, 1) + SourceIndex(0) +1->Emitted(6, 5) Source(32, 15) + SourceIndex(0) +2 >Emitted(6, 16) Source(32, 15) + SourceIndex(0) +3 >Emitted(6, 23) Source(32, 22) + SourceIndex(0) +4 >Emitted(6, 25) Source(6, 1) + SourceIndex(0) --- >>> let Thing; 1 >^^^^^^^^ @@ -181,9 +198,9 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(5, 9) Source(32, 23) + SourceIndex(0) -2 >Emitted(5, 13) Source(32, 23) + SourceIndex(0) -3 >Emitted(5, 18) Source(42, 2) + SourceIndex(0) +1 >Emitted(7, 9) Source(32, 23) + SourceIndex(0) +2 >Emitted(7, 13) Source(32, 23) + SourceIndex(0) +3 >Emitted(7, 18) Source(42, 2) + SourceIndex(0) --- >>> (function (Thing_1) { 1->^^^^^^^^ @@ -194,10 +211,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > 3 > Thing 4 > -1->Emitted(6, 9) Source(32, 23) + SourceIndex(0) -2 >Emitted(6, 20) Source(32, 23) + SourceIndex(0) -3 >Emitted(6, 27) Source(32, 28) + SourceIndex(0) -4 >Emitted(6, 29) Source(6, 1) + SourceIndex(0) +1->Emitted(8, 9) Source(32, 23) + SourceIndex(0) +2 >Emitted(8, 20) Source(32, 23) + SourceIndex(0) +3 >Emitted(8, 27) Source(32, 28) + SourceIndex(0) +4 >Emitted(8, 29) Source(6, 1) + SourceIndex(0) --- >>> let Find; 1 >^^^^^^^^^^^^ @@ -243,9 +260,9 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(7, 13) Source(32, 29) + SourceIndex(0) -2 >Emitted(7, 17) Source(32, 29) + SourceIndex(0) -3 >Emitted(7, 21) Source(42, 2) + SourceIndex(0) +1 >Emitted(9, 13) Source(32, 29) + SourceIndex(0) +2 >Emitted(9, 17) Source(32, 29) + SourceIndex(0) +3 >Emitted(9, 21) Source(42, 2) + SourceIndex(0) --- >>> (function (Find) { 1->^^^^^^^^^^^^ @@ -257,10 +274,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > 3 > Find 4 > -1->Emitted(8, 13) Source(32, 29) + SourceIndex(0) -2 >Emitted(8, 24) Source(32, 29) + SourceIndex(0) -3 >Emitted(8, 28) Source(32, 33) + SourceIndex(0) -4 >Emitted(8, 30) Source(32, 34) + SourceIndex(0) +1->Emitted(10, 13) Source(32, 29) + SourceIndex(0) +2 >Emitted(10, 24) Source(32, 29) + SourceIndex(0) +3 >Emitted(10, 28) Source(32, 33) + SourceIndex(0) +4 >Emitted(10, 30) Source(32, 34) + SourceIndex(0) --- >>> class StartFindAction { 1->^^^^^^^^^^^^^^^^ @@ -271,9 +288,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > export class 3 > StartFindAction -1->Emitted(9, 17) Source(33, 2) + SourceIndex(0) -2 >Emitted(9, 23) Source(33, 15) + SourceIndex(0) -3 >Emitted(9, 38) Source(33, 30) + SourceIndex(0) +1->Emitted(11, 17) Source(33, 2) + SourceIndex(0) +2 >Emitted(11, 23) Source(33, 15) + SourceIndex(0) +3 >Emitted(11, 38) Source(33, 30) + SourceIndex(0) --- >>> getId() { return "yo"; } 1->^^^^^^^^^^^^^^^^^^^^ @@ -296,15 +313,15 @@ sourceFile:recursiveClassReferenceTest.ts 7 > ; 8 > 9 > } -1->Emitted(10, 21) Source(35, 10) + SourceIndex(0) -2 >Emitted(10, 26) Source(35, 15) + SourceIndex(0) -3 >Emitted(10, 29) Source(35, 18) + SourceIndex(0) -4 >Emitted(10, 31) Source(35, 20) + SourceIndex(0) -5 >Emitted(10, 38) Source(35, 27) + SourceIndex(0) -6 >Emitted(10, 42) Source(35, 31) + SourceIndex(0) -7 >Emitted(10, 43) Source(35, 32) + SourceIndex(0) -8 >Emitted(10, 44) Source(35, 32) + SourceIndex(0) -9 >Emitted(10, 45) Source(35, 34) + SourceIndex(0) +1->Emitted(12, 21) Source(35, 10) + SourceIndex(0) +2 >Emitted(12, 26) Source(35, 15) + SourceIndex(0) +3 >Emitted(12, 29) Source(35, 18) + SourceIndex(0) +4 >Emitted(12, 31) Source(35, 20) + SourceIndex(0) +5 >Emitted(12, 38) Source(35, 27) + SourceIndex(0) +6 >Emitted(12, 42) Source(35, 31) + SourceIndex(0) +7 >Emitted(12, 43) Source(35, 32) + SourceIndex(0) +8 >Emitted(12, 44) Source(35, 32) + SourceIndex(0) +9 >Emitted(12, 45) Source(35, 34) + SourceIndex(0) --- >>> run(Thing) { 1 >^^^^^^^^^^^^^^^^^^^^ @@ -320,11 +337,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ( 4 > Thing:Sample.Thing.ICodeThing 5 > ):boolean -1 >Emitted(11, 21) Source(37, 10) + SourceIndex(0) -2 >Emitted(11, 24) Source(37, 13) + SourceIndex(0) -3 >Emitted(11, 25) Source(37, 14) + SourceIndex(0) -4 >Emitted(11, 30) Source(37, 43) + SourceIndex(0) -5 >Emitted(11, 32) Source(37, 53) + SourceIndex(0) +1 >Emitted(13, 21) Source(37, 10) + SourceIndex(0) +2 >Emitted(13, 24) Source(37, 13) + SourceIndex(0) +3 >Emitted(13, 25) Source(37, 14) + SourceIndex(0) +4 >Emitted(13, 30) Source(37, 43) + SourceIndex(0) +5 >Emitted(13, 32) Source(37, 53) + SourceIndex(0) --- >>> return true; 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -337,10 +354,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > return 3 > true 4 > ; -1->Emitted(12, 25) Source(39, 4) + SourceIndex(0) -2 >Emitted(12, 32) Source(39, 11) + SourceIndex(0) -3 >Emitted(12, 36) Source(39, 15) + SourceIndex(0) -4 >Emitted(12, 37) Source(39, 16) + SourceIndex(0) +1->Emitted(14, 25) Source(39, 4) + SourceIndex(0) +2 >Emitted(14, 32) Source(39, 11) + SourceIndex(0) +3 >Emitted(14, 36) Source(39, 15) + SourceIndex(0) +4 >Emitted(14, 37) Source(39, 16) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -348,15 +365,15 @@ sourceFile:recursiveClassReferenceTest.ts 1 > 2 > > } -1 >Emitted(13, 21) Source(39, 16) + SourceIndex(0) -2 >Emitted(13, 22) Source(40, 4) + SourceIndex(0) +1 >Emitted(15, 21) Source(39, 16) + SourceIndex(0) +2 >Emitted(15, 22) Source(40, 4) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > } -1 >Emitted(14, 18) Source(41, 3) + SourceIndex(0) +1 >Emitted(16, 18) Source(41, 3) + SourceIndex(0) --- >>> Find.StartFindAction = StartFindAction; 1->^^^^^^^^^^^^^^^^ @@ -378,11 +395,11 @@ sourceFile:recursiveClassReferenceTest.ts > } > } 5 > -1->Emitted(15, 17) Source(33, 15) + SourceIndex(0) -2 >Emitted(15, 22) Source(33, 15) + SourceIndex(0) -3 >Emitted(15, 37) Source(33, 30) + SourceIndex(0) -4 >Emitted(15, 55) Source(41, 3) + SourceIndex(0) -5 >Emitted(15, 56) Source(41, 3) + SourceIndex(0) +1->Emitted(17, 17) Source(33, 15) + SourceIndex(0) +2 >Emitted(17, 22) Source(33, 15) + SourceIndex(0) +3 >Emitted(17, 37) Source(33, 30) + SourceIndex(0) +4 >Emitted(17, 55) Source(41, 3) + SourceIndex(0) +5 >Emitted(17, 56) Source(41, 3) + SourceIndex(0) --- >>> })(Find = Thing_1.Find || (Thing_1.Find = {})); 1->^^^^^^^^^^^^ @@ -418,17 +435,17 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1->Emitted(16, 13) Source(41, 3) + SourceIndex(0) -2 >Emitted(16, 14) Source(42, 2) + SourceIndex(0) -3 >Emitted(16, 16) Source(32, 29) + SourceIndex(0) -4 >Emitted(16, 20) Source(32, 33) + SourceIndex(0) -5 >Emitted(16, 23) Source(32, 29) + SourceIndex(0) -6 >Emitted(16, 31) Source(32, 29) + SourceIndex(0) -7 >Emitted(16, 35) Source(32, 33) + SourceIndex(0) -8 >Emitted(16, 40) Source(32, 29) + SourceIndex(0) -9 >Emitted(16, 48) Source(32, 29) + SourceIndex(0) -10>Emitted(16, 52) Source(32, 33) + SourceIndex(0) -11>Emitted(16, 60) Source(42, 2) + SourceIndex(0) +1->Emitted(18, 13) Source(41, 3) + SourceIndex(0) +2 >Emitted(18, 14) Source(42, 2) + SourceIndex(0) +3 >Emitted(18, 16) Source(32, 29) + SourceIndex(0) +4 >Emitted(18, 20) Source(32, 33) + SourceIndex(0) +5 >Emitted(18, 23) Source(32, 29) + SourceIndex(0) +6 >Emitted(18, 31) Source(32, 29) + SourceIndex(0) +7 >Emitted(18, 35) Source(32, 33) + SourceIndex(0) +8 >Emitted(18, 40) Source(32, 29) + SourceIndex(0) +9 >Emitted(18, 48) Source(32, 29) + SourceIndex(0) +10>Emitted(18, 52) Source(32, 33) + SourceIndex(0) +11>Emitted(18, 60) Source(42, 2) + SourceIndex(0) --- >>> })(Thing = Actions.Thing || (Actions.Thing = {})); 1 >^^^^^^^^ @@ -498,18 +515,18 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(17, 9) Source(41, 3) + SourceIndex(0) -2 >Emitted(17, 10) Source(42, 1) + SourceIndex(0) -3 >Emitted(17, 10) Source(1, 1) + SourceIndex(0) -4 >Emitted(17, 12) Source(32, 23) + SourceIndex(0) -5 >Emitted(17, 17) Source(32, 28) + SourceIndex(0) -6 >Emitted(17, 20) Source(32, 23) + SourceIndex(0) -7 >Emitted(17, 28) Source(32, 23) + SourceIndex(0) -8 >Emitted(17, 33) Source(32, 28) + SourceIndex(0) -9 >Emitted(17, 38) Source(32, 23) + SourceIndex(0) -10>Emitted(17, 46) Source(32, 23) + SourceIndex(0) -11>Emitted(17, 51) Source(32, 28) + SourceIndex(0) -12>Emitted(17, 59) Source(42, 2) + SourceIndex(0) +1 >Emitted(19, 9) Source(41, 3) + SourceIndex(0) +2 >Emitted(19, 10) Source(42, 1) + SourceIndex(0) +3 >Emitted(19, 10) Source(1, 1) + SourceIndex(0) +4 >Emitted(19, 12) Source(32, 23) + SourceIndex(0) +5 >Emitted(19, 17) Source(32, 28) + SourceIndex(0) +6 >Emitted(19, 20) Source(32, 23) + SourceIndex(0) +7 >Emitted(19, 28) Source(32, 23) + SourceIndex(0) +8 >Emitted(19, 33) Source(32, 28) + SourceIndex(0) +9 >Emitted(19, 38) Source(32, 23) + SourceIndex(0) +10>Emitted(19, 46) Source(32, 23) + SourceIndex(0) +11>Emitted(19, 51) Source(32, 28) + SourceIndex(0) +12>Emitted(19, 59) Source(42, 2) + SourceIndex(0) --- >>> })(Actions = Sample.Actions || (Sample.Actions = {})); 1->^^^^ @@ -578,18 +595,18 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1->Emitted(18, 5) Source(41, 3) + SourceIndex(0) -2 >Emitted(18, 6) Source(42, 1) + SourceIndex(0) -3 >Emitted(18, 6) Source(1, 1) + SourceIndex(0) -4 >Emitted(18, 8) Source(32, 15) + SourceIndex(0) -5 >Emitted(18, 15) Source(32, 22) + SourceIndex(0) -6 >Emitted(18, 18) Source(32, 15) + SourceIndex(0) -7 >Emitted(18, 25) Source(32, 15) + SourceIndex(0) -8 >Emitted(18, 32) Source(32, 22) + SourceIndex(0) -9 >Emitted(18, 37) Source(32, 15) + SourceIndex(0) -10>Emitted(18, 44) Source(32, 15) + SourceIndex(0) -11>Emitted(18, 51) Source(32, 22) + SourceIndex(0) -12>Emitted(18, 59) Source(42, 2) + SourceIndex(0) +1->Emitted(20, 5) Source(41, 3) + SourceIndex(0) +2 >Emitted(20, 6) Source(42, 1) + SourceIndex(0) +3 >Emitted(20, 6) Source(1, 1) + SourceIndex(0) +4 >Emitted(20, 8) Source(32, 15) + SourceIndex(0) +5 >Emitted(20, 15) Source(32, 22) + SourceIndex(0) +6 >Emitted(20, 18) Source(32, 15) + SourceIndex(0) +7 >Emitted(20, 25) Source(32, 15) + SourceIndex(0) +8 >Emitted(20, 32) Source(32, 22) + SourceIndex(0) +9 >Emitted(20, 37) Source(32, 15) + SourceIndex(0) +10>Emitted(20, 44) Source(32, 15) + SourceIndex(0) +11>Emitted(20, 51) Source(32, 22) + SourceIndex(0) +12>Emitted(20, 59) Source(42, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -650,14 +667,14 @@ sourceFile:recursiveClassReferenceTest.ts > } > } > } -1 >Emitted(19, 1) Source(41, 3) + SourceIndex(0) -2 >Emitted(19, 2) Source(42, 1) + SourceIndex(0) -3 >Emitted(19, 2) Source(1, 1) + SourceIndex(0) -4 >Emitted(19, 4) Source(32, 8) + SourceIndex(0) -5 >Emitted(19, 10) Source(32, 14) + SourceIndex(0) -6 >Emitted(19, 15) Source(32, 8) + SourceIndex(0) -7 >Emitted(19, 21) Source(32, 14) + SourceIndex(0) -8 >Emitted(19, 29) Source(42, 2) + SourceIndex(0) +1 >Emitted(21, 1) Source(41, 3) + SourceIndex(0) +2 >Emitted(21, 2) Source(42, 1) + SourceIndex(0) +3 >Emitted(21, 2) Source(1, 1) + SourceIndex(0) +4 >Emitted(21, 4) Source(32, 8) + SourceIndex(0) +5 >Emitted(21, 10) Source(32, 14) + SourceIndex(0) +6 >Emitted(21, 15) Source(32, 8) + SourceIndex(0) +7 >Emitted(21, 21) Source(32, 14) + SourceIndex(0) +8 >Emitted(21, 29) Source(42, 2) + SourceIndex(0) --- >>>(function (Sample) { 1 > @@ -670,10 +687,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 >module 3 > Sample 4 > -1 >Emitted(20, 1) Source(44, 1) + SourceIndex(0) -2 >Emitted(20, 12) Source(44, 8) + SourceIndex(0) -3 >Emitted(20, 18) Source(44, 14) + SourceIndex(0) -4 >Emitted(20, 20) Source(6, 1) + SourceIndex(0) +1 >Emitted(22, 1) Source(44, 1) + SourceIndex(0) +2 >Emitted(22, 12) Source(44, 8) + SourceIndex(0) +3 >Emitted(22, 18) Source(44, 14) + SourceIndex(0) +4 >Emitted(22, 20) Source(6, 1) + SourceIndex(0) --- >>> let Thing; 1 >^^^^ @@ -741,9 +758,9 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(21, 5) Source(44, 15) + SourceIndex(0) -2 >Emitted(21, 9) Source(44, 15) + SourceIndex(0) -3 >Emitted(21, 14) Source(64, 2) + SourceIndex(0) +1 >Emitted(23, 5) Source(44, 15) + SourceIndex(0) +2 >Emitted(23, 9) Source(44, 15) + SourceIndex(0) +3 >Emitted(23, 14) Source(64, 2) + SourceIndex(0) --- >>> (function (Thing) { 1->^^^^ @@ -754,10 +771,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > 3 > Thing 4 > -1->Emitted(22, 5) Source(44, 15) + SourceIndex(0) -2 >Emitted(22, 16) Source(44, 15) + SourceIndex(0) -3 >Emitted(22, 21) Source(44, 20) + SourceIndex(0) -4 >Emitted(22, 23) Source(6, 1) + SourceIndex(0) +1->Emitted(24, 5) Source(44, 15) + SourceIndex(0) +2 >Emitted(24, 16) Source(44, 15) + SourceIndex(0) +3 >Emitted(24, 21) Source(44, 20) + SourceIndex(0) +4 >Emitted(24, 23) Source(6, 1) + SourceIndex(0) --- >>> let Widgets; 1 >^^^^^^^^ @@ -825,9 +842,9 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(23, 9) Source(44, 21) + SourceIndex(0) -2 >Emitted(23, 13) Source(44, 21) + SourceIndex(0) -3 >Emitted(23, 20) Source(64, 2) + SourceIndex(0) +1 >Emitted(25, 9) Source(44, 21) + SourceIndex(0) +2 >Emitted(25, 13) Source(44, 21) + SourceIndex(0) +3 >Emitted(25, 20) Source(64, 2) + SourceIndex(0) --- >>> (function (Widgets) { 1->^^^^^^^^ @@ -839,10 +856,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > 3 > Widgets 4 > -1->Emitted(24, 9) Source(44, 21) + SourceIndex(0) -2 >Emitted(24, 20) Source(44, 21) + SourceIndex(0) -3 >Emitted(24, 27) Source(44, 28) + SourceIndex(0) -4 >Emitted(24, 29) Source(44, 29) + SourceIndex(0) +1->Emitted(26, 9) Source(44, 21) + SourceIndex(0) +2 >Emitted(26, 20) Source(44, 21) + SourceIndex(0) +3 >Emitted(26, 27) Source(44, 28) + SourceIndex(0) +4 >Emitted(26, 29) Source(44, 29) + SourceIndex(0) --- >>> class FindWidget { 1->^^^^^^^^^^^^ @@ -852,9 +869,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > export class 3 > FindWidget -1->Emitted(25, 13) Source(45, 2) + SourceIndex(0) -2 >Emitted(25, 19) Source(45, 15) + SourceIndex(0) -3 >Emitted(25, 29) Source(45, 25) + SourceIndex(0) +1->Emitted(27, 13) Source(45, 2) + SourceIndex(0) +2 >Emitted(27, 19) Source(45, 15) + SourceIndex(0) +3 >Emitted(27, 29) Source(45, 25) + SourceIndex(0) --- >>> codeThing; 1 >^^^^^^^^^^^^^^^^ @@ -867,8 +884,8 @@ sourceFile:recursiveClassReferenceTest.ts > private domNode:any = null; > constructor(private 2 > codeThing -1 >Emitted(26, 17) Source(50, 23) + SourceIndex(0) -2 >Emitted(26, 26) Source(50, 32) + SourceIndex(0) +1 >Emitted(28, 17) Source(50, 23) + SourceIndex(0) +2 >Emitted(28, 26) Source(50, 32) + SourceIndex(0) --- >>> gar(runner) { if (true) { 1->^^^^^^^^^^^^^^^^ @@ -891,16 +908,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > true 9 > ) 10> { -1->Emitted(27, 17) Source(47, 10) + SourceIndex(0) -2 >Emitted(27, 20) Source(47, 13) + SourceIndex(0) -3 >Emitted(27, 21) Source(47, 14) + SourceIndex(0) -4 >Emitted(27, 27) Source(47, 55) + SourceIndex(0) -5 >Emitted(27, 29) Source(47, 57) + SourceIndex(0) -6 >Emitted(27, 31) Source(47, 59) + SourceIndex(0) -7 >Emitted(27, 35) Source(47, 63) + SourceIndex(0) -8 >Emitted(27, 39) Source(47, 67) + SourceIndex(0) -9 >Emitted(27, 41) Source(47, 69) + SourceIndex(0) -10>Emitted(27, 42) Source(47, 70) + SourceIndex(0) +1->Emitted(29, 17) Source(47, 10) + SourceIndex(0) +2 >Emitted(29, 20) Source(47, 13) + SourceIndex(0) +3 >Emitted(29, 21) Source(47, 14) + SourceIndex(0) +4 >Emitted(29, 27) Source(47, 55) + SourceIndex(0) +5 >Emitted(29, 29) Source(47, 57) + SourceIndex(0) +6 >Emitted(29, 31) Source(47, 59) + SourceIndex(0) +7 >Emitted(29, 35) Source(47, 63) + SourceIndex(0) +8 >Emitted(29, 39) Source(47, 67) + SourceIndex(0) +9 >Emitted(29, 41) Source(47, 69) + SourceIndex(0) +10>Emitted(29, 42) Source(47, 70) + SourceIndex(0) --- >>> return runner(this); 1 >^^^^^^^^^^^^^^^^^^^^ @@ -917,13 +934,13 @@ sourceFile:recursiveClassReferenceTest.ts 5 > this 6 > ) 7 > ; -1 >Emitted(28, 21) Source(47, 70) + SourceIndex(0) -2 >Emitted(28, 28) Source(47, 77) + SourceIndex(0) -3 >Emitted(28, 34) Source(47, 83) + SourceIndex(0) -4 >Emitted(28, 35) Source(47, 84) + SourceIndex(0) -5 >Emitted(28, 39) Source(47, 88) + SourceIndex(0) -6 >Emitted(28, 40) Source(47, 89) + SourceIndex(0) -7 >Emitted(28, 41) Source(47, 90) + SourceIndex(0) +1 >Emitted(30, 21) Source(47, 70) + SourceIndex(0) +2 >Emitted(30, 28) Source(47, 77) + SourceIndex(0) +3 >Emitted(30, 34) Source(47, 83) + SourceIndex(0) +4 >Emitted(30, 35) Source(47, 84) + SourceIndex(0) +5 >Emitted(30, 39) Source(47, 88) + SourceIndex(0) +6 >Emitted(30, 40) Source(47, 89) + SourceIndex(0) +7 >Emitted(30, 41) Source(47, 90) + SourceIndex(0) --- >>> } } 1 >^^^^^^^^^^^^^^^^ @@ -935,10 +952,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > } 3 > 4 > } -1 >Emitted(29, 17) Source(47, 90) + SourceIndex(0) -2 >Emitted(29, 18) Source(47, 91) + SourceIndex(0) -3 >Emitted(29, 19) Source(47, 91) + SourceIndex(0) -4 >Emitted(29, 20) Source(47, 92) + SourceIndex(0) +1 >Emitted(31, 17) Source(47, 90) + SourceIndex(0) +2 >Emitted(31, 18) Source(47, 91) + SourceIndex(0) +3 >Emitted(31, 19) Source(47, 91) + SourceIndex(0) +4 >Emitted(31, 20) Source(47, 92) + SourceIndex(0) --- >>> domNode = null; 1->^^^^^^^^^^^^^^^^ @@ -954,11 +971,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > :any = 4 > null 5 > ; -1->Emitted(30, 17) Source(49, 11) + SourceIndex(0) -2 >Emitted(30, 24) Source(49, 18) + SourceIndex(0) -3 >Emitted(30, 27) Source(49, 25) + SourceIndex(0) -4 >Emitted(30, 31) Source(49, 29) + SourceIndex(0) -5 >Emitted(30, 32) Source(49, 30) + SourceIndex(0) +1->Emitted(32, 17) Source(49, 11) + SourceIndex(0) +2 >Emitted(32, 24) Source(49, 18) + SourceIndex(0) +3 >Emitted(32, 27) Source(49, 25) + SourceIndex(0) +4 >Emitted(32, 31) Source(49, 29) + SourceIndex(0) +5 >Emitted(32, 32) Source(49, 30) + SourceIndex(0) --- >>> constructor(codeThing) { 1->^^^^^^^^^^^^^^^^ @@ -971,18 +988,18 @@ sourceFile:recursiveClassReferenceTest.ts 2 > constructor(private 3 > codeThing: Sample.Thing.ICodeThing 4 > ) -1->Emitted(31, 17) Source(50, 3) + SourceIndex(0) -2 >Emitted(31, 29) Source(50, 23) + SourceIndex(0) -3 >Emitted(31, 38) Source(50, 57) + SourceIndex(0) -4 >Emitted(31, 40) Source(50, 59) + SourceIndex(0) +1->Emitted(33, 17) Source(50, 3) + SourceIndex(0) +2 >Emitted(33, 29) Source(50, 23) + SourceIndex(0) +3 >Emitted(33, 38) Source(50, 57) + SourceIndex(0) +4 >Emitted(33, 40) Source(50, 59) + SourceIndex(0) --- >>> this.codeThing = codeThing; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^ 1-> 2 > codeThing -1->Emitted(32, 38) Source(50, 23) + SourceIndex(0) -2 >Emitted(32, 47) Source(50, 32) + SourceIndex(0) +1->Emitted(34, 38) Source(50, 23) + SourceIndex(0) +2 >Emitted(34, 47) Source(50, 32) + SourceIndex(0) --- >>> // scenario 1 1 >^^^^^^^^^^^^^^^^^^^^ @@ -991,8 +1008,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 >: Sample.Thing.ICodeThing) { > 2 > // scenario 1 -1 >Emitted(33, 21) Source(51, 7) + SourceIndex(0) -2 >Emitted(33, 34) Source(51, 20) + SourceIndex(0) +1 >Emitted(35, 21) Source(51, 7) + SourceIndex(0) +2 >Emitted(35, 34) Source(51, 20) + SourceIndex(0) --- >>> codeThing.addWidget("addWidget", this); 1->^^^^^^^^^^^^^^^^^^^^ @@ -1016,16 +1033,16 @@ sourceFile:recursiveClassReferenceTest.ts 8 > this 9 > ) 10> ; -1->Emitted(34, 21) Source(52, 7) + SourceIndex(0) -2 >Emitted(34, 30) Source(52, 16) + SourceIndex(0) -3 >Emitted(34, 31) Source(52, 17) + SourceIndex(0) -4 >Emitted(34, 40) Source(52, 26) + SourceIndex(0) -5 >Emitted(34, 41) Source(52, 27) + SourceIndex(0) -6 >Emitted(34, 52) Source(52, 38) + SourceIndex(0) -7 >Emitted(34, 54) Source(52, 40) + SourceIndex(0) -8 >Emitted(34, 58) Source(52, 44) + SourceIndex(0) -9 >Emitted(34, 59) Source(52, 45) + SourceIndex(0) -10>Emitted(34, 60) Source(52, 46) + SourceIndex(0) +1->Emitted(36, 21) Source(52, 7) + SourceIndex(0) +2 >Emitted(36, 30) Source(52, 16) + SourceIndex(0) +3 >Emitted(36, 31) Source(52, 17) + SourceIndex(0) +4 >Emitted(36, 40) Source(52, 26) + SourceIndex(0) +5 >Emitted(36, 41) Source(52, 27) + SourceIndex(0) +6 >Emitted(36, 52) Source(52, 38) + SourceIndex(0) +7 >Emitted(36, 54) Source(52, 40) + SourceIndex(0) +8 >Emitted(36, 58) Source(52, 44) + SourceIndex(0) +9 >Emitted(36, 59) Source(52, 45) + SourceIndex(0) +10>Emitted(36, 60) Source(52, 46) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^ @@ -1034,8 +1051,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > 2 > > } -1 >Emitted(35, 17) Source(52, 46) + SourceIndex(0) -2 >Emitted(35, 18) Source(53, 4) + SourceIndex(0) +1 >Emitted(37, 17) Source(52, 46) + SourceIndex(0) +2 >Emitted(37, 18) Source(53, 4) + SourceIndex(0) --- >>> getDomNode() { 1->^^^^^^^^^^^^^^^^ @@ -1047,9 +1064,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > getDomNode 3 > () -1->Emitted(36, 17) Source(55, 10) + SourceIndex(0) -2 >Emitted(36, 27) Source(55, 20) + SourceIndex(0) -3 >Emitted(36, 30) Source(55, 23) + SourceIndex(0) +1->Emitted(38, 17) Source(55, 10) + SourceIndex(0) +2 >Emitted(38, 27) Source(55, 20) + SourceIndex(0) +3 >Emitted(38, 30) Source(55, 23) + SourceIndex(0) --- >>> return domNode; 1->^^^^^^^^^^^^^^^^^^^^ @@ -1061,10 +1078,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > return 3 > domNode 4 > ; -1->Emitted(37, 21) Source(56, 4) + SourceIndex(0) -2 >Emitted(37, 28) Source(56, 11) + SourceIndex(0) -3 >Emitted(37, 35) Source(56, 18) + SourceIndex(0) -4 >Emitted(37, 36) Source(56, 19) + SourceIndex(0) +1->Emitted(39, 21) Source(56, 4) + SourceIndex(0) +2 >Emitted(39, 28) Source(56, 11) + SourceIndex(0) +3 >Emitted(39, 35) Source(56, 18) + SourceIndex(0) +4 >Emitted(39, 36) Source(56, 19) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^ @@ -1073,8 +1090,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > 2 > > } -1 >Emitted(38, 17) Source(56, 19) + SourceIndex(0) -2 >Emitted(38, 18) Source(57, 4) + SourceIndex(0) +1 >Emitted(40, 17) Source(56, 19) + SourceIndex(0) +2 >Emitted(40, 18) Source(57, 4) + SourceIndex(0) --- >>> destroy() { 1->^^^^^^^^^^^^^^^^ @@ -1085,9 +1102,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > destroy 3 > () -1->Emitted(39, 17) Source(59, 10) + SourceIndex(0) -2 >Emitted(39, 24) Source(59, 17) + SourceIndex(0) -3 >Emitted(39, 27) Source(59, 20) + SourceIndex(0) +1->Emitted(41, 17) Source(59, 10) + SourceIndex(0) +2 >Emitted(41, 24) Source(59, 17) + SourceIndex(0) +3 >Emitted(41, 27) Source(59, 20) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^ @@ -1096,8 +1113,8 @@ sourceFile:recursiveClassReferenceTest.ts 2 > > > } -1 >Emitted(40, 17) Source(59, 21) + SourceIndex(0) -2 >Emitted(40, 18) Source(61, 4) + SourceIndex(0) +1 >Emitted(42, 17) Source(59, 21) + SourceIndex(0) +2 >Emitted(42, 18) Source(61, 4) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^ @@ -1105,7 +1122,7 @@ sourceFile:recursiveClassReferenceTest.ts 1 > > > } -1 >Emitted(41, 14) Source(63, 3) + SourceIndex(0) +1 >Emitted(43, 14) Source(63, 3) + SourceIndex(0) --- >>> Widgets.FindWidget = FindWidget; 1->^^^^^^^^^^^^ @@ -1137,11 +1154,11 @@ sourceFile:recursiveClassReferenceTest.ts > > } 5 > -1->Emitted(42, 13) Source(45, 15) + SourceIndex(0) -2 >Emitted(42, 21) Source(45, 15) + SourceIndex(0) -3 >Emitted(42, 31) Source(45, 25) + SourceIndex(0) -4 >Emitted(42, 44) Source(63, 3) + SourceIndex(0) -5 >Emitted(42, 45) Source(63, 3) + SourceIndex(0) +1->Emitted(44, 13) Source(45, 15) + SourceIndex(0) +2 >Emitted(44, 21) Source(45, 15) + SourceIndex(0) +3 >Emitted(44, 31) Source(45, 25) + SourceIndex(0) +4 >Emitted(44, 44) Source(63, 3) + SourceIndex(0) +5 >Emitted(44, 45) Source(63, 3) + SourceIndex(0) --- >>> })(Widgets = Thing.Widgets || (Thing.Widgets = {})); 1->^^^^^^^^ @@ -1187,17 +1204,17 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(43, 9) Source(63, 3) + SourceIndex(0) -2 >Emitted(43, 10) Source(64, 2) + SourceIndex(0) -3 >Emitted(43, 12) Source(44, 21) + SourceIndex(0) -4 >Emitted(43, 19) Source(44, 28) + SourceIndex(0) -5 >Emitted(43, 22) Source(44, 21) + SourceIndex(0) -6 >Emitted(43, 28) Source(44, 21) + SourceIndex(0) -7 >Emitted(43, 35) Source(44, 28) + SourceIndex(0) -8 >Emitted(43, 40) Source(44, 21) + SourceIndex(0) -9 >Emitted(43, 46) Source(44, 21) + SourceIndex(0) -10>Emitted(43, 53) Source(44, 28) + SourceIndex(0) -11>Emitted(43, 61) Source(64, 2) + SourceIndex(0) +1->Emitted(45, 9) Source(63, 3) + SourceIndex(0) +2 >Emitted(45, 10) Source(64, 2) + SourceIndex(0) +3 >Emitted(45, 12) Source(44, 21) + SourceIndex(0) +4 >Emitted(45, 19) Source(44, 28) + SourceIndex(0) +5 >Emitted(45, 22) Source(44, 21) + SourceIndex(0) +6 >Emitted(45, 28) Source(44, 21) + SourceIndex(0) +7 >Emitted(45, 35) Source(44, 28) + SourceIndex(0) +8 >Emitted(45, 40) Source(44, 21) + SourceIndex(0) +9 >Emitted(45, 46) Source(44, 21) + SourceIndex(0) +10>Emitted(45, 53) Source(44, 28) + SourceIndex(0) +11>Emitted(45, 61) Source(64, 2) + SourceIndex(0) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -1288,18 +1305,18 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(44, 5) Source(63, 3) + SourceIndex(0) -2 >Emitted(44, 6) Source(64, 1) + SourceIndex(0) -3 >Emitted(44, 6) Source(1, 1) + SourceIndex(0) -4 >Emitted(44, 8) Source(44, 15) + SourceIndex(0) -5 >Emitted(44, 13) Source(44, 20) + SourceIndex(0) -6 >Emitted(44, 16) Source(44, 15) + SourceIndex(0) -7 >Emitted(44, 23) Source(44, 15) + SourceIndex(0) -8 >Emitted(44, 28) Source(44, 20) + SourceIndex(0) -9 >Emitted(44, 33) Source(44, 15) + SourceIndex(0) -10>Emitted(44, 40) Source(44, 15) + SourceIndex(0) -11>Emitted(44, 45) Source(44, 20) + SourceIndex(0) -12>Emitted(44, 53) Source(64, 2) + SourceIndex(0) +1 >Emitted(46, 5) Source(63, 3) + SourceIndex(0) +2 >Emitted(46, 6) Source(64, 1) + SourceIndex(0) +3 >Emitted(46, 6) Source(1, 1) + SourceIndex(0) +4 >Emitted(46, 8) Source(44, 15) + SourceIndex(0) +5 >Emitted(46, 13) Source(44, 20) + SourceIndex(0) +6 >Emitted(46, 16) Source(44, 15) + SourceIndex(0) +7 >Emitted(46, 23) Source(44, 15) + SourceIndex(0) +8 >Emitted(46, 28) Source(44, 20) + SourceIndex(0) +9 >Emitted(46, 33) Source(44, 15) + SourceIndex(0) +10>Emitted(46, 40) Source(44, 15) + SourceIndex(0) +11>Emitted(46, 45) Source(44, 20) + SourceIndex(0) +12>Emitted(46, 53) Source(64, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -1382,14 +1399,14 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(45, 1) Source(63, 3) + SourceIndex(0) -2 >Emitted(45, 2) Source(64, 1) + SourceIndex(0) -3 >Emitted(45, 2) Source(1, 1) + SourceIndex(0) -4 >Emitted(45, 4) Source(44, 8) + SourceIndex(0) -5 >Emitted(45, 10) Source(44, 14) + SourceIndex(0) -6 >Emitted(45, 15) Source(44, 8) + SourceIndex(0) -7 >Emitted(45, 21) Source(44, 14) + SourceIndex(0) -8 >Emitted(45, 29) Source(64, 2) + SourceIndex(0) +1 >Emitted(47, 1) Source(63, 3) + SourceIndex(0) +2 >Emitted(47, 2) Source(64, 1) + SourceIndex(0) +3 >Emitted(47, 2) Source(1, 1) + SourceIndex(0) +4 >Emitted(47, 4) Source(44, 8) + SourceIndex(0) +5 >Emitted(47, 10) Source(44, 14) + SourceIndex(0) +6 >Emitted(47, 15) Source(44, 8) + SourceIndex(0) +7 >Emitted(47, 21) Source(44, 14) + SourceIndex(0) +8 >Emitted(47, 29) Source(64, 2) + SourceIndex(0) --- >>>class AbstractMode { 1 > @@ -1402,9 +1419,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 >class 3 > AbstractMode -1 >Emitted(46, 1) Source(67, 1) + SourceIndex(0) -2 >Emitted(46, 7) Source(67, 7) + SourceIndex(0) -3 >Emitted(46, 19) Source(67, 19) + SourceIndex(0) +1 >Emitted(48, 1) Source(67, 1) + SourceIndex(0) +2 >Emitted(48, 7) Source(67, 7) + SourceIndex(0) +3 >Emitted(48, 19) Source(67, 19) + SourceIndex(0) --- >>> getInitialState() { return null; } 1->^^^^ @@ -1425,21 +1442,21 @@ sourceFile:recursiveClassReferenceTest.ts 7 > ; 8 > 9 > } -1->Emitted(47, 5) Source(67, 46) + SourceIndex(0) -2 >Emitted(47, 20) Source(67, 61) + SourceIndex(0) -3 >Emitted(47, 23) Source(67, 72) + SourceIndex(0) -4 >Emitted(47, 25) Source(67, 74) + SourceIndex(0) -5 >Emitted(47, 32) Source(67, 81) + SourceIndex(0) -6 >Emitted(47, 36) Source(67, 85) + SourceIndex(0) -7 >Emitted(47, 37) Source(67, 86) + SourceIndex(0) -8 >Emitted(47, 38) Source(67, 86) + SourceIndex(0) -9 >Emitted(47, 39) Source(67, 87) + SourceIndex(0) +1->Emitted(49, 5) Source(67, 46) + SourceIndex(0) +2 >Emitted(49, 20) Source(67, 61) + SourceIndex(0) +3 >Emitted(49, 23) Source(67, 72) + SourceIndex(0) +4 >Emitted(49, 25) Source(67, 74) + SourceIndex(0) +5 >Emitted(49, 32) Source(67, 81) + SourceIndex(0) +6 >Emitted(49, 36) Source(67, 85) + SourceIndex(0) +7 >Emitted(49, 37) Source(67, 86) + SourceIndex(0) +8 >Emitted(49, 38) Source(67, 86) + SourceIndex(0) +9 >Emitted(49, 39) Source(67, 87) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(48, 2) Source(67, 89) + SourceIndex(0) +1 >Emitted(50, 2) Source(67, 89) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -1459,10 +1476,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 >module 3 > Sample 4 > -1->Emitted(49, 1) Source(76, 1) + SourceIndex(0) -2 >Emitted(49, 12) Source(76, 8) + SourceIndex(0) -3 >Emitted(49, 18) Source(76, 14) + SourceIndex(0) -4 >Emitted(49, 20) Source(6, 1) + SourceIndex(0) +1->Emitted(51, 1) Source(76, 1) + SourceIndex(0) +2 >Emitted(51, 12) Source(76, 8) + SourceIndex(0) +3 >Emitted(51, 18) Source(76, 14) + SourceIndex(0) +4 >Emitted(51, 20) Source(6, 1) + SourceIndex(0) --- >>> let Thing; 1 >^^^^ @@ -1566,9 +1583,9 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(50, 5) Source(76, 15) + SourceIndex(0) -2 >Emitted(50, 9) Source(76, 15) + SourceIndex(0) -3 >Emitted(50, 14) Source(100, 2) + SourceIndex(0) +1 >Emitted(52, 5) Source(76, 15) + SourceIndex(0) +2 >Emitted(52, 9) Source(76, 15) + SourceIndex(0) +3 >Emitted(52, 14) Source(100, 2) + SourceIndex(0) --- >>> (function (Thing) { 1->^^^^ @@ -1580,10 +1597,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > 3 > Thing 4 > -1->Emitted(51, 5) Source(76, 15) + SourceIndex(0) -2 >Emitted(51, 16) Source(76, 15) + SourceIndex(0) -3 >Emitted(51, 21) Source(76, 20) + SourceIndex(0) -4 >Emitted(51, 23) Source(6, 1) + SourceIndex(0) +1->Emitted(53, 5) Source(76, 15) + SourceIndex(0) +2 >Emitted(53, 16) Source(76, 15) + SourceIndex(0) +3 >Emitted(53, 21) Source(76, 20) + SourceIndex(0) +4 >Emitted(53, 23) Source(6, 1) + SourceIndex(0) --- >>> let Languages; 1->^^^^^^^^ @@ -1687,9 +1704,9 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(52, 9) Source(76, 21) + SourceIndex(0) -2 >Emitted(52, 13) Source(76, 21) + SourceIndex(0) -3 >Emitted(52, 22) Source(100, 2) + SourceIndex(0) +1->Emitted(54, 9) Source(76, 21) + SourceIndex(0) +2 >Emitted(54, 13) Source(76, 21) + SourceIndex(0) +3 >Emitted(54, 22) Source(100, 2) + SourceIndex(0) --- >>> (function (Languages) { 1->^^^^^^^^ @@ -1700,10 +1717,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > 3 > Languages 4 > -1->Emitted(53, 9) Source(76, 21) + SourceIndex(0) -2 >Emitted(53, 20) Source(76, 21) + SourceIndex(0) -3 >Emitted(53, 29) Source(76, 30) + SourceIndex(0) -4 >Emitted(53, 31) Source(6, 1) + SourceIndex(0) +1->Emitted(55, 9) Source(76, 21) + SourceIndex(0) +2 >Emitted(55, 20) Source(76, 21) + SourceIndex(0) +3 >Emitted(55, 29) Source(76, 30) + SourceIndex(0) +4 >Emitted(55, 31) Source(6, 1) + SourceIndex(0) --- >>> let PlainText; 1 >^^^^^^^^^^^^ @@ -1807,9 +1824,9 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(54, 13) Source(76, 31) + SourceIndex(0) -2 >Emitted(54, 17) Source(76, 31) + SourceIndex(0) -3 >Emitted(54, 26) Source(100, 2) + SourceIndex(0) +1 >Emitted(56, 13) Source(76, 31) + SourceIndex(0) +2 >Emitted(56, 17) Source(76, 31) + SourceIndex(0) +3 >Emitted(56, 26) Source(100, 2) + SourceIndex(0) --- >>> (function (PlainText) { 1->^^^^^^^^^^^^ @@ -1820,10 +1837,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > 3 > PlainText 4 > -1->Emitted(55, 13) Source(76, 31) + SourceIndex(0) -2 >Emitted(55, 24) Source(76, 31) + SourceIndex(0) -3 >Emitted(55, 33) Source(76, 40) + SourceIndex(0) -4 >Emitted(55, 35) Source(76, 41) + SourceIndex(0) +1->Emitted(57, 13) Source(76, 31) + SourceIndex(0) +2 >Emitted(57, 24) Source(76, 31) + SourceIndex(0) +3 >Emitted(57, 33) Source(76, 40) + SourceIndex(0) +4 >Emitted(57, 35) Source(76, 41) + SourceIndex(0) --- >>> class State { 1 >^^^^^^^^^^^^^^^^ @@ -1834,9 +1851,9 @@ sourceFile:recursiveClassReferenceTest.ts > 2 > export class 3 > State -1 >Emitted(56, 17) Source(78, 2) + SourceIndex(0) -2 >Emitted(56, 23) Source(78, 15) + SourceIndex(0) -3 >Emitted(56, 28) Source(78, 20) + SourceIndex(0) +1 >Emitted(58, 17) Source(78, 2) + SourceIndex(0) +2 >Emitted(58, 23) Source(78, 15) + SourceIndex(0) +3 >Emitted(58, 28) Source(78, 20) + SourceIndex(0) --- >>> mode; 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1845,8 +1862,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > implements IState { > constructor(private 2 > mode -1 >Emitted(57, 21) Source(79, 29) + SourceIndex(0) -2 >Emitted(57, 25) Source(79, 33) + SourceIndex(0) +1 >Emitted(59, 21) Source(79, 29) + SourceIndex(0) +2 >Emitted(59, 25) Source(79, 33) + SourceIndex(0) --- >>> constructor(mode) { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1858,18 +1875,18 @@ sourceFile:recursiveClassReferenceTest.ts 2 > constructor(private 3 > mode: IMode 4 > ) -1->Emitted(58, 21) Source(79, 9) + SourceIndex(0) -2 >Emitted(58, 33) Source(79, 29) + SourceIndex(0) -3 >Emitted(58, 37) Source(79, 40) + SourceIndex(0) -4 >Emitted(58, 39) Source(79, 42) + SourceIndex(0) +1->Emitted(60, 21) Source(79, 9) + SourceIndex(0) +2 >Emitted(60, 33) Source(79, 29) + SourceIndex(0) +3 >Emitted(60, 37) Source(79, 40) + SourceIndex(0) +4 >Emitted(60, 39) Source(79, 42) + SourceIndex(0) --- >>> this.mode = mode; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^ 1-> 2 > mode -1->Emitted(59, 37) Source(79, 29) + SourceIndex(0) -2 >Emitted(59, 41) Source(79, 33) + SourceIndex(0) +1->Emitted(61, 37) Source(79, 29) + SourceIndex(0) +2 >Emitted(61, 41) Source(79, 33) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1877,8 +1894,8 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ^^^^^^^^^-> 1 >: IMode) { 2 > } -1 >Emitted(60, 21) Source(79, 43) + SourceIndex(0) -2 >Emitted(60, 22) Source(79, 45) + SourceIndex(0) +1 >Emitted(62, 21) Source(79, 43) + SourceIndex(0) +2 >Emitted(62, 22) Source(79, 45) + SourceIndex(0) --- >>> clone() { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1889,9 +1906,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > clone 3 > ():IState -1->Emitted(61, 21) Source(80, 10) + SourceIndex(0) -2 >Emitted(61, 26) Source(80, 15) + SourceIndex(0) -3 >Emitted(61, 29) Source(80, 25) + SourceIndex(0) +1->Emitted(63, 21) Source(80, 10) + SourceIndex(0) +2 >Emitted(63, 26) Source(80, 15) + SourceIndex(0) +3 >Emitted(63, 29) Source(80, 25) + SourceIndex(0) --- >>> return this; 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1903,10 +1920,10 @@ sourceFile:recursiveClassReferenceTest.ts 2 > return 3 > this 4 > ; -1->Emitted(62, 25) Source(81, 4) + SourceIndex(0) -2 >Emitted(62, 32) Source(81, 11) + SourceIndex(0) -3 >Emitted(62, 36) Source(81, 15) + SourceIndex(0) -4 >Emitted(62, 37) Source(81, 16) + SourceIndex(0) +1->Emitted(64, 25) Source(81, 4) + SourceIndex(0) +2 >Emitted(64, 32) Source(81, 11) + SourceIndex(0) +3 >Emitted(64, 36) Source(81, 15) + SourceIndex(0) +4 >Emitted(64, 37) Source(81, 16) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1915,8 +1932,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > 2 > > } -1 >Emitted(63, 21) Source(81, 16) + SourceIndex(0) -2 >Emitted(63, 22) Source(82, 4) + SourceIndex(0) +1 >Emitted(65, 21) Source(81, 16) + SourceIndex(0) +2 >Emitted(65, 22) Source(82, 4) + SourceIndex(0) --- >>> equals(other) { 1->^^^^^^^^^^^^^^^^^^^^ @@ -1932,11 +1949,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > ( 4 > other:IState 5 > ):boolean -1->Emitted(64, 21) Source(84, 10) + SourceIndex(0) -2 >Emitted(64, 27) Source(84, 16) + SourceIndex(0) -3 >Emitted(64, 28) Source(84, 17) + SourceIndex(0) -4 >Emitted(64, 33) Source(84, 29) + SourceIndex(0) -5 >Emitted(64, 35) Source(84, 39) + SourceIndex(0) +1->Emitted(66, 21) Source(84, 10) + SourceIndex(0) +2 >Emitted(66, 27) Source(84, 16) + SourceIndex(0) +3 >Emitted(66, 28) Source(84, 17) + SourceIndex(0) +4 >Emitted(66, 33) Source(84, 29) + SourceIndex(0) +5 >Emitted(66, 35) Source(84, 39) + SourceIndex(0) --- >>> return this === other; 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1952,12 +1969,12 @@ sourceFile:recursiveClassReferenceTest.ts 4 > === 5 > other 6 > ; -1->Emitted(65, 25) Source(85, 4) + SourceIndex(0) -2 >Emitted(65, 32) Source(85, 11) + SourceIndex(0) -3 >Emitted(65, 36) Source(85, 15) + SourceIndex(0) -4 >Emitted(65, 41) Source(85, 20) + SourceIndex(0) -5 >Emitted(65, 46) Source(85, 25) + SourceIndex(0) -6 >Emitted(65, 47) Source(85, 26) + SourceIndex(0) +1->Emitted(67, 25) Source(85, 4) + SourceIndex(0) +2 >Emitted(67, 32) Source(85, 11) + SourceIndex(0) +3 >Emitted(67, 36) Source(85, 15) + SourceIndex(0) +4 >Emitted(67, 41) Source(85, 20) + SourceIndex(0) +5 >Emitted(67, 46) Source(85, 25) + SourceIndex(0) +6 >Emitted(67, 47) Source(85, 26) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1966,8 +1983,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > 2 > > } -1 >Emitted(66, 21) Source(85, 26) + SourceIndex(0) -2 >Emitted(66, 22) Source(86, 4) + SourceIndex(0) +1 >Emitted(68, 21) Source(85, 26) + SourceIndex(0) +2 >Emitted(68, 22) Source(86, 4) + SourceIndex(0) --- >>> getMode() { return mode; } 1->^^^^^^^^^^^^^^^^^^^^ @@ -1990,22 +2007,22 @@ sourceFile:recursiveClassReferenceTest.ts 7 > ; 8 > 9 > } -1->Emitted(67, 21) Source(88, 10) + SourceIndex(0) -2 >Emitted(67, 28) Source(88, 17) + SourceIndex(0) -3 >Emitted(67, 31) Source(88, 27) + SourceIndex(0) -4 >Emitted(67, 33) Source(88, 29) + SourceIndex(0) -5 >Emitted(67, 40) Source(88, 36) + SourceIndex(0) -6 >Emitted(67, 44) Source(88, 40) + SourceIndex(0) -7 >Emitted(67, 45) Source(88, 41) + SourceIndex(0) -8 >Emitted(67, 46) Source(88, 41) + SourceIndex(0) -9 >Emitted(67, 47) Source(88, 43) + SourceIndex(0) +1->Emitted(69, 21) Source(88, 10) + SourceIndex(0) +2 >Emitted(69, 28) Source(88, 17) + SourceIndex(0) +3 >Emitted(69, 31) Source(88, 27) + SourceIndex(0) +4 >Emitted(69, 33) Source(88, 29) + SourceIndex(0) +5 >Emitted(69, 40) Source(88, 36) + SourceIndex(0) +6 >Emitted(69, 44) Source(88, 40) + SourceIndex(0) +7 >Emitted(69, 45) Source(88, 41) + SourceIndex(0) +8 >Emitted(69, 46) Source(88, 41) + SourceIndex(0) +9 >Emitted(69, 47) Source(88, 43) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > } -1 >Emitted(68, 18) Source(89, 3) + SourceIndex(0) +1 >Emitted(70, 18) Source(89, 3) + SourceIndex(0) --- >>> PlainText.State = State; 1->^^^^^^^^^^^^^^^^ @@ -2030,11 +2047,11 @@ sourceFile:recursiveClassReferenceTest.ts > public getMode(): IMode { return mode; } > } 5 > -1->Emitted(69, 17) Source(78, 15) + SourceIndex(0) -2 >Emitted(69, 27) Source(78, 15) + SourceIndex(0) -3 >Emitted(69, 32) Source(78, 20) + SourceIndex(0) -4 >Emitted(69, 40) Source(89, 3) + SourceIndex(0) -5 >Emitted(69, 41) Source(89, 3) + SourceIndex(0) +1->Emitted(71, 17) Source(78, 15) + SourceIndex(0) +2 >Emitted(71, 27) Source(78, 15) + SourceIndex(0) +3 >Emitted(71, 32) Source(78, 20) + SourceIndex(0) +4 >Emitted(71, 40) Source(89, 3) + SourceIndex(0) +5 >Emitted(71, 41) Source(89, 3) + SourceIndex(0) --- >>> class Mode extends AbstractMode { 1->^^^^^^^^^^^^^^^^ @@ -2049,11 +2066,11 @@ sourceFile:recursiveClassReferenceTest.ts 3 > Mode 4 > extends 5 > AbstractMode -1->Emitted(70, 17) Source(91, 2) + SourceIndex(0) -2 >Emitted(70, 23) Source(91, 15) + SourceIndex(0) -3 >Emitted(70, 27) Source(91, 20) + SourceIndex(0) -4 >Emitted(70, 36) Source(91, 28) + SourceIndex(0) -5 >Emitted(70, 48) Source(91, 40) + SourceIndex(0) +1->Emitted(72, 17) Source(91, 2) + SourceIndex(0) +2 >Emitted(72, 23) Source(91, 15) + SourceIndex(0) +3 >Emitted(72, 27) Source(91, 20) + SourceIndex(0) +4 >Emitted(72, 36) Source(91, 28) + SourceIndex(0) +5 >Emitted(72, 48) Source(91, 40) + SourceIndex(0) --- >>> // scenario 2 1 >^^^^^^^^^^^^^^^^^^^^ @@ -2063,8 +2080,8 @@ sourceFile:recursiveClassReferenceTest.ts > > 2 > // scenario 2 -1 >Emitted(71, 21) Source(93, 3) + SourceIndex(0) -2 >Emitted(71, 34) Source(93, 16) + SourceIndex(0) +1 >Emitted(73, 21) Source(93, 3) + SourceIndex(0) +2 >Emitted(73, 34) Source(93, 16) + SourceIndex(0) --- >>> getInitialState() { 1->^^^^^^^^^^^^^^^^^^^^ @@ -2075,9 +2092,9 @@ sourceFile:recursiveClassReferenceTest.ts > public 2 > getInitialState 3 > (): IState -1->Emitted(72, 21) Source(94, 10) + SourceIndex(0) -2 >Emitted(72, 36) Source(94, 25) + SourceIndex(0) -3 >Emitted(72, 39) Source(94, 36) + SourceIndex(0) +1->Emitted(74, 21) Source(94, 10) + SourceIndex(0) +2 >Emitted(74, 36) Source(94, 25) + SourceIndex(0) +3 >Emitted(74, 39) Source(94, 36) + SourceIndex(0) --- >>> return new State(self); 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2097,14 +2114,14 @@ sourceFile:recursiveClassReferenceTest.ts 6 > self 7 > ) 8 > ; -1->Emitted(73, 25) Source(95, 4) + SourceIndex(0) -2 >Emitted(73, 32) Source(95, 11) + SourceIndex(0) -3 >Emitted(73, 36) Source(95, 15) + SourceIndex(0) -4 >Emitted(73, 41) Source(95, 20) + SourceIndex(0) -5 >Emitted(73, 42) Source(95, 21) + SourceIndex(0) -6 >Emitted(73, 46) Source(95, 25) + SourceIndex(0) -7 >Emitted(73, 47) Source(95, 26) + SourceIndex(0) -8 >Emitted(73, 48) Source(95, 27) + SourceIndex(0) +1->Emitted(75, 25) Source(95, 4) + SourceIndex(0) +2 >Emitted(75, 32) Source(95, 11) + SourceIndex(0) +3 >Emitted(75, 36) Source(95, 15) + SourceIndex(0) +4 >Emitted(75, 41) Source(95, 20) + SourceIndex(0) +5 >Emitted(75, 42) Source(95, 21) + SourceIndex(0) +6 >Emitted(75, 46) Source(95, 25) + SourceIndex(0) +7 >Emitted(75, 47) Source(95, 26) + SourceIndex(0) +8 >Emitted(75, 48) Source(95, 27) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -2112,8 +2129,8 @@ sourceFile:recursiveClassReferenceTest.ts 1 > 2 > > } -1 >Emitted(74, 21) Source(95, 27) + SourceIndex(0) -2 >Emitted(74, 22) Source(96, 4) + SourceIndex(0) +1 >Emitted(76, 21) Source(95, 27) + SourceIndex(0) +2 >Emitted(76, 22) Source(96, 4) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^ @@ -2122,7 +2139,7 @@ sourceFile:recursiveClassReferenceTest.ts > > > } -1 >Emitted(75, 18) Source(99, 3) + SourceIndex(0) +1 >Emitted(77, 18) Source(99, 3) + SourceIndex(0) --- >>> PlainText.Mode = Mode; 1->^^^^^^^^^^^^^^^^ @@ -2144,11 +2161,11 @@ sourceFile:recursiveClassReferenceTest.ts > > } 5 > -1->Emitted(76, 17) Source(91, 15) + SourceIndex(0) -2 >Emitted(76, 27) Source(91, 15) + SourceIndex(0) -3 >Emitted(76, 31) Source(91, 19) + SourceIndex(0) -4 >Emitted(76, 38) Source(99, 3) + SourceIndex(0) -5 >Emitted(76, 39) Source(99, 3) + SourceIndex(0) +1->Emitted(78, 17) Source(91, 15) + SourceIndex(0) +2 >Emitted(78, 27) Source(91, 15) + SourceIndex(0) +3 >Emitted(78, 31) Source(91, 19) + SourceIndex(0) +4 >Emitted(78, 38) Source(99, 3) + SourceIndex(0) +5 >Emitted(78, 39) Source(99, 3) + SourceIndex(0) --- >>> })(PlainText = Languages.PlainText || (Languages.PlainText = {})); 1->^^^^^^^^^^^^ @@ -2198,17 +2215,17 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1->Emitted(77, 13) Source(99, 3) + SourceIndex(0) -2 >Emitted(77, 14) Source(100, 2) + SourceIndex(0) -3 >Emitted(77, 16) Source(76, 31) + SourceIndex(0) -4 >Emitted(77, 25) Source(76, 40) + SourceIndex(0) -5 >Emitted(77, 28) Source(76, 31) + SourceIndex(0) -6 >Emitted(77, 38) Source(76, 31) + SourceIndex(0) -7 >Emitted(77, 47) Source(76, 40) + SourceIndex(0) -8 >Emitted(77, 52) Source(76, 31) + SourceIndex(0) -9 >Emitted(77, 62) Source(76, 31) + SourceIndex(0) -10>Emitted(77, 71) Source(76, 40) + SourceIndex(0) -11>Emitted(77, 79) Source(100, 2) + SourceIndex(0) +1->Emitted(79, 13) Source(99, 3) + SourceIndex(0) +2 >Emitted(79, 14) Source(100, 2) + SourceIndex(0) +3 >Emitted(79, 16) Source(76, 31) + SourceIndex(0) +4 >Emitted(79, 25) Source(76, 40) + SourceIndex(0) +5 >Emitted(79, 28) Source(76, 31) + SourceIndex(0) +6 >Emitted(79, 38) Source(76, 31) + SourceIndex(0) +7 >Emitted(79, 47) Source(76, 40) + SourceIndex(0) +8 >Emitted(79, 52) Source(76, 31) + SourceIndex(0) +9 >Emitted(79, 62) Source(76, 31) + SourceIndex(0) +10>Emitted(79, 71) Source(76, 40) + SourceIndex(0) +11>Emitted(79, 79) Source(100, 2) + SourceIndex(0) --- >>> })(Languages = Thing.Languages || (Thing.Languages = {})); 1 >^^^^^^^^ @@ -2335,18 +2352,18 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(78, 9) Source(99, 3) + SourceIndex(0) -2 >Emitted(78, 10) Source(100, 1) + SourceIndex(0) -3 >Emitted(78, 10) Source(1, 1) + SourceIndex(0) -4 >Emitted(78, 12) Source(76, 21) + SourceIndex(0) -5 >Emitted(78, 21) Source(76, 30) + SourceIndex(0) -6 >Emitted(78, 24) Source(76, 21) + SourceIndex(0) -7 >Emitted(78, 30) Source(76, 21) + SourceIndex(0) -8 >Emitted(78, 39) Source(76, 30) + SourceIndex(0) -9 >Emitted(78, 44) Source(76, 21) + SourceIndex(0) -10>Emitted(78, 50) Source(76, 21) + SourceIndex(0) -11>Emitted(78, 59) Source(76, 30) + SourceIndex(0) -12>Emitted(78, 67) Source(100, 2) + SourceIndex(0) +1 >Emitted(80, 9) Source(99, 3) + SourceIndex(0) +2 >Emitted(80, 10) Source(100, 1) + SourceIndex(0) +3 >Emitted(80, 10) Source(1, 1) + SourceIndex(0) +4 >Emitted(80, 12) Source(76, 21) + SourceIndex(0) +5 >Emitted(80, 21) Source(76, 30) + SourceIndex(0) +6 >Emitted(80, 24) Source(76, 21) + SourceIndex(0) +7 >Emitted(80, 30) Source(76, 21) + SourceIndex(0) +8 >Emitted(80, 39) Source(76, 30) + SourceIndex(0) +9 >Emitted(80, 44) Source(76, 21) + SourceIndex(0) +10>Emitted(80, 50) Source(76, 21) + SourceIndex(0) +11>Emitted(80, 59) Source(76, 30) + SourceIndex(0) +12>Emitted(80, 67) Source(100, 2) + SourceIndex(0) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -2473,18 +2490,18 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(79, 5) Source(99, 3) + SourceIndex(0) -2 >Emitted(79, 6) Source(100, 1) + SourceIndex(0) -3 >Emitted(79, 6) Source(1, 1) + SourceIndex(0) -4 >Emitted(79, 8) Source(76, 15) + SourceIndex(0) -5 >Emitted(79, 13) Source(76, 20) + SourceIndex(0) -6 >Emitted(79, 16) Source(76, 15) + SourceIndex(0) -7 >Emitted(79, 23) Source(76, 15) + SourceIndex(0) -8 >Emitted(79, 28) Source(76, 20) + SourceIndex(0) -9 >Emitted(79, 33) Source(76, 15) + SourceIndex(0) -10>Emitted(79, 40) Source(76, 15) + SourceIndex(0) -11>Emitted(79, 45) Source(76, 20) + SourceIndex(0) -12>Emitted(79, 53) Source(100, 2) + SourceIndex(0) +1 >Emitted(81, 5) Source(99, 3) + SourceIndex(0) +2 >Emitted(81, 6) Source(100, 1) + SourceIndex(0) +3 >Emitted(81, 6) Source(1, 1) + SourceIndex(0) +4 >Emitted(81, 8) Source(76, 15) + SourceIndex(0) +5 >Emitted(81, 13) Source(76, 20) + SourceIndex(0) +6 >Emitted(81, 16) Source(76, 15) + SourceIndex(0) +7 >Emitted(81, 23) Source(76, 15) + SourceIndex(0) +8 >Emitted(81, 28) Source(76, 20) + SourceIndex(0) +9 >Emitted(81, 33) Source(76, 15) + SourceIndex(0) +10>Emitted(81, 40) Source(76, 15) + SourceIndex(0) +11>Emitted(81, 45) Source(76, 20) + SourceIndex(0) +12>Emitted(81, 53) Source(100, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -2604,13 +2621,13 @@ sourceFile:recursiveClassReferenceTest.ts > > } > } -1 >Emitted(80, 1) Source(99, 3) + SourceIndex(0) -2 >Emitted(80, 2) Source(100, 1) + SourceIndex(0) -3 >Emitted(80, 2) Source(1, 1) + SourceIndex(0) -4 >Emitted(80, 4) Source(76, 8) + SourceIndex(0) -5 >Emitted(80, 10) Source(76, 14) + SourceIndex(0) -6 >Emitted(80, 15) Source(76, 8) + SourceIndex(0) -7 >Emitted(80, 21) Source(76, 14) + SourceIndex(0) -8 >Emitted(80, 29) Source(100, 2) + SourceIndex(0) +1 >Emitted(82, 1) Source(99, 3) + SourceIndex(0) +2 >Emitted(82, 2) Source(100, 1) + SourceIndex(0) +3 >Emitted(82, 2) Source(1, 1) + SourceIndex(0) +4 >Emitted(82, 4) Source(76, 8) + SourceIndex(0) +5 >Emitted(82, 10) Source(76, 14) + SourceIndex(0) +6 >Emitted(82, 15) Source(76, 8) + SourceIndex(0) +7 >Emitted(82, 21) Source(76, 14) + SourceIndex(0) +8 >Emitted(82, 29) Source(100, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=recursiveClassReferenceTest.js.map \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.sourcemap.txt.diff b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.sourcemap.txt.diff index 93b2d5d6c0..683d991fed 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.sourcemap.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/recursiveClassReferenceTest.sourcemap.txt.diff @@ -1,41 +1,16 @@ --- old.recursiveClassReferenceTest.sourcemap.txt +++ new.recursiveClassReferenceTest.sourcemap.txt -@@= skipped -7, +7 lines =@@ - emittedFile:recursiveClassReferenceTest.js - sourceFile:recursiveClassReferenceTest.ts - ------------------------------------------------------------------- -->>>// Scenario 1: Test reqursive function call with "this" parameter --1 > --2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --3 > ^^^^^^^^^^-> --1 > --2 >// Scenario 1: Test reqursive function call with "this" parameter --1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) --2 >Emitted(1, 66) Source(1, 66) + SourceIndex(0) ----- -->>>// Scenario 2: Test recursive function call with cast and "this" parameter --1-> --2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --1-> -- > --2 >// Scenario 2: Test recursive function call with cast and "this" parameter --1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) --2 >Emitted(2, 75) Source(2, 75) + SourceIndex(0) ----- - >>>var Sample; +@@= skipped -29, +29 lines =@@ 1 > 2 >^^^^ 3 > ^^^^^^ -4 > ^ -5 > ^^^^^^^^^^-> --1 > +4 > ^^^^^^^^^^^-> -+1 >// Scenario 1: Test reqursive function call with "this" parameter -+ >// Scenario 2: Test recursive function call with cast and "this" parameter - > + 1 > > > -@@= skipped -56, +38 lines =@@ +@@= skipped -34, +33 lines =@@ > > 2 >module @@ -51,10 +26,6 @@ - > } - > } - > } --1 >Emitted(3, 1) Source(32, 1) + SourceIndex(0) --2 >Emitted(3, 5) Source(32, 8) + SourceIndex(0) --3 >Emitted(3, 11) Source(32, 14) + SourceIndex(0) --4 >Emitted(3, 12) Source(42, 2) + SourceIndex(0) +3 > Sample.Actions.Thing.Find { + > export class StartFindAction implements Sample.Thing.IAction { + > @@ -66,9 +37,11 @@ + > } + > } + > } -+1 >Emitted(1, 1) Source(32, 1) + SourceIndex(0) -+2 >Emitted(1, 5) Source(32, 8) + SourceIndex(0) -+3 >Emitted(1, 11) Source(42, 2) + SourceIndex(0) + 1 >Emitted(3, 1) Source(32, 1) + SourceIndex(0) + 2 >Emitted(3, 5) Source(32, 8) + SourceIndex(0) +-3 >Emitted(3, 11) Source(32, 14) + SourceIndex(0) +-4 >Emitted(3, 12) Source(42, 2) + SourceIndex(0) ++3 >Emitted(3, 11) Source(42, 2) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -78,14 +51,11 @@ 1-> 2 >module 3 > Sample --1->Emitted(4, 1) Source(32, 1) + SourceIndex(0) --2 >Emitted(4, 12) Source(32, 8) + SourceIndex(0) --3 >Emitted(4, 18) Source(32, 14) + SourceIndex(0) +4 > -+1->Emitted(2, 1) Source(32, 1) + SourceIndex(0) -+2 >Emitted(2, 12) Source(32, 8) + SourceIndex(0) -+3 >Emitted(2, 18) Source(32, 14) + SourceIndex(0) -+4 >Emitted(2, 20) Source(6, 1) + SourceIndex(0) + 1->Emitted(4, 1) Source(32, 1) + SourceIndex(0) + 2 >Emitted(4, 12) Source(32, 8) + SourceIndex(0) + 3 >Emitted(4, 18) Source(32, 14) + SourceIndex(0) ++4 >Emitted(4, 20) Source(6, 1) + SourceIndex(0) --- ->>> var Actions; +>>> let Actions; @@ -136,10 +106,6 @@ - > } - > } - > } --1 >Emitted(5, 5) Source(32, 15) + SourceIndex(0) --2 >Emitted(5, 9) Source(32, 15) + SourceIndex(0) --3 >Emitted(5, 16) Source(32, 22) + SourceIndex(0) --4 >Emitted(5, 17) Source(42, 2) + SourceIndex(0) +3 > Actions.Thing.Find { + > export class StartFindAction implements Sample.Thing.IAction { + > @@ -151,9 +117,11 @@ + > } + > } + > } -+1 >Emitted(3, 5) Source(32, 15) + SourceIndex(0) -+2 >Emitted(3, 9) Source(32, 15) + SourceIndex(0) -+3 >Emitted(3, 16) Source(42, 2) + SourceIndex(0) + 1 >Emitted(5, 5) Source(32, 15) + SourceIndex(0) + 2 >Emitted(5, 9) Source(32, 15) + SourceIndex(0) +-3 >Emitted(5, 16) Source(32, 22) + SourceIndex(0) +-4 >Emitted(5, 17) Source(42, 2) + SourceIndex(0) ++3 >Emitted(5, 16) Source(42, 2) + SourceIndex(0) --- >>> (function (Actions) { 1->^^^^ @@ -163,14 +131,11 @@ 1-> 2 > 3 > Actions --1->Emitted(6, 5) Source(32, 15) + SourceIndex(0) --2 >Emitted(6, 16) Source(32, 15) + SourceIndex(0) --3 >Emitted(6, 23) Source(32, 22) + SourceIndex(0) +4 > -+1->Emitted(4, 5) Source(32, 15) + SourceIndex(0) -+2 >Emitted(4, 16) Source(32, 15) + SourceIndex(0) -+3 >Emitted(4, 23) Source(32, 22) + SourceIndex(0) -+4 >Emitted(4, 25) Source(6, 1) + SourceIndex(0) + 1->Emitted(6, 5) Source(32, 15) + SourceIndex(0) + 2 >Emitted(6, 16) Source(32, 15) + SourceIndex(0) + 3 >Emitted(6, 23) Source(32, 22) + SourceIndex(0) ++4 >Emitted(6, 25) Source(6, 1) + SourceIndex(0) --- ->>> var Thing; +>>> let Thing; @@ -221,10 +186,6 @@ - > } - > } - > } --1 >Emitted(7, 9) Source(32, 23) + SourceIndex(0) --2 >Emitted(7, 13) Source(32, 23) + SourceIndex(0) --3 >Emitted(7, 18) Source(32, 28) + SourceIndex(0) --4 >Emitted(7, 19) Source(42, 2) + SourceIndex(0) +3 > Thing.Find { + > export class StartFindAction implements Sample.Thing.IAction { + > @@ -236,9 +197,11 @@ + > } + > } + > } -+1 >Emitted(5, 9) Source(32, 23) + SourceIndex(0) -+2 >Emitted(5, 13) Source(32, 23) + SourceIndex(0) -+3 >Emitted(5, 18) Source(42, 2) + SourceIndex(0) + 1 >Emitted(7, 9) Source(32, 23) + SourceIndex(0) + 2 >Emitted(7, 13) Source(32, 23) + SourceIndex(0) +-3 >Emitted(7, 18) Source(32, 28) + SourceIndex(0) +-4 >Emitted(7, 19) Source(42, 2) + SourceIndex(0) ++3 >Emitted(7, 18) Source(42, 2) + SourceIndex(0) --- >>> (function (Thing_1) { 1->^^^^^^^^ @@ -248,14 +211,11 @@ 1-> 2 > 3 > Thing --1->Emitted(8, 9) Source(32, 23) + SourceIndex(0) --2 >Emitted(8, 20) Source(32, 23) + SourceIndex(0) --3 >Emitted(8, 27) Source(32, 28) + SourceIndex(0) +4 > -+1->Emitted(6, 9) Source(32, 23) + SourceIndex(0) -+2 >Emitted(6, 20) Source(32, 23) + SourceIndex(0) -+3 >Emitted(6, 27) Source(32, 28) + SourceIndex(0) -+4 >Emitted(6, 29) Source(6, 1) + SourceIndex(0) + 1->Emitted(8, 9) Source(32, 23) + SourceIndex(0) + 2 >Emitted(8, 20) Source(32, 23) + SourceIndex(0) + 3 >Emitted(8, 27) Source(32, 28) + SourceIndex(0) ++4 >Emitted(8, 29) Source(6, 1) + SourceIndex(0) --- ->>> var Find; +>>> let Find; @@ -306,10 +266,6 @@ - > } - > } - > } --1 >Emitted(9, 13) Source(32, 29) + SourceIndex(0) --2 >Emitted(9, 17) Source(32, 29) + SourceIndex(0) --3 >Emitted(9, 21) Source(32, 33) + SourceIndex(0) --4 >Emitted(9, 22) Source(42, 2) + SourceIndex(0) +3 > Find { + > export class StartFindAction implements Sample.Thing.IAction { + > @@ -321,9 +277,11 @@ + > } + > } + > } -+1 >Emitted(7, 13) Source(32, 29) + SourceIndex(0) -+2 >Emitted(7, 17) Source(32, 29) + SourceIndex(0) -+3 >Emitted(7, 21) Source(42, 2) + SourceIndex(0) + 1 >Emitted(9, 13) Source(32, 29) + SourceIndex(0) + 2 >Emitted(9, 17) Source(32, 29) + SourceIndex(0) +-3 >Emitted(9, 21) Source(32, 33) + SourceIndex(0) +-4 >Emitted(9, 22) Source(42, 2) + SourceIndex(0) ++3 >Emitted(9, 21) Source(42, 2) + SourceIndex(0) --- >>> (function (Find) { 1->^^^^^^^^^^^^ @@ -335,14 +293,11 @@ 1-> 2 > 3 > Find --1->Emitted(10, 13) Source(32, 29) + SourceIndex(0) --2 >Emitted(10, 24) Source(32, 29) + SourceIndex(0) --3 >Emitted(10, 28) Source(32, 33) + SourceIndex(0) +4 > -+1->Emitted(8, 13) Source(32, 29) + SourceIndex(0) -+2 >Emitted(8, 24) Source(32, 29) + SourceIndex(0) -+3 >Emitted(8, 28) Source(32, 33) + SourceIndex(0) -+4 >Emitted(8, 30) Source(32, 34) + SourceIndex(0) + 1->Emitted(10, 13) Source(32, 29) + SourceIndex(0) + 2 >Emitted(10, 24) Source(32, 29) + SourceIndex(0) + 3 >Emitted(10, 28) Source(32, 33) + SourceIndex(0) ++4 >Emitted(10, 30) Source(32, 34) + SourceIndex(0) --- >>> class StartFindAction { 1->^^^^^^^^^^^^^^^^ @@ -354,13 +309,7 @@ > 2 > export class 3 > StartFindAction --1->Emitted(11, 17) Source(33, 2) + SourceIndex(0) --2 >Emitted(11, 23) Source(33, 15) + SourceIndex(0) --3 >Emitted(11, 38) Source(33, 30) + SourceIndex(0) -+1->Emitted(9, 17) Source(33, 2) + SourceIndex(0) -+2 >Emitted(9, 23) Source(33, 15) + SourceIndex(0) -+3 >Emitted(9, 38) Source(33, 30) + SourceIndex(0) - --- +@@= skipped -153, +232 lines =@@ >>> getId() { return "yo"; } 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^ @@ -387,14 +336,6 @@ -6 > ; -7 > -8 > } --1->Emitted(12, 21) Source(35, 10) + SourceIndex(0) --2 >Emitted(12, 26) Source(35, 15) + SourceIndex(0) --3 >Emitted(12, 31) Source(35, 20) + SourceIndex(0) --4 >Emitted(12, 38) Source(35, 27) + SourceIndex(0) --5 >Emitted(12, 42) Source(35, 31) + SourceIndex(0) --6 >Emitted(12, 43) Source(35, 32) + SourceIndex(0) --7 >Emitted(12, 44) Source(35, 33) + SourceIndex(0) --8 >Emitted(12, 45) Source(35, 34) + SourceIndex(0) +3 > () +4 > { +5 > return @@ -402,15 +343,21 @@ +7 > ; +8 > +9 > } -+1->Emitted(10, 21) Source(35, 10) + SourceIndex(0) -+2 >Emitted(10, 26) Source(35, 15) + SourceIndex(0) -+3 >Emitted(10, 29) Source(35, 18) + SourceIndex(0) -+4 >Emitted(10, 31) Source(35, 20) + SourceIndex(0) -+5 >Emitted(10, 38) Source(35, 27) + SourceIndex(0) -+6 >Emitted(10, 42) Source(35, 31) + SourceIndex(0) -+7 >Emitted(10, 43) Source(35, 32) + SourceIndex(0) -+8 >Emitted(10, 44) Source(35, 32) + SourceIndex(0) -+9 >Emitted(10, 45) Source(35, 34) + SourceIndex(0) + 1->Emitted(12, 21) Source(35, 10) + SourceIndex(0) + 2 >Emitted(12, 26) Source(35, 15) + SourceIndex(0) +-3 >Emitted(12, 31) Source(35, 20) + SourceIndex(0) +-4 >Emitted(12, 38) Source(35, 27) + SourceIndex(0) +-5 >Emitted(12, 42) Source(35, 31) + SourceIndex(0) +-6 >Emitted(12, 43) Source(35, 32) + SourceIndex(0) +-7 >Emitted(12, 44) Source(35, 33) + SourceIndex(0) +-8 >Emitted(12, 45) Source(35, 34) + SourceIndex(0) ++3 >Emitted(12, 29) Source(35, 18) + SourceIndex(0) ++4 >Emitted(12, 31) Source(35, 20) + SourceIndex(0) ++5 >Emitted(12, 38) Source(35, 27) + SourceIndex(0) ++6 >Emitted(12, 42) Source(35, 31) + SourceIndex(0) ++7 >Emitted(12, 43) Source(35, 32) + SourceIndex(0) ++8 >Emitted(12, 44) Source(35, 32) + SourceIndex(0) ++9 >Emitted(12, 45) Source(35, 34) + SourceIndex(0) --- >>> run(Thing) { 1 >^^^^^^^^^^^^^^^^^^^^ @@ -426,16 +373,12 @@ 2 > run 3 > ( 4 > Thing:Sample.Thing.ICodeThing --1 >Emitted(13, 21) Source(37, 10) + SourceIndex(0) --2 >Emitted(13, 24) Source(37, 13) + SourceIndex(0) --3 >Emitted(13, 25) Source(37, 14) + SourceIndex(0) --4 >Emitted(13, 30) Source(37, 43) + SourceIndex(0) +5 > ):boolean -+1 >Emitted(11, 21) Source(37, 10) + SourceIndex(0) -+2 >Emitted(11, 24) Source(37, 13) + SourceIndex(0) -+3 >Emitted(11, 25) Source(37, 14) + SourceIndex(0) -+4 >Emitted(11, 30) Source(37, 43) + SourceIndex(0) -+5 >Emitted(11, 32) Source(37, 53) + SourceIndex(0) + 1 >Emitted(13, 21) Source(37, 10) + SourceIndex(0) + 2 >Emitted(13, 24) Source(37, 13) + SourceIndex(0) + 3 >Emitted(13, 25) Source(37, 14) + SourceIndex(0) + 4 >Emitted(13, 30) Source(37, 43) + SourceIndex(0) ++5 >Emitted(13, 32) Source(37, 53) + SourceIndex(0) --- >>> return true; 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -447,37 +390,20 @@ > > 2 > return - 3 > true - 4 > ; --1->Emitted(14, 25) Source(39, 4) + SourceIndex(0) --2 >Emitted(14, 32) Source(39, 11) + SourceIndex(0) --3 >Emitted(14, 36) Source(39, 15) + SourceIndex(0) --4 >Emitted(14, 37) Source(39, 16) + SourceIndex(0) -+1->Emitted(12, 25) Source(39, 4) + SourceIndex(0) -+2 >Emitted(12, 32) Source(39, 11) + SourceIndex(0) -+3 >Emitted(12, 36) Source(39, 15) + SourceIndex(0) -+4 >Emitted(12, 37) Source(39, 16) + SourceIndex(0) - --- - >>> } +@@= skipped -62, +68 lines =@@ 1 >^^^^^^^^^^^^^^^^^^^^ 2 > ^ 1 > - > -2 > } -1 >Emitted(15, 21) Source(40, 3) + SourceIndex(0) --2 >Emitted(15, 22) Source(40, 4) + SourceIndex(0) +2 > + > } -+1 >Emitted(13, 21) Source(39, 16) + SourceIndex(0) -+2 >Emitted(13, 22) Source(40, 4) + SourceIndex(0) ++1 >Emitted(15, 21) Source(39, 16) + SourceIndex(0) + 2 >Emitted(15, 22) Source(40, 4) + SourceIndex(0) --- >>> } - 1 >^^^^^^^^^^^^^^^^^ - 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> - 1 > - > } --1 >Emitted(16, 18) Source(41, 3) + SourceIndex(0) -+1 >Emitted(14, 18) Source(41, 3) + SourceIndex(0) +@@= skipped -14, +14 lines =@@ --- >>> Find.StartFindAction = StartFindAction; 1->^^^^^^^^^^^^^^^^ @@ -499,21 +425,20 @@ > > public getId() { return "yo"; } > -@@= skipped -244, +331 lines =@@ +@@= skipped -15, +17 lines =@@ > return true; > } > } -4 > --1->Emitted(17, 17) Source(33, 15) + SourceIndex(0) ++5 > + 1->Emitted(17, 17) Source(33, 15) + SourceIndex(0) -2 >Emitted(17, 37) Source(33, 30) + SourceIndex(0) -3 >Emitted(17, 55) Source(41, 3) + SourceIndex(0) -4 >Emitted(17, 56) Source(41, 3) + SourceIndex(0) -+5 > -+1->Emitted(15, 17) Source(33, 15) + SourceIndex(0) -+2 >Emitted(15, 22) Source(33, 15) + SourceIndex(0) -+3 >Emitted(15, 37) Source(33, 30) + SourceIndex(0) -+4 >Emitted(15, 55) Source(41, 3) + SourceIndex(0) -+5 >Emitted(15, 56) Source(41, 3) + SourceIndex(0) ++2 >Emitted(17, 22) Source(33, 15) + SourceIndex(0) ++3 >Emitted(17, 37) Source(33, 30) + SourceIndex(0) ++4 >Emitted(17, 55) Source(41, 3) + SourceIndex(0) ++5 >Emitted(17, 56) Source(41, 3) + SourceIndex(0) --- >>> })(Find = Thing_1.Find || (Thing_1.Find = {})); 1->^^^^^^^^^^^^ @@ -557,25 +482,21 @@ > } > } -1->Emitted(18, 13) Source(42, 1) + SourceIndex(0) --2 >Emitted(18, 14) Source(42, 2) + SourceIndex(0) --3 >Emitted(18, 16) Source(32, 29) + SourceIndex(0) --4 >Emitted(18, 20) Source(32, 33) + SourceIndex(0) --5 >Emitted(18, 23) Source(32, 29) + SourceIndex(0) ++1->Emitted(18, 13) Source(41, 3) + SourceIndex(0) + 2 >Emitted(18, 14) Source(42, 2) + SourceIndex(0) + 3 >Emitted(18, 16) Source(32, 29) + SourceIndex(0) + 4 >Emitted(18, 20) Source(32, 33) + SourceIndex(0) + 5 >Emitted(18, 23) Source(32, 29) + SourceIndex(0) -6 >Emitted(18, 35) Source(32, 33) + SourceIndex(0) -7 >Emitted(18, 40) Source(32, 29) + SourceIndex(0) -8 >Emitted(18, 52) Source(32, 33) + SourceIndex(0) -9 >Emitted(18, 60) Source(42, 2) + SourceIndex(0) -+1->Emitted(16, 13) Source(41, 3) + SourceIndex(0) -+2 >Emitted(16, 14) Source(42, 2) + SourceIndex(0) -+3 >Emitted(16, 16) Source(32, 29) + SourceIndex(0) -+4 >Emitted(16, 20) Source(32, 33) + SourceIndex(0) -+5 >Emitted(16, 23) Source(32, 29) + SourceIndex(0) -+6 >Emitted(16, 31) Source(32, 29) + SourceIndex(0) -+7 >Emitted(16, 35) Source(32, 33) + SourceIndex(0) -+8 >Emitted(16, 40) Source(32, 29) + SourceIndex(0) -+9 >Emitted(16, 48) Source(32, 29) + SourceIndex(0) -+10>Emitted(16, 52) Source(32, 33) + SourceIndex(0) -+11>Emitted(16, 60) Source(42, 2) + SourceIndex(0) ++6 >Emitted(18, 31) Source(32, 29) + SourceIndex(0) ++7 >Emitted(18, 35) Source(32, 33) + SourceIndex(0) ++8 >Emitted(18, 40) Source(32, 29) + SourceIndex(0) ++9 >Emitted(18, 48) Source(32, 29) + SourceIndex(0) ++10>Emitted(18, 52) Source(32, 33) + SourceIndex(0) ++11>Emitted(18, 60) Source(42, 2) + SourceIndex(0) --- >>> })(Thing = Actions.Thing || (Actions.Thing = {})); 1 >^^^^^^^^ @@ -666,18 +587,18 @@ -7 >Emitted(19, 38) Source(32, 23) + SourceIndex(0) -8 >Emitted(19, 51) Source(32, 28) + SourceIndex(0) -9 >Emitted(19, 59) Source(42, 2) + SourceIndex(0) -+1 >Emitted(17, 9) Source(41, 3) + SourceIndex(0) -+2 >Emitted(17, 10) Source(42, 1) + SourceIndex(0) -+3 >Emitted(17, 10) Source(1, 1) + SourceIndex(0) -+4 >Emitted(17, 12) Source(32, 23) + SourceIndex(0) -+5 >Emitted(17, 17) Source(32, 28) + SourceIndex(0) -+6 >Emitted(17, 20) Source(32, 23) + SourceIndex(0) -+7 >Emitted(17, 28) Source(32, 23) + SourceIndex(0) -+8 >Emitted(17, 33) Source(32, 28) + SourceIndex(0) -+9 >Emitted(17, 38) Source(32, 23) + SourceIndex(0) -+10>Emitted(17, 46) Source(32, 23) + SourceIndex(0) -+11>Emitted(17, 51) Source(32, 28) + SourceIndex(0) -+12>Emitted(17, 59) Source(42, 2) + SourceIndex(0) ++1 >Emitted(19, 9) Source(41, 3) + SourceIndex(0) ++2 >Emitted(19, 10) Source(42, 1) + SourceIndex(0) ++3 >Emitted(19, 10) Source(1, 1) + SourceIndex(0) ++4 >Emitted(19, 12) Source(32, 23) + SourceIndex(0) ++5 >Emitted(19, 17) Source(32, 28) + SourceIndex(0) ++6 >Emitted(19, 20) Source(32, 23) + SourceIndex(0) ++7 >Emitted(19, 28) Source(32, 23) + SourceIndex(0) ++8 >Emitted(19, 33) Source(32, 28) + SourceIndex(0) ++9 >Emitted(19, 38) Source(32, 23) + SourceIndex(0) ++10>Emitted(19, 46) Source(32, 23) + SourceIndex(0) ++11>Emitted(19, 51) Source(32, 28) + SourceIndex(0) ++12>Emitted(19, 59) Source(42, 2) + SourceIndex(0) --- >>> })(Actions = Sample.Actions || (Sample.Actions = {})); 1->^^^^ @@ -766,18 +687,18 @@ -7 >Emitted(20, 37) Source(32, 15) + SourceIndex(0) -8 >Emitted(20, 51) Source(32, 22) + SourceIndex(0) -9 >Emitted(20, 59) Source(42, 2) + SourceIndex(0) -+1->Emitted(18, 5) Source(41, 3) + SourceIndex(0) -+2 >Emitted(18, 6) Source(42, 1) + SourceIndex(0) -+3 >Emitted(18, 6) Source(1, 1) + SourceIndex(0) -+4 >Emitted(18, 8) Source(32, 15) + SourceIndex(0) -+5 >Emitted(18, 15) Source(32, 22) + SourceIndex(0) -+6 >Emitted(18, 18) Source(32, 15) + SourceIndex(0) -+7 >Emitted(18, 25) Source(32, 15) + SourceIndex(0) -+8 >Emitted(18, 32) Source(32, 22) + SourceIndex(0) -+9 >Emitted(18, 37) Source(32, 15) + SourceIndex(0) -+10>Emitted(18, 44) Source(32, 15) + SourceIndex(0) -+11>Emitted(18, 51) Source(32, 22) + SourceIndex(0) -+12>Emitted(18, 59) Source(42, 2) + SourceIndex(0) ++1->Emitted(20, 5) Source(41, 3) + SourceIndex(0) ++2 >Emitted(20, 6) Source(42, 1) + SourceIndex(0) ++3 >Emitted(20, 6) Source(1, 1) + SourceIndex(0) ++4 >Emitted(20, 8) Source(32, 15) + SourceIndex(0) ++5 >Emitted(20, 15) Source(32, 22) + SourceIndex(0) ++6 >Emitted(20, 18) Source(32, 15) + SourceIndex(0) ++7 >Emitted(20, 25) Source(32, 15) + SourceIndex(0) ++8 >Emitted(20, 32) Source(32, 22) + SourceIndex(0) ++9 >Emitted(20, 37) Source(32, 15) + SourceIndex(0) ++10>Emitted(20, 44) Source(32, 15) + SourceIndex(0) ++11>Emitted(20, 51) Source(32, 22) + SourceIndex(0) ++12>Emitted(20, 59) Source(42, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -852,14 +773,14 @@ -5 >Emitted(21, 15) Source(32, 8) + SourceIndex(0) -6 >Emitted(21, 21) Source(32, 14) + SourceIndex(0) -7 >Emitted(21, 29) Source(42, 2) + SourceIndex(0) -+1 >Emitted(19, 1) Source(41, 3) + SourceIndex(0) -+2 >Emitted(19, 2) Source(42, 1) + SourceIndex(0) -+3 >Emitted(19, 2) Source(1, 1) + SourceIndex(0) -+4 >Emitted(19, 4) Source(32, 8) + SourceIndex(0) -+5 >Emitted(19, 10) Source(32, 14) + SourceIndex(0) -+6 >Emitted(19, 15) Source(32, 8) + SourceIndex(0) -+7 >Emitted(19, 21) Source(32, 14) + SourceIndex(0) -+8 >Emitted(19, 29) Source(42, 2) + SourceIndex(0) ++1 >Emitted(21, 1) Source(41, 3) + SourceIndex(0) ++2 >Emitted(21, 2) Source(42, 1) + SourceIndex(0) ++3 >Emitted(21, 2) Source(1, 1) + SourceIndex(0) ++4 >Emitted(21, 4) Source(32, 8) + SourceIndex(0) ++5 >Emitted(21, 10) Source(32, 14) + SourceIndex(0) ++6 >Emitted(21, 15) Source(32, 8) + SourceIndex(0) ++7 >Emitted(21, 21) Source(32, 14) + SourceIndex(0) ++8 >Emitted(21, 29) Source(42, 2) + SourceIndex(0) --- >>>(function (Sample) { 1 > @@ -871,14 +792,11 @@ > 2 >module 3 > Sample --1 >Emitted(22, 1) Source(44, 1) + SourceIndex(0) --2 >Emitted(22, 12) Source(44, 8) + SourceIndex(0) --3 >Emitted(22, 18) Source(44, 14) + SourceIndex(0) +4 > -+1 >Emitted(20, 1) Source(44, 1) + SourceIndex(0) -+2 >Emitted(20, 12) Source(44, 8) + SourceIndex(0) -+3 >Emitted(20, 18) Source(44, 14) + SourceIndex(0) -+4 >Emitted(20, 20) Source(6, 1) + SourceIndex(0) + 1 >Emitted(22, 1) Source(44, 1) + SourceIndex(0) + 2 >Emitted(22, 12) Source(44, 8) + SourceIndex(0) + 3 >Emitted(22, 18) Source(44, 14) + SourceIndex(0) ++4 >Emitted(22, 20) Source(6, 1) + SourceIndex(0) --- ->>> var Thing; +>>> let Thing; @@ -951,10 +869,6 @@ - > - > } - > } --1 >Emitted(23, 5) Source(44, 15) + SourceIndex(0) --2 >Emitted(23, 9) Source(44, 15) + SourceIndex(0) --3 >Emitted(23, 14) Source(44, 20) + SourceIndex(0) --4 >Emitted(23, 15) Source(64, 2) + SourceIndex(0) +3 > Thing.Widgets { + > export class FindWidget implements Sample.Thing.IWidget { + > @@ -976,9 +890,11 @@ + > + > } + > } -+1 >Emitted(21, 5) Source(44, 15) + SourceIndex(0) -+2 >Emitted(21, 9) Source(44, 15) + SourceIndex(0) -+3 >Emitted(21, 14) Source(64, 2) + SourceIndex(0) + 1 >Emitted(23, 5) Source(44, 15) + SourceIndex(0) + 2 >Emitted(23, 9) Source(44, 15) + SourceIndex(0) +-3 >Emitted(23, 14) Source(44, 20) + SourceIndex(0) +-4 >Emitted(23, 15) Source(64, 2) + SourceIndex(0) ++3 >Emitted(23, 14) Source(64, 2) + SourceIndex(0) --- >>> (function (Thing) { 1->^^^^ @@ -989,14 +905,11 @@ 1-> 2 > 3 > Thing --1->Emitted(24, 5) Source(44, 15) + SourceIndex(0) --2 >Emitted(24, 16) Source(44, 15) + SourceIndex(0) --3 >Emitted(24, 21) Source(44, 20) + SourceIndex(0) +4 > -+1->Emitted(22, 5) Source(44, 15) + SourceIndex(0) -+2 >Emitted(22, 16) Source(44, 15) + SourceIndex(0) -+3 >Emitted(22, 21) Source(44, 20) + SourceIndex(0) -+4 >Emitted(22, 23) Source(6, 1) + SourceIndex(0) + 1->Emitted(24, 5) Source(44, 15) + SourceIndex(0) + 2 >Emitted(24, 16) Source(44, 15) + SourceIndex(0) + 3 >Emitted(24, 21) Source(44, 20) + SourceIndex(0) ++4 >Emitted(24, 23) Source(6, 1) + SourceIndex(0) --- ->>> var Widgets; -1->^^^^^^^^ @@ -1071,9 +984,6 @@ - > } - > } -1->Emitted(25, 9) Source(44, 21) + SourceIndex(0) --2 >Emitted(25, 13) Source(44, 21) + SourceIndex(0) --3 >Emitted(25, 20) Source(44, 28) + SourceIndex(0) --4 >Emitted(25, 21) Source(64, 2) + SourceIndex(0) +3 > Widgets { + > export class FindWidget implements Sample.Thing.IWidget { + > @@ -1095,9 +1005,11 @@ + > + > } + > } -+1 >Emitted(23, 9) Source(44, 21) + SourceIndex(0) -+2 >Emitted(23, 13) Source(44, 21) + SourceIndex(0) -+3 >Emitted(23, 20) Source(64, 2) + SourceIndex(0) ++1 >Emitted(25, 9) Source(44, 21) + SourceIndex(0) + 2 >Emitted(25, 13) Source(44, 21) + SourceIndex(0) +-3 >Emitted(25, 20) Source(44, 28) + SourceIndex(0) +-4 >Emitted(25, 21) Source(64, 2) + SourceIndex(0) ++3 >Emitted(25, 20) Source(64, 2) + SourceIndex(0) --- >>> (function (Widgets) { 1->^^^^^^^^ @@ -1109,14 +1021,11 @@ 1-> 2 > 3 > Widgets --1->Emitted(26, 9) Source(44, 21) + SourceIndex(0) --2 >Emitted(26, 20) Source(44, 21) + SourceIndex(0) --3 >Emitted(26, 27) Source(44, 28) + SourceIndex(0) +4 > -+1->Emitted(24, 9) Source(44, 21) + SourceIndex(0) -+2 >Emitted(24, 20) Source(44, 21) + SourceIndex(0) -+3 >Emitted(24, 27) Source(44, 28) + SourceIndex(0) -+4 >Emitted(24, 29) Source(44, 29) + SourceIndex(0) + 1->Emitted(26, 9) Source(44, 21) + SourceIndex(0) + 2 >Emitted(26, 20) Source(44, 21) + SourceIndex(0) + 3 >Emitted(26, 27) Source(44, 28) + SourceIndex(0) ++4 >Emitted(26, 29) Source(44, 29) + SourceIndex(0) --- >>> class FindWidget { 1->^^^^^^^^^^^^ @@ -1128,13 +1037,10 @@ > 2 > export class 3 > FindWidget --1->Emitted(27, 13) Source(45, 2) + SourceIndex(0) --2 >Emitted(27, 19) Source(45, 15) + SourceIndex(0) --3 >Emitted(27, 29) Source(45, 25) + SourceIndex(0) -+1->Emitted(25, 13) Source(45, 2) + SourceIndex(0) -+2 >Emitted(25, 19) Source(45, 15) + SourceIndex(0) -+3 >Emitted(25, 29) Source(45, 25) + SourceIndex(0) -+--- +@@= skipped -128, +206 lines =@@ + 2 >Emitted(27, 19) Source(45, 15) + SourceIndex(0) + 3 >Emitted(27, 29) Source(45, 25) + SourceIndex(0) + --- +>>> codeThing; +1 >^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^ @@ -1146,9 +1052,9 @@ + > private domNode:any = null; + > constructor(private +2 > codeThing -+1 >Emitted(26, 17) Source(50, 23) + SourceIndex(0) -+2 >Emitted(26, 26) Source(50, 32) + SourceIndex(0) - --- ++1 >Emitted(28, 17) Source(50, 23) + SourceIndex(0) ++2 >Emitted(28, 26) Source(50, 32) + SourceIndex(0) ++--- >>> gar(runner) { if (true) { 1->^^^^^^^^^^^^^^^^ 2 > ^^^ @@ -1192,20 +1098,20 @@ +8 > true +9 > ) +10> { -+1->Emitted(27, 17) Source(47, 10) + SourceIndex(0) -+2 >Emitted(27, 20) Source(47, 13) + SourceIndex(0) -+3 >Emitted(27, 21) Source(47, 14) + SourceIndex(0) -+4 >Emitted(27, 27) Source(47, 55) + SourceIndex(0) -+5 >Emitted(27, 29) Source(47, 57) + SourceIndex(0) -+6 >Emitted(27, 31) Source(47, 59) + SourceIndex(0) -+7 >Emitted(27, 35) Source(47, 63) + SourceIndex(0) -+8 >Emitted(27, 39) Source(47, 67) + SourceIndex(0) -+9 >Emitted(27, 41) Source(47, 69) + SourceIndex(0) -+10>Emitted(27, 42) Source(47, 70) + SourceIndex(0) ++1->Emitted(29, 17) Source(47, 10) + SourceIndex(0) ++2 >Emitted(29, 20) Source(47, 13) + SourceIndex(0) ++3 >Emitted(29, 21) Source(47, 14) + SourceIndex(0) ++4 >Emitted(29, 27) Source(47, 55) + SourceIndex(0) ++5 >Emitted(29, 29) Source(47, 57) + SourceIndex(0) ++6 >Emitted(29, 31) Source(47, 59) + SourceIndex(0) ++7 >Emitted(29, 35) Source(47, 63) + SourceIndex(0) ++8 >Emitted(29, 39) Source(47, 67) + SourceIndex(0) ++9 >Emitted(29, 41) Source(47, 69) + SourceIndex(0) ++10>Emitted(29, 42) Source(47, 70) + SourceIndex(0) --- >>> return runner(this); 1 >^^^^^^^^^^^^^^^^^^^^ -@@= skipped -174, +267 lines =@@ +@@= skipped -46, +61 lines =@@ 5 > this 6 > ) 7 > ; @@ -1216,13 +1122,13 @@ -5 >Emitted(29, 39) Source(47, 88) + SourceIndex(0) -6 >Emitted(29, 40) Source(47, 89) + SourceIndex(0) -7 >Emitted(29, 41) Source(47, 90) + SourceIndex(0) -+1 >Emitted(28, 21) Source(47, 70) + SourceIndex(0) -+2 >Emitted(28, 28) Source(47, 77) + SourceIndex(0) -+3 >Emitted(28, 34) Source(47, 83) + SourceIndex(0) -+4 >Emitted(28, 35) Source(47, 84) + SourceIndex(0) -+5 >Emitted(28, 39) Source(47, 88) + SourceIndex(0) -+6 >Emitted(28, 40) Source(47, 89) + SourceIndex(0) -+7 >Emitted(28, 41) Source(47, 90) + SourceIndex(0) ++1 >Emitted(30, 21) Source(47, 70) + SourceIndex(0) ++2 >Emitted(30, 28) Source(47, 77) + SourceIndex(0) ++3 >Emitted(30, 34) Source(47, 83) + SourceIndex(0) ++4 >Emitted(30, 35) Source(47, 84) + SourceIndex(0) ++5 >Emitted(30, 39) Source(47, 88) + SourceIndex(0) ++6 >Emitted(30, 40) Source(47, 89) + SourceIndex(0) ++7 >Emitted(30, 41) Source(47, 90) + SourceIndex(0) --- >>> } } 1 >^^^^^^^^^^^^^^^^ @@ -1239,10 +1145,10 @@ -2 >Emitted(30, 18) Source(47, 91) + SourceIndex(0) -3 >Emitted(30, 19) Source(47, 91) + SourceIndex(0) -4 >Emitted(30, 20) Source(47, 92) + SourceIndex(0) -+1 >Emitted(29, 17) Source(47, 90) + SourceIndex(0) -+2 >Emitted(29, 18) Source(47, 91) + SourceIndex(0) -+3 >Emitted(29, 19) Source(47, 91) + SourceIndex(0) -+4 >Emitted(29, 20) Source(47, 92) + SourceIndex(0) ++1 >Emitted(31, 17) Source(47, 90) + SourceIndex(0) ++2 >Emitted(31, 18) Source(47, 91) + SourceIndex(0) ++3 >Emitted(31, 19) Source(47, 91) + SourceIndex(0) ++4 >Emitted(31, 20) Source(47, 92) + SourceIndex(0) +--- +>>> domNode = null; +1->^^^^^^^^^^^^^^^^ @@ -1258,11 +1164,11 @@ +3 > :any = +4 > null +5 > ; -+1->Emitted(30, 17) Source(49, 11) + SourceIndex(0) -+2 >Emitted(30, 24) Source(49, 18) + SourceIndex(0) -+3 >Emitted(30, 27) Source(49, 25) + SourceIndex(0) -+4 >Emitted(30, 31) Source(49, 29) + SourceIndex(0) -+5 >Emitted(30, 32) Source(49, 30) + SourceIndex(0) ++1->Emitted(32, 17) Source(49, 11) + SourceIndex(0) ++2 >Emitted(32, 24) Source(49, 18) + SourceIndex(0) ++3 >Emitted(32, 27) Source(49, 25) + SourceIndex(0) ++4 >Emitted(32, 31) Source(49, 29) + SourceIndex(0) ++5 >Emitted(32, 32) Source(49, 30) + SourceIndex(0) --- >>> constructor(codeThing) { 1->^^^^^^^^^^^^^^^^ @@ -1277,11 +1183,14 @@ > 2 > constructor(private 3 > codeThing: Sample.Thing.ICodeThing +-1->Emitted(31, 17) Source(50, 3) + SourceIndex(0) +-2 >Emitted(31, 29) Source(50, 23) + SourceIndex(0) +-3 >Emitted(31, 38) Source(50, 57) + SourceIndex(0) +4 > ) - 1->Emitted(31, 17) Source(50, 3) + SourceIndex(0) - 2 >Emitted(31, 29) Source(50, 23) + SourceIndex(0) - 3 >Emitted(31, 38) Source(50, 57) + SourceIndex(0) -+4 >Emitted(31, 40) Source(50, 59) + SourceIndex(0) ++1->Emitted(33, 17) Source(50, 3) + SourceIndex(0) ++2 >Emitted(33, 29) Source(50, 23) + SourceIndex(0) ++3 >Emitted(33, 38) Source(50, 57) + SourceIndex(0) ++4 >Emitted(33, 40) Source(50, 59) + SourceIndex(0) --- >>> this.codeThing = codeThing; -1->^^^^^^^^^^^^^^^^^^^^ @@ -1319,8 +1228,8 @@ -4 >Emitted(33, 40) Source(49, 29) + SourceIndex(0) -5 >Emitted(33, 41) Source(49, 30) + SourceIndex(0) +2 > codeThing -+1->Emitted(32, 38) Source(50, 23) + SourceIndex(0) -+2 >Emitted(32, 47) Source(50, 32) + SourceIndex(0) ++1->Emitted(34, 38) Source(50, 23) + SourceIndex(0) ++2 >Emitted(34, 47) Source(50, 32) + SourceIndex(0) --- >>> // scenario 1 1 >^^^^^^^^^^^^^^^^^^^^ @@ -1333,8 +1242,8 @@ 2 > // scenario 1 -1 >Emitted(34, 21) Source(51, 7) + SourceIndex(0) -2 >Emitted(34, 34) Source(51, 20) + SourceIndex(0) -+1 >Emitted(33, 21) Source(51, 7) + SourceIndex(0) -+2 >Emitted(33, 34) Source(51, 20) + SourceIndex(0) ++1 >Emitted(35, 21) Source(51, 7) + SourceIndex(0) ++2 >Emitted(35, 34) Source(51, 20) + SourceIndex(0) --- >>> codeThing.addWidget("addWidget", this); 1->^^^^^^^^^^^^^^^^^^^^ @@ -1352,16 +1261,16 @@ -8 >Emitted(35, 58) Source(52, 44) + SourceIndex(0) -9 >Emitted(35, 59) Source(52, 45) + SourceIndex(0) -10>Emitted(35, 60) Source(52, 46) + SourceIndex(0) -+1->Emitted(34, 21) Source(52, 7) + SourceIndex(0) -+2 >Emitted(34, 30) Source(52, 16) + SourceIndex(0) -+3 >Emitted(34, 31) Source(52, 17) + SourceIndex(0) -+4 >Emitted(34, 40) Source(52, 26) + SourceIndex(0) -+5 >Emitted(34, 41) Source(52, 27) + SourceIndex(0) -+6 >Emitted(34, 52) Source(52, 38) + SourceIndex(0) -+7 >Emitted(34, 54) Source(52, 40) + SourceIndex(0) -+8 >Emitted(34, 58) Source(52, 44) + SourceIndex(0) -+9 >Emitted(34, 59) Source(52, 45) + SourceIndex(0) -+10>Emitted(34, 60) Source(52, 46) + SourceIndex(0) ++1->Emitted(36, 21) Source(52, 7) + SourceIndex(0) ++2 >Emitted(36, 30) Source(52, 16) + SourceIndex(0) ++3 >Emitted(36, 31) Source(52, 17) + SourceIndex(0) ++4 >Emitted(36, 40) Source(52, 26) + SourceIndex(0) ++5 >Emitted(36, 41) Source(52, 27) + SourceIndex(0) ++6 >Emitted(36, 52) Source(52, 38) + SourceIndex(0) ++7 >Emitted(36, 54) Source(52, 40) + SourceIndex(0) ++8 >Emitted(36, 58) Source(52, 44) + SourceIndex(0) ++9 >Emitted(36, 59) Source(52, 45) + SourceIndex(0) ++10>Emitted(36, 60) Source(52, 46) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^ @@ -1374,8 +1283,8 @@ -2 >Emitted(36, 18) Source(53, 4) + SourceIndex(0) +2 > + > } -+1 >Emitted(35, 17) Source(52, 46) + SourceIndex(0) -+2 >Emitted(35, 18) Source(53, 4) + SourceIndex(0) ++1 >Emitted(37, 17) Source(52, 46) + SourceIndex(0) ++2 >Emitted(37, 18) Source(53, 4) + SourceIndex(0) --- >>> getDomNode() { 1->^^^^^^^^^^^^^^^^ @@ -1390,9 +1299,9 @@ -1->Emitted(37, 17) Source(55, 10) + SourceIndex(0) -2 >Emitted(37, 27) Source(55, 20) + SourceIndex(0) +3 > () -+1->Emitted(36, 17) Source(55, 10) + SourceIndex(0) -+2 >Emitted(36, 27) Source(55, 20) + SourceIndex(0) -+3 >Emitted(36, 30) Source(55, 23) + SourceIndex(0) ++1->Emitted(38, 17) Source(55, 10) + SourceIndex(0) ++2 >Emitted(38, 27) Source(55, 20) + SourceIndex(0) ++3 >Emitted(38, 30) Source(55, 23) + SourceIndex(0) --- >>> return domNode; 1->^^^^^^^^^^^^^^^^^^^^ @@ -1409,10 +1318,10 @@ -2 >Emitted(38, 28) Source(56, 11) + SourceIndex(0) -3 >Emitted(38, 35) Source(56, 18) + SourceIndex(0) -4 >Emitted(38, 36) Source(56, 19) + SourceIndex(0) -+1->Emitted(37, 21) Source(56, 4) + SourceIndex(0) -+2 >Emitted(37, 28) Source(56, 11) + SourceIndex(0) -+3 >Emitted(37, 35) Source(56, 18) + SourceIndex(0) -+4 >Emitted(37, 36) Source(56, 19) + SourceIndex(0) ++1->Emitted(39, 21) Source(56, 4) + SourceIndex(0) ++2 >Emitted(39, 28) Source(56, 11) + SourceIndex(0) ++3 >Emitted(39, 35) Source(56, 18) + SourceIndex(0) ++4 >Emitted(39, 36) Source(56, 19) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^ @@ -1425,8 +1334,8 @@ -2 >Emitted(39, 18) Source(57, 4) + SourceIndex(0) +2 > + > } -+1 >Emitted(38, 17) Source(56, 19) + SourceIndex(0) -+2 >Emitted(38, 18) Source(57, 4) + SourceIndex(0) ++1 >Emitted(40, 17) Source(56, 19) + SourceIndex(0) ++2 >Emitted(40, 18) Source(57, 4) + SourceIndex(0) --- >>> destroy() { 1->^^^^^^^^^^^^^^^^ @@ -1439,9 +1348,9 @@ -1->Emitted(40, 17) Source(59, 10) + SourceIndex(0) -2 >Emitted(40, 24) Source(59, 17) + SourceIndex(0) +3 > () -+1->Emitted(39, 17) Source(59, 10) + SourceIndex(0) -+2 >Emitted(39, 24) Source(59, 17) + SourceIndex(0) -+3 >Emitted(39, 27) Source(59, 20) + SourceIndex(0) ++1->Emitted(41, 17) Source(59, 10) + SourceIndex(0) ++2 >Emitted(41, 24) Source(59, 17) + SourceIndex(0) ++3 >Emitted(41, 27) Source(59, 20) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^ @@ -1456,8 +1365,8 @@ +2 > + > + > } -+1 >Emitted(40, 17) Source(59, 21) + SourceIndex(0) -+2 >Emitted(40, 18) Source(61, 4) + SourceIndex(0) ++1 >Emitted(42, 17) Source(59, 21) + SourceIndex(0) ++2 >Emitted(42, 18) Source(61, 4) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^ @@ -1466,7 +1375,7 @@ > > } -1 >Emitted(42, 14) Source(63, 3) + SourceIndex(0) -+1 >Emitted(41, 14) Source(63, 3) + SourceIndex(0) ++1 >Emitted(43, 14) Source(63, 3) + SourceIndex(0) --- >>> Widgets.FindWidget = FindWidget; 1->^^^^^^^^^^^^ @@ -1498,11 +1407,11 @@ -3 >Emitted(43, 44) Source(63, 3) + SourceIndex(0) -4 >Emitted(43, 45) Source(63, 3) + SourceIndex(0) +5 > -+1->Emitted(42, 13) Source(45, 15) + SourceIndex(0) -+2 >Emitted(42, 21) Source(45, 15) + SourceIndex(0) -+3 >Emitted(42, 31) Source(45, 25) + SourceIndex(0) -+4 >Emitted(42, 44) Source(63, 3) + SourceIndex(0) -+5 >Emitted(42, 45) Source(63, 3) + SourceIndex(0) ++1->Emitted(44, 13) Source(45, 15) + SourceIndex(0) ++2 >Emitted(44, 21) Source(45, 15) + SourceIndex(0) ++3 >Emitted(44, 31) Source(45, 25) + SourceIndex(0) ++4 >Emitted(44, 44) Source(63, 3) + SourceIndex(0) ++5 >Emitted(44, 45) Source(63, 3) + SourceIndex(0) --- >>> })(Widgets = Thing.Widgets || (Thing.Widgets = {})); 1->^^^^^^^^ @@ -1554,17 +1463,17 @@ -7 >Emitted(44, 40) Source(44, 21) + SourceIndex(0) -8 >Emitted(44, 53) Source(44, 28) + SourceIndex(0) -9 >Emitted(44, 61) Source(64, 2) + SourceIndex(0) -+1->Emitted(43, 9) Source(63, 3) + SourceIndex(0) -+2 >Emitted(43, 10) Source(64, 2) + SourceIndex(0) -+3 >Emitted(43, 12) Source(44, 21) + SourceIndex(0) -+4 >Emitted(43, 19) Source(44, 28) + SourceIndex(0) -+5 >Emitted(43, 22) Source(44, 21) + SourceIndex(0) -+6 >Emitted(43, 28) Source(44, 21) + SourceIndex(0) -+7 >Emitted(43, 35) Source(44, 28) + SourceIndex(0) -+8 >Emitted(43, 40) Source(44, 21) + SourceIndex(0) -+9 >Emitted(43, 46) Source(44, 21) + SourceIndex(0) -+10>Emitted(43, 53) Source(44, 28) + SourceIndex(0) -+11>Emitted(43, 61) Source(64, 2) + SourceIndex(0) ++1->Emitted(45, 9) Source(63, 3) + SourceIndex(0) ++2 >Emitted(45, 10) Source(64, 2) + SourceIndex(0) ++3 >Emitted(45, 12) Source(44, 21) + SourceIndex(0) ++4 >Emitted(45, 19) Source(44, 28) + SourceIndex(0) ++5 >Emitted(45, 22) Source(44, 21) + SourceIndex(0) ++6 >Emitted(45, 28) Source(44, 21) + SourceIndex(0) ++7 >Emitted(45, 35) Source(44, 28) + SourceIndex(0) ++8 >Emitted(45, 40) Source(44, 21) + SourceIndex(0) ++9 >Emitted(45, 46) Source(44, 21) + SourceIndex(0) ++10>Emitted(45, 53) Source(44, 28) + SourceIndex(0) ++11>Emitted(45, 61) Source(64, 2) + SourceIndex(0) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -1665,18 +1574,18 @@ -7 >Emitted(45, 33) Source(44, 15) + SourceIndex(0) -8 >Emitted(45, 45) Source(44, 20) + SourceIndex(0) -9 >Emitted(45, 53) Source(64, 2) + SourceIndex(0) -+1 >Emitted(44, 5) Source(63, 3) + SourceIndex(0) -+2 >Emitted(44, 6) Source(64, 1) + SourceIndex(0) -+3 >Emitted(44, 6) Source(1, 1) + SourceIndex(0) -+4 >Emitted(44, 8) Source(44, 15) + SourceIndex(0) -+5 >Emitted(44, 13) Source(44, 20) + SourceIndex(0) -+6 >Emitted(44, 16) Source(44, 15) + SourceIndex(0) -+7 >Emitted(44, 23) Source(44, 15) + SourceIndex(0) -+8 >Emitted(44, 28) Source(44, 20) + SourceIndex(0) -+9 >Emitted(44, 33) Source(44, 15) + SourceIndex(0) -+10>Emitted(44, 40) Source(44, 15) + SourceIndex(0) -+11>Emitted(44, 45) Source(44, 20) + SourceIndex(0) -+12>Emitted(44, 53) Source(64, 2) + SourceIndex(0) ++1 >Emitted(46, 5) Source(63, 3) + SourceIndex(0) ++2 >Emitted(46, 6) Source(64, 1) + SourceIndex(0) ++3 >Emitted(46, 6) Source(1, 1) + SourceIndex(0) ++4 >Emitted(46, 8) Source(44, 15) + SourceIndex(0) ++5 >Emitted(46, 13) Source(44, 20) + SourceIndex(0) ++6 >Emitted(46, 16) Source(44, 15) + SourceIndex(0) ++7 >Emitted(46, 23) Source(44, 15) + SourceIndex(0) ++8 >Emitted(46, 28) Source(44, 20) + SourceIndex(0) ++9 >Emitted(46, 33) Source(44, 15) + SourceIndex(0) ++10>Emitted(46, 40) Source(44, 15) + SourceIndex(0) ++11>Emitted(46, 45) Source(44, 20) + SourceIndex(0) ++12>Emitted(46, 53) Source(64, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -1763,14 +1672,14 @@ -5 >Emitted(46, 15) Source(44, 8) + SourceIndex(0) -6 >Emitted(46, 21) Source(44, 14) + SourceIndex(0) -7 >Emitted(46, 29) Source(64, 2) + SourceIndex(0) -+1 >Emitted(45, 1) Source(63, 3) + SourceIndex(0) -+2 >Emitted(45, 2) Source(64, 1) + SourceIndex(0) -+3 >Emitted(45, 2) Source(1, 1) + SourceIndex(0) -+4 >Emitted(45, 4) Source(44, 8) + SourceIndex(0) -+5 >Emitted(45, 10) Source(44, 14) + SourceIndex(0) -+6 >Emitted(45, 15) Source(44, 8) + SourceIndex(0) -+7 >Emitted(45, 21) Source(44, 14) + SourceIndex(0) -+8 >Emitted(45, 29) Source(64, 2) + SourceIndex(0) ++1 >Emitted(47, 1) Source(63, 3) + SourceIndex(0) ++2 >Emitted(47, 2) Source(64, 1) + SourceIndex(0) ++3 >Emitted(47, 2) Source(1, 1) + SourceIndex(0) ++4 >Emitted(47, 4) Source(44, 8) + SourceIndex(0) ++5 >Emitted(47, 10) Source(44, 14) + SourceIndex(0) ++6 >Emitted(47, 15) Source(44, 8) + SourceIndex(0) ++7 >Emitted(47, 21) Source(44, 14) + SourceIndex(0) ++8 >Emitted(47, 29) Source(64, 2) + SourceIndex(0) --- >>>class AbstractMode { 1 > @@ -1781,9 +1690,9 @@ -1 >Emitted(47, 1) Source(67, 1) + SourceIndex(0) -2 >Emitted(47, 7) Source(67, 7) + SourceIndex(0) -3 >Emitted(47, 19) Source(67, 19) + SourceIndex(0) -+1 >Emitted(46, 1) Source(67, 1) + SourceIndex(0) -+2 >Emitted(46, 7) Source(67, 7) + SourceIndex(0) -+3 >Emitted(46, 19) Source(67, 19) + SourceIndex(0) ++1 >Emitted(48, 1) Source(67, 1) + SourceIndex(0) ++2 >Emitted(48, 7) Source(67, 7) + SourceIndex(0) ++3 >Emitted(48, 19) Source(67, 19) + SourceIndex(0) --- >>> getInitialState() { return null; } 1->^^^^ @@ -1824,22 +1733,22 @@ +7 > ; +8 > +9 > } -+1->Emitted(47, 5) Source(67, 46) + SourceIndex(0) -+2 >Emitted(47, 20) Source(67, 61) + SourceIndex(0) -+3 >Emitted(47, 23) Source(67, 72) + SourceIndex(0) -+4 >Emitted(47, 25) Source(67, 74) + SourceIndex(0) -+5 >Emitted(47, 32) Source(67, 81) + SourceIndex(0) -+6 >Emitted(47, 36) Source(67, 85) + SourceIndex(0) -+7 >Emitted(47, 37) Source(67, 86) + SourceIndex(0) -+8 >Emitted(47, 38) Source(67, 86) + SourceIndex(0) -+9 >Emitted(47, 39) Source(67, 87) + SourceIndex(0) ++1->Emitted(49, 5) Source(67, 46) + SourceIndex(0) ++2 >Emitted(49, 20) Source(67, 61) + SourceIndex(0) ++3 >Emitted(49, 23) Source(67, 72) + SourceIndex(0) ++4 >Emitted(49, 25) Source(67, 74) + SourceIndex(0) ++5 >Emitted(49, 32) Source(67, 81) + SourceIndex(0) ++6 >Emitted(49, 36) Source(67, 85) + SourceIndex(0) ++7 >Emitted(49, 37) Source(67, 86) + SourceIndex(0) ++8 >Emitted(49, 38) Source(67, 86) + SourceIndex(0) ++9 >Emitted(49, 39) Source(67, 87) + SourceIndex(0) --- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^^^^-> 1 > } -1 >Emitted(49, 2) Source(67, 89) + SourceIndex(0) -+1 >Emitted(48, 2) Source(67, 89) + SourceIndex(0) ++1 >Emitted(50, 2) Source(67, 89) + SourceIndex(0) --- >>>(function (Sample) { 1-> @@ -1857,10 +1766,10 @@ -2 >Emitted(50, 12) Source(76, 8) + SourceIndex(0) -3 >Emitted(50, 18) Source(76, 14) + SourceIndex(0) +4 > -+1->Emitted(49, 1) Source(76, 1) + SourceIndex(0) -+2 >Emitted(49, 12) Source(76, 8) + SourceIndex(0) -+3 >Emitted(49, 18) Source(76, 14) + SourceIndex(0) -+4 >Emitted(49, 20) Source(6, 1) + SourceIndex(0) ++1->Emitted(51, 1) Source(76, 1) + SourceIndex(0) ++2 >Emitted(51, 12) Source(76, 8) + SourceIndex(0) ++3 >Emitted(51, 18) Source(76, 14) + SourceIndex(0) ++4 >Emitted(51, 20) Source(6, 1) + SourceIndex(0) --- ->>> var Thing; +>>> let Thing; @@ -1998,9 +1907,9 @@ + > + > } + > } -+1 >Emitted(50, 5) Source(76, 15) + SourceIndex(0) -+2 >Emitted(50, 9) Source(76, 15) + SourceIndex(0) -+3 >Emitted(50, 14) Source(100, 2) + SourceIndex(0) ++1 >Emitted(52, 5) Source(76, 15) + SourceIndex(0) ++2 >Emitted(52, 9) Source(76, 15) + SourceIndex(0) ++3 >Emitted(52, 14) Source(100, 2) + SourceIndex(0) --- >>> (function (Thing) { 1->^^^^ @@ -2016,10 +1925,10 @@ -2 >Emitted(52, 16) Source(76, 15) + SourceIndex(0) -3 >Emitted(52, 21) Source(76, 20) + SourceIndex(0) +4 > -+1->Emitted(51, 5) Source(76, 15) + SourceIndex(0) -+2 >Emitted(51, 16) Source(76, 15) + SourceIndex(0) -+3 >Emitted(51, 21) Source(76, 20) + SourceIndex(0) -+4 >Emitted(51, 23) Source(6, 1) + SourceIndex(0) ++1->Emitted(53, 5) Source(76, 15) + SourceIndex(0) ++2 >Emitted(53, 16) Source(76, 15) + SourceIndex(0) ++3 >Emitted(53, 21) Source(76, 20) + SourceIndex(0) ++4 >Emitted(53, 23) Source(6, 1) + SourceIndex(0) --- ->>> var Languages; +>>> let Languages; @@ -2157,9 +2066,9 @@ + > + > } + > } -+1->Emitted(52, 9) Source(76, 21) + SourceIndex(0) -+2 >Emitted(52, 13) Source(76, 21) + SourceIndex(0) -+3 >Emitted(52, 22) Source(100, 2) + SourceIndex(0) ++1->Emitted(54, 9) Source(76, 21) + SourceIndex(0) ++2 >Emitted(54, 13) Source(76, 21) + SourceIndex(0) ++3 >Emitted(54, 22) Source(100, 2) + SourceIndex(0) --- >>> (function (Languages) { 1->^^^^^^^^ @@ -2173,10 +2082,10 @@ -2 >Emitted(54, 20) Source(76, 21) + SourceIndex(0) -3 >Emitted(54, 29) Source(76, 30) + SourceIndex(0) +4 > -+1->Emitted(53, 9) Source(76, 21) + SourceIndex(0) -+2 >Emitted(53, 20) Source(76, 21) + SourceIndex(0) -+3 >Emitted(53, 29) Source(76, 30) + SourceIndex(0) -+4 >Emitted(53, 31) Source(6, 1) + SourceIndex(0) ++1->Emitted(55, 9) Source(76, 21) + SourceIndex(0) ++2 >Emitted(55, 20) Source(76, 21) + SourceIndex(0) ++3 >Emitted(55, 29) Source(76, 30) + SourceIndex(0) ++4 >Emitted(55, 31) Source(6, 1) + SourceIndex(0) --- ->>> var PlainText; +>>> let PlainText; @@ -2314,9 +2223,9 @@ + > + > } + > } -+1 >Emitted(54, 13) Source(76, 31) + SourceIndex(0) -+2 >Emitted(54, 17) Source(76, 31) + SourceIndex(0) -+3 >Emitted(54, 26) Source(100, 2) + SourceIndex(0) ++1 >Emitted(56, 13) Source(76, 31) + SourceIndex(0) ++2 >Emitted(56, 17) Source(76, 31) + SourceIndex(0) ++3 >Emitted(56, 26) Source(100, 2) + SourceIndex(0) --- >>> (function (PlainText) { 1->^^^^^^^^^^^^ @@ -2330,10 +2239,10 @@ -2 >Emitted(56, 24) Source(76, 31) + SourceIndex(0) -3 >Emitted(56, 33) Source(76, 40) + SourceIndex(0) +4 > -+1->Emitted(55, 13) Source(76, 31) + SourceIndex(0) -+2 >Emitted(55, 24) Source(76, 31) + SourceIndex(0) -+3 >Emitted(55, 33) Source(76, 40) + SourceIndex(0) -+4 >Emitted(55, 35) Source(76, 41) + SourceIndex(0) ++1->Emitted(57, 13) Source(76, 31) + SourceIndex(0) ++2 >Emitted(57, 24) Source(76, 31) + SourceIndex(0) ++3 >Emitted(57, 33) Source(76, 40) + SourceIndex(0) ++4 >Emitted(57, 35) Source(76, 41) + SourceIndex(0) --- >>> class State { 1 >^^^^^^^^^^^^^^^^ @@ -2349,9 +2258,9 @@ -1 >Emitted(57, 17) Source(78, 2) + SourceIndex(0) -2 >Emitted(57, 23) Source(78, 15) + SourceIndex(0) -3 >Emitted(57, 28) Source(78, 20) + SourceIndex(0) -+1 >Emitted(56, 17) Source(78, 2) + SourceIndex(0) -+2 >Emitted(56, 23) Source(78, 15) + SourceIndex(0) -+3 >Emitted(56, 28) Source(78, 20) + SourceIndex(0) ++1 >Emitted(58, 17) Source(78, 2) + SourceIndex(0) ++2 >Emitted(58, 23) Source(78, 15) + SourceIndex(0) ++3 >Emitted(58, 28) Source(78, 20) + SourceIndex(0) +--- +>>> mode; +1 >^^^^^^^^^^^^^^^^^^^^ @@ -2360,8 +2269,8 @@ +1 > implements IState { + > constructor(private +2 > mode -+1 >Emitted(57, 21) Source(79, 29) + SourceIndex(0) -+2 >Emitted(57, 25) Source(79, 33) + SourceIndex(0) ++1 >Emitted(59, 21) Source(79, 29) + SourceIndex(0) ++2 >Emitted(59, 25) Source(79, 33) + SourceIndex(0) --- >>> constructor(mode) { 1->^^^^^^^^^^^^^^^^^^^^ @@ -2375,11 +2284,14 @@ +1-> 2 > constructor(private 3 > mode: IMode +-1->Emitted(58, 21) Source(79, 9) + SourceIndex(0) +-2 >Emitted(58, 33) Source(79, 29) + SourceIndex(0) +-3 >Emitted(58, 37) Source(79, 40) + SourceIndex(0) +4 > ) - 1->Emitted(58, 21) Source(79, 9) + SourceIndex(0) - 2 >Emitted(58, 33) Source(79, 29) + SourceIndex(0) - 3 >Emitted(58, 37) Source(79, 40) + SourceIndex(0) -+4 >Emitted(58, 39) Source(79, 42) + SourceIndex(0) ++1->Emitted(60, 21) Source(79, 9) + SourceIndex(0) ++2 >Emitted(60, 33) Source(79, 29) + SourceIndex(0) ++3 >Emitted(60, 37) Source(79, 40) + SourceIndex(0) ++4 >Emitted(60, 39) Source(79, 42) + SourceIndex(0) --- >>> this.mode = mode; -1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2400,8 +2312,8 @@ -4 >Emitted(59, 41) Source(79, 33) + SourceIndex(0) -5 >Emitted(59, 42) Source(79, 40) + SourceIndex(0) +2 > mode -+1->Emitted(59, 37) Source(79, 29) + SourceIndex(0) -+2 >Emitted(59, 41) Source(79, 33) + SourceIndex(0) ++1->Emitted(61, 37) Source(79, 29) + SourceIndex(0) ++2 >Emitted(61, 41) Source(79, 33) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^^^^ @@ -2410,10 +2322,11 @@ -1 >) { -2 > } -1 >Emitted(60, 21) Source(79, 44) + SourceIndex(0) +-2 >Emitted(60, 22) Source(79, 45) + SourceIndex(0) +1 >: IMode) { +2 > } -+1 >Emitted(60, 21) Source(79, 43) + SourceIndex(0) - 2 >Emitted(60, 22) Source(79, 45) + SourceIndex(0) ++1 >Emitted(62, 21) Source(79, 43) + SourceIndex(0) ++2 >Emitted(62, 22) Source(79, 45) + SourceIndex(0) --- >>> clone() { 1->^^^^^^^^^^^^^^^^^^^^ @@ -2424,10 +2337,12 @@ 1-> > public 2 > clone +-1->Emitted(61, 21) Source(80, 10) + SourceIndex(0) +-2 >Emitted(61, 26) Source(80, 15) + SourceIndex(0) +3 > ():IState - 1->Emitted(61, 21) Source(80, 10) + SourceIndex(0) - 2 >Emitted(61, 26) Source(80, 15) + SourceIndex(0) -+3 >Emitted(61, 29) Source(80, 25) + SourceIndex(0) ++1->Emitted(63, 21) Source(80, 10) + SourceIndex(0) ++2 >Emitted(63, 26) Source(80, 15) + SourceIndex(0) ++3 >Emitted(63, 29) Source(80, 25) + SourceIndex(0) --- >>> return this; 1->^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2439,20 +2354,32 @@ > 2 > return 3 > this -@@= skipped -238, +455 lines =@@ + 4 > ; +-1->Emitted(62, 25) Source(81, 4) + SourceIndex(0) +-2 >Emitted(62, 32) Source(81, 11) + SourceIndex(0) +-3 >Emitted(62, 36) Source(81, 15) + SourceIndex(0) +-4 >Emitted(62, 37) Source(81, 16) + SourceIndex(0) ++1->Emitted(64, 25) Source(81, 4) + SourceIndex(0) ++2 >Emitted(64, 32) Source(81, 11) + SourceIndex(0) ++3 >Emitted(64, 36) Source(81, 15) + SourceIndex(0) ++4 >Emitted(64, 37) Source(81, 16) + SourceIndex(0) + --- + >>> } + 1 >^^^^^^^^^^^^^^^^^^^^ 2 > ^ 3 > ^^^^^^^^^^^^^^^-> 1 > - > -2 > } -1 >Emitted(63, 21) Source(82, 3) + SourceIndex(0) +-2 >Emitted(63, 22) Source(82, 4) + SourceIndex(0) +2 > + > } -+1 >Emitted(63, 21) Source(81, 16) + SourceIndex(0) - 2 >Emitted(63, 22) Source(82, 4) + SourceIndex(0) ++1 >Emitted(65, 21) Source(81, 16) + SourceIndex(0) ++2 >Emitted(65, 22) Source(82, 4) + SourceIndex(0) --- >>> equals(other) { -@@= skipped -10, +10 lines =@@ + 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^^ 3 > ^ 4 > ^^^^^ @@ -2465,16 +2392,20 @@ 2 > equals 3 > ( 4 > other:IState +-1->Emitted(64, 21) Source(84, 10) + SourceIndex(0) +-2 >Emitted(64, 27) Source(84, 16) + SourceIndex(0) +-3 >Emitted(64, 28) Source(84, 17) + SourceIndex(0) +-4 >Emitted(64, 33) Source(84, 29) + SourceIndex(0) +5 > ):boolean - 1->Emitted(64, 21) Source(84, 10) + SourceIndex(0) - 2 >Emitted(64, 27) Source(84, 16) + SourceIndex(0) - 3 >Emitted(64, 28) Source(84, 17) + SourceIndex(0) - 4 >Emitted(64, 33) Source(84, 29) + SourceIndex(0) -+5 >Emitted(64, 35) Source(84, 39) + SourceIndex(0) ++1->Emitted(66, 21) Source(84, 10) + SourceIndex(0) ++2 >Emitted(66, 27) Source(84, 16) + SourceIndex(0) ++3 >Emitted(66, 28) Source(84, 17) + SourceIndex(0) ++4 >Emitted(66, 33) Source(84, 29) + SourceIndex(0) ++5 >Emitted(66, 35) Source(84, 39) + SourceIndex(0) --- >>> return this === other; 1->^^^^^^^^^^^^^^^^^^^^^^^^ -@@= skipped -19, +22 lines =@@ +@@= skipped -267, +487 lines =@@ 4 > ^^^^^ 5 > ^^^^^ 6 > ^ @@ -2483,17 +2414,35 @@ > 2 > return 3 > this -@@= skipped -19, +19 lines =@@ + 4 > === + 5 > other + 6 > ; +-1->Emitted(65, 25) Source(85, 4) + SourceIndex(0) +-2 >Emitted(65, 32) Source(85, 11) + SourceIndex(0) +-3 >Emitted(65, 36) Source(85, 15) + SourceIndex(0) +-4 >Emitted(65, 41) Source(85, 20) + SourceIndex(0) +-5 >Emitted(65, 46) Source(85, 25) + SourceIndex(0) +-6 >Emitted(65, 47) Source(85, 26) + SourceIndex(0) ++1->Emitted(67, 25) Source(85, 4) + SourceIndex(0) ++2 >Emitted(67, 32) Source(85, 11) + SourceIndex(0) ++3 >Emitted(67, 36) Source(85, 15) + SourceIndex(0) ++4 >Emitted(67, 41) Source(85, 20) + SourceIndex(0) ++5 >Emitted(67, 46) Source(85, 25) + SourceIndex(0) ++6 >Emitted(67, 47) Source(85, 26) + SourceIndex(0) + --- + >>> } + 1 >^^^^^^^^^^^^^^^^^^^^ 2 > ^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > - > -2 > } -1 >Emitted(66, 21) Source(86, 3) + SourceIndex(0) +-2 >Emitted(66, 22) Source(86, 4) + SourceIndex(0) +2 > + > } -+1 >Emitted(66, 21) Source(85, 26) + SourceIndex(0) - 2 >Emitted(66, 22) Source(86, 4) + SourceIndex(0) ++1 >Emitted(68, 21) Source(85, 26) + SourceIndex(0) ++2 >Emitted(68, 22) Source(86, 4) + SourceIndex(0) --- >>> getMode() { return mode; } 1->^^^^^^^^^^^^^^^^^^^^ @@ -2521,6 +2470,14 @@ -6 > ; -7 > -8 > } +-1->Emitted(67, 21) Source(88, 10) + SourceIndex(0) +-2 >Emitted(67, 28) Source(88, 17) + SourceIndex(0) +-3 >Emitted(67, 33) Source(88, 29) + SourceIndex(0) +-4 >Emitted(67, 40) Source(88, 36) + SourceIndex(0) +-5 >Emitted(67, 44) Source(88, 40) + SourceIndex(0) +-6 >Emitted(67, 45) Source(88, 41) + SourceIndex(0) +-7 >Emitted(67, 46) Source(88, 42) + SourceIndex(0) +-8 >Emitted(67, 47) Source(88, 43) + SourceIndex(0) +3 > (): IMode +4 > { +5 > return @@ -2528,25 +2485,23 @@ +7 > ; +8 > +9 > } - 1->Emitted(67, 21) Source(88, 10) + SourceIndex(0) - 2 >Emitted(67, 28) Source(88, 17) + SourceIndex(0) --3 >Emitted(67, 33) Source(88, 29) + SourceIndex(0) --4 >Emitted(67, 40) Source(88, 36) + SourceIndex(0) --5 >Emitted(67, 44) Source(88, 40) + SourceIndex(0) --6 >Emitted(67, 45) Source(88, 41) + SourceIndex(0) --7 >Emitted(67, 46) Source(88, 42) + SourceIndex(0) --8 >Emitted(67, 47) Source(88, 43) + SourceIndex(0) -+3 >Emitted(67, 31) Source(88, 27) + SourceIndex(0) -+4 >Emitted(67, 33) Source(88, 29) + SourceIndex(0) -+5 >Emitted(67, 40) Source(88, 36) + SourceIndex(0) -+6 >Emitted(67, 44) Source(88, 40) + SourceIndex(0) -+7 >Emitted(67, 45) Source(88, 41) + SourceIndex(0) -+8 >Emitted(67, 46) Source(88, 41) + SourceIndex(0) -+9 >Emitted(67, 47) Source(88, 43) + SourceIndex(0) ++1->Emitted(69, 21) Source(88, 10) + SourceIndex(0) ++2 >Emitted(69, 28) Source(88, 17) + SourceIndex(0) ++3 >Emitted(69, 31) Source(88, 27) + SourceIndex(0) ++4 >Emitted(69, 33) Source(88, 29) + SourceIndex(0) ++5 >Emitted(69, 40) Source(88, 36) + SourceIndex(0) ++6 >Emitted(69, 44) Source(88, 40) + SourceIndex(0) ++7 >Emitted(69, 45) Source(88, 41) + SourceIndex(0) ++8 >Emitted(69, 46) Source(88, 41) + SourceIndex(0) ++9 >Emitted(69, 47) Source(88, 43) + SourceIndex(0) --- >>> } 1 >^^^^^^^^^^^^^^^^^ -@@= skipped -42, +45 lines =@@ + 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> + 1 > + > } +-1 >Emitted(68, 18) Source(89, 3) + SourceIndex(0) ++1 >Emitted(70, 18) Source(89, 3) + SourceIndex(0) --- >>> PlainText.State = State; 1->^^^^^^^^^^^^^^^^ @@ -2568,24 +2523,50 @@ > constructor(private mode: IMode) { } > public clone():IState { > return this; -@@= skipped -18, +20 lines =@@ +@@= skipped -79, +84 lines =@@ > > public getMode(): IMode { return mode; } > } -4 > -+5 > - 1->Emitted(69, 17) Source(78, 15) + SourceIndex(0) +-1->Emitted(69, 17) Source(78, 15) + SourceIndex(0) -2 >Emitted(69, 32) Source(78, 20) + SourceIndex(0) -3 >Emitted(69, 40) Source(89, 3) + SourceIndex(0) -4 >Emitted(69, 41) Source(89, 3) + SourceIndex(0) -+2 >Emitted(69, 27) Source(78, 15) + SourceIndex(0) -+3 >Emitted(69, 32) Source(78, 20) + SourceIndex(0) -+4 >Emitted(69, 40) Source(89, 3) + SourceIndex(0) -+5 >Emitted(69, 41) Source(89, 3) + SourceIndex(0) ++5 > ++1->Emitted(71, 17) Source(78, 15) + SourceIndex(0) ++2 >Emitted(71, 27) Source(78, 15) + SourceIndex(0) ++3 >Emitted(71, 32) Source(78, 20) + SourceIndex(0) ++4 >Emitted(71, 40) Source(89, 3) + SourceIndex(0) ++5 >Emitted(71, 41) Source(89, 3) + SourceIndex(0) --- >>> class Mode extends AbstractMode { 1->^^^^^^^^^^^^^^^^ -@@= skipped -39, +40 lines =@@ +@@= skipped -19, +20 lines =@@ + 3 > Mode + 4 > extends + 5 > AbstractMode +-1->Emitted(70, 17) Source(91, 2) + SourceIndex(0) +-2 >Emitted(70, 23) Source(91, 15) + SourceIndex(0) +-3 >Emitted(70, 27) Source(91, 20) + SourceIndex(0) +-4 >Emitted(70, 36) Source(91, 28) + SourceIndex(0) +-5 >Emitted(70, 48) Source(91, 40) + SourceIndex(0) ++1->Emitted(72, 17) Source(91, 2) + SourceIndex(0) ++2 >Emitted(72, 23) Source(91, 15) + SourceIndex(0) ++3 >Emitted(72, 27) Source(91, 20) + SourceIndex(0) ++4 >Emitted(72, 36) Source(91, 28) + SourceIndex(0) ++5 >Emitted(72, 48) Source(91, 40) + SourceIndex(0) + --- + >>> // scenario 2 + 1 >^^^^^^^^^^^^^^^^^^^^ +@@= skipped -14, +14 lines =@@ + > + > + 2 > // scenario 2 +-1 >Emitted(71, 21) Source(93, 3) + SourceIndex(0) +-2 >Emitted(71, 34) Source(93, 16) + SourceIndex(0) ++1 >Emitted(73, 21) Source(93, 3) + SourceIndex(0) ++2 >Emitted(73, 34) Source(93, 16) + SourceIndex(0) + --- >>> getInitialState() { 1->^^^^^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^ @@ -2595,14 +2576,16 @@ 1-> > public 2 > getInitialState +-1->Emitted(72, 21) Source(94, 10) + SourceIndex(0) +-2 >Emitted(72, 36) Source(94, 25) + SourceIndex(0) +3 > (): IState - 1->Emitted(72, 21) Source(94, 10) + SourceIndex(0) - 2 >Emitted(72, 36) Source(94, 25) + SourceIndex(0) -+3 >Emitted(72, 39) Source(94, 36) + SourceIndex(0) ++1->Emitted(74, 21) Source(94, 10) + SourceIndex(0) ++2 >Emitted(74, 36) Source(94, 25) + SourceIndex(0) ++3 >Emitted(74, 39) Source(94, 36) + SourceIndex(0) --- >>> return new State(self); 1->^^^^^^^^^^^^^^^^^^^^^^^^ -@@= skipped -16, +19 lines =@@ +@@= skipped -22, +25 lines =@@ 6 > ^^^^ 7 > ^ 8 > ^ @@ -2611,20 +2594,48 @@ > 2 > return 3 > new -@@= skipped -22, +22 lines =@@ +@@= skipped -9, +9 lines =@@ + 6 > self + 7 > ) + 8 > ; +-1->Emitted(73, 25) Source(95, 4) + SourceIndex(0) +-2 >Emitted(73, 32) Source(95, 11) + SourceIndex(0) +-3 >Emitted(73, 36) Source(95, 15) + SourceIndex(0) +-4 >Emitted(73, 41) Source(95, 20) + SourceIndex(0) +-5 >Emitted(73, 42) Source(95, 21) + SourceIndex(0) +-6 >Emitted(73, 46) Source(95, 25) + SourceIndex(0) +-7 >Emitted(73, 47) Source(95, 26) + SourceIndex(0) +-8 >Emitted(73, 48) Source(95, 27) + SourceIndex(0) ++1->Emitted(75, 25) Source(95, 4) + SourceIndex(0) ++2 >Emitted(75, 32) Source(95, 11) + SourceIndex(0) ++3 >Emitted(75, 36) Source(95, 15) + SourceIndex(0) ++4 >Emitted(75, 41) Source(95, 20) + SourceIndex(0) ++5 >Emitted(75, 42) Source(95, 21) + SourceIndex(0) ++6 >Emitted(75, 46) Source(95, 25) + SourceIndex(0) ++7 >Emitted(75, 47) Source(95, 26) + SourceIndex(0) ++8 >Emitted(75, 48) Source(95, 27) + SourceIndex(0) + --- + >>> } 1 >^^^^^^^^^^^^^^^^^^^^ 2 > ^ 1 > - > -2 > } -1 >Emitted(74, 21) Source(96, 3) + SourceIndex(0) +-2 >Emitted(74, 22) Source(96, 4) + SourceIndex(0) +2 > + > } -+1 >Emitted(74, 21) Source(95, 27) + SourceIndex(0) - 2 >Emitted(74, 22) Source(96, 4) + SourceIndex(0) ++1 >Emitted(76, 21) Source(95, 27) + SourceIndex(0) ++2 >Emitted(76, 22) Source(96, 4) + SourceIndex(0) --- >>> } -@@= skipped -16, +16 lines =@@ + 1 >^^^^^^^^^^^^^^^^^ +@@= skipped -25, +25 lines =@@ + > + > + > } +-1 >Emitted(75, 18) Source(99, 3) + SourceIndex(0) ++1 >Emitted(77, 18) Source(99, 3) + SourceIndex(0) --- >>> PlainText.Mode = Mode; 1->^^^^^^^^^^^^^^^^ @@ -2646,20 +2657,21 @@ > > // scenario 2 > public getInitialState(): IState { -@@= skipped -15, +17 lines =@@ +@@= skipped -19, +21 lines =@@ > > > } -4 > -+5 > - 1->Emitted(76, 17) Source(91, 15) + SourceIndex(0) +-1->Emitted(76, 17) Source(91, 15) + SourceIndex(0) -2 >Emitted(76, 31) Source(91, 19) + SourceIndex(0) -3 >Emitted(76, 38) Source(99, 3) + SourceIndex(0) -4 >Emitted(76, 39) Source(99, 3) + SourceIndex(0) -+2 >Emitted(76, 27) Source(91, 15) + SourceIndex(0) -+3 >Emitted(76, 31) Source(91, 19) + SourceIndex(0) -+4 >Emitted(76, 38) Source(99, 3) + SourceIndex(0) -+5 >Emitted(76, 39) Source(99, 3) + SourceIndex(0) ++5 > ++1->Emitted(78, 17) Source(91, 15) + SourceIndex(0) ++2 >Emitted(78, 27) Source(91, 15) + SourceIndex(0) ++3 >Emitted(78, 31) Source(91, 19) + SourceIndex(0) ++4 >Emitted(78, 38) Source(99, 3) + SourceIndex(0) ++5 >Emitted(78, 39) Source(99, 3) + SourceIndex(0) --- >>> })(PlainText = Languages.PlainText || (Languages.PlainText = {})); 1->^^^^^^^^^^^^ @@ -2703,21 +2715,25 @@ > } > } -1->Emitted(77, 13) Source(100, 1) + SourceIndex(0) -+1->Emitted(77, 13) Source(99, 3) + SourceIndex(0) - 2 >Emitted(77, 14) Source(100, 2) + SourceIndex(0) - 3 >Emitted(77, 16) Source(76, 31) + SourceIndex(0) - 4 >Emitted(77, 25) Source(76, 40) + SourceIndex(0) - 5 >Emitted(77, 28) Source(76, 31) + SourceIndex(0) +-2 >Emitted(77, 14) Source(100, 2) + SourceIndex(0) +-3 >Emitted(77, 16) Source(76, 31) + SourceIndex(0) +-4 >Emitted(77, 25) Source(76, 40) + SourceIndex(0) +-5 >Emitted(77, 28) Source(76, 31) + SourceIndex(0) -6 >Emitted(77, 47) Source(76, 40) + SourceIndex(0) -7 >Emitted(77, 52) Source(76, 31) + SourceIndex(0) -8 >Emitted(77, 71) Source(76, 40) + SourceIndex(0) -9 >Emitted(77, 79) Source(100, 2) + SourceIndex(0) -+6 >Emitted(77, 38) Source(76, 31) + SourceIndex(0) -+7 >Emitted(77, 47) Source(76, 40) + SourceIndex(0) -+8 >Emitted(77, 52) Source(76, 31) + SourceIndex(0) -+9 >Emitted(77, 62) Source(76, 31) + SourceIndex(0) -+10>Emitted(77, 71) Source(76, 40) + SourceIndex(0) -+11>Emitted(77, 79) Source(100, 2) + SourceIndex(0) ++1->Emitted(79, 13) Source(99, 3) + SourceIndex(0) ++2 >Emitted(79, 14) Source(100, 2) + SourceIndex(0) ++3 >Emitted(79, 16) Source(76, 31) + SourceIndex(0) ++4 >Emitted(79, 25) Source(76, 40) + SourceIndex(0) ++5 >Emitted(79, 28) Source(76, 31) + SourceIndex(0) ++6 >Emitted(79, 38) Source(76, 31) + SourceIndex(0) ++7 >Emitted(79, 47) Source(76, 40) + SourceIndex(0) ++8 >Emitted(79, 52) Source(76, 31) + SourceIndex(0) ++9 >Emitted(79, 62) Source(76, 31) + SourceIndex(0) ++10>Emitted(79, 71) Source(76, 40) + SourceIndex(0) ++11>Emitted(79, 79) Source(100, 2) + SourceIndex(0) --- >>> })(Languages = Thing.Languages || (Thing.Languages = {})); 1 >^^^^^^^^ @@ -2850,18 +2866,18 @@ -7 >Emitted(78, 44) Source(76, 21) + SourceIndex(0) -8 >Emitted(78, 59) Source(76, 30) + SourceIndex(0) -9 >Emitted(78, 67) Source(100, 2) + SourceIndex(0) -+1 >Emitted(78, 9) Source(99, 3) + SourceIndex(0) -+2 >Emitted(78, 10) Source(100, 1) + SourceIndex(0) -+3 >Emitted(78, 10) Source(1, 1) + SourceIndex(0) -+4 >Emitted(78, 12) Source(76, 21) + SourceIndex(0) -+5 >Emitted(78, 21) Source(76, 30) + SourceIndex(0) -+6 >Emitted(78, 24) Source(76, 21) + SourceIndex(0) -+7 >Emitted(78, 30) Source(76, 21) + SourceIndex(0) -+8 >Emitted(78, 39) Source(76, 30) + SourceIndex(0) -+9 >Emitted(78, 44) Source(76, 21) + SourceIndex(0) -+10>Emitted(78, 50) Source(76, 21) + SourceIndex(0) -+11>Emitted(78, 59) Source(76, 30) + SourceIndex(0) -+12>Emitted(78, 67) Source(100, 2) + SourceIndex(0) ++1 >Emitted(80, 9) Source(99, 3) + SourceIndex(0) ++2 >Emitted(80, 10) Source(100, 1) + SourceIndex(0) ++3 >Emitted(80, 10) Source(1, 1) + SourceIndex(0) ++4 >Emitted(80, 12) Source(76, 21) + SourceIndex(0) ++5 >Emitted(80, 21) Source(76, 30) + SourceIndex(0) ++6 >Emitted(80, 24) Source(76, 21) + SourceIndex(0) ++7 >Emitted(80, 30) Source(76, 21) + SourceIndex(0) ++8 >Emitted(80, 39) Source(76, 30) + SourceIndex(0) ++9 >Emitted(80, 44) Source(76, 21) + SourceIndex(0) ++10>Emitted(80, 50) Source(76, 21) + SourceIndex(0) ++11>Emitted(80, 59) Source(76, 30) + SourceIndex(0) ++12>Emitted(80, 67) Source(100, 2) + SourceIndex(0) --- >>> })(Thing = Sample.Thing || (Sample.Thing = {})); 1 >^^^^ @@ -2994,18 +3010,18 @@ -7 >Emitted(79, 33) Source(76, 15) + SourceIndex(0) -8 >Emitted(79, 45) Source(76, 20) + SourceIndex(0) -9 >Emitted(79, 53) Source(100, 2) + SourceIndex(0) -+1 >Emitted(79, 5) Source(99, 3) + SourceIndex(0) -+2 >Emitted(79, 6) Source(100, 1) + SourceIndex(0) -+3 >Emitted(79, 6) Source(1, 1) + SourceIndex(0) -+4 >Emitted(79, 8) Source(76, 15) + SourceIndex(0) -+5 >Emitted(79, 13) Source(76, 20) + SourceIndex(0) -+6 >Emitted(79, 16) Source(76, 15) + SourceIndex(0) -+7 >Emitted(79, 23) Source(76, 15) + SourceIndex(0) -+8 >Emitted(79, 28) Source(76, 20) + SourceIndex(0) -+9 >Emitted(79, 33) Source(76, 15) + SourceIndex(0) -+10>Emitted(79, 40) Source(76, 15) + SourceIndex(0) -+11>Emitted(79, 45) Source(76, 20) + SourceIndex(0) -+12>Emitted(79, 53) Source(100, 2) + SourceIndex(0) ++1 >Emitted(81, 5) Source(99, 3) + SourceIndex(0) ++2 >Emitted(81, 6) Source(100, 1) + SourceIndex(0) ++3 >Emitted(81, 6) Source(1, 1) + SourceIndex(0) ++4 >Emitted(81, 8) Source(76, 15) + SourceIndex(0) ++5 >Emitted(81, 13) Source(76, 20) + SourceIndex(0) ++6 >Emitted(81, 16) Source(76, 15) + SourceIndex(0) ++7 >Emitted(81, 23) Source(76, 15) + SourceIndex(0) ++8 >Emitted(81, 28) Source(76, 20) + SourceIndex(0) ++9 >Emitted(81, 33) Source(76, 15) + SourceIndex(0) ++10>Emitted(81, 40) Source(76, 15) + SourceIndex(0) ++11>Emitted(81, 45) Source(76, 20) + SourceIndex(0) ++12>Emitted(81, 53) Source(100, 2) + SourceIndex(0) --- >>>})(Sample || (Sample = {})); 1 > @@ -3126,13 +3142,13 @@ -5 >Emitted(80, 15) Source(76, 8) + SourceIndex(0) -6 >Emitted(80, 21) Source(76, 14) + SourceIndex(0) -7 >Emitted(80, 29) Source(100, 2) + SourceIndex(0) -+1 >Emitted(80, 1) Source(99, 3) + SourceIndex(0) -+2 >Emitted(80, 2) Source(100, 1) + SourceIndex(0) -+3 >Emitted(80, 2) Source(1, 1) + SourceIndex(0) -+4 >Emitted(80, 4) Source(76, 8) + SourceIndex(0) -+5 >Emitted(80, 10) Source(76, 14) + SourceIndex(0) -+6 >Emitted(80, 15) Source(76, 8) + SourceIndex(0) -+7 >Emitted(80, 21) Source(76, 14) + SourceIndex(0) -+8 >Emitted(80, 29) Source(100, 2) + SourceIndex(0) ++1 >Emitted(82, 1) Source(99, 3) + SourceIndex(0) ++2 >Emitted(82, 2) Source(100, 1) + SourceIndex(0) ++3 >Emitted(82, 2) Source(1, 1) + SourceIndex(0) ++4 >Emitted(82, 4) Source(76, 8) + SourceIndex(0) ++5 >Emitted(82, 10) Source(76, 14) + SourceIndex(0) ++6 >Emitted(82, 15) Source(76, 8) + SourceIndex(0) ++7 >Emitted(82, 21) Source(76, 14) + SourceIndex(0) ++8 >Emitted(82, 29) Source(100, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=recursiveClassReferenceTest.js.map \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash2.js b/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash2.js index f8e19f6742..0ef2a76ebe 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash2.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash2.js @@ -19,4 +19,5 @@ export type UseQueryOptions = Expand__ //// [recursiveConditionalCrash2.js] "use strict"; +// Simplified #43529 Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash2.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash2.js.diff deleted file mode 100644 index 1f0633d43e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash2.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.recursiveConditionalCrash2.js -+++ new.recursiveConditionalCrash2.js -@@= skipped -18, +18 lines =@@ - - //// [recursiveConditionalCrash2.js] - "use strict"; --// Simplified #43529 - Object.defineProperty(exports, "__esModule", { value: true }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash3.js b/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash3.js index 27c6da19f7..5d726d5a72 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash3.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash3.js @@ -151,6 +151,7 @@ let t: UseQueryOptions //// [recursiveConditionalCrash3.js] "use strict"; +// #43529 Object.defineProperty(exports, "__esModule", { value: true }); /** * These two functions work as charm, also they are superfast and as expected they don't use additional Memory diff --git a/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash3.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash3.js.diff deleted file mode 100644 index 5313135627..0000000000 --- a/testdata/baselines/reference/submodule/compiler/recursiveConditionalCrash3.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.recursiveConditionalCrash3.js -+++ new.recursiveConditionalCrash3.js -@@= skipped -150, +150 lines =@@ - - //// [recursiveConditionalCrash3.js] - "use strict"; --// #43529 - Object.defineProperty(exports, "__esModule", { value: true }); - /** - * These two functions work as charm, also they are superfast and as expected they don't use additional Memory \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveConditionalTypes.js b/testdata/baselines/reference/submodule/compiler/recursiveConditionalTypes.js index 2a469765c8..2365d463b0 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveConditionalTypes.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveConditionalTypes.js @@ -174,6 +174,7 @@ function foo2(value: T): Enumerate { //// [recursiveConditionalTypes.js] +// Awaiting promises function f11(tx, ta, ux, ua) { ta = ua; ua = ta; // Error diff --git a/testdata/baselines/reference/submodule/compiler/recursiveConditionalTypes.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveConditionalTypes.js.diff index b1aa684066..749885f54a 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveConditionalTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/recursiveConditionalTypes.js.diff @@ -5,7 +5,6 @@ //// [recursiveConditionalTypes.js] -"use strict"; --// Awaiting promises + // Awaiting promises function f11(tx, ta, ux, ua) { - ta = ua; - ua = ta; // Error \ No newline at end of file + ta = ua; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveExcessPropertyChecks.js b/testdata/baselines/reference/submodule/compiler/recursiveExcessPropertyChecks.js index 54a8290126..c3657e0cc5 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveExcessPropertyChecks.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveExcessPropertyChecks.js @@ -17,6 +17,7 @@ getMaxId(nodes); //// [recursiveExcessPropertyChecks.js] +// Repro from #35804 function getMaxId(items) { } const nodes = []; diff --git a/testdata/baselines/reference/submodule/compiler/recursiveExcessPropertyChecks.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveExcessPropertyChecks.js.diff index 24b9038832..01001ef3eb 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveExcessPropertyChecks.js.diff +++ b/testdata/baselines/reference/submodule/compiler/recursiveExcessPropertyChecks.js.diff @@ -5,7 +5,6 @@ //// [recursiveExcessPropertyChecks.js] -"use strict"; --// Repro from #35804 + // Repro from #35804 function getMaxId(items) { - } - const nodes = []; \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveResolveTypeMembers.js b/testdata/baselines/reference/submodule/compiler/recursiveResolveTypeMembers.js index 3bd72df2bd..24b272348e 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveResolveTypeMembers.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveResolveTypeMembers.js @@ -10,3 +10,4 @@ type Promised = PromisedTuple<[1, 2, 3]> //// [recursiveResolveTypeMembers.js] +// Repro from #25291 diff --git a/testdata/baselines/reference/submodule/compiler/recursiveResolveTypeMembers.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveResolveTypeMembers.js.diff deleted file mode 100644 index b1e2b73353..0000000000 --- a/testdata/baselines/reference/submodule/compiler/recursiveResolveTypeMembers.js.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.recursiveResolveTypeMembers.js -+++ new.recursiveResolveTypeMembers.js -@@= skipped -9, +9 lines =@@ - - - //// [recursiveResolveTypeMembers.js] --// Repro from #25291 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveReverseMappedType.js b/testdata/baselines/reference/submodule/compiler/recursiveReverseMappedType.js index 241770d95d..287d40a1f9 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveReverseMappedType.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveReverseMappedType.js @@ -17,6 +17,7 @@ function a(l: Recur[]): void { //// [recursiveReverseMappedType.js] +// Repro from #38198 function join(l) { return ['marker', ...l]; } diff --git a/testdata/baselines/reference/submodule/compiler/recursiveReverseMappedType.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveReverseMappedType.js.diff index 607b35331a..3488dfc69a 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveReverseMappedType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/recursiveReverseMappedType.js.diff @@ -5,7 +5,6 @@ //// [recursiveReverseMappedType.js] -"use strict"; --// Repro from #38198 + // Repro from #38198 function join(l) { - return ['marker', ...l]; - } \ No newline at end of file + return ['marker', ...l]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveTupleTypeInference.js b/testdata/baselines/reference/submodule/compiler/recursiveTupleTypeInference.js index befecc076e..c56e013c04 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveTupleTypeInference.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveTupleTypeInference.js @@ -28,6 +28,7 @@ foo(gK); //// [recursiveTupleTypeInference.js] "use strict"; +// Repro from #37475 Object.defineProperty(exports, "__esModule", { value: true }); const gK = { b: ["number", "null"] }; function foo(g) { diff --git a/testdata/baselines/reference/submodule/compiler/recursiveTupleTypeInference.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveTupleTypeInference.js.diff deleted file mode 100644 index 76a61bfca6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/recursiveTupleTypeInference.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.recursiveTupleTypeInference.js -+++ new.recursiveTupleTypeInference.js -@@= skipped -27, +27 lines =@@ - - //// [recursiveTupleTypeInference.js] - "use strict"; --// Repro from #37475 - Object.defineProperty(exports, "__esModule", { value: true }); - const gK = { b: ["number", "null"] }; - function foo(g) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison.js b/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison.js index 6373ad1317..25c7528d3c 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison.js @@ -18,5 +18,6 @@ var stuck: Property = p; //// [recursiveTypeComparison.js] +// Before fix this would take an exceeding long time to complete (#1170) var p; var stuck = p; diff --git a/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison.js.diff deleted file mode 100644 index 12fc5f6a6d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.recursiveTypeComparison.js -+++ new.recursiveTypeComparison.js -@@= skipped -17, +17 lines =@@ - - - //// [recursiveTypeComparison.js] --// Before fix this would take an exceeding long time to complete (#1170) - var p; - var stuck = p; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison2.js b/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison2.js index 74bcbb68df..91ef344d47 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison2.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison2.js @@ -33,4 +33,5 @@ declare module Bacon { var stuck: Bacon.Bus = new Bacon.Bus(); //// [recursiveTypeComparison2.js] +// Before fix this would cause compiler to hang (#1170) var stuck = new Bacon.Bus(); diff --git a/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison2.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison2.js.diff deleted file mode 100644 index 976958954f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/recursiveTypeComparison2.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.recursiveTypeComparison2.js -+++ new.recursiveTypeComparison2.js -@@= skipped -32, +32 lines =@@ - var stuck: Bacon.Bus = new Bacon.Bus(); - - //// [recursiveTypeComparison2.js] --// Before fix this would cause compiler to hang (#1170) - var stuck = new Bacon.Bus(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/recursiveTypeRelations.js b/testdata/baselines/reference/submodule/compiler/recursiveTypeRelations.js index d52b290cd4..47a334cdf9 100644 --- a/testdata/baselines/reference/submodule/compiler/recursiveTypeRelations.js +++ b/testdata/baselines/reference/submodule/compiler/recursiveTypeRelations.js @@ -40,6 +40,7 @@ export function css(styles: S, ...classNam //// [recursiveTypeRelations.js] "use strict"; +// Repro from #14896 Object.defineProperty(exports, "__esModule", { value: true }); exports.css = css; class Query { diff --git a/testdata/baselines/reference/submodule/compiler/recursiveTypeRelations.js.diff b/testdata/baselines/reference/submodule/compiler/recursiveTypeRelations.js.diff deleted file mode 100644 index 72cb5f8aa6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/recursiveTypeRelations.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.recursiveTypeRelations.js -+++ new.recursiveTypeRelations.js -@@= skipped -39, +39 lines =@@ - - //// [recursiveTypeRelations.js] - "use strict"; --// Repro from #14896 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.css = css; - class Query { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/reexportMissingDefault4.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/reexportMissingDefault4.errors.txt.diff deleted file mode 100644 index fa73d785e0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/reexportMissingDefault4.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.reexportMissingDefault4.errors.txt -+++ new.reexportMissingDefault4.errors.txt -@@= skipped -0, +0 lines =@@ --a.ts(2,10): error TS2305: Module '"./b"' has no exported member 'default'. -- -- --==== b.d.ts (0 errors) ==== -- declare var b: number; -- export { b }; -- --==== a.ts (1 errors) ==== -- export { b } from "./b"; -- export { default } from "./b"; -- ~~~~~~~ --!!! error TS2305: Module '"./b"' has no exported member 'default'. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/reexportMissingDefault4.types.diff b/testdata/baselines/reference/submodule/compiler/reexportMissingDefault4.types.diff deleted file mode 100644 index b2f037525c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/reexportMissingDefault4.types.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.reexportMissingDefault4.types -+++ new.reexportMissingDefault4.types -@@= skipped -11, +11 lines =@@ - >b : number - - export { default } from "./b"; -->default : any -+>default : typeof import("b") diff --git a/testdata/baselines/reference/submodule/compiler/renamingDestructuredPropertyInFunctionType.js b/testdata/baselines/reference/submodule/compiler/renamingDestructuredPropertyInFunctionType.js index c5fd0453d8..af19e36e72 100644 --- a/testdata/baselines/reference/submodule/compiler/renamingDestructuredPropertyInFunctionType.js +++ b/testdata/baselines/reference/submodule/compiler/renamingDestructuredPropertyInFunctionType.js @@ -69,6 +69,7 @@ const f11 = ({ [2]: string }) => { }; function f12({ a: string = "" }: O): typeof string { return "a"; } //// [renamingDestructuredPropertyInFunctionType.js] +// GH#37454, GH#41044 // Below are OK but renaming should be removed from declaration emit function f1({ a: string }) { } const f2 = function ({ a: string }) { }; diff --git a/testdata/baselines/reference/submodule/compiler/renamingDestructuredPropertyInFunctionType.js.diff b/testdata/baselines/reference/submodule/compiler/renamingDestructuredPropertyInFunctionType.js.diff index b04e4ff52c..a08c1d16aa 100644 --- a/testdata/baselines/reference/submodule/compiler/renamingDestructuredPropertyInFunctionType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/renamingDestructuredPropertyInFunctionType.js.diff @@ -1,14 +1,6 @@ --- old.renamingDestructuredPropertyInFunctionType.js +++ new.renamingDestructuredPropertyInFunctionType.js -@@= skipped -68, +68 lines =@@ - function f12({ a: string = "" }: O): typeof string { return "a"; } - - //// [renamingDestructuredPropertyInFunctionType.js] --// GH#37454, GH#41044 - // Below are OK but renaming should be removed from declaration emit - function f1({ a: string }) { } - const f2 = function ({ a: string }) { }; -@@= skipped -102, +101 lines =@@ +@@= skipped -170, +170 lines =@@ declare function f1({ a: string }: O): void; declare const f2: ({ a: string }: O) => void; declare const f3: ({ a: string, b, c }: O) => void; diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt.diff index 6c5fc37220..ced70dff4b 100644 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt.diff @@ -2,10 +2,12 @@ +++ new.requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt @@= skipped -0, +0 lines =@@ -error TS5071: Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'. +-error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve', 'commonjs', or 'es2015' or later. -file1.ts(1,1): error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'. - - -!!! error TS5071: Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'. +-!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve', 'commonjs', or 'es2015' or later. -==== file1.ts (1 errors) ==== - import * as b from './b.json'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.errors.txt.diff index 44608e6282..eccd38e743 100644 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.errors.txt.diff @@ -1,47 +1,37 @@ --- old.requireOfJsonFileWithoutResolveJsonModule.errors.txt +++ new.requireOfJsonFileWithoutResolveJsonModule.errors.txt @@= skipped -0, +0 lines =@@ --file1.ts(1,21): error TS2732: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. --file1.ts(3,21): error TS2732: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. -- -- --==== file1.ts (2 errors) ==== -+b.json(1,1): error TS1005: '{' expected. -+b.json(1,10): error TS1005: ',' expected. -+b.json(1,14): error TS1005: ',' expected. -+b.json(1,18): error TS1005: '}' expected. -+file1.ts(2,12): error TS2339: Property 'a' does not exist on type '{ contents: any; Not: any; read: any; }'. -+file1.ts(5,16): error TS2339: Property 'b' does not exist on type '{ contents: any; Not: any; read: any; }'. -+file1.ts(6,13): error TS2339: Property 'b' does not exist on type '{ contents: any; Not: any; read: any; }'. -+ -+ -+==== file1.ts (3 errors) ==== - import b1 = require('./b.json'); // error -- ~~~~~~~~~~ --!!! error TS2732: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. - let x = b1.a; -+ ~ -+!!! error TS2339: Property 'a' does not exist on type '{ contents: any; Not: any; read: any; }'. - import b2 = require('./b.json'); // error -- ~~~~~~~~~~ --!!! error TS2732: Cannot find module './b.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. - if (x) { - let b = b2.b; -+ ~ -+!!! error TS2339: Property 'b' does not exist on type '{ contents: any; Not: any; read: any; }'. - x = (b1.b === b); -+ ~ -+!!! error TS2339: Property 'b' does not exist on type '{ contents: any; Not: any; read: any; }'. + b.json(1,1): error TS1005: '{' expected. +-b.json(1,1): error TS1136: Property assignment expected. + b.json(1,10): error TS1005: ',' expected. +-b.json(1,10): error TS1136: Property assignment expected. + b.json(1,14): error TS1005: ',' expected. +-b.json(1,14): error TS1136: Property assignment expected. + b.json(1,18): error TS1005: '}' expected. + file1.ts(2,12): error TS2339: Property 'a' does not exist on type '{ contents: any; Not: any; read: any; }'. + file1.ts(5,16): error TS2339: Property 'b' does not exist on type '{ contents: any; Not: any; read: any; }'. +@@= skipped -24, +21 lines =@@ + !!! error TS2339: Property 'b' does not exist on type '{ contents: any; Not: any; read: any; }'. } --==== b.json (0 errors) ==== +-==== b.json (7 errors) ==== +==== b.json (4 errors) ==== contents Not read -+ ~~~~~~~~ -+!!! error TS1005: '{' expected. + ~~~~~~~~ + !!! error TS1005: '{' expected. +- ~~~~~~~~ +-!!! error TS1136: Property assignment expected. +- ~~~ +-!!! error TS1005: ',' expected. +- ~~~ +-!!! error TS1136: Property assignment expected. +- ~~~~ +-!!! error TS1005: ',' expected. +- ~~~~ +-!!! error TS1136: Property assignment expected. + ~~~ +!!! error TS1005: ',' expected. + ~~~~ +!!! error TS1005: ',' expected. -+ -+!!! error TS1005: '}' expected. \ No newline at end of file + + !!! error TS1005: '}' expected. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.js.diff b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.js.diff index 8663a3403b..d1d1ffc48a 100644 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.js.diff +++ b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.js.diff @@ -1,11 +1,6 @@ --- old.requireOfJsonFileWithoutResolveJsonModule.js +++ new.requireOfJsonFileWithoutResolveJsonModule.js -@@= skipped -11, +11 lines =@@ - //// [b.json] - contents Not read - -+//// [out/b.json] -+{ contents, Not, read } +@@= skipped -16, +16 lines =@@ //// [out/file1.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.symbols.diff b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.symbols.diff deleted file mode 100644 index 49a2c5f46f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.requireOfJsonFileWithoutResolveJsonModule.symbols -+++ new.requireOfJsonFileWithoutResolveJsonModule.symbols -@@= skipped -23, +23 lines =@@ - >b : Symbol(b, Decl(file1.ts, 4, 7)) - } - -+=== b.json === -+contents Not read -+>contents : Symbol(contents, Decl(b.json, 0, 0)) -+>Not : Symbol(Not, Decl(b.json, 0, 8)) -+>read : Symbol(read, Decl(b.json, 0, 12)) -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.types.diff b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.types.diff deleted file mode 100644 index a5c1231997..0000000000 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileWithoutResolveJsonModule.types.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.requireOfJsonFileWithoutResolveJsonModule.types -+++ new.requireOfJsonFileWithoutResolveJsonModule.types -@@= skipped -1, +1 lines =@@ - - === file1.ts === - import b1 = require('./b.json'); // error -->b1 : any -+>b1 : { contents: any; Not: any; read: any; } - - let x = b1.a; - >x : any - >b1.a : any -->b1 : any -+>b1 : { contents: any; Not: any; read: any; } - >a : any - - import b2 = require('./b.json'); // error -->b2 : any -+>b2 : { contents: any; Not: any; read: any; } - - if (x) { - >x : any -@@= skipped -17, +17 lines =@@ - let b = b2.b; - >b : any - >b2.b : any -->b2 : any -+>b2 : { contents: any; Not: any; read: any; } - >b : any - - x = (b1.b === b); -@@= skipped -9, +9 lines =@@ - >(b1.b === b) : boolean - >b1.b === b : boolean - >b1.b : any -->b1 : any -+>b1 : { contents: any; Not: any; read: any; } - >b : any - >b : any - } -+ -+=== b.json === -+contents Not read -+>contents Not read : { contents: any; Not: any; read: any; } -+>contents : any -+>Not : any -+>read : any diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt.diff deleted file mode 100644 index 170780f0b0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt -+++ new.resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt -@@= skipped -0, +0 lines =@@ --tsconfig.json(2,5): error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. - test.ts(1,19): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - - --==== tsconfig.json (1 errors) ==== -+==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { -- ~~~~~~~~~~~~~~~~~ --!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. - "paths": { - "foo/*": ["./dist/*"], - "baz/*.ts": ["./types/*.d.ts"] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).errors.txt b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).errors.txt deleted file mode 100644 index 40b353506a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -test.ts(1,19): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - - -==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "paths": { - "foo/*": ["./dist/*"], - "baz/*.ts": ["./types/*.d.ts"] - } - } - } - -==== dist/bar.ts (0 errors) ==== - export const a = 1234; - -==== types/main.d.ts (0 errors) ==== - export const b: string; - -==== test.ts (1 errors) ==== - import { a } from "foo/bar.ts"; - ~~~~~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - import { b } from "baz/main.ts"; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).js b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).js deleted file mode 100644 index fc322d5465..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).js +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/resolutionCandidateFromPackageJsonField2.ts] //// - -//// [bar.ts] -export const a = 1234; - -//// [main.d.ts] -export const b: string; - -//// [test.ts] -import { a } from "foo/bar.ts"; -import { b } from "baz/main.ts"; - - -//// [bar.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = 1234; -//// [test.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).symbols b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).symbols deleted file mode 100644 index 5ea0f09478..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).symbols +++ /dev/null @@ -1,17 +0,0 @@ -//// [tests/cases/compiler/resolutionCandidateFromPackageJsonField2.ts] //// - -=== dist/bar.ts === -export const a = 1234; ->a : Symbol(a, Decl(bar.ts, 0, 12)) - -=== types/main.d.ts === -export const b: string; ->b : Symbol(b, Decl(main.d.ts, 0, 12)) - -=== test.ts === -import { a } from "foo/bar.ts"; ->a : Symbol(a, Decl(test.ts, 0, 8)) - -import { b } from "baz/main.ts"; ->b : Symbol(b, Decl(test.ts, 1, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).types b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).types deleted file mode 100644 index 297dbfbfe9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=node10).types +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/resolutionCandidateFromPackageJsonField2.ts] //// - -=== dist/bar.ts === -export const a = 1234; ->a : 1234 ->1234 : 1234 - -=== types/main.d.ts === -export const b: string; ->b : string - -=== test.ts === -import { a } from "foo/bar.ts"; ->a : 1234 - -import { b } from "baz/main.ts"; ->b : string - diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2.errors.txt similarity index 100% rename from testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt rename to testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2.errors.txt diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).js b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2.js similarity index 100% rename from testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).js rename to testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2.js diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).symbols b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2.symbols similarity index 100% rename from testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).symbols rename to testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2.symbols diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).types b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2.types similarity index 100% rename from testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).types rename to testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2.types diff --git a/testdata/baselines/reference/submodule/compiler/restParameterTypeInstantiation.js b/testdata/baselines/reference/submodule/compiler/restParameterTypeInstantiation.js index c4e1667691..a9c85a1024 100644 --- a/testdata/baselines/reference/submodule/compiler/restParameterTypeInstantiation.js +++ b/testdata/baselines/reference/submodule/compiler/restParameterTypeInstantiation.js @@ -16,6 +16,7 @@ const result: number = removeF({ f: '', g: 3 }).g //// [restParameterTypeInstantiation.js] +// Repro from #33823 var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) diff --git a/testdata/baselines/reference/submodule/compiler/restParameterTypeInstantiation.js.diff b/testdata/baselines/reference/submodule/compiler/restParameterTypeInstantiation.js.diff index 26c08689c4..41c49e47b0 100644 --- a/testdata/baselines/reference/submodule/compiler/restParameterTypeInstantiation.js.diff +++ b/testdata/baselines/reference/submodule/compiler/restParameterTypeInstantiation.js.diff @@ -5,7 +5,6 @@ //// [restParameterTypeInstantiation.js] -"use strict"; --// Repro from #33823 + // Repro from #33823 var __rest = (this && this.__rest) || function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) \ No newline at end of file + var t = {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/reverseMappedContravariantInference.js b/testdata/baselines/reference/submodule/compiler/reverseMappedContravariantInference.js index 5926930ecf..e95d8ac61b 100644 --- a/testdata/baselines/reference/submodule/compiler/reverseMappedContravariantInference.js +++ b/testdata/baselines/reference/submodule/compiler/reverseMappedContravariantInference.js @@ -8,4 +8,5 @@ conforms({ foo: (v: string) => false })({ foo: "hello" }); //// [reverseMappedContravariantInference.js] +// Repro from #21273 conforms({ foo: (v) => false })({ foo: "hello" }); diff --git a/testdata/baselines/reference/submodule/compiler/reverseMappedContravariantInference.js.diff b/testdata/baselines/reference/submodule/compiler/reverseMappedContravariantInference.js.diff index 1e91b9b2a8..058bb5bd55 100644 --- a/testdata/baselines/reference/submodule/compiler/reverseMappedContravariantInference.js.diff +++ b/testdata/baselines/reference/submodule/compiler/reverseMappedContravariantInference.js.diff @@ -5,5 +5,5 @@ //// [reverseMappedContravariantInference.js] -"use strict"; --// Repro from #21273 + // Repro from #21273 conforms({ foo: (v) => false })({ foo: "hello" }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/reverseMappedPartiallyInferableTypes.js b/testdata/baselines/reference/submodule/compiler/reverseMappedPartiallyInferableTypes.js index 08a36fe515..23d5953f63 100644 --- a/testdata/baselines/reference/submodule/compiler/reverseMappedPartiallyInferableTypes.js +++ b/testdata/baselines/reference/submodule/compiler/reverseMappedPartiallyInferableTypes.js @@ -131,6 +131,7 @@ inferMappedReadonly({ //// [reverseMappedPartiallyInferableTypes.js] "use strict"; +// Repro from #30505 Object.defineProperty(exports, "__esModule", { value: true }); const r = extend({ props: { diff --git a/testdata/baselines/reference/submodule/compiler/reverseMappedPartiallyInferableTypes.js.diff b/testdata/baselines/reference/submodule/compiler/reverseMappedPartiallyInferableTypes.js.diff deleted file mode 100644 index 90fab6c9cb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/reverseMappedPartiallyInferableTypes.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.reverseMappedPartiallyInferableTypes.js -+++ new.reverseMappedPartiallyInferableTypes.js -@@= skipped -130, +130 lines =@@ - - //// [reverseMappedPartiallyInferableTypes.js] - "use strict"; --// Repro from #30505 - Object.defineProperty(exports, "__esModule", { value: true }); - const r = extend({ - props: { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/shebangBeforeReferences.js b/testdata/baselines/reference/submodule/compiler/shebangBeforeReferences.js index 761ac88c07..94a4999a00 100644 --- a/testdata/baselines/reference/submodule/compiler/shebangBeforeReferences.js +++ b/testdata/baselines/reference/submodule/compiler/shebangBeforeReferences.js @@ -17,7 +17,7 @@ use(x); //// [f.js] #!/usr/bin/env node "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const test_1 = require("test"); use(test_1.x); diff --git a/testdata/baselines/reference/submodule/compiler/shebangBeforeReferences.js.diff b/testdata/baselines/reference/submodule/compiler/shebangBeforeReferences.js.diff index 09c897fae0..0f54cd3448 100644 --- a/testdata/baselines/reference/submodule/compiler/shebangBeforeReferences.js.diff +++ b/testdata/baselines/reference/submodule/compiler/shebangBeforeReferences.js.diff @@ -1,12 +1,9 @@ --- old.shebangBeforeReferences.js +++ new.shebangBeforeReferences.js -@@= skipped -16, +16 lines =@@ - //// [f.js] - #!/usr/bin/env node +@@= skipped -18, +18 lines =@@ "use strict"; --/// + /// Object.defineProperty(exports, "__esModule", { value: true }); -var test_1 = require("test"); -+/// +const test_1 = require("test"); use(test_1.x); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/silentNeverPropagation.js b/testdata/baselines/reference/submodule/compiler/silentNeverPropagation.js index e7f5287854..eaeee061fc 100644 --- a/testdata/baselines/reference/submodule/compiler/silentNeverPropagation.js +++ b/testdata/baselines/reference/submodule/compiler/silentNeverPropagation.js @@ -29,6 +29,7 @@ breaks.foo() //// [silentNeverPropagation.js] +// Repro from #45041 const breaks = convert(createModule({ a: 12 }, { foo() { return true; } })); breaks.state.a; breaks.state.z; diff --git a/testdata/baselines/reference/submodule/compiler/silentNeverPropagation.js.diff b/testdata/baselines/reference/submodule/compiler/silentNeverPropagation.js.diff index 24c4d9e259..b208c9fe5a 100644 --- a/testdata/baselines/reference/submodule/compiler/silentNeverPropagation.js.diff +++ b/testdata/baselines/reference/submodule/compiler/silentNeverPropagation.js.diff @@ -5,7 +5,6 @@ //// [silentNeverPropagation.js] -"use strict"; --// Repro from #45041 + // Repro from #45041 const breaks = convert(createModule({ a: 12 }, { foo() { return true; } })); - breaks.state.a; - breaks.state.z; \ No newline at end of file + breaks.state.a; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/specedNoStackBlown.js b/testdata/baselines/reference/submodule/compiler/specedNoStackBlown.js index 40ae9e3318..232227568e 100644 --- a/testdata/baselines/reference/submodule/compiler/specedNoStackBlown.js +++ b/testdata/baselines/reference/submodule/compiler/specedNoStackBlown.js @@ -40,5 +40,10 @@ export default spected; //// [specedNoStackBlown.js] "use strict"; +// Type definitions for spected 0.7 +// Project: https://github.com/25th-floor/spected +// Definitions by: Benjamin Makus +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 Object.defineProperty(exports, "__esModule", { value: true }); exports.default = spected; diff --git a/testdata/baselines/reference/submodule/compiler/specedNoStackBlown.js.diff b/testdata/baselines/reference/submodule/compiler/specedNoStackBlown.js.diff deleted file mode 100644 index 569a89b30b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/specedNoStackBlown.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.specedNoStackBlown.js -+++ new.specedNoStackBlown.js -@@= skipped -39, +39 lines =@@ - - //// [specedNoStackBlown.js] - "use strict"; --// Type definitions for spected 0.7 --// Project: https://github.com/25th-floor/spected --// Definitions by: Benjamin Makus --// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped --// TypeScript Version: 2.8 - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = spected; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/specialIntersectionsInMappedTypes.js b/testdata/baselines/reference/submodule/compiler/specialIntersectionsInMappedTypes.js index f06fdff189..1daf03a3f2 100644 --- a/testdata/baselines/reference/submodule/compiler/specialIntersectionsInMappedTypes.js +++ b/testdata/baselines/reference/submodule/compiler/specialIntersectionsInMappedTypes.js @@ -18,6 +18,7 @@ a.other.length; // Error expected here //// [specialIntersectionsInMappedTypes.js] +// Repro from #50683 const a = { left: "align-left", center: "align-center", diff --git a/testdata/baselines/reference/submodule/compiler/specialIntersectionsInMappedTypes.js.diff b/testdata/baselines/reference/submodule/compiler/specialIntersectionsInMappedTypes.js.diff index 4dfbc08838..779e459e55 100644 --- a/testdata/baselines/reference/submodule/compiler/specialIntersectionsInMappedTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/specialIntersectionsInMappedTypes.js.diff @@ -5,7 +5,6 @@ //// [specialIntersectionsInMappedTypes.js] -"use strict"; --// Repro from #50683 + // Repro from #50683 const a = { - left: "align-left", - center: "align-center", \ No newline at end of file + left: "align-left", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualType.js b/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualType.js index fe87157055..0955ee08dc 100644 --- a/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualType.js +++ b/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualType.js @@ -22,6 +22,7 @@ function test2(item: T): T { //// [spreadExpressionContextualType.js] +// Repro from #43966 var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { diff --git a/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualType.js.diff b/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualType.js.diff index 7e538b55b2..c9b02c1ef9 100644 --- a/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualType.js.diff +++ b/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualType.js.diff @@ -5,7 +5,6 @@ //// [spreadExpressionContextualType.js] -"use strict"; --// Repro from #43966 + // Repro from #43966 var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { \ No newline at end of file + __assign = Object.assign || function(t) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualTypeWithNamespace.js b/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualTypeWithNamespace.js index 132ae598ca..58620e049f 100644 --- a/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualTypeWithNamespace.js +++ b/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualTypeWithNamespace.js @@ -36,11 +36,11 @@ getStuff().exportedDirectly; //// [spreadExpressionContextualTypeWithNamespace_0.js] "use strict"; +// Repro from #44179 with some modification Object.defineProperty(exports, "__esModule", { value: true }); exports.obj = exports.klass = void 0; exports.func = func; exports.exportedDirectly = exportedDirectly; -// Repro from #44179 with some modification function func() { } class klass { } diff --git a/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualTypeWithNamespace.js.diff b/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualTypeWithNamespace.js.diff index e22623ce91..c8f0893e6d 100644 --- a/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualTypeWithNamespace.js.diff +++ b/testdata/baselines/reference/submodule/compiler/spreadExpressionContextualTypeWithNamespace.js.diff @@ -1,19 +1,6 @@ --- old.spreadExpressionContextualTypeWithNamespace.js +++ new.spreadExpressionContextualTypeWithNamespace.js -@@= skipped -35, +35 lines =@@ - - //// [spreadExpressionContextualTypeWithNamespace_0.js] - "use strict"; --// Repro from #44179 with some modification - Object.defineProperty(exports, "__esModule", { value: true }); - exports.obj = exports.klass = void 0; - exports.func = func; - exports.exportedDirectly = exportedDirectly; -+// Repro from #44179 with some modification - function func() { } - class klass { - } -@@= skipped -26, +26 lines =@@ +@@= skipped -61, +61 lines =@@ return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties2.js b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties2.js index ce5b102681..faed3c3d7f 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties2.js +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties2.js @@ -8,6 +8,7 @@ type T2 = [(string | undefined)?] extends [string?] ? true : false; // false //// [strictOptionalProperties2.js] +// Repro from #44567 //// [strictOptionalProperties2.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties2.js.diff b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties2.js.diff index 9a3f80a1e6..1f43d8fe3b 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties2.js.diff @@ -5,7 +5,5 @@ //// [strictOptionalProperties2.js] -"use strict"; --// Repro from #44567 + // Repro from #44567 - - //// [strictOptionalProperties2.d.ts] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/strictSubtypeAndNarrowing.js b/testdata/baselines/reference/submodule/compiler/strictSubtypeAndNarrowing.js index 3176fd3168..65ea4cd3b8 100644 --- a/testdata/baselines/reference/submodule/compiler/strictSubtypeAndNarrowing.js +++ b/testdata/baselines/reference/submodule/compiler/strictSubtypeAndNarrowing.js @@ -234,6 +234,7 @@ const f = (value: Union) => { //// [strictSubtypeAndNarrowing.js] +// Check that `any` is a strict supertype of `unknown` const a11 = [x11, x12]; const a12 = [x12, x11]; const a21 = [x22, x21]; diff --git a/testdata/baselines/reference/submodule/compiler/strictSubtypeAndNarrowing.js.diff b/testdata/baselines/reference/submodule/compiler/strictSubtypeAndNarrowing.js.diff index 963b0d7755..a357bd50ad 100644 --- a/testdata/baselines/reference/submodule/compiler/strictSubtypeAndNarrowing.js.diff +++ b/testdata/baselines/reference/submodule/compiler/strictSubtypeAndNarrowing.js.diff @@ -5,7 +5,6 @@ //// [strictSubtypeAndNarrowing.js] -"use strict"; --// Check that `any` is a strict supertype of `unknown` + // Check that `any` is a strict supertype of `unknown` const a11 = [x11, x12]; - const a12 = [x12, x11]; - const a21 = [x22, x21]; \ No newline at end of file + const a12 = [x12, x11]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.js b/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.js index e639d7e8e2..bdbf5554d0 100644 --- a/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.js +++ b/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.js @@ -16,6 +16,6 @@ var m1; //// [stringLiteralObjectLiteralDeclaration1.d.ts] declare namespace m1 { var n: { - "foo bar": number; + 'foo bar': number; }; } diff --git a/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.js.diff b/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.js.diff deleted file mode 100644 index 1bfc073b54..0000000000 --- a/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.stringLiteralObjectLiteralDeclaration1.js -+++ new.stringLiteralObjectLiteralDeclaration1.js -@@= skipped -15, +15 lines =@@ - //// [stringLiteralObjectLiteralDeclaration1.d.ts] - declare namespace m1 { - var n: { -- 'foo bar': number; -+ "foo bar": number; - }; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.types b/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.types index 231045a792..1629571fc6 100644 --- a/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.types +++ b/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.types @@ -5,8 +5,8 @@ module m1 { >m1 : typeof m1 export var n = { 'foo bar': 4 }; ->n : { "foo bar": number; } ->{ 'foo bar': 4 } : { "foo bar": number; } +>n : { 'foo bar': number; } +>{ 'foo bar': 4 } : { 'foo bar': number; } >'foo bar' : number >4 : 4 } diff --git a/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.types.diff b/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.types.diff deleted file mode 100644 index e835ded18a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/stringLiteralObjectLiteralDeclaration1.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.stringLiteralObjectLiteralDeclaration1.types -+++ new.stringLiteralObjectLiteralDeclaration1.types -@@= skipped -4, +4 lines =@@ - >m1 : typeof m1 - - export var n = { 'foo bar': 4 }; -->n : { 'foo bar': number; } -->{ 'foo bar': 4 } : { 'foo bar': number; } -+>n : { "foo bar": number; } -+>{ 'foo bar': 4 } : { "foo bar": number; } - >'foo bar' : number - >4 : 4 - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/substitutionTypesInIndexedAccessTypes.js b/testdata/baselines/reference/submodule/compiler/substitutionTypesInIndexedAccessTypes.js index c97b325e5c..716b8ff27c 100644 --- a/testdata/baselines/reference/submodule/compiler/substitutionTypesInIndexedAccessTypes.js +++ b/testdata/baselines/reference/submodule/compiler/substitutionTypesInIndexedAccessTypes.js @@ -22,6 +22,7 @@ const withoutBoundaryResult = withoutBoundary({ //// [substitutionTypesInIndexedAccessTypes.js] +// Repro from #31086 const boundaryResult = withBoundary({ select: true, }); diff --git a/testdata/baselines/reference/submodule/compiler/substitutionTypesInIndexedAccessTypes.js.diff b/testdata/baselines/reference/submodule/compiler/substitutionTypesInIndexedAccessTypes.js.diff index a53e59395f..012b6eca39 100644 --- a/testdata/baselines/reference/submodule/compiler/substitutionTypesInIndexedAccessTypes.js.diff +++ b/testdata/baselines/reference/submodule/compiler/substitutionTypesInIndexedAccessTypes.js.diff @@ -5,7 +5,6 @@ //// [substitutionTypesInIndexedAccessTypes.js] -"use strict"; --// Repro from #31086 + // Repro from #31086 const boundaryResult = withBoundary({ - select: true, - }); \ No newline at end of file + select: true, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/taggedTemplateStringWithSymbolExpression01.js b/testdata/baselines/reference/submodule/compiler/taggedTemplateStringWithSymbolExpression01.js index d0753d67d3..8d1a2f2949 100644 --- a/testdata/baselines/reference/submodule/compiler/taggedTemplateStringWithSymbolExpression01.js +++ b/testdata/baselines/reference/submodule/compiler/taggedTemplateStringWithSymbolExpression01.js @@ -10,5 +10,6 @@ let result: number = foo`${x}`; //// [taggedTemplateStringWithSymbolExpression01.js] +// taggedTemplateStringWithSymbolExpression01.ts let x; let result = foo `${x}`; diff --git a/testdata/baselines/reference/submodule/compiler/taggedTemplateStringWithSymbolExpression01.js.diff b/testdata/baselines/reference/submodule/compiler/taggedTemplateStringWithSymbolExpression01.js.diff deleted file mode 100644 index 56b8221ef6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/taggedTemplateStringWithSymbolExpression01.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.taggedTemplateStringWithSymbolExpression01.js -+++ new.taggedTemplateStringWithSymbolExpression01.js -@@= skipped -9, +9 lines =@@ - - - //// [taggedTemplateStringWithSymbolExpression01.js] --// taggedTemplateStringWithSymbolExpression01.ts - let x; - let result = foo `${x}`; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/taggedTemplateStringsWithCurriedFunction.js b/testdata/baselines/reference/submodule/compiler/taggedTemplateStringsWithCurriedFunction.js index a920b38ccd..bd943b8645 100644 --- a/testdata/baselines/reference/submodule/compiler/taggedTemplateStringsWithCurriedFunction.js +++ b/testdata/baselines/reference/submodule/compiler/taggedTemplateStringsWithCurriedFunction.js @@ -13,6 +13,7 @@ f({ x: (() => 1)(), ...{ y: 1 } })``; //// [taggedTemplateStringsWithCurriedFunction.js] +// Originated from #38558 var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -24,7 +25,6 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; -// Originated from #38558 const f = _ => (..._) => ""; f(__assign({ x: 0 })) ``; f(__assign({ x: 0 })) `x`; diff --git a/testdata/baselines/reference/submodule/compiler/taggedTemplateStringsWithCurriedFunction.js.diff b/testdata/baselines/reference/submodule/compiler/taggedTemplateStringsWithCurriedFunction.js.diff deleted file mode 100644 index b32a21039c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/taggedTemplateStringsWithCurriedFunction.js.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.taggedTemplateStringsWithCurriedFunction.js -+++ new.taggedTemplateStringsWithCurriedFunction.js -@@= skipped -12, +12 lines =@@ - - - //// [taggedTemplateStringsWithCurriedFunction.js] --// Originated from #38558 - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -12, +11 lines =@@ - }; - return __assign.apply(this, arguments); - }; -+// Originated from #38558 - const f = _ => (..._) => ""; - f(__assign({ x: 0 })) ``; - f(__assign({ x: 0 })) `x`; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=commonjs).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=commonjs).errors.txt.diff deleted file mode 100644 index d1bf09c663..0000000000 --- a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=commonjs).errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.tripleSlashTypesReferenceWithMissingExports(module=commonjs).errors.txt -+++ new.tripleSlashTypesReferenceWithMissingExports(module=commonjs).errors.txt -@@= skipped -0, +0 lines =@@ -- -+usage.ts(1,23): error TS2688: Cannot find type definition file for 'pkg'. -+ -+ -+==== node_modules/pkg/index.d.ts (0 errors) ==== -+ interface GlobalThing { a: number } -+==== node_modules/pkg/package.json (0 errors) ==== -+ { -+ "name": "pkg", -+ "types": "index.d.ts", -+ "exports": "some-other-thing.js" -+ } -+==== usage.ts (1 errors) ==== -+ /// -+ ~~~ -+!!! error TS2688: Cannot find type definition file for 'pkg'. -+ -+ const a: GlobalThing = { a: 0 }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node16).js b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node16).js index 6d734ae2ed..7c518b3b9d 100644 --- a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node16).js +++ b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node16).js @@ -15,6 +15,6 @@ const a: GlobalThing = { a: 0 }; //// [usage.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const a = { a: 0 }; diff --git a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node16).js.diff b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node16).js.diff deleted file mode 100644 index 050a3b1053..0000000000 --- a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node16).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.tripleSlashTypesReferenceWithMissingExports(module=node16).js -+++ new.tripleSlashTypesReferenceWithMissingExports(module=node16).js -@@= skipped -14, +14 lines =@@ - - //// [usage.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); -+/// - const a = { a: 0 }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node20).js b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node20).js index 6d734ae2ed..7c518b3b9d 100644 --- a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node20).js +++ b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node20).js @@ -15,6 +15,6 @@ const a: GlobalThing = { a: 0 }; //// [usage.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const a = { a: 0 }; diff --git a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node20).js.diff b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node20).js.diff deleted file mode 100644 index 18ceeaf53b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node20).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.tripleSlashTypesReferenceWithMissingExports(module=node20).js -+++ new.tripleSlashTypesReferenceWithMissingExports(module=node20).js -@@= skipped -14, +14 lines =@@ - - //// [usage.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); -+/// - const a = { a: 0 }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=nodenext).js b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=nodenext).js index 6d734ae2ed..7c518b3b9d 100644 --- a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=nodenext).js +++ b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=nodenext).js @@ -15,6 +15,6 @@ const a: GlobalThing = { a: 0 }; //// [usage.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /// +Object.defineProperty(exports, "__esModule", { value: true }); const a = { a: 0 }; diff --git a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=nodenext).js.diff b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=nodenext).js.diff deleted file mode 100644 index 02147f9a60..0000000000 --- a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=nodenext).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.tripleSlashTypesReferenceWithMissingExports(module=nodenext).js -+++ new.tripleSlashTypesReferenceWithMissingExports(module=nodenext).js -@@= skipped -14, +14 lines =@@ - - //// [usage.js] - "use strict"; --/// - Object.defineProperty(exports, "__esModule", { value: true }); -+/// - const a = { a: 0 }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/tsxFragmentChildrenCheck.js b/testdata/baselines/reference/submodule/compiler/tsxFragmentChildrenCheck.js index 5eacef6509..f4c4b661aa 100644 --- a/testdata/baselines/reference/submodule/compiler/tsxFragmentChildrenCheck.js +++ b/testdata/baselines/reference/submodule/compiler/tsxFragmentChildrenCheck.js @@ -44,7 +44,10 @@ const MY_STRING = 'Ceci n\'est pas une string.'; const MY_CLASSNAME = 'jeclass'; class RenderString extends React.PureComponent { render() { - return (React.createElement(React.Fragment, null, React.createElement(my_component_1.MyComponent, null), React.createElement("span", null, MY_STRING), React.createElement("span", { className: MY_CLASSNAME }))); + return (React.createElement(React.Fragment, null, + React.createElement(my_component_1.MyComponent, null), + React.createElement("span", null, MY_STRING), + React.createElement("span", { className: MY_CLASSNAME }))); } } exports.default = RenderString; diff --git a/testdata/baselines/reference/submodule/compiler/tsxFragmentChildrenCheck.js.diff b/testdata/baselines/reference/submodule/compiler/tsxFragmentChildrenCheck.js.diff index faf9661d65..ee5d7d029c 100644 --- a/testdata/baselines/reference/submodule/compiler/tsxFragmentChildrenCheck.js.diff +++ b/testdata/baselines/reference/submodule/compiler/tsxFragmentChildrenCheck.js.diff @@ -10,13 +10,4 @@ +const my_component_1 = require("./my-component"); const MY_STRING = 'Ceci n\'est pas une string.'; const MY_CLASSNAME = 'jeclass'; - class RenderString extends React.PureComponent { - render() { -- return (React.createElement(React.Fragment, null, -- React.createElement(my_component_1.MyComponent, null), -- React.createElement("span", null, MY_STRING), -- React.createElement("span", { className: MY_CLASSNAME }))); -+ return (React.createElement(React.Fragment, null, React.createElement(my_component_1.MyComponent, null), React.createElement("span", null, MY_STRING), React.createElement("span", { className: MY_CLASSNAME }))); - } - } - exports.default = RenderString; \ No newline at end of file + class RenderString extends React.PureComponent { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/tsxNotUsingApparentTypeOfSFC.js b/testdata/baselines/reference/submodule/compiler/tsxNotUsingApparentTypeOfSFC.js index 37e3dbd216..86f61ddfe3 100644 --- a/testdata/baselines/reference/submodule/compiler/tsxNotUsingApparentTypeOfSFC.js +++ b/testdata/baselines/reference/submodule/compiler/tsxNotUsingApparentTypeOfSFC.js @@ -23,6 +23,7 @@ function test

(wrappedProps: P) { //// [tsxNotUsingApparentTypeOfSFC.js] "use strict"; +/// var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -38,7 +39,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -/// const react_1 = __importDefault(require("react")); function test(wrappedProps) { let MySFC = function (props) { diff --git a/testdata/baselines/reference/submodule/compiler/tsxNotUsingApparentTypeOfSFC.js.diff b/testdata/baselines/reference/submodule/compiler/tsxNotUsingApparentTypeOfSFC.js.diff index adaeb0ae16..46768e7061 100644 --- a/testdata/baselines/reference/submodule/compiler/tsxNotUsingApparentTypeOfSFC.js.diff +++ b/testdata/baselines/reference/submodule/compiler/tsxNotUsingApparentTypeOfSFC.js.diff @@ -1,19 +1,10 @@ --- old.tsxNotUsingApparentTypeOfSFC.js +++ new.tsxNotUsingApparentTypeOfSFC.js -@@= skipped -22, +22 lines =@@ - - //// [tsxNotUsingApparentTypeOfSFC.js] - "use strict"; --/// - var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { -@@= skipped -16, +15 lines =@@ +@@= skipped -38, +38 lines =@@ return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -var react_1 = __importDefault(require("react")); -+/// +const react_1 = __importDefault(require("react")); function test(wrappedProps) { let MySFC = function (props) { diff --git a/testdata/baselines/reference/submodule/compiler/tsxReactPropsInferenceSucceedsOnIntersections.js b/testdata/baselines/reference/submodule/compiler/tsxReactPropsInferenceSucceedsOnIntersections.js index 6a231bf839..238668914a 100644 --- a/testdata/baselines/reference/submodule/compiler/tsxReactPropsInferenceSucceedsOnIntersections.js +++ b/testdata/baselines/reference/submodule/compiler/tsxReactPropsInferenceSucceedsOnIntersections.js @@ -20,6 +20,7 @@ const CustomButton: React.SFC = props =>