mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-15 08:20:53 -06:00
Mark allowArbitraryExtensions as affectsProgramStructure (#52437)
This commit is contained in:
parent
5e8bf480e4
commit
d63d081e37
@ -1221,7 +1221,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
{
|
||||
name: "allowArbitraryExtensions",
|
||||
type: "boolean",
|
||||
affectsModuleResolution: true,
|
||||
affectsProgramStructure: true,
|
||||
category: Diagnostics.Modules,
|
||||
description: Diagnostics.Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present,
|
||||
defaultValueDescription: false,
|
||||
|
||||
@ -273,6 +273,48 @@ describe("unittests:: tsc-watch:: program updates", () => {
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "Updates diagnostics when '--allowArbitraryExtensions' changes",
|
||||
commandLineArgs: ["-w", "-p", "/tsconfig.json"],
|
||||
sys: () => {
|
||||
const aTs: File = {
|
||||
path: "/a.ts",
|
||||
content: "import {} from './b.css'"
|
||||
};
|
||||
const bCssTs: File = {
|
||||
path: "/b.d.css.ts",
|
||||
content: "declare const style: string;"
|
||||
};
|
||||
const tsconfig: File = {
|
||||
path: "/tsconfig.json",
|
||||
content: JSON.stringify({
|
||||
compilerOptions: { allowArbitraryExtensions: true },
|
||||
files: ["/a.ts"],
|
||||
})
|
||||
};
|
||||
return createWatchedSystem([libFile, aTs, bCssTs, tsconfig]);
|
||||
},
|
||||
edits: [
|
||||
{
|
||||
caption: "Disable allowArbitraryExtensions",
|
||||
edit: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
compilerOptions: { allowArbitraryExtensions: false },
|
||||
files: ["/a.ts"],
|
||||
})),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
|
||||
},
|
||||
{
|
||||
caption: "Enable allowArbitraryExtensions",
|
||||
edit: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
|
||||
compilerOptions: { allowArbitraryExtensions: true },
|
||||
files: ["/a.ts"],
|
||||
})),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "updates diagnostics and emit for decorators",
|
||||
|
||||
@ -0,0 +1,181 @@
|
||||
Input::
|
||||
//// [/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.ts]
|
||||
import {} from './b.css'
|
||||
|
||||
//// [/b.d.css.ts]
|
||||
declare const style: string;
|
||||
|
||||
//// [/tsconfig.json]
|
||||
{"compilerOptions":{"allowArbitraryExtensions":true},"files":["/a.ts"]}
|
||||
|
||||
|
||||
/a/lib/tsc.js -w -p /tsconfig.json
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:15 AM[0m] Starting compilation in watch mode...
|
||||
|
||||
[96ma.ts[0m:[93m1[0m:[93m16[0m - [91merror[0m[90m TS2306: [0mFile '/b.d.css.ts' is not a module.
|
||||
|
||||
[7m1[0m import {} from './b.css'
|
||||
[7m [0m [91m ~~~~~~~~~[0m
|
||||
|
||||
[[90m12:00:18 AM[0m] Found 1 error. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
Program root files: ["/a.ts"]
|
||||
Program options: {"allowArbitraryExtensions":true,"watch":true,"project":"/tsconfig.json","configFilePath":"/tsconfig.json"}
|
||||
Program structureReused: Not
|
||||
Program files::
|
||||
/a/lib/lib.d.ts
|
||||
/b.d.css.ts
|
||||
/a.ts
|
||||
|
||||
Semantic diagnostics in builder refreshed for::
|
||||
/a/lib/lib.d.ts
|
||||
/b.d.css.ts
|
||||
/a.ts
|
||||
|
||||
Shape signatures in builder refreshed for::
|
||||
/a/lib/lib.d.ts (used version)
|
||||
/b.d.css.ts (used version)
|
||||
/a.ts (used version)
|
||||
|
||||
PolledWatches::
|
||||
|
||||
FsWatches::
|
||||
/tsconfig.json:
|
||||
{}
|
||||
/a.ts:
|
||||
{}
|
||||
/b.d.css.ts:
|
||||
{}
|
||||
/a/lib/lib.d.ts:
|
||||
{}
|
||||
|
||||
FsWatchesRecursive::
|
||||
|
||||
exitCode:: ExitStatus.undefined
|
||||
|
||||
//// [/a.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
|
||||
|
||||
|
||||
Change:: Disable allowArbitraryExtensions
|
||||
|
||||
Input::
|
||||
//// [/tsconfig.json]
|
||||
{"compilerOptions":{"allowArbitraryExtensions":false},"files":["/a.ts"]}
|
||||
|
||||
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:21 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
[96ma.ts[0m:[93m1[0m:[93m16[0m - [91merror[0m[90m TS6263: [0mModule './b.css' was resolved to '/b.d.css.ts', but '--allowArbitraryExtensions' is not set.
|
||||
|
||||
[7m1[0m import {} from './b.css'
|
||||
[7m [0m [91m ~~~~~~~~~[0m
|
||||
|
||||
[[90m12:00:25 AM[0m] Found 1 error. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
Program root files: ["/a.ts"]
|
||||
Program options: {"allowArbitraryExtensions":false,"watch":true,"project":"/tsconfig.json","configFilePath":"/tsconfig.json"}
|
||||
Program structureReused: SafeModules
|
||||
Program files::
|
||||
/a/lib/lib.d.ts
|
||||
/a.ts
|
||||
|
||||
Semantic diagnostics in builder refreshed for::
|
||||
/a.ts
|
||||
|
||||
Shape signatures in builder refreshed for::
|
||||
/a.ts (computed .d.ts)
|
||||
|
||||
PolledWatches::
|
||||
|
||||
FsWatches::
|
||||
/tsconfig.json:
|
||||
{}
|
||||
/a.ts:
|
||||
{}
|
||||
/a/lib/lib.d.ts:
|
||||
{}
|
||||
|
||||
FsWatchesRecursive::
|
||||
|
||||
exitCode:: ExitStatus.undefined
|
||||
|
||||
//// [/a.js] file written with same contents
|
||||
|
||||
Change:: Enable allowArbitraryExtensions
|
||||
|
||||
Input::
|
||||
//// [/tsconfig.json]
|
||||
{"compilerOptions":{"allowArbitraryExtensions":true},"files":["/a.ts"]}
|
||||
|
||||
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:28 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
[96ma.ts[0m:[93m1[0m:[93m16[0m - [91merror[0m[90m TS2306: [0mFile '/b.d.css.ts' is not a module.
|
||||
|
||||
[7m1[0m import {} from './b.css'
|
||||
[7m [0m [91m ~~~~~~~~~[0m
|
||||
|
||||
[[90m12:00:32 AM[0m] Found 1 error. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
Program root files: ["/a.ts"]
|
||||
Program options: {"allowArbitraryExtensions":true,"watch":true,"project":"/tsconfig.json","configFilePath":"/tsconfig.json"}
|
||||
Program structureReused: SafeModules
|
||||
Program files::
|
||||
/a/lib/lib.d.ts
|
||||
/b.d.css.ts
|
||||
/a.ts
|
||||
|
||||
Semantic diagnostics in builder refreshed for::
|
||||
/a/lib/lib.d.ts
|
||||
/b.d.css.ts
|
||||
/a.ts
|
||||
|
||||
Shape signatures in builder refreshed for::
|
||||
/b.d.css.ts (used version)
|
||||
/a.ts (computed .d.ts)
|
||||
|
||||
PolledWatches::
|
||||
|
||||
FsWatches::
|
||||
/tsconfig.json:
|
||||
{}
|
||||
/a.ts:
|
||||
{}
|
||||
/a/lib/lib.d.ts:
|
||||
{}
|
||||
/b.d.css.ts:
|
||||
{}
|
||||
|
||||
FsWatchesRecursive::
|
||||
|
||||
exitCode:: ExitStatus.undefined
|
||||
|
||||
//// [/a.js] file written with same contents
|
||||
Loading…
x
Reference in New Issue
Block a user