mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 13:48:46 -05:00
When tsconfig file doesnt contain file names, consume .js files of directory only if specified in the options
This commit is contained in:
@@ -245,6 +245,10 @@ namespace ts {
|
||||
},
|
||||
description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
|
||||
error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic,
|
||||
},
|
||||
{
|
||||
name: "consumeJsFiles",
|
||||
type: "boolean",
|
||||
}
|
||||
];
|
||||
|
||||
@@ -414,8 +418,9 @@ namespace ts {
|
||||
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
|
||||
let errors: Diagnostic[] = [];
|
||||
|
||||
let options = getCompilerOptions();
|
||||
return {
|
||||
options: getCompilerOptions(),
|
||||
options,
|
||||
fileNames: getFileNames(),
|
||||
errors
|
||||
};
|
||||
@@ -474,7 +479,10 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
|
||||
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)).concat(host.readDirectory(basePath, ".js", exclude));
|
||||
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
|
||||
if (options.consumeJsFiles) {
|
||||
sysFiles = sysFiles.concat(host.readDirectory(basePath, ".js", exclude));
|
||||
}
|
||||
for (let i = 0; i < sysFiles.length; i++) {
|
||||
let name = sysFiles[i];
|
||||
if (fileExtensionIs(name, ".js")) {
|
||||
|
||||
@@ -2061,7 +2061,8 @@ namespace ts {
|
||||
experimentalDecorators?: boolean;
|
||||
experimentalAsyncFunctions?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
moduleResolution?: ModuleResolutionKind
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
consumeJsFiles?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
"project": "DifferentNamesNotSpecified",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesNotSpecified/a.ts",
|
||||
"DifferentNamesNotSpecified/b.js"
|
||||
"DifferentNamesNotSpecified/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
"project": "DifferentNamesNotSpecified",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesNotSpecified/a.ts",
|
||||
"DifferentNamesNotSpecified/b.js"
|
||||
"DifferentNamesNotSpecified/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files and consumeJsFiles is true",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesNotSpecifiedWithConsumeJsFiles",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesNotSpecifiedWithConsumeJsFiles/a.ts",
|
||||
"DifferentNamesNotSpecifiedWithConsumeJsFiles/b.js"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
||||
"test.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
declare var test: number;
|
||||
@@ -0,0 +1 @@
|
||||
var test = 10;
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files and consumeJsFiles is true",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesNotSpecifiedWithConsumeJsFiles",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesNotSpecifiedWithConsumeJsFiles/a.ts",
|
||||
"DifferentNamesNotSpecifiedWithConsumeJsFiles/b.js"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
||||
"test.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
declare var test: number;
|
||||
@@ -0,0 +1 @@
|
||||
var test = 10;
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json and consumeJsFiles is true",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameDTsNotSpecifiedWithConsumeJsFiles",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameDTsNotSpecifiedWithConsumeJsFiles/a.d.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json and consumeJsFiles is true",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameDTsNotSpecifiedWithConsumeJsFiles",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameDTsNotSpecifiedWithConsumeJsFiles/a.d.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
declare var test: number;
|
||||
@@ -0,0 +1 @@
|
||||
var test = 10;
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json and consumeJsFiles is true",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameFilesNotSpecifiedWithConsumeJsFiles",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameFilesNotSpecifiedWithConsumeJsFiles/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"SameNameFilesNotSpecifiedWithConsumeJsFiles/a.js",
|
||||
"SameNameFilesNotSpecifiedWithConsumeJsFiles/a.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
declare var test: number;
|
||||
@@ -0,0 +1 @@
|
||||
var test = 10;
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json and consumeJsFiles is true",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameFilesNotSpecifiedWithConsumeJsFiles",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameFilesNotSpecifiedWithConsumeJsFiles/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"SameNameFilesNotSpecifiedWithConsumeJsFiles/a.js",
|
||||
"SameNameFilesNotSpecifiedWithConsumeJsFiles/a.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files and consumeJsFiles is true",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesNotSpecifiedWithConsumeJsFiles"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json and consumeJsFiles is true",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameDTsNotSpecifiedWithConsumeJsFiles"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json and consumeJsFiles is true",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameFilesNotSpecifiedWithConsumeJsFiles"
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
var test2 = 10; // Should get compiled
|
||||
var test2 = 10; // Shouldnt get compiled
|
||||
@@ -0,0 +1 @@
|
||||
var test = 10;
|
||||
@@ -0,0 +1 @@
|
||||
var test2 = 10; // Should get compiled
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"out": "test.js",
|
||||
"consumeJsFiles": true
|
||||
}
|
||||
}
|
||||
1
tests/cases/projects/jsFileCompilation/SameNameDtsNotSpecifiedWithConsumeJsFiles/a.d.ts
vendored
Normal file
1
tests/cases/projects/jsFileCompilation/SameNameDtsNotSpecifiedWithConsumeJsFiles/a.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare var a: number;
|
||||
@@ -0,0 +1 @@
|
||||
var test1 = 10; // Shouldnt get compiled
|
||||
@@ -0,0 +1 @@
|
||||
{ "compilerOptions": { "consumeJsFiles": true } }
|
||||
@@ -0,0 +1 @@
|
||||
var test1 = 10; // Shouldnt get compiled
|
||||
@@ -0,0 +1 @@
|
||||
var test = 10;
|
||||
@@ -0,0 +1 @@
|
||||
{ "compilerOptions": { "consumeJsFiles": true } }
|
||||
Reference in New Issue
Block a user