-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
allowImportingTsExtensions
to be set in any module resolution…
… mode (#52230)
- Loading branch information
1 parent
8094007
commit 436833a
Showing
8 changed files
with
219 additions
and
8 deletions.
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"; |