-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Compilation of Js Files #5471
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
Compilation of Js Files #5471
Changes from 103 commits
0a67ac3
74a3f67
279018d
e9688dd
fad0db2
d3dfd2a
1dc3414
63de162
57e17d2
7e30827
2252354
3107bbb
885babc
60f295f
8da3bd2
8aeff92
bc48c7c
9daf635
70d3de4
0f73c16
dbb2772
14b6082
2860435
68c65cd
fce9f32
e32c920
60e15b2
400b353
c30104e
1df341b
7f09c81
607564f
e044d3e
0fe282e
ce652dc
460c597
108f856
b3e4f8e
db9faf6
938c533
567d71c
756052a
b580c55
17fca98
242eb8b
f7b7204
2d083f7
2c3c321
5e14edb
a87dae1
6882035
f28fbfd
286fb3e
b38a81b
d4d6e48
9f96f47
11b270f
8176354
5aa7086
1ae1464
acf7de7
0496bfe
6804087
3215438
d14934e
c26d2da
93cc1e5
ff933be
bf05ea3
8f03d00
57362f6
ba3d34f
382b86b
ea57efa
a8eb76f
45b995d
2d3a345
0c3c7f1
fdb7a3e
38ebb1d
b217b8b
94a647b
daba901
6ea74ae
67bed26
4d3457c
9f337bc
a0318c7
c6d54d6
06bf08c
2b582a0
62d4fd6
51caf1a
def7b66
4c84259
d2445b6
1ed67f4
0b21540
3bdad8a
fc07763
0482afd
1ee5022
073b69a
5ac6eb2
a19307d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,6 +279,11 @@ namespace ts { | |
name: "forceConsistentCasingInFileNames", | ||
type: "boolean", | ||
description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file | ||
}, | ||
{ | ||
name: "allowJs", | ||
type: "boolean", | ||
description: Diagnostics.Allow_javascript_files_to_be_compiled, | ||
} | ||
]; | ||
|
||
|
@@ -474,15 +479,16 @@ namespace ts { | |
* @param basePath A root directory to resolve relative path entries in the config | ||
* file to. e.g. outDir | ||
*/ | ||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine { | ||
const { options, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath); | ||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}): ParsedCommandLine { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we passing the existing options here? previously the caller has to call extend on them, so why is the change in the API? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. plus one to the question |
||
const { options: optionsFromJsonConfigFile, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath); | ||
|
||
const options = extend(existingOptions, optionsFromJsonConfigFile); | ||
return { | ||
options, | ||
fileNames: getFileNames(), | ||
errors | ||
}; | ||
|
||
function getFileNames(): string[] { | ||
let fileNames: string[] = []; | ||
if (hasProperty(json, "files")) { | ||
|
@@ -494,23 +500,32 @@ namespace ts { | |
} | ||
} | ||
else { | ||
const filesSeen: Map<boolean> = {}; | ||
const exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined; | ||
const sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); | ||
for (let i = 0; i < sysFiles.length; i++) { | ||
const name = sysFiles[i]; | ||
if (fileExtensionIs(name, ".d.ts")) { | ||
const baseName = name.substr(0, name.length - ".d.ts".length); | ||
if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) { | ||
fileNames.push(name); | ||
const supportedExtensions = getSupportedExtensions(options); | ||
Debug.assert(indexOf(supportedExtensions, ".ts") < indexOf(supportedExtensions, ".d.ts"), "Changed priority of extensions to pick"); | ||
|
||
// Get files of supported extensions in their order of resolution | ||
for (const extension of supportedExtensions) { | ||
const filesInDirWithExtension = host.readDirectory(basePath, extension, exclude); | ||
for (const fileName of filesInDirWithExtension) { | ||
// .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension, | ||
// lets pick them when its turn comes up | ||
if (extension === ".ts" && fileExtensionIs(fileName, ".d.ts")) { | ||
continue; | ||
} | ||
} | ||
else if (fileExtensionIs(name, ".ts")) { | ||
if (!contains(sysFiles, name + "x")) { | ||
fileNames.push(name); | ||
|
||
// If this is one of the output extension (which would be .d.ts and .js if we are allowing compilation of js files) | ||
// do not include this file if we included .ts or .tsx file with same base name as it could be output of the earlier compilation | ||
if (extension === ".d.ts" || (options.allowJs && contains(supportedJavascriptExtensions, extension))) { | ||
const baseName = fileName.substr(0, fileName.length - extension.length); | ||
if (hasProperty(filesSeen, baseName + ".ts") || hasProperty(filesSeen, baseName + ".tsx")) { | ||
continue; | ||
} | ||
} | ||
} | ||
else { | ||
fileNames.push(name); | ||
|
||
filesSeen[fileName] = true; | ||
fileNames.push(fileName); | ||
} | ||
} | ||
} | ||
|
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.
can you please add a comment
symbol
instead oflocalSymbol
?