From bc2d21d99dec18b7edd18f1624fc52c637a92432 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 19:03:29 +0000 Subject: [PATCH 1/2] Initial plan From 0e3fbddb70b6b8673f54b46e75716f9df3ab33d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Feb 2026 19:26:51 +0000 Subject: [PATCH 2/2] Port TS PR #63200: Add symbol name to TS2742 error message (new TS2883) - Add new TS2883 diagnostic with symbol name in error message - Keep TS2742 unchanged for backward compatibility - Update SymbolTracker interface to pass symbolName parameter - Update all implementations (symboltracker.go, nodebuilderimpl.go, tracker.go) - Add declarationEmitUnsafeImportSymbolName test case - Accept updated baselines Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@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 +++-- ...ationEmitUnsafeImportSymbolName.errors.txt | 16 +++++++++ .../declarationEmitUnsafeImportSymbolName.js | 24 +++++++++++++ ...larationEmitUnsafeImportSymbolName.symbols | 25 ++++++++++++++ ...eclarationEmitUnsafeImportSymbolName.types | 23 +++++++++++++ ...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 ++++++++++ .../declarationEmitUnsafeImportSymbolName.ts | 13 +++++++ 36 files changed, 388 insertions(+), 35 deletions(-) create mode 100644 testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.errors.txt create mode 100644 testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.js create mode 100644 testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.symbols create mode 100644 testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.types 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 create mode 100644 testdata/tests/cases/compiler/declarationEmitUnsafeImportSymbolName.ts 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..c6a3d821b37 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__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__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/compiler/declarationEmitUnsafeImportSymbolName.errors.txt b/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.errors.txt new file mode 100644 index 00000000000..64c559942c6 --- /dev/null +++ b/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.errors.txt @@ -0,0 +1,16 @@ +r/entry.ts(2,14): error TS2883: The inferred type of 'special' cannot be named without a reference to 'MySpecialType' 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) ==== + export interface MySpecialType { + val: string; + } +==== r/node_modules/foo/index.d.ts (0 errors) ==== + import { MySpecialType } from "nested"; + export function getSpecial(): MySpecialType; +==== r/entry.ts (1 errors) ==== + import { getSpecial } from "foo"; + export const special = getSpecial(); + ~~~~~~~ +!!! error TS2883: The inferred type of 'special' cannot be named without a reference to 'MySpecialType' from 'foo/node_modules/nested'. This is likely not portable. A type annotation is necessary. + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.js b/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.js new file mode 100644 index 00000000000..6bc88888a43 --- /dev/null +++ b/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/declarationEmitUnsafeImportSymbolName.ts] //// + +//// [index.d.ts] +export interface MySpecialType { + val: string; +} +//// [index.d.ts] +import { MySpecialType } from "nested"; +export function getSpecial(): MySpecialType; +//// [entry.ts] +import { getSpecial } from "foo"; +export const special = getSpecial(); + + +//// [entry.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.special = void 0; +const foo_1 = require("foo"); +exports.special = (0, foo_1.getSpecial)(); + + +//// [entry.d.ts] +export declare const special: any; diff --git a/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.symbols b/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.symbols new file mode 100644 index 00000000000..ae266c8fedd --- /dev/null +++ b/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/declarationEmitUnsafeImportSymbolName.ts] //// + +=== r/node_modules/foo/node_modules/nested/index.d.ts === +export interface MySpecialType { +>MySpecialType : Symbol(MySpecialType, Decl(index.d.ts, 0, 0)) + + val: string; +>val : Symbol(MySpecialType.val, Decl(index.d.ts, 0, 32)) +} +=== r/node_modules/foo/index.d.ts === +import { MySpecialType } from "nested"; +>MySpecialType : Symbol(MySpecialType, Decl(index.d.ts, 0, 8)) + +export function getSpecial(): MySpecialType; +>getSpecial : Symbol(getSpecial, Decl(index.d.ts, 0, 39)) +>MySpecialType : Symbol(MySpecialType, Decl(index.d.ts, 0, 8)) + +=== r/entry.ts === +import { getSpecial } from "foo"; +>getSpecial : Symbol(getSpecial, Decl(entry.ts, 0, 8)) + +export const special = getSpecial(); +>special : Symbol(special, Decl(entry.ts, 1, 12)) +>getSpecial : Symbol(getSpecial, Decl(entry.ts, 0, 8)) + diff --git a/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.types b/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.types new file mode 100644 index 00000000000..f913b179567 --- /dev/null +++ b/testdata/baselines/reference/compiler/declarationEmitUnsafeImportSymbolName.types @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/declarationEmitUnsafeImportSymbolName.ts] //// + +=== r/node_modules/foo/node_modules/nested/index.d.ts === +export interface MySpecialType { + val: string; +>val : string +} +=== r/node_modules/foo/index.d.ts === +import { MySpecialType } from "nested"; +>MySpecialType : any + +export function getSpecial(): MySpecialType; +>getSpecial : () => MySpecialType + +=== r/entry.ts === +import { getSpecial } from "foo"; +>getSpecial : () => import("foo/node_modules/nested").MySpecialType + +export const special = getSpecial(); +>special : import("foo/node_modules/nested").MySpecialType +>getSpecial() : import("foo/node_modules/nested").MySpecialType +>getSpecial : () => import("foo/node_modules/nested").MySpecialType + 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 diff --git a/testdata/tests/cases/compiler/declarationEmitUnsafeImportSymbolName.ts b/testdata/tests/cases/compiler/declarationEmitUnsafeImportSymbolName.ts new file mode 100644 index 00000000000..0fddc5b43bc --- /dev/null +++ b/testdata/tests/cases/compiler/declarationEmitUnsafeImportSymbolName.ts @@ -0,0 +1,13 @@ +// @module: commonjs +// @target: es2015 +// @declaration: true +// @filename: r/node_modules/foo/node_modules/nested/index.d.ts +export interface MySpecialType { + val: string; +} +// @filename: r/node_modules/foo/index.d.ts +import { MySpecialType } from "nested"; +export function getSpecial(): MySpecialType; +// @filename: r/entry.ts +import { getSpecial } from "foo"; +export const special = getSpecial();