-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Allow allowImportingTsExtensions
to be set in any module resolution mode
#52230
Merged
andrewbranch
merged 3 commits into
microsoft:main
from
andrewbranch:allowImportingTsExtesions-any-mode
Jan 17, 2023
Merged
Changes from all commits
Commits
Show all changes
3 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 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 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 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 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 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 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
146 changes: 146 additions & 0 deletions
146
...ence/tscWatch/programUpdates/when-changing-`allowImportingTsExtensions`-of-config-file.js
This file contains 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,146 @@ | ||
Input:: | ||
//// [/user/username/projects/myproject/a.ts] | ||
|
||
|
||
//// [/user/username/projects/myproject/b.ts] | ||
import "./a.ts"; | ||
|
||
//// [/user/username/projects/myproject/tsconfig.json] | ||
{"compilerOptions":{"noEmit":true,"allowImportingTsExtensions":false}} | ||
|
||
//// [/a/lib/lib.d.ts] | ||
/// <reference no-default-lib="true"/> | ||
interface Boolean {} | ||
interface Function {} | ||
interface CallableFunction {} | ||
interface NewableFunction {} | ||
interface IArguments {} | ||
interface Number { toExponential: any; } | ||
interface Object {} | ||
interface RegExp {} | ||
interface String { charAt: any; } | ||
interface Array<T> { length: number; [n: number]: T; } | ||
|
||
|
||
/a/lib/tsc.js -w -p . --extendedDiagnostics | ||
Output:: | ||
[[90m12:00:23 AM[0m] Starting compilation in watch mode... | ||
|
||
Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false | ||
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file | ||
Synchronizing program | ||
CreatingProgramWith:: | ||
roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] | ||
options: {"noEmit":true,"allowImportingTsExtensions":false,"watch":true,"project":"/user/username/projects/myproject","extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} | ||
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 undefined Source file | ||
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/b.ts 250 undefined Source file | ||
FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file | ||
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots | ||
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots | ||
[96mb.ts[0m:[93m1[0m:[93m8[0m - [91merror[0m[90m TS5097: [0mAn import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. | ||
|
||
[7m1[0m import "./a.ts"; | ||
[7m [0m [91m ~~~~~~~~[0m | ||
|
||
[[90m12:00:24 AM[0m] Found 1 error. Watching for file changes. | ||
|
||
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory | ||
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory | ||
|
||
|
||
Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] | ||
Program options: {"noEmit":true,"allowImportingTsExtensions":false,"watch":true,"project":"/user/username/projects/myproject","extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} | ||
Program structureReused: Not | ||
Program files:: | ||
/a/lib/lib.d.ts | ||
/user/username/projects/myproject/a.ts | ||
/user/username/projects/myproject/b.ts | ||
|
||
Semantic diagnostics in builder refreshed for:: | ||
/a/lib/lib.d.ts | ||
/user/username/projects/myproject/a.ts | ||
/user/username/projects/myproject/b.ts | ||
|
||
Shape signatures in builder refreshed for:: | ||
/a/lib/lib.d.ts (used version) | ||
/user/username/projects/myproject/a.ts (used version) | ||
/user/username/projects/myproject/b.ts (used version) | ||
|
||
PolledWatches:: | ||
/user/username/projects/myproject/node_modules/@types: | ||
{"pollingInterval":500} | ||
|
||
FsWatches:: | ||
/user/username/projects/myproject/tsconfig.json: | ||
{} | ||
/user/username/projects/myproject/a.ts: | ||
{} | ||
/user/username/projects/myproject/b.ts: | ||
{} | ||
/a/lib/lib.d.ts: | ||
{} | ||
|
||
FsWatchesRecursive:: | ||
/user/username/projects/myproject: | ||
{} | ||
|
||
exitCode:: ExitStatus.undefined | ||
|
||
|
||
Change:: Change allowImportingTsExtensions to true | ||
|
||
Input:: | ||
//// [/user/username/projects/myproject/tsconfig.json] | ||
{"compilerOptions":{"noEmit":true,"allowImportingTsExtensions":true}} | ||
|
||
|
||
Output:: | ||
FileWatcher:: Triggered with /user/username/projects/myproject/tsconfig.json 1:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file | ||
Scheduling update | ||
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/tsconfig.json 1:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file | ||
Reloading config file: /user/username/projects/myproject/tsconfig.json | ||
Synchronizing program | ||
[[90m12:00:28 AM[0m] File change detected. Starting incremental compilation... | ||
|
||
CreatingProgramWith:: | ||
roots: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] | ||
options: {"noEmit":true,"allowImportingTsExtensions":true,"watch":true,"project":"/user/username/projects/myproject","extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} | ||
[[90m12:00:29 AM[0m] Found 0 errors. Watching for file changes. | ||
|
||
|
||
|
||
Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] | ||
Program options: {"noEmit":true,"allowImportingTsExtensions":true,"watch":true,"project":"/user/username/projects/myproject","extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} | ||
Program structureReused: Completely | ||
Program files:: | ||
/a/lib/lib.d.ts | ||
/user/username/projects/myproject/a.ts | ||
/user/username/projects/myproject/b.ts | ||
|
||
Semantic diagnostics in builder refreshed for:: | ||
/a/lib/lib.d.ts | ||
/user/username/projects/myproject/a.ts | ||
/user/username/projects/myproject/b.ts | ||
|
||
No shapes updated in the builder:: | ||
|
||
PolledWatches:: | ||
/user/username/projects/myproject/node_modules/@types: | ||
{"pollingInterval":500} | ||
|
||
FsWatches:: | ||
/user/username/projects/myproject/tsconfig.json: | ||
{} | ||
/user/username/projects/myproject/a.ts: | ||
{} | ||
/user/username/projects/myproject/b.ts: | ||
{} | ||
/a/lib/lib.d.ts: | ||
{} | ||
|
||
FsWatchesRecursive:: | ||
/user/username/projects/myproject: | ||
{} | ||
|
||
exitCode:: ExitStatus.undefined | ||
|
29 changes: 29 additions & 0 deletions
29
tests/cases/conformance/moduleResolution/allowImportingTsExtensions.ts
This file contains 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,29 @@ | ||
// @allowImportingTsExtensions: true | ||
// @noEmit: true | ||
// @moduleResolution: classic,node10,node16,nodenext,bundler | ||
// @jsx: preserve | ||
// @noTypesAndSymbols: true | ||
|
||
// @Filename: /ts.ts | ||
export {}; | ||
|
||
// @Filename: /tsx.tsx | ||
export {}; | ||
|
||
// @Filename: /dts.d.ts | ||
export {}; | ||
|
||
// @Filename: /b.ts | ||
import {} from "./ts.js"; | ||
import {} from "./ts.ts"; | ||
import type {} from "./ts.d.ts"; | ||
|
||
import {} from "./tsx.js"; | ||
import {} from "./tsx.jsx"; | ||
import {} from "./tsx.ts"; | ||
import {} from "./tsx.tsx"; | ||
import type {} from "./tsx.d.ts"; | ||
|
||
import {} from "./dts.js"; | ||
import {} from "./dts.ts"; | ||
import type {} from "./dts.d.ts"; |
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.
This was a mistake—the option has very intentionally never affected how module resolution works, only whether an error is raised. I’m not sure whether it caused the issue we observed during the bug bash, but I added a unit test that shows the error disappearing when updating this option.