mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
online and offline CR feedback
This commit is contained in:
parent
35b972e1d8
commit
4aba58c3ea
@ -308,8 +308,7 @@ namespace ts {
|
||||
},
|
||||
{
|
||||
name: "disableSizeLimit",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Disable_the_upper_limit_for_the_total_file_size_of_a_project
|
||||
type: "boolean"
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@ -2458,10 +2458,6 @@
|
||||
"category": "Message",
|
||||
"code": 6112
|
||||
},
|
||||
"Disable the upper limit for the total file size of a project.": {
|
||||
"category": "Message",
|
||||
"code": 6113
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
@ -2666,7 +2662,7 @@
|
||||
"category": "Error",
|
||||
"code": 17010
|
||||
},
|
||||
"Too many JavaScript files in the project. Use an exact 'files' list, or use the 'exclude' setting in project configuration to limit included source folders. The likely folder to exclude is '{0}'. To disable the project size limit, set the 'disableSizeLimit' compiler option to 'true'": {
|
||||
"Too many JavaScript files in the project. Consider specifying the 'exclude' setting in project configuration to limit included source folders. The likely folder to exclude is '{0}'. To disable the project size limit, set the 'disableSizeLimit' compiler option to 'true'.": {
|
||||
"category": "Error",
|
||||
"code": 17012
|
||||
}
|
||||
|
||||
@ -348,6 +348,7 @@ namespace ts {
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
let classifiableNames: Map<string>;
|
||||
let programSizeForNonTsFiles = 0;
|
||||
|
||||
let skipDefaultLib = options.noLib;
|
||||
const supportedExtensions = getSupportedExtensions(options);
|
||||
@ -401,34 +402,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
if (options.disableSizeLimit === true) {
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
|
||||
}
|
||||
else {
|
||||
let programSize = 0;
|
||||
for (const name of rootNames) {
|
||||
const path = toPath(name, currentDirectory, getCanonicalFileName);
|
||||
if (programSize <= maxProgramSize) {
|
||||
processRootFile(name, /*isDefaultLib*/ false);
|
||||
const file = filesByName.get(path);
|
||||
if (!hasTypeScriptFileExtension(name) && file && file.text) {
|
||||
programSize += file.text.length;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If the program size limit was reached when processing a file, this file is
|
||||
// likely in the problematic folder than contains too many files
|
||||
const commonSourceDirectory = getCommonSourceDirectory();
|
||||
let rootLevelDirectory = path.substring(0, Math.max(commonSourceDirectory.length, path.indexOf(directorySeparator, commonSourceDirectory.length)));
|
||||
if (rootLevelDirectory[rootLevelDirectory.length - 1] !== directorySeparator) {
|
||||
rootLevelDirectory += directorySeparator;
|
||||
}
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Too_many_JavaScript_files_in_the_project_Use_an_exact_files_list_or_use_the_exclude_setting_in_project_configuration_to_limit_included_source_folders_The_likely_folder_to_exclude_is_0_To_disable_the_project_size_limit_set_the_disableSizeLimit_compiler_option_to_true, rootLevelDirectory));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
|
||||
// Do not process the default library if:
|
||||
// - The '--noLib' flag is used.
|
||||
// - A 'no-default-lib' reference comment is encountered in
|
||||
@ -1115,6 +1089,27 @@ namespace ts {
|
||||
return file;
|
||||
}
|
||||
|
||||
if (!options.disableSizeLimit) {
|
||||
if (programSizeForNonTsFiles === -1) {
|
||||
return;
|
||||
}
|
||||
if (programSizeForNonTsFiles > maxProgramSizeForNonTsFiles) {
|
||||
// If the program size limit was reached when processing a file, this file is
|
||||
// likely in the problematic folder than contains too many files.
|
||||
// Normally the folder is one level down from the commonSourceDirectory, for example,
|
||||
// if the commonSourceDirectory is "/src/", and the last processed path was "/src/node_modules/a/b.js",
|
||||
// we should show in the error message "/src/node_modules/".
|
||||
const commonSourceDirectory = getCommonSourceDirectory();
|
||||
let rootLevelDirectory = path.substring(0, Math.max(commonSourceDirectory.length, path.indexOf(directorySeparator, commonSourceDirectory.length)));
|
||||
if (rootLevelDirectory[rootLevelDirectory.length - 1] !== directorySeparator) {
|
||||
rootLevelDirectory += directorySeparator;
|
||||
}
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Too_many_JavaScript_files_in_the_project_Consider_specifying_the_exclude_setting_in_project_configuration_to_limit_included_source_folders_The_likely_folder_to_exclude_is_0_To_disable_the_project_size_limit_set_the_disableSizeLimit_compiler_option_to_true, rootLevelDirectory));
|
||||
programSizeForNonTsFiles = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
const file = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
@ -1126,6 +1121,10 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
|
||||
if (!options.disableSizeLimit && file && file.text && !hasTypeScriptFileExtension(file.fileName)) {
|
||||
programSizeForNonTsFiles += file.text.length;
|
||||
}
|
||||
|
||||
filesByName.set(path, file);
|
||||
if (file) {
|
||||
file.path = path;
|
||||
|
||||
@ -2863,5 +2863,5 @@ namespace ts {
|
||||
return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
|
||||
}
|
||||
|
||||
export const maxProgramSize = 20 * 1024 * 1024;
|
||||
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
|
||||
}
|
||||
|
||||
@ -1217,7 +1217,7 @@ namespace ts.server {
|
||||
}
|
||||
else {
|
||||
const project = this.createProject(configFilename, projectOptions);
|
||||
let programSize = 0;
|
||||
let programSizeForNonTsFiles = 0;
|
||||
|
||||
// As the project openning might not be complete if there are too many files,
|
||||
// therefore to surface the diagnostics we need to make sure the given client file is opened.
|
||||
@ -1225,7 +1225,7 @@ namespace ts.server {
|
||||
if (this.host.fileExists(clientFileName)) {
|
||||
const currentClientFileInfo = this.openFile(clientFileName, /*openedByClient*/ true);
|
||||
project.addRoot(currentClientFileInfo);
|
||||
programSize += currentClientFileInfo.content.length;
|
||||
programSizeForNonTsFiles += currentClientFileInfo.content.length;
|
||||
}
|
||||
else {
|
||||
return { errorMsg: "specified file " + clientFileName + " not found" };
|
||||
@ -1238,15 +1238,15 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
if (this.host.fileExists(rootFilename)) {
|
||||
if (projectOptions.compilerOptions.disableSizeLimit === true) {
|
||||
if (projectOptions.compilerOptions.disableSizeLimit) {
|
||||
const info = this.openFile(rootFilename, /*openedByClient*/ false);
|
||||
project.addRoot(info);
|
||||
}
|
||||
else if (programSize <= maxProgramSize) {
|
||||
else if (programSizeForNonTsFiles <= maxProgramSizeForNonTsFiles) {
|
||||
const info = this.openFile(rootFilename, /*openedByClient*/ false);
|
||||
project.addRoot(info);
|
||||
if (!hasTypeScriptFileExtension(rootFilename)) {
|
||||
programSize += info.content.length;
|
||||
programSizeForNonTsFiles += info.content.length;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@ -2759,7 +2759,8 @@ namespace ts {
|
||||
oldSettings.module !== newSettings.module ||
|
||||
oldSettings.noResolve !== newSettings.noResolve ||
|
||||
oldSettings.jsx !== newSettings.jsx ||
|
||||
oldSettings.allowJs !== newSettings.allowJs);
|
||||
oldSettings.allowJs !== newSettings.allowJs ||
|
||||
oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit);
|
||||
|
||||
// Now create a new compiler
|
||||
const compilerHost: CompilerHost = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user