-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Adds the symbol name to the error message for TS2742 #63200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/declarationEmitUnsafeImportSymbolName.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| r/entry.ts(2,14): error TS2742: 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 TS2742: 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. | ||
|
|
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/declarationEmitUnsafeImportSymbolName.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //// [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)(); |
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/declarationEmitUnsafeImportSymbolName.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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)) | ||
|
|
30 changes: 30 additions & 0 deletions
30
tests/baselines/reference/declarationEmitUnsafeImportSymbolName.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| //// [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 | ||
| > : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
tests/baselines/reference/legacyNodeModulesExportsSpecifierGenerationConditions.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.