-
Notifications
You must be signed in to change notification settings - Fork 12.9k
feat: adjust TS2691 message for .ts import sources #42184
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
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
Prev
Previous commit
Added tests for TS2691
- Loading branch information
commit f34e5e49c8a04da8b32f678f6e23b663ae8943f8
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/moduleResolutionNoTsCJS.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,33 @@ | ||
tests/cases/compiler/user.ts(1,15): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './x' instead. | ||
tests/cases/compiler/user.ts(2,15): error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './y' instead. | ||
tests/cases/compiler/user.ts(3,15): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './z' instead. | ||
|
||
|
||
==== tests/cases/compiler/x.ts (0 errors) ==== | ||
// CommonJS output | ||
|
||
export default 0; | ||
|
||
==== tests/cases/compiler/y.tsx (0 errors) ==== | ||
export default 0; | ||
|
||
==== tests/cases/compiler/z.d.ts (0 errors) ==== | ||
declare const x: number; | ||
export default x; | ||
|
||
==== tests/cases/compiler/user.ts (3 errors) ==== | ||
import x from "./x.ts"; | ||
~~~~~~~~ | ||
!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './x' instead. | ||
import y from "./y.tsx"; | ||
~~~~~~~~~ | ||
!!! error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './y' instead. | ||
import z from "./z.d.ts"; | ||
~~~~~~~~~~ | ||
!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './z' instead. | ||
|
||
// Making sure the suggested fixes are valid: | ||
import x2 from "./x"; | ||
import y2 from "./y"; | ||
import z2 from "./z"; | ||
|
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,37 @@ | ||
//// [tests/cases/compiler/moduleResolutionNoTsCJS.ts] //// | ||
|
||
//// [x.ts] | ||
// CommonJS output | ||
|
||
export default 0; | ||
|
||
//// [y.tsx] | ||
export default 0; | ||
|
||
//// [z.d.ts] | ||
declare const x: number; | ||
export default x; | ||
|
||
//// [user.ts] | ||
import x from "./x.ts"; | ||
import y from "./y.tsx"; | ||
import z from "./z.d.ts"; | ||
|
||
// Making sure the suggested fixes are valid: | ||
import x2 from "./x"; | ||
import y2 from "./y"; | ||
import z2 from "./z"; | ||
|
||
|
||
//// [x.js] | ||
"use strict"; | ||
// CommonJS output | ||
exports.__esModule = true; | ||
exports["default"] = 0; | ||
//// [y.jsx] | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports["default"] = 0; | ||
//// [user.js] | ||
"use strict"; | ||
exports.__esModule = true; |
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,35 @@ | ||
=== tests/cases/compiler/x.ts === | ||
// CommonJS output | ||
No type information for this code. | ||
No type information for this code.export default 0; | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/y.tsx === | ||
export default 0; | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/z.d.ts === | ||
declare const x: number; | ||
>x : Symbol(x, Decl(z.d.ts, 0, 13)) | ||
|
||
export default x; | ||
>x : Symbol(x, Decl(z.d.ts, 0, 13)) | ||
|
||
=== tests/cases/compiler/user.ts === | ||
import x from "./x.ts"; | ||
>x : Symbol(x, Decl(user.ts, 0, 6)) | ||
|
||
import y from "./y.tsx"; | ||
>y : Symbol(y, Decl(user.ts, 1, 6)) | ||
|
||
import z from "./z.d.ts"; | ||
>z : Symbol(z, Decl(user.ts, 2, 6)) | ||
|
||
// Making sure the suggested fixes are valid: | ||
import x2 from "./x"; | ||
>x2 : Symbol(x2, Decl(user.ts, 5, 6)) | ||
|
||
import y2 from "./y"; | ||
>y2 : Symbol(y2, Decl(user.ts, 6, 6)) | ||
|
||
import z2 from "./z"; | ||
>z2 : Symbol(z2, Decl(user.ts, 7, 6)) | ||
|
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,35 @@ | ||
=== tests/cases/compiler/x.ts === | ||
// CommonJS output | ||
No type information for this code. | ||
No type information for this code.export default 0; | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/y.tsx === | ||
export default 0; | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/z.d.ts === | ||
declare const x: number; | ||
>x : number | ||
|
||
export default x; | ||
>x : number | ||
|
||
=== tests/cases/compiler/user.ts === | ||
import x from "./x.ts"; | ||
>x : any | ||
|
||
import y from "./y.tsx"; | ||
>y : any | ||
|
||
import z from "./z.d.ts"; | ||
>z : any | ||
|
||
// Making sure the suggested fixes are valid: | ||
import x2 from "./x"; | ||
>x2 : 0 | ||
|
||
import y2 from "./y"; | ||
>y2 : 0 | ||
|
||
import z2 from "./z"; | ||
>z2 : number | ||
|
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/moduleResolutionNoTsESM.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,33 @@ | ||
tests/cases/compiler/user.ts(1,15): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './x.js' instead. | ||
tests/cases/compiler/user.ts(2,15): error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './y.js' instead. | ||
tests/cases/compiler/user.ts(3,15): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './z.js' instead. | ||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggested change for ES module target. |
||
8000 |
|
|
|
||
==== tests/cases/compiler/x.ts (0 errors) ==== | ||
// ESM output | ||
|
||
export default 0; | ||
|
||
==== tests/cases/compiler/y.tsx (0 errors) ==== | ||
export default 0; | ||
|
||
==== tests/cases/compiler/z.d.ts (0 errors) ==== | ||
declare const x: number; | ||
export default x; | ||
|
||
==== tests/cases/compiler/user.ts (3 errors) ==== | ||
import x from "./x.ts"; | ||
~~~~~~~~ | ||
!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './x.js' instead. | ||
import y from "./y.tsx"; | ||
~~~~~~~~~ | ||
!!! error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './y.js' instead. | ||
import z from "./z.d.ts"; | ||
~~~~~~~~~~ | ||
!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './z.js' instead. | ||
|
||
// Making sure the suggested fixes are valid: | ||
import x2 from "./x"; | ||
import y2 from "./y"; | ||
import z2 from "./z"; | ||
|
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,32 @@ | ||
//// [tests/cases/compiler/moduleResolutionNoTsESM.ts] //// | ||
|
||
//// [x.ts] | ||
// ESM output | ||
|
||
export default 0; | ||
|
||
//// [y.tsx] | ||
export default 0; | ||
|
||
//// [z.d.ts] | ||
declare const x: number; | ||
export default x; | ||
|
||
//// [user.ts] | ||
import x from "./x.ts"; | ||
import y from "./y.tsx"; | ||
import z from "./z.d.ts"; | ||
|
||
// Making sure the suggested fixes are valid: | ||
import x2 from "./x"; | ||
import y2 from "./y"; | ||
import z2 from "./z"; | ||
|
||
|
||
//// [x.js] | ||
// ESM output | ||
export default 0; | ||
//// [y.jsx] | ||
export default 0; | ||
//// [user.js] | ||
export {}; |
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,35 @@ | ||
=== tests/cases/compiler/x.ts === | ||
// ESM output | ||
No type information for this code. | ||
No type information for this code.export default 0; | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/y.tsx === | ||
export default 0; | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/z.d.ts === | ||
declare const x: number; | ||
>x : Symbol(x, Decl(z.d.ts, 0, 13)) | ||
|
||
export default x; | ||
>x : Symbol(x, Decl(z.d.ts, 0, 13)) | ||
|
||
=== tests/cases/compiler/user.ts === | ||
import x from "./x.ts"; | ||
>x : Symbol(x, Decl(user.ts, 0, 6)) | ||
|
||
import y from "./y.tsx"; | ||
>y : Symbol(y, Decl(user.ts, 1, 6)) | ||
|
||
import z from "./z.d.ts"; | ||
>z : Symbol(z, Decl(user.ts, 2, 6)) | ||
|
||
// Making sure the suggested fixes are valid: | ||
import x2 from "./x"; | ||
>x2 : Symbol(x2, Decl(user.ts, 5, 6)) | ||
|
||
import y2 from "./y"; | ||
>y2 : Symbol(y2, Decl(user.ts, 6, 6)) | ||
|
||
import z2 from "./z"; | ||
>z2 : Symbol(z2, Decl(user.ts, 7, 6)) | ||
|
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,35 @@ | ||
=== tests/cases/compiler/x.ts === | ||
// ESM output | ||
No type information for this code. | ||
No type information for this code.export default 0; | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/y.tsx === | ||
export default 0; | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/z.d.ts === | ||
declare const x: number; | ||
>x : number | ||
|
||
export default x; | ||
>x : number | ||
|
||
=== tests/cases/compiler/user.ts === | ||
import x from "./x.ts"; | ||
>x : any | ||
|
||
import y from "./y.tsx"; | ||
>y : any | ||
|
||
import z from "./z.d.ts"; | ||
>z : any | ||
|
||
// Making sure the suggested fixes are valid: | ||
import x2 from "./x"; | ||
>x2 : 0 | ||
|
||
import y2 from "./y"; | ||
>y2 : 0 | ||
|
||
import z2 from "./z"; | ||
>z2 : number | ||
|
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,23 @@ | ||
// CommonJS output | ||
// @module: commonjs | ||
|
||
// @jsx: Preserve | ||
// @filename: x.ts | ||
export default 0; | ||
|
||
// @filename: y.tsx | ||
export default 0; | ||
|
||
// @filename: z.d.ts | ||
declare const x: number; | ||
export default x; | ||
|
||
// @filename: user.ts | ||
import x from "./x.ts"; | ||
import y from "./y.tsx"; | ||
import z from "./z.d.ts"; | ||
|
||
// Making sure the suggested fixes are valid: | ||
import x2 from "./x"; | ||
import y2 from "./y"; | ||
import z2 from "./z"; |
3 changes: 3 additions & 0 deletions
3
tests/cases/compiler/moduleResolutionNoTs.ts → ...cases/compiler/moduleResolutionNoTsESM.ts
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// ESM output | ||
// @module: es2015 | ||
|
||
// @jsx: Preserve | ||
// @filename: x.ts | ||
export default 0; | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change for CJS module target.