From 3c0d84108cd591f222ab683fc0c30da8c1d7e9e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 19:33:49 +0000 Subject: [PATCH 1/5] Initial plan From 26393359cd9843c754598e69b6b90ed2144d5e62 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 19:50:02 +0000 Subject: [PATCH 2/5] Port PR #63200: Add symbol name to TS2742/TS2883 error message Add new diagnostic TS2883 that includes the symbol name in the error message for unsafe import references. Update SymbolTracker interface and implementations to pass through the symbol name parameter. Co-authored-by: gabritto <19519347+gabritto@users.noreply.github.com> --- internal/checker/nodebuilderimpl.go | 2 +- internal/checker/symboltracker.go | 4 +-- internal/diagnostics/diagnostics_generated.go | 4 +++ internal/nodebuilder/types.go | 2 +- internal/transformers/declarations/tracker.go | 8 +++-- ...mitCommonJsModuleReferencedType.errors.txt | 4 +-- ...mmonJsModuleReferencedType.errors.txt.diff | 16 +++++++++ ...EmitObjectAssignedDefaultExport.errors.txt | 4 +-- ...bjectAssignedDefaultExport.errors.txt.diff | 15 ++++++++ ...EmitReexportedSymlinkReference3.errors.txt | 4 +-- ...eexportedSymlinkReference3.errors.txt.diff | 17 ++++++++++ .../declarationEmitUsingTypeAlias1.errors.txt | 13 ++++--- ...arationEmitUsingTypeAlias1.errors.txt.diff | 34 +++++++++++++++++++ ...tsSpecifierGenerationConditions.errors.txt | 4 +-- ...cifierGenerationConditions.errors.txt.diff | 15 ++++++++ ...cifierResolution(module=node16).errors.txt | 4 +-- ...rResolution(module=node16).errors.txt.diff | 18 ++++++++++ ...cifierResolution(module=node18).errors.txt | 4 +-- ...rResolution(module=node18).errors.txt.diff | 18 ++++++++++ ...cifierResolution(module=node20).errors.txt | 4 +-- ...rResolution(module=node20).errors.txt.diff | 18 ++++++++++ ...fierResolution(module=nodenext).errors.txt | 4 +-- ...esolution(module=nodenext).errors.txt.diff | 18 ++++++++++ ...sExportsSourceTs(module=node16).errors.txt | 4 +-- ...rtsSourceTs(module=node16).errors.txt.diff | 18 ++++++++++ ...sExportsSourceTs(module=node18).errors.txt | 4 +-- ...rtsSourceTs(module=node18).errors.txt.diff | 18 ++++++++++ ...sExportsSourceTs(module=node20).errors.txt | 4 +-- ...rtsSourceTs(module=node20).errors.txt.diff | 18 ++++++++++ ...xportsSourceTs(module=nodenext).errors.txt | 4 +-- ...sSourceTs(module=nodenext).errors.txt.diff | 18 ++++++++++ 31 files changed, 287 insertions(+), 35 deletions(-) create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitUsingTypeAlias1.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node16).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node18).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node20).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=nodenext).errors.txt.diff diff --git a/internal/checker/nodebuilderimpl.go b/internal/checker/nodebuilderimpl.go index 512bb34c000..10f8a7336a3 100644 --- a/internal/checker/nodebuilderimpl.go +++ b/internal/checker/nodebuilderimpl.go @@ -578,7 +578,7 @@ func (b *NodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFl // If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error // since declaration files with these kinds of references are liable to fail when published :( b.ctx.encounteredError = true - b.ctx.tracker.ReportLikelyUnsafeImportRequiredError(oldSpecifier) + b.ctx.tracker.ReportLikelyUnsafeImportRequiredError(oldSpecifier, symbol.Name) } } diff --git a/internal/checker/symboltracker.go b/internal/checker/symboltracker.go index 2c606c294a0..7cf7b162a57 100644 --- a/internal/checker/symboltracker.go +++ b/internal/checker/symboltracker.go @@ -71,12 +71,12 @@ func (this *SymbolTrackerImpl) ReportCyclicStructureError() { this.inner.ReportCyclicStructureError() } -func (this *SymbolTrackerImpl) ReportLikelyUnsafeImportRequiredError(specifier string) { +func (this *SymbolTrackerImpl) ReportLikelyUnsafeImportRequiredError(specifier string, symbolName string) { this.onDiagnosticReported() if this.inner == nil { return } - this.inner.ReportLikelyUnsafeImportRequiredError(specifier) + this.inner.ReportLikelyUnsafeImportRequiredError(specifier, symbolName) } func (this *SymbolTrackerImpl) ReportTruncationError() { diff --git a/internal/diagnostics/diagnostics_generated.go b/internal/diagnostics/diagnostics_generated.go index 816ee833cbc..8b4f4555266 100644 --- a/internal/diagnostics/diagnostics_generated.go +++ b/internal/diagnostics/diagnostics_generated.go @@ -2008,6 +2008,8 @@ var This_expression_is_never_nullish = &Message{code: 2881, category: CategoryEr var Cannot_find_module_or_type_declarations_for_side_effect_import_of_0 = &Message{code: 2882, category: CategoryError, key: "Cannot_find_module_or_type_declarations_for_side_effect_import_of_0_2882", text: "Cannot find module or type declarations for side-effect import of '{0}'."} +var The_inferred_type_of_0_cannot_be_named_without_a_reference_to_2_from_1_This_is_likely_not_portable_A_type_annotation_is_necessary = &Message{code: 2883, category: CategoryError, key: "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_2_from_1_This_is_likely_not_portable_A_type_a_2883", text: "The inferred type of '{0}' cannot be named without a reference to '{2}' from '{1}'. This is likely not portable. A type annotation is necessary."} + var Import_declaration_0_is_using_private_name_1 = &Message{code: 4000, category: CategoryError, key: "Import_declaration_0_is_using_private_name_1_4000", text: "Import declaration '{0}' is using private name '{1}'."} var Type_parameter_0_of_exported_class_has_or_is_using_private_name_1 = &Message{code: 4002, category: CategoryError, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", text: "Type parameter '{0}' of exported class has or is using private name '{1}'."} @@ -6294,6 +6296,8 @@ func keyToMessage(key Key) *Message { return This_expression_is_never_nullish case "Cannot_find_module_or_type_declarations_for_side_effect_import_of_0_2882": return Cannot_find_module_or_type_declarations_for_side_effect_import_of_0 + case "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_2_from_1_This_is_likely_not_portable_A_type_a_2883": + return The_inferred_type_of_0_cannot_be_named_without_a_reference_to_2_from_1_This_is_likely_not_portable_A_type_annotation_is_necessary case "Import_declaration_0_is_using_private_name_1_4000": return Import_declaration_0_is_using_private_name_1 case "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002": diff --git a/internal/nodebuilder/types.go b/internal/nodebuilder/types.go index aada4c96a52..cdfc32bc98c 100644 --- a/internal/nodebuilder/types.go +++ b/internal/nodebuilder/types.go @@ -12,7 +12,7 @@ type SymbolTracker interface { ReportPrivateInBaseOfClassExpression(propertyName string) ReportInaccessibleUniqueSymbolError() ReportCyclicStructureError() - ReportLikelyUnsafeImportRequiredError(specifier string) + ReportLikelyUnsafeImportRequiredError(specifier string, symbolName string) ReportTruncationError() ReportNonlocalAugmentation(containingFile *ast.SourceFile, parentSymbol *ast.Symbol, augmentingSymbol *ast.Symbol) ReportNonSerializableProperty(propertyName string) diff --git a/internal/transformers/declarations/tracker.go b/internal/transformers/declarations/tracker.go index 0333eb1eea5..3b47d53d3a8 100644 --- a/internal/transformers/declarations/tracker.go +++ b/internal/transformers/declarations/tracker.go @@ -67,10 +67,14 @@ func (s *SymbolTrackerImpl) ReportInferenceFallback(node *ast.Node) { } // ReportLikelyUnsafeImportRequiredError implements checker.SymbolTracker. -func (s *SymbolTrackerImpl) ReportLikelyUnsafeImportRequiredError(specifier string) { +func (s *SymbolTrackerImpl) ReportLikelyUnsafeImportRequiredError(specifier string, symbolName string) { location := s.errorLocation() if location != nil { - s.state.addDiagnostic(createDiagnosticForNode(location, diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, s.errorDeclarationNameWithFallback(), specifier)) + if symbolName != "" { + s.state.addDiagnostic(createDiagnosticForNode(location, diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_2_from_1_This_is_likely_not_portable_A_type_annotation_is_necessary, s.errorDeclarationNameWithFallback(), specifier, symbolName)) + } else { + s.state.addDiagnostic(createDiagnosticForNode(location, diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, s.errorDeclarationNameWithFallback(), specifier)) + } } } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.errors.txt index 5b208e8259a..7cc3bfb9b7d 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.errors.txt @@ -1,4 +1,4 @@ -r/entry.ts(3,14): error TS2742: The inferred type of 'x' cannot be named without a reference to 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. +r/entry.ts(3,14): error TS2883: The inferred type of 'x' cannot be named without a reference to 'NestedProps' from 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. ==== r/node_modules/foo/node_modules/nested/index.d.ts (0 errors) ==== @@ -23,6 +23,6 @@ r/entry.ts(3,14): error TS2742: The inferred type of 'x' cannot be named without import { bar } from "root"; export const x = foo(); ~ -!!! error TS2742: The inferred type of 'x' cannot be named without a reference to 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'x' cannot be named without a reference to 'NestedProps' from 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. export const y = bar(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.errors.txt.diff new file mode 100644 index 00000000000..db0921e81a8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCommonJsModuleReferencedType.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.declarationEmitCommonJsModuleReferencedType.errors.txt ++++ new.declarationEmitCommonJsModuleReferencedType.errors.txt +@@= skipped -0, +0 lines =@@ +-r/entry.ts(3,14): error TS2742: The inferred type of 'x' cannot be named without a reference to 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. ++r/entry.ts(3,14): error TS2883: The inferred type of 'x' cannot be named without a reference to 'NestedProps' from 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. + + + ==== r/node_modules/foo/node_modules/nested/index.d.ts (0 errors) ==== +@@= skipped -22, +22 lines =@@ + import { bar } from "root"; + export const x = foo(); + ~ +-!!! error TS2742: The inferred type of 'x' cannot be named without a reference to 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'x' cannot be named without a reference to 'NestedProps' from 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. + export const y = bar(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.errors.txt index 1971f0d340c..8396aee5921 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.errors.txt @@ -1,4 +1,4 @@ -index.ts(7,1): error TS2742: The inferred type of 'default' cannot be named without a reference to 'styled-components/node_modules/hoist-non-react-statics'. This is likely not portable. A type annotation is necessary. +index.ts(7,1): error TS2883: The inferred type of 'default' cannot be named without a reference to 'NonReactStatics' from 'styled-components/node_modules/hoist-non-react-statics'. This is likely not portable. A type annotation is necessary. ==== node_modules/styled-components/node_modules/hoist-non-react-statics/index.d.ts (0 errors) ==== @@ -43,5 +43,5 @@ index.ts(7,1): error TS2742: The inferred type of 'default' cannot be named with ~~~~~ }); ~~~ -!!! error TS2742: The inferred type of 'default' cannot be named without a reference to 'styled-components/node_modules/hoist-non-react-statics'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'default' cannot be named without a reference to 'NonReactStatics' from 'styled-components/node_modules/hoist-non-react-statics'. This is likely not portable. A type annotation is necessary. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.errors.txt.diff new file mode 100644 index 00000000000..607fe05cee0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectAssignedDefaultExport.errors.txt.diff @@ -0,0 +1,15 @@ +--- old.declarationEmitObjectAssignedDefaultExport.errors.txt ++++ new.declarationEmitObjectAssignedDefaultExport.errors.txt +@@= skipped -0, +0 lines =@@ +-index.ts(7,1): error TS2742: The inferred type of 'default' cannot be named without a reference to 'styled-components/node_modules/hoist-non-react-statics'. This is likely not portable. A type annotation is necessary. ++index.ts(7,1): error TS2883: The inferred type of 'default' cannot be named without a reference to 'NonReactStatics' from 'styled-components/node_modules/hoist-non-react-statics'. This is likely not portable. A type annotation is necessary. + + + ==== node_modules/styled-components/node_modules/hoist-non-react-statics/index.d.ts (0 errors) ==== +@@= skipped -42, +42 lines =@@ + ~~~~~ + }); + ~~~ +-!!! error TS2742: The inferred type of 'default' cannot be named without a reference to 'styled-components/node_modules/hoist-non-react-statics'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'default' cannot be named without a reference to 'NonReactStatics' from 'styled-components/node_modules/hoist-non-react-statics'. This is likely not portable. A type annotation is necessary. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.errors.txt index be730da192e..f0520d30e21 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.errors.txt @@ -1,4 +1,4 @@ -monorepo/pkg3/src/keys.ts(3,14): error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. +monorepo/pkg3/src/keys.ts(3,14): error TS2883: The inferred type of 'ADMIN' cannot be named without a reference to 'IdType' from '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. ==== monorepo/pkg3/tsconfig.json (0 errors) ==== @@ -21,7 +21,7 @@ monorepo/pkg3/src/keys.ts(3,14): error TS2742: The inferred type of 'ADMIN' cann export const ADMIN = MetadataAccessor.create('1'); ~~~~~ -!!! error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'ADMIN' cannot be named without a reference to 'IdType' from '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. ==== monorepo/pkg1/dist/index.d.ts (0 errors) ==== export * from './types'; ==== monorepo/pkg1/dist/types.d.ts (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.errors.txt.diff new file mode 100644 index 00000000000..10e15d4a5e3 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitReexportedSymlinkReference3.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.declarationEmitReexportedSymlinkReference3.errors.txt ++++ new.declarationEmitReexportedSymlinkReference3.errors.txt +@@= skipped -0, +0 lines =@@ +-monorepo/pkg3/src/keys.ts(3,14): error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. ++monorepo/pkg3/src/keys.ts(3,14): error TS2883: The inferred type of 'ADMIN' cannot be named without a reference to 'IdType' from '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. + + + ==== monorepo/pkg3/tsconfig.json (0 errors) ==== +@@= skipped -20, +20 lines =@@ + + export const ADMIN = MetadataAccessor.create('1'); + ~~~~~ +-!!! error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'ADMIN' cannot be named without a reference to 'IdType' from '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. + ==== monorepo/pkg1/dist/index.d.ts (0 errors) ==== + export * from './types'; + ==== monorepo/pkg1/dist/types.d.ts (0 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUsingTypeAlias1.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitUsingTypeAlias1.errors.txt index c31e66a237a..15bdbce24b7 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitUsingTypeAlias1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUsingTypeAlias1.errors.txt @@ -1,5 +1,6 @@ -src/index.ts(3,14): error TS2742: The inferred type of 'foo' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. -src/index.ts(7,14): error TS2742: The inferred type of 'bar' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. +src/index.ts(3,14): error TS2883: The inferred type of 'foo' cannot be named without a reference to 'SomeType' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. +src/index.ts(7,14): error TS2883: The inferred type of 'bar' cannot be named without a reference to 'Other' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. +src/index.ts(7,14): error TS2883: The inferred type of 'bar' cannot be named without a reference to 'SomeType' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. ==== node_modules/some-dep/dist/inner.d.ts (0 errors) ==== @@ -18,17 +19,19 @@ src/index.ts(7,14): error TS2742: The inferred type of 'bar' cannot be named wit } } -==== src/index.ts (2 errors) ==== +==== src/index.ts (3 errors) ==== import { SomeType } from "some-dep"; export const foo = (thing: SomeType) => { ~~~ -!!! error TS2742: The inferred type of 'foo' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'foo' cannot be named without a reference to 'SomeType' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. return thing; }; export const bar = (thing: SomeType) => { ~~~ -!!! error TS2742: The inferred type of 'bar' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'bar' cannot be named without a reference to 'Other' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. + ~~~ +!!! error TS2883: The inferred type of 'bar' cannot be named without a reference to 'SomeType' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. return thing.arg; }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitUsingTypeAlias1.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitUsingTypeAlias1.errors.txt.diff new file mode 100644 index 00000000000..02a28b79f03 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitUsingTypeAlias1.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.declarationEmitUsingTypeAlias1.errors.txt ++++ new.declarationEmitUsingTypeAlias1.errors.txt +@@= skipped -0, +0 lines =@@ +-src/index.ts(3,14): error TS2742: The inferred type of 'foo' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. +-src/index.ts(7,14): error TS2742: The inferred type of 'bar' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. ++src/index.ts(3,14): error TS2883: The inferred type of 'foo' cannot be named without a reference to 'SomeType' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. ++src/index.ts(7,14): error TS2883: The inferred type of 'bar' cannot be named without a reference to 'Other' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. ++src/index.ts(7,14): error TS2883: The inferred type of 'bar' cannot be named without a reference to 'SomeType' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. + + + ==== node_modules/some-dep/dist/inner.d.ts (0 errors) ==== +@@= skipped -17, +18 lines =@@ + } + } + +-==== src/index.ts (2 errors) ==== ++==== src/index.ts (3 errors) ==== + import { SomeType } from "some-dep"; + + export const foo = (thing: SomeType) => { + ~~~ +-!!! error TS2742: The inferred type of 'foo' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'foo' cannot be named without a reference to 'SomeType' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. + return thing; + }; + + export const bar = (thing: SomeType) => { + ~~~ +-!!! error TS2742: The inferred type of 'bar' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'bar' cannot be named without a reference to 'Other' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. ++ ~~~ ++!!! error TS2883: The inferred type of 'bar' cannot be named without a reference to 'SomeType' from '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary. + return thing.arg; + }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt b/testdata/baselines/reference/submodule/conformance/legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt index 6d03f776076..71a7854c008 100644 --- a/testdata/baselines/reference/submodule/conformance/legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt @@ -1,10 +1,10 @@ -index.ts(1,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/private'. This is likely not portable. A type annotation is necessary. +index.ts(1,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/private'. This is likely not portable. A type annotation is necessary. ==== index.ts (1 errors) ==== export const a = async () => (await import("inner")).x(); ~ -!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/private'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/private'. This is likely not portable. A type annotation is necessary. ==== node_modules/inner/index.d.ts (0 errors) ==== export { x } from "./other.js"; ==== node_modules/inner/other.d.ts (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt.diff new file mode 100644 index 00000000000..b1a07113a51 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt.diff @@ -0,0 +1,15 @@ +--- old.legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt ++++ new.legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt +@@= skipped -0, +0 lines =@@ +-index.ts(1,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/private'. This is likely not portable. A type annotation is necessary. ++index.ts(1,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/private'. This is likely not portable. A type annotation is necessary. + + + ==== index.ts (1 errors) ==== + export const a = async () => (await import("inner")).x(); + ~ +-!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/private'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/private'. This is likely not portable. A type annotation is necessary. + ==== node_modules/inner/index.d.ts (0 errors) ==== + export { x } from "./other.js"; + ==== node_modules/inner/other.d.ts (0 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt index 7e86097227b..5f2b9b88ecf 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt @@ -1,5 +1,5 @@ index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== index.ts (2 errors) ==== @@ -9,7 +9,7 @@ index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner")).x(); ~ -!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== node_modules/inner/index.d.ts (0 errors) ==== // esm format file export { x } from "./other.js"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt.diff new file mode 100644 index 00000000000..30379528937 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt.diff @@ -0,0 +1,18 @@ +--- old.nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt ++++ new.nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt +@@= skipped -0, +0 lines =@@ + index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. +-index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + + + ==== index.ts (2 errors) ==== +@@= skipped -8, +8 lines =@@ + !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner")).x(); + ~ +-!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + ==== node_modules/inner/index.d.ts (0 errors) ==== + // esm format file + export { x } from "./other.js"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt index 7e86097227b..5f2b9b88ecf 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt @@ -1,5 +1,5 @@ index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== index.ts (2 errors) ==== @@ -9,7 +9,7 @@ index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner")).x(); ~ -!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== node_modules/inner/index.d.ts (0 errors) ==== // esm format file export { x } from "./other.js"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt.diff new file mode 100644 index 00000000000..163f0158ada --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt.diff @@ -0,0 +1,18 @@ +--- old.nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt ++++ new.nodeModulesExportsBlocksSpecifierResolution(module=node18).errors.txt +@@= skipped -0, +0 lines =@@ + index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. +-index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + + + ==== index.ts (2 errors) ==== +@@= skipped -8, +8 lines =@@ + !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner")).x(); + ~ +-!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + ==== node_modules/inner/index.d.ts (0 errors) ==== + // esm format file + export { x } from "./other.js"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt index 7e86097227b..5f2b9b88ecf 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt @@ -1,5 +1,5 @@ index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== index.ts (2 errors) ==== @@ -9,7 +9,7 @@ index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner")).x(); ~ -!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== node_modules/inner/index.d.ts (0 errors) ==== // esm format file export { x } from "./other.js"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt.diff new file mode 100644 index 00000000000..882146a961b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt.diff @@ -0,0 +1,18 @@ +--- old.nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt ++++ new.nodeModulesExportsBlocksSpecifierResolution(module=node20).errors.txt +@@= skipped -0, +0 lines =@@ + index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. +-index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + + + ==== index.ts (2 errors) ==== +@@= skipped -8, +8 lines =@@ + !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner")).x(); + ~ +-!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + ==== node_modules/inner/index.d.ts (0 errors) ==== + // esm format file + export { x } from "./other.js"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt index 7e86097227b..5f2b9b88ecf 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt @@ -1,5 +1,5 @@ index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== index.ts (2 errors) ==== @@ -9,7 +9,7 @@ index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner")).x(); ~ -!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== node_modules/inner/index.d.ts (0 errors) ==== // esm format file export { x } from "./other.js"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt.diff new file mode 100644 index 00000000000..c0b00da2d82 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt.diff @@ -0,0 +1,18 @@ +--- old.nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt ++++ new.nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt +@@= skipped -0, +0 lines =@@ + index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. +-index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + + + ==== index.ts (2 errors) ==== +@@= skipped -8, +8 lines =@@ + !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner")).x(); + ~ +-!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + ==== node_modules/inner/index.d.ts (0 errors) ==== + // esm format file + export { x } from "./other.js"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node16).errors.txt index 358a0e61437..d62434e7004 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node16).errors.txt @@ -1,5 +1,5 @@ index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== index.ts (2 errors) ==== @@ -9,7 +9,7 @@ index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner")).x(); ~ -!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. import {a as a2} from "package"; ==== node_modules/inner/index.ts (0 errors) ==== // esm format file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node16).errors.txt.diff new file mode 100644 index 00000000000..cf8fa003c50 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node16).errors.txt.diff @@ -0,0 +1,18 @@ +--- old.nodeModulesExportsSourceTs(module=node16).errors.txt ++++ new.nodeModulesExportsSourceTs(module=node16).errors.txt +@@= skipped -0, +0 lines =@@ + index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. +-index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + + + ==== index.ts (2 errors) ==== +@@= skipped -8, +8 lines =@@ + !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner")).x(); + ~ +-!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + import {a as a2} from "package"; + ==== node_modules/inner/index.ts (0 errors) ==== + // esm format file \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node18).errors.txt index 358a0e61437..d62434e7004 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node18).errors.txt @@ -1,5 +1,5 @@ index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== index.ts (2 errors) ==== @@ -9,7 +9,7 @@ index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner")).x(); ~ -!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. import {a as a2} from "package"; ==== node_modules/inner/index.ts (0 errors) ==== // esm format file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node18).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node18).errors.txt.diff new file mode 100644 index 00000000000..65b9c29024d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node18).errors.txt.diff @@ -0,0 +1,18 @@ +--- old.nodeModulesExportsSourceTs(module=node18).errors.txt ++++ new.nodeModulesExportsSourceTs(module=node18).errors.txt +@@= skipped -0, +0 lines =@@ + index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. +-index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + + + ==== index.ts (2 errors) ==== +@@= skipped -8, +8 lines =@@ + !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner")).x(); + ~ +-!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + import {a as a2} from "package"; + ==== node_modules/inner/index.ts (0 errors) ==== + // esm format file \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node20).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node20).errors.txt index 358a0e61437..d62434e7004 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node20).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node20).errors.txt @@ -1,5 +1,5 @@ index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== index.ts (2 errors) ==== @@ -9,7 +9,7 @@ index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner")).x(); ~ -!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. import {a as a2} from "package"; ==== node_modules/inner/index.ts (0 errors) ==== // esm format file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node20).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node20).errors.txt.diff new file mode 100644 index 00000000000..31f30ee85af --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=node20).errors.txt.diff @@ -0,0 +1,18 @@ +--- old.nodeModulesExportsSourceTs(module=node20).errors.txt ++++ new.nodeModulesExportsSourceTs(module=node20).errors.txt +@@= skipped -0, +0 lines =@@ + index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. +-index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + + + ==== index.ts (2 errors) ==== +@@= skipped -8, +8 lines =@@ + !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner")).x(); + ~ +-!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + import {a as a2} from "package"; + ==== node_modules/inner/index.ts (0 errors) ==== + // esm format file \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=nodenext).errors.txt index 358a0e61437..d62434e7004 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=nodenext).errors.txt @@ -1,5 +1,5 @@ index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ==== index.ts (2 errors) ==== @@ -9,7 +9,7 @@ index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner")).x(); ~ -!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. import {a as a2} from "package"; ==== node_modules/inner/index.ts (0 errors) ==== // esm format file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=nodenext).errors.txt.diff new file mode 100644 index 00000000000..d81377b04bf --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesExportsSourceTs(module=nodenext).errors.txt.diff @@ -0,0 +1,18 @@ +--- old.nodeModulesExportsSourceTs(module=nodenext).errors.txt ++++ new.nodeModulesExportsSourceTs(module=nodenext).errors.txt +@@= skipped -0, +0 lines =@@ + index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. +-index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++index.ts(3,14): error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + + + ==== index.ts (2 errors) ==== +@@= skipped -8, +8 lines =@@ + !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner")).x(); + ~ +-!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ++!!! error TS2883: The inferred type of 'a' cannot be named without a reference to 'Thing' from './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + import {a as a2} from "package"; + ==== node_modules/inner/index.ts (0 errors) ==== + // esm format file \ No newline at end of file From 1deae0618c25087973181bc44a0aced54eb9484e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 19:55:41 +0000 Subject: [PATCH 3/5] Accept tsc declaration emit baseline change for symlink test Co-authored-by: gabritto <19519347+gabritto@users.noreply.github.com> --- ...n-pkg-references-sibling-package-through-indirect-symlink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js b/testdata/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js index c0b1926068f..d88fd06b7b4 100644 --- a/testdata/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js +++ b/testdata/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js @@ -58,7 +58,7 @@ export const ADMIN = MetadataAccessor.create('1'); tsgo -p pkg3 --explainFiles ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: -pkg3/src/keys.ts:2:14 - error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. +pkg3/src/keys.ts:2:14 - error TS2883: The inferred type of 'ADMIN' cannot be named without a reference to 'IdType' from '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. 2 export const ADMIN = MetadataAccessor.create('1');    ~~~~~ From c265e6d921e72b49a2a86a380e8a057854f7c311 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:43:15 +0000 Subject: [PATCH 4/5] Add nil guard for symbol in ReportLikelyUnsafeImportRequiredError call Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/checker/nodebuilderimpl.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/checker/nodebuilderimpl.go b/internal/checker/nodebuilderimpl.go index 10f8a7336a3..db5e1e690c9 100644 --- a/internal/checker/nodebuilderimpl.go +++ b/internal/checker/nodebuilderimpl.go @@ -578,7 +578,11 @@ func (b *NodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFl // If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error // since declaration files with these kinds of references are liable to fail when published :( b.ctx.encounteredError = true - b.ctx.tracker.ReportLikelyUnsafeImportRequiredError(oldSpecifier, symbol.Name) + symbolName := "" + if symbol != nil { + symbolName = symbol.Name + } + b.ctx.tracker.ReportLikelyUnsafeImportRequiredError(oldSpecifier, symbolName) } } From 72af2d6ec6c13fd1b47baaf36eaf06be35ee4853 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:39:15 +0000 Subject: [PATCH 5/5] Remove unnecessary nil guard for symbol in ReportLikelyUnsafeImportRequiredError call Co-authored-by: gabritto <19519347+gabritto@users.noreply.github.com> --- internal/checker/nodebuilderimpl.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/internal/checker/nodebuilderimpl.go b/internal/checker/nodebuilderimpl.go index db5e1e690c9..10f8a7336a3 100644 --- a/internal/checker/nodebuilderimpl.go +++ b/internal/checker/nodebuilderimpl.go @@ -578,11 +578,7 @@ func (b *NodeBuilderImpl) symbolToTypeNode(symbol *ast.Symbol, mask ast.SymbolFl // If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error // since declaration files with these kinds of references are liable to fail when published :( b.ctx.encounteredError = true - symbolName := "" - if symbol != nil { - symbolName = symbol.Name - } - b.ctx.tracker.ReportLikelyUnsafeImportRequiredError(oldSpecifier, symbolName) + b.ctx.tracker.ReportLikelyUnsafeImportRequiredError(oldSpecifier, symbol.Name) } }