From ce2e9352c8a6e1d977ed08da80a4e5c44abf8ea4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Nov 2025 21:29:19 +0000 Subject: [PATCH 1/2] deps(deps): bump microsoft/typescript-go from `4916e22` to `f60eb37` Bumps [microsoft/typescript-go](https://github.com/microsoft/typescript-go) from `4916e22` to `f60eb37`. - [Commits](https://github.com/microsoft/typescript-go/compare/4916e229ef410a12e6d78388e33869f4f29ef866...f60eb374240d9ecdd29cbe2186a3b77e3ccf6a7e) --- updated-dependencies: - dependency-name: microsoft/typescript-go dependency-version: f60eb374240d9ecdd29cbe2186a3b77e3ccf6a7e dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- microsoft/typescript-go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft/typescript-go b/microsoft/typescript-go index 4916e229..f60eb374 160000 --- a/microsoft/typescript-go +++ b/microsoft/typescript-go @@ -1 +1 @@ -Subproject commit 4916e229ef410a12e6d78388e33869f4f29ef866 +Subproject commit f60eb374240d9ecdd29cbe2186a3b77e3ccf6a7e From a5e16c7f81d4bb7352e35fa6d4869788fb8095f7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 7 Nov 2025 02:35:01 +0000 Subject: [PATCH 2/2] chore(sync): mirror internal packages into pkg/ (auto) --- pkg/checker/checker.go | 2 +- pkg/checker/utilities.go | 14 ------- pkg/execute/tsc.go | 9 ++++- pkg/execute/watcher.go | 35 ++++++++++------- .../importAliasTypeOnlyExport.errors.txt | 14 +++++++ .../importAliasTypeOnlyExport.symbols | 19 +++++++++ .../compiler/importAliasTypeOnlyExport.types | 19 +++++++++ .../watch-with-tsconfig-and-incremental.js | 39 +++++++++++++++++++ .../compiler/importAliasTypeOnlyExport.ts | 11 ++++++ 9 files changed, 133 insertions(+), 29 deletions(-) create mode 100644 testdata/baselines/reference/compiler/importAliasTypeOnlyExport.errors.txt create mode 100644 testdata/baselines/reference/compiler/importAliasTypeOnlyExport.symbols create mode 100644 testdata/baselines/reference/compiler/importAliasTypeOnlyExport.types create mode 100644 testdata/tests/cases/compiler/importAliasTypeOnlyExport.ts diff --git a/pkg/checker/checker.go b/pkg/checker/checker.go index c0b5f443..77294bb8 100644 --- a/pkg/checker/checker.go +++ b/pkg/checker/checker.go @@ -13987,7 +13987,7 @@ func (c *Checker) checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(nod // TODO: how to get name for export *? name := "*" if !ast.IsExportDeclaration(typeOnlyDeclaration) { - name = getNameFromImportDeclaration(typeOnlyDeclaration).Text() + name = typeOnlyDeclaration.Name().Text() } c.error(decl.ModuleReference, message).AddRelatedInfo(createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name)) } diff --git a/pkg/checker/utilities.go b/pkg/checker/utilities.go index 85109d05..c9c0f0d3 100644 --- a/pkg/checker/utilities.go +++ b/pkg/checker/utilities.go @@ -189,20 +189,6 @@ func IsInTypeQuery(node *ast.Node) bool { }) != nil } -func getNameFromImportDeclaration(node *ast.Node) *ast.Node { - switch node.Kind { - case ast.KindImportSpecifier: - return node.AsImportSpecifier().Name() - case ast.KindNamespaceImport: - return node.AsNamespaceImport().Name() - case ast.KindImportClause: - return node.AsImportClause().Name() - case ast.KindImportEqualsDeclaration: - return node.AsImportEqualsDeclaration().Name() - } - return nil -} - func nodeCanBeDecorated(useLegacyDecorators bool, node *ast.Node, parent *ast.Node, grandparent *ast.Node) bool { // private names cannot be used with decorators yet if useLegacyDecorators && node.Name() != nil && ast.IsPrivateIdentifier(node.Name()) { diff --git a/pkg/execute/tsc.go b/pkg/execute/tsc.go index f803ca42..e03040d3 100644 --- a/pkg/execute/tsc.go +++ b/pkg/execute/tsc.go @@ -193,7 +193,14 @@ func tscCompilation(sys tsc.System, commandLine *tsoptions.ParsedCommandLine, te return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess} } if configForCompilation.CompilerOptions().Watch.IsTrue() { - watcher := createWatcher(sys, configForCompilation, reportDiagnostic, reportErrorSummary, testing) + watcher := createWatcher( + sys, + configForCompilation, + compilerOptionsFromCommandLine, + reportDiagnostic, + reportErrorSummary, + testing, + ) watcher.start() return tsc.CommandLineResult{Status: tsc.ExitStatusSuccess, Watcher: watcher} } else if configForCompilation.CompilerOptions().IsIncremental() { diff --git a/pkg/execute/watcher.go b/pkg/execute/watcher.go index a4c09ad8..a4b693ba 100644 --- a/pkg/execute/watcher.go +++ b/pkg/execute/watcher.go @@ -14,12 +14,13 @@ import ( ) type Watcher struct { - sys tsc.System - configFileName string - config *tsoptions.ParsedCommandLine - reportDiagnostic tsc.DiagnosticReporter - reportErrorSummary tsc.DiagnosticsReporter - testing tsc.CommandLineTesting + sys tsc.System + configFileName string + config *tsoptions.ParsedCommandLine + compilerOptionsFromCommandLine *core.CompilerOptions + reportDiagnostic tsc.DiagnosticReporter + reportErrorSummary tsc.DiagnosticsReporter + testing tsc.CommandLineTesting host compiler.CompilerHost program *incremental.Program @@ -29,13 +30,21 @@ type Watcher struct { var _ tsc.Watcher = (*Watcher)(nil) -func createWatcher(sys tsc.System, configParseResult *tsoptions.ParsedCommandLine, reportDiagnostic tsc.DiagnosticReporter, reportErrorSummary tsc.DiagnosticsReporter, testing tsc.CommandLineTesting) *Watcher { +func createWatcher( + sys tsc.System, + configParseResult *tsoptions.ParsedCommandLine, + compilerOptionsFromCommandLine *core.CompilerOptions, + reportDiagnostic tsc.DiagnosticReporter, + reportErrorSummary tsc.DiagnosticsReporter, + testing tsc.CommandLineTesting, +) *Watcher { w := &Watcher{ - sys: sys, - config: configParseResult, - reportDiagnostic: reportDiagnostic, - reportErrorSummary: reportErrorSummary, - testing: testing, + sys: sys, + config: configParseResult, + compilerOptionsFromCommandLine: compilerOptionsFromCommandLine, + reportDiagnostic: reportDiagnostic, + reportErrorSummary: reportErrorSummary, + testing: testing, // reportWatchStatus: createWatchStatusReporter(sys, configParseResult.CompilerOptions().Pretty), } if configParseResult.ConfigFile != nil { @@ -108,7 +117,7 @@ func (w *Watcher) hasErrorsInTsConfig() bool { extendedConfigCache := &tsc.ExtendedConfigCache{} if w.configFileName != "" { // !!! need to check that this merges compileroptions correctly. This differs from non-watch, since we allow overriding of previous options - configParseResult, errors := tsoptions.GetParsedCommandLineOfConfigFile(w.configFileName, &core.CompilerOptions{}, w.sys, extendedConfigCache) + configParseResult, errors := tsoptions.GetParsedCommandLineOfConfigFile(w.configFileName, w.compilerOptionsFromCommandLine, w.sys, extendedConfigCache) if len(errors) > 0 { for _, e := range errors { w.reportDiagnostic(e) diff --git a/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.errors.txt b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.errors.txt new file mode 100644 index 00000000..39c8d407 --- /dev/null +++ b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.errors.txt @@ -0,0 +1,14 @@ +t.ts(2,14): error TS1379: An import alias cannot reference a declaration that was exported using 'export type'. + + +==== t.ts (1 errors) ==== + import a = require("./a"); + import foo = a.Foo + ~~~~~ +!!! error TS1379: An import alias cannot reference a declaration that was exported using 'export type'. +!!! related TS1377 a.ts:2:15: 'Foo' was exported here. + +==== a.ts (0 errors) ==== + type Foo = { x: number } + export type { Foo }; + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.symbols b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.symbols new file mode 100644 index 00000000..fa41228c --- /dev/null +++ b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/importAliasTypeOnlyExport.ts] //// + +=== t.ts === +import a = require("./a"); +>a : Symbol(a, Decl(t.ts, 0, 0)) + +import foo = a.Foo +>foo : Symbol(foo, Decl(t.ts, 0, 26)) +>a : Symbol(a, Decl(t.ts, 0, 0)) +>Foo : Symbol(a.Foo, Decl(a.ts, 1, 13)) + +=== a.ts === +type Foo = { x: number } +>Foo : Symbol(Foo, Decl(a.ts, 0, 0)) +>x : Symbol(x, Decl(a.ts, 0, 12)) + +export type { Foo }; +>Foo : Symbol(Foo, Decl(a.ts, 1, 13)) + diff --git a/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.types b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.types new file mode 100644 index 00000000..73e51f00 --- /dev/null +++ b/testdata/baselines/reference/compiler/importAliasTypeOnlyExport.types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/importAliasTypeOnlyExport.ts] //// + +=== t.ts === +import a = require("./a"); +>a : typeof a + +import foo = a.Foo +>foo : any +>a : typeof a +>Foo : foo + +=== a.ts === +type Foo = { x: number } +>Foo : Foo +>x : number + +export type { Foo }; +>Foo : Foo + diff --git a/testdata/baselines/reference/tscWatch/commandLineWatch/watch-with-tsconfig-and-incremental.js b/testdata/baselines/reference/tscWatch/commandLineWatch/watch-with-tsconfig-and-incremental.js index 67055b18..6c3b8dce 100644 --- a/testdata/baselines/reference/tscWatch/commandLineWatch/watch-with-tsconfig-and-incremental.js +++ b/testdata/baselines/reference/tscWatch/commandLineWatch/watch-with-tsconfig-and-incremental.js @@ -36,6 +36,45 @@ interface Symbol { declare const console: { log(msg: any): void; }; //// [/home/src/workspaces/project/index.js] *new* +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./index.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"99aa06d3014798d86001c324468d497f-"]} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "root": [ + { + "files": [ + "./index.ts" + ], + "original": 2 + } + ], + "fileNames": [ + "lib.d.ts", + "./index.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./index.ts", + "version": "99aa06d3014798d86001c324468d497f-", + "signature": "99aa06d3014798d86001c324468d497f-", + "impliedNodeFormat": "CommonJS" + } + ], + "size": 896 +} tsconfig.json:: SemanticDiagnostics:: diff --git a/testdata/tests/cases/compiler/importAliasTypeOnlyExport.ts b/testdata/tests/cases/compiler/importAliasTypeOnlyExport.ts new file mode 100644 index 00000000..032fdc3e --- /dev/null +++ b/testdata/tests/cases/compiler/importAliasTypeOnlyExport.ts @@ -0,0 +1,11 @@ +// @target: esnext +// @module: commonjs +// @noEmit: true + +// @filename: t.ts +import a = require("./a"); +import foo = a.Foo + +// @filename: a.ts +type Foo = { x: number } +export type { Foo };