mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Unify error message for custom-type compiler option
This commit is contained in:
parent
4d915e59d9
commit
92bee6a533
@ -58,7 +58,6 @@ namespace ts {
|
||||
},
|
||||
paramType: Diagnostics.KIND,
|
||||
description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react,
|
||||
error: Diagnostics.Argument_for_jsx_must_be_preserve_or_react
|
||||
},
|
||||
{
|
||||
name: "reactNamespace",
|
||||
@ -94,7 +93,6 @@ namespace ts {
|
||||
},
|
||||
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
|
||||
paramType: Diagnostics.KIND,
|
||||
error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none
|
||||
},
|
||||
{
|
||||
name: "newLine",
|
||||
@ -104,7 +102,6 @@ namespace ts {
|
||||
},
|
||||
description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
|
||||
paramType: Diagnostics.NEWLINE,
|
||||
error: Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF
|
||||
},
|
||||
{
|
||||
name: "noEmit",
|
||||
@ -233,7 +230,6 @@ namespace ts {
|
||||
},
|
||||
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
|
||||
paramType: Diagnostics.VERSION,
|
||||
error: Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES2015
|
||||
},
|
||||
{
|
||||
name: "version",
|
||||
@ -265,7 +261,6 @@ namespace ts {
|
||||
"classic": ModuleResolutionKind.Classic,
|
||||
},
|
||||
description: Diagnostics.Specify_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: "lib",
|
||||
@ -297,7 +292,6 @@ namespace ts {
|
||||
"es6.symbol.wellknown": "lib.es6.symbol.wellknown.d.ts",
|
||||
"es7.array.include": "lib.es7.array.include.d.ts"
|
||||
},
|
||||
error: Diagnostics.Arguments_for_library_option_must_be_Colon_0,
|
||||
},
|
||||
description: Diagnostics.Specify_library_to_be_included_in_the_compilation_Colon,
|
||||
},
|
||||
@ -423,25 +417,15 @@ namespace ts {
|
||||
return optionNameMapCache;
|
||||
}
|
||||
|
||||
// Cache between the name of commandline which is a custom type and a list of all possible custom types
|
||||
const namesOfCustomTypeMapCache: Map<string[]> = {};
|
||||
|
||||
/* @internal */
|
||||
export function getNamesOfCustomTypeFromCommandLineOptionsOfCustomType(opt: CommandLineOptionOfCustomType): string[] {
|
||||
if (hasProperty(namesOfCustomTypeMapCache, opt.name)) {
|
||||
return namesOfCustomTypeMapCache[opt.name];
|
||||
}
|
||||
export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic {
|
||||
|
||||
const type = opt.type;
|
||||
const namesOfType: string[] = [];
|
||||
for (const typeName in type) {
|
||||
if (hasProperty(type, typeName)) {
|
||||
namesOfType.push(typeName);
|
||||
}
|
||||
}
|
||||
ts.forEachKey(opt.type, key => {
|
||||
namesOfType.push(` '${key}'`);
|
||||
});
|
||||
|
||||
namesOfCustomTypeMapCache[opt.name] = namesOfType;
|
||||
return namesOfCustomTypeMapCache[opt.name];
|
||||
return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType);
|
||||
}
|
||||
|
||||
export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine {
|
||||
@ -518,19 +502,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string) {
|
||||
const key = (value || "").trim().toLowerCase();
|
||||
const map = opt.type;
|
||||
const key = (value || "").toLowerCase();
|
||||
if (hasProperty(map, key)) {
|
||||
return map[key];
|
||||
}
|
||||
else {
|
||||
const suggestedOption = getNamesOfCustomTypeFromCommandLineOptionsOfCustomType(opt);
|
||||
errors.push(createCompilerDiagnostic(opt.error, suggestedOption ? suggestedOption : undefined));
|
||||
errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
|
||||
}
|
||||
}
|
||||
|
||||
function parseListTypeOption(opt: CommandLineOptionOfListType, value: string): (number | string)[] {
|
||||
const values = (value.trim() || "").split(",");
|
||||
const values = (value || "").trim().split(",");
|
||||
switch (opt.element.type) {
|
||||
case "number":
|
||||
return ts.map(values, parseInt);
|
||||
@ -788,7 +771,7 @@ namespace ts {
|
||||
return opt.type[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(opt.error));
|
||||
errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2364,14 +2364,10 @@
|
||||
"category": "Error",
|
||||
"code": 6045
|
||||
},
|
||||
"Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'none'.": {
|
||||
"Argument for '{0}' option must be: {1}": {
|
||||
"category": "Error",
|
||||
"code": 6046
|
||||
},
|
||||
"Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'.": {
|
||||
"category": "Error",
|
||||
"code": 6047
|
||||
},
|
||||
"Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 6048
|
||||
@ -2424,10 +2420,6 @@
|
||||
"category": "Message",
|
||||
"code": 6061
|
||||
},
|
||||
"Argument for '--newLine' option must be 'CRLF' or 'LF'.": {
|
||||
"category": "Error",
|
||||
"code": 6062
|
||||
},
|
||||
"Argument for '--moduleResolution' option must be 'node' or 'classic'.": {
|
||||
"category": "Error",
|
||||
"code": 6063
|
||||
|
||||
@ -2549,7 +2549,6 @@ namespace ts {
|
||||
/* @internal */
|
||||
export interface CommandLineOptionOfCustomType extends CommandLineOptionBase {
|
||||
type: Map<number | string>; // an object literal mapping named values to actual values
|
||||
error: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
@ -16,8 +16,9 @@ namespace ts {
|
||||
for (let i = 0; i < parsedErrors.length; ++i) {
|
||||
const parsedError = parsedErrors[i];
|
||||
const expectedError = expectedErrors[i];
|
||||
assert.equal(parsedError.code, expectedError.code, `Expected error-code: ${JSON.stringify(expectedError.code)}. Actual error-code: ${JSON.stringify(parsedError.code)}.`);
|
||||
assert.equal(parsedError.category, expectedError.category, `Expected error-category: ${JSON.stringify(expectedError.category)}. Actual error-category: ${JSON.stringify(parsedError.category)}.`);
|
||||
assert.equal(parsedError.code, expectedError.code);
|
||||
assert.equal(parsedError.category, expectedError.category);
|
||||
assert.equal(parsedError.messageText, expectedError.messageText);
|
||||
}
|
||||
|
||||
const parsedFileNames = parsed.fileNames;
|
||||
@ -26,7 +27,7 @@ namespace ts {
|
||||
for (let i = 0; i < parsedFileNames.length; ++i) {
|
||||
const parsedFileName = parsedFileNames[i];
|
||||
const expectedFileName = expectedFileNames[i];
|
||||
assert.equal(parsedFileName, expectedFileName, `Expected filename: ${JSON.stringify(expectedFileName)}. Actual fileName: ${JSON.stringify(parsedFileName)}.`);
|
||||
assert.equal(parsedFileName, expectedFileName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,9 +60,9 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5,es8", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "",
|
||||
category: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.category,
|
||||
code: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.code,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es7', 'dom', 'webworker', 'scripthost', 'es6.array', 'es6.collection', 'es6.function', 'es6.iterable', 'es6.math', 'es6.number', 'es6.object', 'es6.promise', 'es6.proxy', 'es6.reflect', 'es6.regexp', 'es6.symbol', 'es6.symbol.wellknown', 'es7.array.include'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
@ -74,14 +75,172 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse incorrect form of library flags ", () => {
|
||||
it("Parse empty options of --jsx ", () => {
|
||||
// 0.ts --lib
|
||||
assertParseResult(["0.ts", "--jsx"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Compiler option 'jsx' expects an argument.",
|
||||
category: ts.Diagnostics.Compiler_option_0_expects_an_argument.category,
|
||||
code: ts.Diagnostics.Compiler_option_0_expects_an_argument.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}],
|
||||
fileNames: ["0.ts"],
|
||||
options: {}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse empty options of --module ", () => {
|
||||
// 0.ts --lib
|
||||
assertParseResult(["0.ts", "--module"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Compiler option 'module' expects an argument.",
|
||||
category: ts.Diagnostics.Compiler_option_0_expects_an_argument.category,
|
||||
code: ts.Diagnostics.Compiler_option_0_expects_an_argument.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}],
|
||||
fileNames: ["0.ts"],
|
||||
options: {}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse empty options of --newLine ", () => {
|
||||
// 0.ts --lib
|
||||
assertParseResult(["0.ts", "--newLine"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Compiler option 'newLine' expects an argument.",
|
||||
category: ts.Diagnostics.Compiler_option_0_expects_an_argument.category,
|
||||
code: ts.Diagnostics.Compiler_option_0_expects_an_argument.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}],
|
||||
fileNames: ["0.ts"],
|
||||
options: {}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse empty options of --target ", () => {
|
||||
// 0.ts --lib
|
||||
assertParseResult(["0.ts", "--target"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Compiler option 'target' expects an argument.",
|
||||
category: ts.Diagnostics.Compiler_option_0_expects_an_argument.category,
|
||||
code: ts.Diagnostics.Compiler_option_0_expects_an_argument.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}],
|
||||
fileNames: ["0.ts"],
|
||||
options: {}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse empty options of --moduleResolution ", () => {
|
||||
// 0.ts --lib
|
||||
assertParseResult(["0.ts", "--moduleResolution"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Compiler option 'moduleResolution' expects an argument.",
|
||||
category: ts.Diagnostics.Compiler_option_0_expects_an_argument.category,
|
||||
code: ts.Diagnostics.Compiler_option_0_expects_an_argument.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}],
|
||||
fileNames: ["0.ts"],
|
||||
options: {}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse empty options of --lib ", () => {
|
||||
// 0.ts --lib
|
||||
assertParseResult(["0.ts", "--lib"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Compiler option 'lib' expects an argument.",
|
||||
category: ts.Diagnostics.Compiler_option_0_expects_an_argument.category,
|
||||
code: ts.Diagnostics.Compiler_option_0_expects_an_argument.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es7', 'dom', 'webworker', 'scripthost', 'es6.array', 'es6.collection', 'es6.function', 'es6.iterable', 'es6.math', 'es6.number', 'es6.object', 'es6.promise', 'es6.proxy', 'es6.reflect', 'es6.regexp', 'es6.symbol', 'es6.symbol.wellknown', 'es7.array.include'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}],
|
||||
fileNames: ["0.ts"],
|
||||
options: {
|
||||
lib: []
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse --lib option with extra comma ", () => {
|
||||
// --lib es5, es7 0.ts
|
||||
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "",
|
||||
category: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.category,
|
||||
code: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.code,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es7', 'dom', 'webworker', 'scripthost', 'es6.array', 'es6.collection', 'es6.function', 'es6.iterable', 'es6.math', 'es6.number', 'es6.object', 'es6.promise', 'es6.proxy', 'es6.reflect', 'es6.regexp', 'es6.symbol', 'es6.symbol.wellknown', 'es7.array.include'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
@ -94,14 +253,14 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse incorrect form of library flags with trailing white-space ", () => {
|
||||
it("Parse --lib option with trailing white-space ", () => {
|
||||
// --lib es5, es7 0.ts
|
||||
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "",
|
||||
category: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.category,
|
||||
code: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.code,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es7', 'dom', 'webworker', 'scripthost', 'es6.array', 'es6.collection', 'es6.function', 'es6.iterable', 'es6.math', 'es6.number', 'es6.object', 'es6.promise', 'es6.proxy', 'es6.reflect', 'es6.regexp', 'es6.symbol', 'es6.symbol.wellknown', 'es7.array.include'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
@ -141,14 +300,14 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse incorrect form of multiple compiler flags with input files in the middle", () => {
|
||||
it("Parse --lib as the last arguments", () => {
|
||||
// --module commonjs --target es5 0.ts --lib es5, es6.symbol.wellknown
|
||||
assertParseResult(["--module", "commonjs", "--target", "es5", "0.ts", "--lib", "es5,", "es6.symbol.wellknown"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "",
|
||||
category: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.category,
|
||||
code: ts.Diagnostics.Arguments_for_library_option_must_be_Colon_0.code,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es7', 'dom', 'webworker', 'scripthost', 'es6.array', 'es6.collection', 'es6.function', 'es6.iterable', 'es6.math', 'es6.number', 'es6.object', 'es6.promise', 'es6.proxy', 'es6.reflect', 'es6.regexp', 'es6.symbol', 'es6.symbol.wellknown', 'es7.array.include'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
|
||||
@ -16,8 +16,9 @@ namespace ts {
|
||||
for (let i = 0; i < actualErrors.length; ++i) {
|
||||
const actualError = actualErrors[i];
|
||||
const expectedError = expectedErrors[i];
|
||||
assert.equal(actualError.code, expectedError.code, `Expected error-code: ${JSON.stringify(expectedError.code)}. Actual error-code: ${JSON.stringify(actualError.code)}.`);
|
||||
assert.equal(actualError.category, expectedError.category, `Expected error-category: ${JSON.stringify(expectedError.category)}. Actual error-category: ${JSON.stringify(actualError.category)}.`);
|
||||
assert.equal(actualError.code, expectedError.code);
|
||||
assert.equal(actualError.category, expectedError.category);
|
||||
assert.equal(actualError.messageText, expectedError.messageText);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +72,145 @@ namespace ts {
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it("Convert incorrectly option of jsx to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
"jsx": ""
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert incorrectly option of module to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert incorrectly option of newLine to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"newLine": "",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert incorrectly option of target to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert incorrectly option of module-resolution to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert incorrectly option of libs to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
@ -95,14 +234,131 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "",
|
||||
code: Diagnostics.Arguments_for_library_option_must_be_Colon_0.code,
|
||||
category: Diagnostics.Arguments_for_library_option_must_be_Colon_0.category
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es7', 'dom', 'webworker', 'scripthost', 'es6.array', 'es6.collection', 'es6.function', 'es6.iterable', 'es6.math', 'es6.number', 'es6.object', 'es6.promise', 'es6.proxy', 'es6.reflect', 'es6.regexp', 'es6.symbol', 'es6.symbol.wellknown', 'es7.array.include'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert empty string option of libs to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
"lib": ["es5", ""]
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
lib: ["lib.es5.d.ts"]
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es7', 'dom', 'webworker', 'scripthost', 'es6.array', 'es6.collection', 'es6.function', 'es6.iterable', 'es6.math', 'es6.number', 'es6.object', 'es6.promise', 'es6.proxy', 'es6.reflect', 'es6.regexp', 'es6.symbol', 'es6.symbol.wellknown', 'es7.array.include'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert empty string option of libs to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
"lib": [""]
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
lib: []
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es7', 'dom', 'webworker', 'scripthost', 'es6.array', 'es6.collection', 'es6.function', 'es6.iterable', 'es6.math', 'es6.number', 'es6.object', 'es6.promise', 'es6.proxy', 'es6.reflect', 'es6.regexp', 'es6.symbol', 'es6.symbol.wellknown', 'es7.array.include'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert trailing-whitespace string option of libs to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
"lib": [" "]
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
lib: []
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es7', 'dom', 'webworker', 'scripthost', 'es6.array', 'es6.collection', 'es6.function', 'es6.iterable', 'es6.math', 'es6.number', 'es6.object', 'es6.promise', 'es6.proxy', 'es6.reflect', 'es6.regexp', 'es6.symbol', 'es6.symbol.wellknown', 'es7.array.include'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert empty option of libs to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
"lib": []
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
lib: []
|
||||
},
|
||||
errors: []
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert incorrectly format tsconfig.json to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
@ -116,7 +372,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "",
|
||||
messageText: "Unknown compiler option 'modu'.",
|
||||
code: Diagnostics.Unknown_compiler_option_0.code,
|
||||
category: Diagnostics.Unknown_compiler_option_0.category
|
||||
}]
|
||||
@ -185,38 +441,6 @@ namespace ts {
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert incorrectly option of libs to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
"lib": ["es5", "es6.array", "es8"]
|
||||
}
|
||||
}, "jsconfig.json",
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
allowJs: true,
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
sourceMap: false,
|
||||
lib: ["lib.es5.d.ts", "lib.es6.array.d.ts"]
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "",
|
||||
code: Diagnostics.Arguments_for_library_option_must_be_Colon_0.code,
|
||||
category: Diagnostics.Arguments_for_library_option_must_be_Colon_0.category
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("Convert incorrectly format jsconfig.json to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
@ -233,7 +457,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "",
|
||||
messageText: "Unknown compiler option 'modu'.",
|
||||
code: Diagnostics.Unknown_compiler_option_0.code,
|
||||
category: Diagnostics.Unknown_compiler_option_0.category
|
||||
}]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user