Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
40 changes: 40 additions & 0 deletions src/testRunner/unittests/tscWatch/programUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,46 @@ 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: [aTs.path],
})
};
return createWatchedSystem([libFile, aTs, bCssTs, tsconfig]);
},
edits: [
{
caption: "Disable allowArbitraryExtensions",
edit: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
compilerOptions: { allowArbitraryExtensions: false }
Comment thread
jakebailey marked this conversation as resolved.
Outdated
})),
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1)
},
{
caption: "Enable allowArbitraryExtensions",
edit: sys => sys.modifyFile("/tsconfig.json", JSON.stringify({
compilerOptions: { allowArbitraryExtensions: true }
})),
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
}
]
});

verifyTscWatch({
scenario,
subScenario: "updates diagnostics and emit for decorators",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
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
[12:00:15 AM] Starting compilation in watch mode...

a.ts:1:16 - error TS2306: File '/b.d.css.ts' is not a module.

1 import {} from './b.css'
   ~~~~~~~~~

[12:00:18 AM] 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}}


Output::
>> Screen clear
[12:00:21 AM] File change detected. Starting incremental compilation...

a.ts:1:16 - error TS2306: File '/b.d.css.ts' is not a module.

1 import {} from './b.css'
   ~~~~~~~~~

[12:00:22 AM] Found 1 error. Watching for file changes.



Program root files: ["/a.ts","/b.d.css.ts","/a/lib/lib.d.ts"]
Program options: {"allowArbitraryExtensions":false,"watch":true,"project":"/tsconfig.json","configFilePath":"/tsconfig.json"}
Program structureReused: Not
Program files::
/a.ts
/b.d.css.ts
/a/lib/lib.d.ts

Semantic diagnostics in builder refreshed for::

No shapes updated in the builder::

PolledWatches::

FsWatches::
/tsconfig.json:
{}
/a.ts:
{}
/b.d.css.ts:
{}
/a/lib/lib.d.ts:
{}

FsWatchesRecursive::
/:
{}

exitCode:: ExitStatus.undefined


Change:: Enable allowArbitraryExtensions

Input::
//// [/tsconfig.json]
{"compilerOptions":{"allowArbitraryExtensions":true}}


Output::
>> Screen clear
[12:00:25 AM] File change detected. Starting incremental compilation...

a.ts:1:16 - error TS2306: File '/b.d.css.ts' is not a module.

1 import {} from './b.css'
   ~~~~~~~~~

[12:00:26 AM] Found 1 error. Watching for file changes.



Program root files: ["/a.ts","/b.d.css.ts","/a/lib/lib.d.ts"]
Program options: {"allowArbitraryExtensions":true,"watch":true,"project":"/tsconfig.json","configFilePath":"/tsconfig.json"}
Program structureReused: SafeModules
Program files::
/b.d.css.ts
/a.ts
/a/lib/lib.d.ts

Semantic diagnostics in builder refreshed for::

No shapes updated in the builder::

PolledWatches::

FsWatches::
/tsconfig.json:
{}
/a.ts:
{}
/b.d.css.ts:
{}
/a/lib/lib.d.ts:
{}

FsWatchesRecursive::
/:
{}

exitCode:: ExitStatus.undefined