-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Don't allow .ts
to appear in an import
#9646
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
448a480
Don't allow `.ts` to appear in an import
a8c05a9
Add specific error message for unwanted '.ts' extension
2821d98
Merge branch 'master' into no_ts_extension
0f134ed
Improve error message
359c8b1
Don't allow ".d.ts" extension in an import either.
3de8c22
Merge branch 'master' into no_ts_extension
2eb159e
Rename 'find' functions
8fc17af
Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeS…
297cb50
Merge branch 'master' into no_ts_extension
b452469
Fix tests
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
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
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,31 @@ | ||
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) ==== | ||
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,33 @@ | ||
//// [tests/cases/compiler/moduleResolutionNoTs.ts] //// | ||
|
||
//// [x.ts] | ||
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"; | ||
exports.__esModule = true; | ||
exports["default"] = 0; | ||
//// [y.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports["default"] = 0; | ||
//// [user.js] | ||
"use strict"; |
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.
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.
do we know that
candidate
is extensionless already?tryAddingExtensions
looks like it blindly addsext
to the end ofcandidate
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.
That's right, so if someone imports "foo.bar" they can get "foo.bar.ts".