Add option --jsExtensions to handle extensions to treat as javascript
- Command line now takes --jsExtension multiple times or comma separated list of extensions - tsconfig accepts array of extension strings
This commit is contained in:
parent
400b353de2
commit
c30104e3b6
|
@ -247,8 +247,11 @@ namespace ts {
|
|||
error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic,
|
||||
},
|
||||
{
|
||||
name: "consumeJsFiles",
|
||||
type: "boolean",
|
||||
name: "jsExtensions",
|
||||
type: "string[]",
|
||||
description: Diagnostics.Specifies_extensions_to_treat_as_javascript_file_To_specify_multiple_extensions_either_use_this_option_multiple_times_or_provide_comma_separated_list,
|
||||
paramType: Diagnostics.EXTENSION_S,
|
||||
error: Diagnostics.Argument_for_jsExtensions_option_must_be_either_extension_or_comma_separated_list_of_extensions,
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -309,31 +312,23 @@ namespace ts {
|
|||
if (hasProperty(optionNameMap, s)) {
|
||||
let opt = optionNameMap[s];
|
||||
|
||||
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
|
||||
if (!args[i] && opt.type !== "boolean") {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_expects_an_argument, opt.name));
|
||||
if (opt.type === "boolean") {
|
||||
// This needs to be treated specially since it doesnt accept argument
|
||||
options[opt.name] = true;
|
||||
}
|
||||
else {
|
||||
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
|
||||
if (!args[i]) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_expects_an_argument, opt.name));
|
||||
}
|
||||
|
||||
switch (opt.type) {
|
||||
case "number":
|
||||
options[opt.name] = parseInt(args[i++]);
|
||||
break;
|
||||
case "boolean":
|
||||
options[opt.name] = true;
|
||||
break;
|
||||
case "string":
|
||||
options[opt.name] = args[i++] || "";
|
||||
break;
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
default:
|
||||
let map = <Map<number>>opt.type;
|
||||
let key = (args[i++] || "").toLowerCase();
|
||||
if (hasProperty(map, key)) {
|
||||
options[opt.name] = map[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic((<CommandLineOptionOfCustomType>opt).error));
|
||||
}
|
||||
let { hasError, value} = parseOption(opt, args[i++], options[opt.name]);
|
||||
if (hasError) {
|
||||
errors.push(createCompilerDiagnostic((<CommandLineOptionOfCustomType>opt).error));
|
||||
}
|
||||
else {
|
||||
options[opt.name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -345,7 +340,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function parseResponseFile(fileName: string) {
|
||||
let text = readFile ? readFile(fileName) : sys.readFile(fileName);
|
||||
|
||||
|
@ -380,6 +375,63 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function parseMultiValueStringArray(s: string, existingValue: string[]) {
|
||||
let value: string[] = existingValue || [];
|
||||
let hasError: boolean;
|
||||
let currentString = "";
|
||||
if (s) {
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
let ch = s.charCodeAt(i);
|
||||
if (ch === CharacterCodes.comma) {
|
||||
pushCurrentStringToResult();
|
||||
}
|
||||
else {
|
||||
currentString += s.charAt(i);
|
||||
}
|
||||
}
|
||||
// push last string
|
||||
pushCurrentStringToResult();
|
||||
}
|
||||
return { value, hasError };
|
||||
|
||||
function pushCurrentStringToResult() {
|
||||
if (currentString) {
|
||||
value.push(currentString);
|
||||
currentString = "";
|
||||
}
|
||||
else {
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function parseOption(option: CommandLineOption, stringValue: string, existingValue: CompilerOptionsValueType) {
|
||||
let hasError: boolean;
|
||||
let value: CompilerOptionsValueType;
|
||||
switch (option.type) {
|
||||
case "number":
|
||||
value = parseInt(stringValue);
|
||||
break;
|
||||
case "string":
|
||||
value = stringValue || "";
|
||||
break;
|
||||
case "string[]":
|
||||
return parseMultiValueStringArray(stringValue, <string[]>existingValue);
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
default:
|
||||
let map = <Map<number>>option.type;
|
||||
let key = (stringValue || "").toLowerCase();
|
||||
if (hasProperty(map, key)) {
|
||||
value = map[key];
|
||||
}
|
||||
else {
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
return { hasError, value };
|
||||
}
|
||||
|
||||
/**
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
|
@ -409,23 +461,57 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function parseJsonCompilerOption(opt: CommandLineOption, jsonValue: any, errors: Diagnostic[]) {
|
||||
let optType = opt.type;
|
||||
let expectedType = typeof optType === "string" ? optType : "string";
|
||||
let hasValidValue = true;
|
||||
if (typeof jsonValue === expectedType) {
|
||||
if (typeof optType !== "string") {
|
||||
let key = jsonValue.toLowerCase();
|
||||
if (hasProperty(optType, key)) {
|
||||
jsonValue = optType[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic((<CommandLineOptionOfCustomType>opt).error));
|
||||
jsonValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check if the value asked was string[] and value provided was not string[]
|
||||
else if (expectedType !== "string[]" ||
|
||||
typeof jsonValue !== "object" ||
|
||||
typeof jsonValue.length !== "number" ||
|
||||
forEach(<string[]>jsonValue, individualValue => typeof individualValue !== "string")) {
|
||||
// Not expectedType
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType));
|
||||
hasValidValue = false;
|
||||
}
|
||||
|
||||
return {
|
||||
value: <CompilerOptionsValueType>jsonValue,
|
||||
hasValidValue
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
* @param existingOptions optional existing options to extend into
|
||||
*/
|
||||
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
|
||||
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}): ParsedCommandLine {
|
||||
let errors: Diagnostic[] = [];
|
||||
|
||||
let options = getCompilerOptions();
|
||||
let options = getCompilerOptions(existingOptions);
|
||||
return {
|
||||
options,
|
||||
fileNames: getFileNames(),
|
||||
errors
|
||||
};
|
||||
|
||||
function getCompilerOptions(): CompilerOptions {
|
||||
function getCompilerOptions(existingOptions: CompilerOptions): CompilerOptions {
|
||||
let options: CompilerOptions = {};
|
||||
let optionNameMap: Map<CommandLineOption> = {};
|
||||
forEach(optionDeclarations, option => {
|
||||
|
@ -436,27 +522,9 @@ namespace ts {
|
|||
for (let id in jsonOptions) {
|
||||
if (hasProperty(optionNameMap, id)) {
|
||||
let opt = optionNameMap[id];
|
||||
let optType = opt.type;
|
||||
let value = jsonOptions[id];
|
||||
let expectedType = typeof optType === "string" ? optType : "string";
|
||||
if (typeof value === expectedType) {
|
||||
if (typeof optType !== "string") {
|
||||
let key = value.toLowerCase();
|
||||
if (hasProperty(optType, key)) {
|
||||
value = optType[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic((<CommandLineOptionOfCustomType>opt).error));
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
if (opt.isFilePath) {
|
||||
value = normalizePath(combinePaths(basePath, value));
|
||||
}
|
||||
options[opt.name] = value;
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
|
||||
let { hasValidValue, value } = parseJsonCompilerOption(opt, jsonOptions[id], errors);
|
||||
if (hasValidValue) {
|
||||
options[opt.name] = opt.isFilePath ? normalizePath(combinePaths(basePath, <string>value)) : value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -464,7 +532,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
}
|
||||
return options;
|
||||
return extend(existingOptions, options);
|
||||
}
|
||||
|
||||
function getFileNames(): string[] {
|
||||
|
@ -479,32 +547,31 @@ 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));
|
||||
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")) {
|
||||
let baseName = name.substr(0, name.length - ".js".length);
|
||||
if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts") && !contains(sysFiles, baseName + ".d.ts")) {
|
||||
fileNames.push(name);
|
||||
let extensionsToRead = getSupportedExtensions(options);
|
||||
for (let extensionsIndex = 0; extensionsIndex < extensionsToRead.length; extensionsIndex++) {
|
||||
let extension = extensionsToRead[extensionsIndex];
|
||||
let sysFiles = host.readDirectory(basePath, extension, exclude);
|
||||
for (let i = 0; i < sysFiles.length; i++) {
|
||||
let fileName = sysFiles[i];
|
||||
// If this is not the extension of one of the lower priority extension, then only we can use this file name
|
||||
// This could happen if the extension taking priority is substring of lower priority extension. eg. .ts and .d.ts
|
||||
let hasLowerPriorityExtension: boolean;
|
||||
for (let j = extensionsIndex + 1; !hasLowerPriorityExtension && j < extensionsToRead.length; j++) {
|
||||
hasLowerPriorityExtension = fileExtensionIs(fileName, extensionsToRead[j]);
|
||||
};
|
||||
if (!hasLowerPriorityExtension) {
|
||||
// If the basename + higher priority extensions arent in the filenames, use this file name
|
||||
let baseName = fileName.substr(0, fileName.length - extension.length - 1);
|
||||
let hasSameNameHigherPriorityExtensionFile: boolean;
|
||||
for (let j = 0; !hasSameNameHigherPriorityExtensionFile && j < extensionsIndex; j++) {
|
||||
hasSameNameHigherPriorityExtensionFile = contains(fileNames, baseName + "." + extensionsToRead[j]);
|
||||
};
|
||||
|
||||
if (!hasSameNameHigherPriorityExtensionFile) {
|
||||
fileNames.push(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fileExtensionIs(name, ".d.ts")) {
|
||||
let baseName = name.substr(0, name.length - ".d.ts".length);
|
||||
if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) {
|
||||
fileNames.push(name);
|
||||
}
|
||||
}
|
||||
else if (fileExtensionIs(name, ".ts")) {
|
||||
if (!contains(sysFiles, name + "x")) {
|
||||
fileNames.push(name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileNames.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fileNames;
|
||||
|
|
|
@ -714,20 +714,20 @@ namespace ts {
|
|||
|
||||
export function fileExtensionIs(path: string, extension: string): boolean {
|
||||
let pathLen = path.length;
|
||||
let extLen = extension.length;
|
||||
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
|
||||
let extLen = extension.length + 1;
|
||||
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === "." + extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of supported extensions in order of file resolution precedence.
|
||||
*/
|
||||
export const supportedExtensions = [".ts", ".tsx", ".d.ts", ".js"];
|
||||
export const supportedTypeScriptExtensions = ["ts", "tsx", "d.ts"];
|
||||
|
||||
const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"];
|
||||
const extensionsToRemove = ["d.ts", "ts", "js", "tsx", "jsx"];
|
||||
export function removeFileExtension(path: string): string {
|
||||
for (let ext of extensionsToRemove) {
|
||||
if (fileExtensionIs(path, ext)) {
|
||||
return path.substr(0, path.length - ext.length);
|
||||
return path.substr(0, path.length - ext.length - 1);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
|
|
|
@ -546,6 +546,7 @@ namespace ts {
|
|||
VERSION: { code: 6036, category: DiagnosticCategory.Message, key: "VERSION" },
|
||||
LOCATION: { code: 6037, category: DiagnosticCategory.Message, key: "LOCATION" },
|
||||
DIRECTORY: { code: 6038, category: DiagnosticCategory.Message, key: "DIRECTORY" },
|
||||
EXTENSION_S: { code: 6039, category: DiagnosticCategory.Message, key: "EXTENSION[S]" },
|
||||
Compilation_complete_Watching_for_file_changes: { code: 6042, category: DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." },
|
||||
Generates_corresponding_map_file: { code: 6043, category: DiagnosticCategory.Message, key: "Generates corresponding '.map' file." },
|
||||
Compiler_option_0_expects_an_argument: { code: 6044, category: DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." },
|
||||
|
@ -567,6 +568,7 @@ namespace ts {
|
|||
NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" },
|
||||
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
|
||||
Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." },
|
||||
Argument_for_jsExtensions_option_must_be_either_extension_or_comma_separated_list_of_extensions: { code: 6064, category: DiagnosticCategory.Error, key: "Argument for '--jsExtensions' option must be either extension or comma separated list of extensions." },
|
||||
Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" },
|
||||
Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." },
|
||||
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
|
||||
|
@ -577,6 +579,7 @@ namespace ts {
|
|||
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
|
||||
Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
|
||||
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
|
||||
Specifies_extensions_to_treat_as_javascript_file_To_specify_multiple_extensions_either_use_this_option_multiple_times_or_provide_comma_separated_list: { code: 6073, category: DiagnosticCategory.Message, key: "Specifies extensions to treat as javascript file. To specify multiple extensions, either use this option multiple times or provide comma separated list." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
|
|
|
@ -2174,6 +2174,10 @@
|
|||
"category": "Message",
|
||||
"code": 6038
|
||||
},
|
||||
"EXTENSION[S]": {
|
||||
"category": "Message",
|
||||
"code": 6039
|
||||
},
|
||||
"Compilation complete. Watching for file changes.": {
|
||||
"category": "Message",
|
||||
"code": 6042
|
||||
|
@ -2258,6 +2262,10 @@
|
|||
"category": "Error",
|
||||
"code": 6063
|
||||
},
|
||||
"Argument for '--jsExtensions' option must be either extension or comma separated list of extensions.": {
|
||||
"category": "Error",
|
||||
"code": 6064
|
||||
},
|
||||
|
||||
"Specify JSX code generation: 'preserve' or 'react'": {
|
||||
"category": "Message",
|
||||
|
@ -2299,6 +2307,10 @@
|
|||
"category": "Message",
|
||||
"code": 6072
|
||||
},
|
||||
"Specifies extensions to treat as javascript file. To specify multiple extensions, either use this option multiple times or provide comma separated list.": {
|
||||
"category": "Message",
|
||||
"code": 6073
|
||||
},
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
|
|
|
@ -659,7 +659,7 @@ namespace ts {
|
|||
sourceFile.bindDiagnostics = [];
|
||||
sourceFile.languageVersion = languageVersion;
|
||||
sourceFile.fileName = normalizePath(fileName);
|
||||
sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0;
|
||||
sourceFile.flags = fileExtensionIs(sourceFile.fileName, "d.ts") ? NodeFlags.DeclarationFile : 0;
|
||||
sourceFile.languageVariant = isTsx(sourceFile.fileName) ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
|
||||
return sourceFile;
|
||||
|
|
|
@ -42,24 +42,24 @@ namespace ts {
|
|||
: compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
|
||||
|
||||
switch (moduleResolution) {
|
||||
case ModuleResolutionKind.NodeJs: return nodeModuleNameResolver(moduleName, containingFile, host);
|
||||
case ModuleResolutionKind.NodeJs: return nodeModuleNameResolver(moduleName, containingFile, getSupportedExtensions(compilerOptions), host);
|
||||
case ModuleResolutionKind.Classic: return classicNameResolver(moduleName, containingFile, compilerOptions, host);
|
||||
}
|
||||
}
|
||||
|
||||
export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
export function nodeModuleNameResolver(moduleName: string, containingFile: string, supportedExtensions: string[], host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
let containingDirectory = getDirectoryPath(containingFile);
|
||||
|
||||
if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
|
||||
let failedLookupLocations: string[] = [];
|
||||
let candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
let resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
|
||||
let resolvedFileName = loadNodeModuleFromFile(candidate, supportedExtensions, failedLookupLocations, host);
|
||||
|
||||
if (resolvedFileName) {
|
||||
return { resolvedModule: { resolvedFileName }, failedLookupLocations };
|
||||
}
|
||||
|
||||
resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
|
||||
resolvedFileName = loadNodeModuleFromDirectory(candidate, supportedExtensions, failedLookupLocations, host);
|
||||
return resolvedFileName
|
||||
? { resolvedModule: { resolvedFileName }, failedLookupLocations }
|
||||
: { resolvedModule: undefined, failedLookupLocations };
|
||||
|
@ -69,16 +69,11 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function loadNodeModuleFromFile(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string {
|
||||
if (loadOnlyDts) {
|
||||
return tryLoad(".d.ts");
|
||||
}
|
||||
else {
|
||||
return forEach(supportedExtensions, tryLoad);
|
||||
}
|
||||
function loadNodeModuleFromFile(candidate: string, supportedExtensions: string[], failedLookupLocation: string[], host: ModuleResolutionHost): string {
|
||||
return forEach(supportedExtensions, tryLoad);
|
||||
|
||||
function tryLoad(ext: string): string {
|
||||
let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
|
||||
let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + "." + ext;
|
||||
if (host.fileExists(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
|
@ -89,7 +84,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function loadNodeModuleFromDirectory(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string {
|
||||
function loadNodeModuleFromDirectory(candidate: string, supportedExtensions: string[], failedLookupLocation: string[], host: ModuleResolutionHost): string {
|
||||
let packageJsonPath = combinePaths(candidate, "package.json");
|
||||
if (host.fileExists(packageJsonPath)) {
|
||||
|
||||
|
@ -105,7 +100,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
if (jsonContent.typings) {
|
||||
let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host);
|
||||
let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), supportedExtensions, failedLookupLocation, host);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
@ -116,7 +111,7 @@ namespace ts {
|
|||
failedLookupLocation.push(packageJsonPath);
|
||||
}
|
||||
|
||||
return loadNodeModuleFromFile(combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host);
|
||||
return loadNodeModuleFromFile(combinePaths(candidate, "index"), supportedExtensions, failedLookupLocation, host);
|
||||
}
|
||||
|
||||
function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
|
@ -127,12 +122,12 @@ namespace ts {
|
|||
if (baseName !== "node_modules") {
|
||||
let nodeModulesFolder = combinePaths(directory, "node_modules");
|
||||
let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
|
||||
let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
|
||||
let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ ["d.ts"], failedLookupLocations, host);
|
||||
if (result) {
|
||||
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
|
||||
}
|
||||
|
||||
result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
|
||||
result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ ["d.ts"], failedLookupLocations, host);
|
||||
if (result) {
|
||||
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
|
||||
}
|
||||
|
@ -169,14 +164,14 @@ namespace ts {
|
|||
let referencedSourceFile: string;
|
||||
while (true) {
|
||||
searchName = normalizePath(combinePaths(searchPath, moduleName));
|
||||
referencedSourceFile = forEach(supportedExtensions, extension => {
|
||||
if (extension === ".tsx" && !compilerOptions.jsx) {
|
||||
referencedSourceFile = forEach(getSupportedExtensions(compilerOptions), extension => {
|
||||
if (extension === "tsx" && !compilerOptions.jsx) {
|
||||
// resolve .tsx files only if jsx support is enabled
|
||||
// 'logical not' handles both undefined and None cases
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let candidate = searchName + extension;
|
||||
let candidate = searchName + "." + extension;
|
||||
if (host.fileExists(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
|
@ -368,13 +363,14 @@ namespace ts {
|
|||
}
|
||||
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
forEach(rootNames, name => processRootFile(name, false));
|
||||
let supportedExtensions = getSupportedExtensions(options);
|
||||
forEach(rootNames, name => processRootFile(name, false, supportedExtensions));
|
||||
// Do not process the default library if:
|
||||
// - The '--noLib' flag is used.
|
||||
// - A 'no-default-lib' reference comment is encountered in
|
||||
// processing the root files.
|
||||
if (!skipDefaultLib) {
|
||||
processRootFile(host.getDefaultLibFileName(options), true);
|
||||
processRootFile(host.getDefaultLibFileName(options), true, supportedExtensions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -833,12 +829,8 @@ namespace ts {
|
|||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function hasExtension(fileName: string): boolean {
|
||||
return getBaseFileName(fileName).indexOf(".") >= 0;
|
||||
}
|
||||
|
||||
function processRootFile(fileName: string, isDefaultLib: boolean) {
|
||||
processSourceFile(normalizePath(fileName), isDefaultLib);
|
||||
function processRootFile(fileName: string, isDefaultLib: boolean, supportedExtensions: string[]) {
|
||||
processSourceFile(normalizePath(fileName), isDefaultLib, supportedExtensions);
|
||||
}
|
||||
|
||||
function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean {
|
||||
|
@ -897,7 +889,7 @@ namespace ts {
|
|||
file.imports = imports || emptyArray;
|
||||
}
|
||||
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, supportedExtensions: string[], refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
let diagnosticArgument: string[];
|
||||
let diagnostic: DiagnosticMessage;
|
||||
if (hasExtension(fileName)) {
|
||||
|
@ -905,7 +897,7 @@ namespace ts {
|
|||
diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1;
|
||||
diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"];
|
||||
}
|
||||
else if (!findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
else if (!findSourceFile(fileName, isDefaultLib, supportedExtensions, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
|
@ -915,14 +907,15 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
else {
|
||||
let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd);
|
||||
let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, supportedExtensions, refFile, refPos, refEnd);
|
||||
if (!nonTsFile) {
|
||||
if (options.allowNonTsExtensions) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd))) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
else if (!forEach(getSupportedExtensions(options), extension => findSourceFile(fileName + "." + extension, isDefaultLib, supportedExtensions, refFile, refPos, refEnd))) {
|
||||
// (TODO: shkamat) Should this message be different given we support multiple extensions
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
fileName += ".ts";
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
|
@ -940,7 +933,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||
function findSourceFile(fileName: string, isDefaultLib: boolean, supportedExtensions: string[], refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||
let canonicalName = host.getCanonicalFileName(normalizeSlashes(fileName));
|
||||
if (filesByName.contains(canonicalName)) {
|
||||
// We've already looked for this file, use cached result
|
||||
|
@ -972,11 +965,11 @@ namespace ts {
|
|||
|
||||
let basePath = getDirectoryPath(fileName);
|
||||
if (!options.noResolve) {
|
||||
processReferencedFiles(file, basePath);
|
||||
processReferencedFiles(file, basePath, supportedExtensions);
|
||||
}
|
||||
|
||||
// always process imported modules to record module name resolutions
|
||||
processImportedModules(file, basePath);
|
||||
processImportedModules(file, basePath, supportedExtensions);
|
||||
|
||||
if (isDefaultLib) {
|
||||
file.isDefaultLib = true;
|
||||
|
@ -1008,14 +1001,14 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function processReferencedFiles(file: SourceFile, basePath: string) {
|
||||
function processReferencedFiles(file: SourceFile, basePath: string, supportedExtensions: string[]) {
|
||||
forEach(file.referencedFiles, ref => {
|
||||
let referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName);
|
||||
processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end);
|
||||
processSourceFile(referencedFileName, /* isDefaultLib */ false, supportedExtensions, file, ref.pos, ref.end);
|
||||
});
|
||||
}
|
||||
|
||||
function processImportedModules(file: SourceFile, basePath: string) {
|
||||
function processImportedModules(file: SourceFile, basePath: string, supportedExtensions: string[]) {
|
||||
collectExternalModuleReferences(file);
|
||||
if (file.imports.length) {
|
||||
file.resolvedModules = {};
|
||||
|
@ -1025,13 +1018,13 @@ namespace ts {
|
|||
let resolution = resolutions[i];
|
||||
setResolvedModule(file, moduleNames[i], resolution);
|
||||
if (resolution && !options.noResolve) {
|
||||
const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]);
|
||||
const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i], supportedExtensions);
|
||||
if (importedFile && resolution.isExternalLibraryImport) {
|
||||
if (!isExternalModule(importedFile)) {
|
||||
let start = getTokenPosOfNode(file.imports[i], file)
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
|
||||
}
|
||||
else if (!fileExtensionIs(importedFile.fileName, ".d.ts")) {
|
||||
else if (!fileExtensionIs(importedFile.fileName, "d.ts")) {
|
||||
let start = getTokenPosOfNode(file.imports[i], file)
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition));
|
||||
}
|
||||
|
@ -1049,8 +1042,8 @@ namespace ts {
|
|||
}
|
||||
return;
|
||||
|
||||
function findModuleSourceFile(fileName: string, nameLiteral: Expression) {
|
||||
return findSourceFile(fileName, /* isDefaultLib */ false, file, skipTrivia(file.text, nameLiteral.pos), nameLiteral.end);
|
||||
function findModuleSourceFile(fileName: string, nameLiteral: Expression, supportedExtensions: string[]) {
|
||||
return findSourceFile(fileName, /* isDefaultLib */ false, supportedExtensions, file, skipTrivia(file.text, nameLiteral.pos), nameLiteral.end);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -223,13 +223,13 @@ namespace ts {
|
|||
}
|
||||
|
||||
let configObject = result.config;
|
||||
let configParseResult = parseConfigFile(configObject, sys, getDirectoryPath(configFileName));
|
||||
let configParseResult = parseConfigFile(configObject, sys, getDirectoryPath(configFileName), commandLine.options);
|
||||
if (configParseResult.errors.length > 0) {
|
||||
reportDiagnostics(configParseResult.errors);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
rootFileNames = configParseResult.fileNames;
|
||||
compilerOptions = extend(commandLine.options, configParseResult.options);
|
||||
compilerOptions = configParseResult.options;
|
||||
}
|
||||
else {
|
||||
rootFileNames = commandLine.fileNames;
|
||||
|
@ -519,8 +519,8 @@ namespace ts {
|
|||
|
||||
return;
|
||||
|
||||
function serializeCompilerOptions(options: CompilerOptions): Map<string|number|boolean> {
|
||||
let result: Map<string|number|boolean> = {};
|
||||
function serializeCompilerOptions(options: CompilerOptions): Map<string | number | boolean | string[]> {
|
||||
let result: Map<string | number | boolean | string[]> = {};
|
||||
let optionsNameMap = getOptionNameMap().optionNameMap;
|
||||
|
||||
for (let name in options) {
|
||||
|
@ -537,8 +537,8 @@ namespace ts {
|
|||
let optionDefinition = optionsNameMap[name.toLowerCase()];
|
||||
if (optionDefinition) {
|
||||
if (typeof optionDefinition.type === "string") {
|
||||
// string, number or boolean
|
||||
result[name] = value;
|
||||
// string, number, boolean or string[]
|
||||
result[name] = <string | number | boolean | string[]>value;
|
||||
}
|
||||
else {
|
||||
// Enum
|
||||
|
|
|
@ -2062,15 +2062,17 @@ namespace ts {
|
|||
experimentalAsyncFunctions?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
consumeJsFiles?: boolean;
|
||||
jsExtensions?: string[];
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
/* @internal */ skipDefaultLibCheck?: boolean;
|
||||
|
||||
[option: string]: string | number | boolean;
|
||||
[option: string]: CompilerOptionsValueType;
|
||||
}
|
||||
|
||||
export type CompilerOptionsValueType = string | number | boolean | string[];
|
||||
|
||||
export const enum ModuleKind {
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
|
@ -2134,7 +2136,7 @@ namespace ts {
|
|||
|
||||
/* @internal */
|
||||
export interface CommandLineOptionOfCustomType extends CommandLineOptionBase {
|
||||
type: Map<number>; // an object literal mapping named values to actual values
|
||||
type: Map<number> | string; // an object literal mapping named values to actual values | string if it is string[]
|
||||
error: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
|
||||
}
|
||||
|
||||
|
|
|
@ -1783,13 +1783,17 @@ namespace ts {
|
|||
// 1. in-browser single file compilation scenario
|
||||
// 2. non supported extension file
|
||||
return compilerOptions.isolatedModules ||
|
||||
forEach(supportedExtensions, extension => fileExtensionIs(sourceFile.fileName, extension));
|
||||
forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(sourceFile.fileName, extension));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getSupportedExtensions(options: CompilerOptions): string[] {
|
||||
return options.jsExtensions ? supportedTypeScriptExtensions.concat(options.jsExtensions) : supportedTypeScriptExtensions;
|
||||
}
|
||||
|
||||
export function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration) {
|
||||
let firstAccessor: AccessorDeclaration;
|
||||
let secondAccessor: AccessorDeclaration;
|
||||
|
@ -2063,13 +2067,18 @@ namespace ts {
|
|||
export function getLocalSymbolForExportDefault(symbol: Symbol) {
|
||||
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
|
||||
}
|
||||
|
||||
export function hasExtension(fileName: string): boolean {
|
||||
return getBaseFileName(fileName).indexOf(".") >= 0;
|
||||
}
|
||||
|
||||
export function isJavaScript(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".js");
|
||||
// Treat file as typescript if the extension is not supportedTypeScript
|
||||
return hasExtension(fileName) && !forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
|
||||
}
|
||||
|
||||
export function isTsx(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".tsx");
|
||||
return fileExtensionIs(fileName, "tsx");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -148,7 +148,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
});
|
||||
|
||||
it("Correct JS output for " + fileName, () => {
|
||||
if (!ts.fileExtensionIs(lastUnit.name, ".d.ts") && this.emit) {
|
||||
if (!ts.fileExtensionIs(lastUnit.name, "d.ts") && this.emit) {
|
||||
if (result.files.length === 0 && result.errors.length === 0) {
|
||||
throw new Error("Expected at least one js file to be emitted or at least one error to be created.");
|
||||
}
|
||||
|
|
|
@ -996,23 +996,17 @@ module Harness {
|
|||
}
|
||||
let option = getCommandLineOption(name);
|
||||
if (option) {
|
||||
switch (option.type) {
|
||||
case "boolean":
|
||||
options[option.name] = value.toLowerCase() === "true";
|
||||
break;
|
||||
case "string":
|
||||
options[option.name] = value;
|
||||
break;
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
default:
|
||||
let map = <ts.Map<number>>option.type;
|
||||
let key = value.toLowerCase();
|
||||
if (ts.hasProperty(map, key)) {
|
||||
options[option.name] = map[key];
|
||||
}
|
||||
else {
|
||||
throw new Error(`Unknown value '${value}' for compiler option '${name}'.`);
|
||||
}
|
||||
if (option.type === "boolean") {
|
||||
options[option.name] = value.toLowerCase() === "true";
|
||||
}
|
||||
else {
|
||||
let { hasError, value: parsedValue } = ts.parseOption(option, value, options[option.name]);
|
||||
if (hasError) {
|
||||
throw new Error(`Unknown value '${value}' for compiler option '${name}'.`);
|
||||
}
|
||||
else {
|
||||
options[option.name] = parsedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
///<reference path="runnerbase.ts" />
|
||||
|
||||
// Test case is json of below type in tests/cases/project/
|
||||
interface ProjectRunnerTestCase {
|
||||
interface ProjectRunnerTestCase extends ts.CompilerOptions{
|
||||
scenario: string;
|
||||
projectRoot: string; // project where it lives - this also is the current directory when compiling
|
||||
inputFiles: string[]; // list of input files to be given to program
|
||||
|
@ -50,7 +50,7 @@ class ProjectRunner extends RunnerBase {
|
|||
}
|
||||
|
||||
private runProjectTestCase(testCaseFileName: string) {
|
||||
let testCase: ProjectRunnerTestCase & ts.CompilerOptions;
|
||||
let testCase: ProjectRunnerTestCase;
|
||||
|
||||
let testFileText: string = null;
|
||||
try {
|
||||
|
@ -61,7 +61,7 @@ class ProjectRunner extends RunnerBase {
|
|||
}
|
||||
|
||||
try {
|
||||
testCase = <ProjectRunnerTestCase & ts.CompilerOptions>JSON.parse(testFileText);
|
||||
testCase = <ProjectRunnerTestCase>JSON.parse(testFileText);
|
||||
}
|
||||
catch (e) {
|
||||
assert(false, "Testcase: " + testCaseFileName + " does not contain valid json format: " + e.message);
|
||||
|
@ -181,8 +181,13 @@ class ProjectRunner extends RunnerBase {
|
|||
let nonSubfolderDiskFiles = 0;
|
||||
|
||||
let outputFiles: BatchCompileProjectTestCaseEmittedFile[] = [];
|
||||
let compilerOptions = createCompilerOptions();
|
||||
let inputFiles = testCase.inputFiles;
|
||||
let { errors, compilerOptions } = createCompilerOptions();
|
||||
if (errors.length) {
|
||||
moduleKind,
|
||||
errors
|
||||
};
|
||||
|
||||
let configFileName: string;
|
||||
if (compilerOptions.project) {
|
||||
// Parse project
|
||||
|
@ -203,7 +208,7 @@ class ProjectRunner extends RunnerBase {
|
|||
}
|
||||
|
||||
let configObject = result.config;
|
||||
let configParseResult = ts.parseConfigFile(configObject, { fileExists, readFile: getSourceFileText, readDirectory }, ts.getDirectoryPath(configFileName));
|
||||
let configParseResult = ts.parseConfigFile(configObject, { fileExists, readFile: getSourceFileText, readDirectory }, ts.getDirectoryPath(configFileName), compilerOptions);
|
||||
if (configParseResult.errors.length > 0) {
|
||||
return {
|
||||
moduleKind,
|
||||
|
@ -211,7 +216,7 @@ class ProjectRunner extends RunnerBase {
|
|||
};
|
||||
}
|
||||
inputFiles = configParseResult.fileNames;
|
||||
compilerOptions = ts.extend(compilerOptions, configParseResult.options);
|
||||
compilerOptions = configParseResult.options;
|
||||
}
|
||||
|
||||
let projectCompilerResult = compileProjectFiles(moduleKind, () => inputFiles, getSourceFileText, writeFile, compilerOptions);
|
||||
|
@ -224,7 +229,7 @@ class ProjectRunner extends RunnerBase {
|
|||
errors: projectCompilerResult.errors,
|
||||
};
|
||||
|
||||
function createCompilerOptions(): ts.CompilerOptions {
|
||||
function createCompilerOptions() {
|
||||
// Set the special options that depend on other testcase options
|
||||
let compilerOptions: ts.CompilerOptions = {
|
||||
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? Harness.IO.resolvePath(testCase.mapRoot) : testCase.mapRoot,
|
||||
|
@ -232,7 +237,7 @@ class ProjectRunner extends RunnerBase {
|
|||
module: moduleKind,
|
||||
moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future
|
||||
};
|
||||
|
||||
let errors: ts.Diagnostic[] = [];
|
||||
// Set the values specified using json
|
||||
let optionNameMap: ts.Map<ts.CommandLineOption> = {};
|
||||
ts.forEach(ts.optionDeclarations, option => {
|
||||
|
@ -241,19 +246,14 @@ class ProjectRunner extends RunnerBase {
|
|||
for (let name in testCase) {
|
||||
if (name !== "mapRoot" && name !== "sourceRoot" && ts.hasProperty(optionNameMap, name)) {
|
||||
let option = optionNameMap[name];
|
||||
let optType = option.type;
|
||||
let value = <any>testCase[name];
|
||||
if (typeof optType !== "string") {
|
||||
let key = value.toLowerCase();
|
||||
if (ts.hasProperty(optType, key)) {
|
||||
value = optType[key];
|
||||
}
|
||||
let { hasValidValue, value } = ts.parseJsonCompilerOption(option, testCase[name], errors);
|
||||
if (hasValidValue) {
|
||||
compilerOptions[option.name] = value;
|
||||
}
|
||||
compilerOptions[option.name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return compilerOptions;
|
||||
return { errors, compilerOptions };
|
||||
}
|
||||
|
||||
function getFileNameInTheProjectTest(fileName: string): string {
|
||||
|
@ -389,11 +389,11 @@ class ProjectRunner extends RunnerBase {
|
|||
}
|
||||
|
||||
function getErrorsBaseline(compilerResult: CompileProjectFilesResult) {
|
||||
let inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
let inputFiles = compilerResult.program ? ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
sourceFile => sourceFile.fileName !== "lib.d.ts"),
|
||||
sourceFile => {
|
||||
return { unitName: sourceFile.fileName, content: sourceFile.text };
|
||||
});
|
||||
}): [];
|
||||
|
||||
return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors);
|
||||
}
|
||||
|
|
|
@ -1868,7 +1868,7 @@ namespace ts {
|
|||
let compilerHost: CompilerHost = {
|
||||
getSourceFile: (fileName, target) => fileName === normalizeSlashes(inputFileName) ? sourceFile : undefined,
|
||||
writeFile: (name, text, writeByteOrderMark) => {
|
||||
if (fileExtensionIs(name, ".map")) {
|
||||
if (fileExtensionIs(name, "map")) {
|
||||
Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`);
|
||||
sourceMapText = text;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
||||
|
||||
|
||||
!!! error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
||||
==== tests/cases/compiler/a.js (0 errors) ====
|
||||
declare var v;
|
|
@ -1,6 +1,6 @@
|
|||
error TS6053: File 'a.ts' not found.
|
||||
error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js'.
|
||||
error TS6054: File 'a.t' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
||||
|
||||
|
||||
!!! error TS6053: File 'a.ts' not found.
|
||||
!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js'.
|
||||
!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
|
@ -1,6 +1,6 @@
|
|||
error TS6053: File 'a.ts' not found.
|
||||
error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js'.
|
||||
error TS6054: File 'a.t' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
||||
|
||||
|
||||
!!! error TS6053: File 'a.ts' not found.
|
||||
!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js'.
|
||||
!!! error TS6054: File 'a.t' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files and consumeJsFiles is true",
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesNotSpecifiedWithConsumeJsFiles",
|
||||
"project": "DifferentNamesNotSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesNotSpecifiedWithConsumeJsFiles/a.ts",
|
||||
"DifferentNamesNotSpecifiedWithConsumeJsFiles/b.js"
|
||||
"DifferentNamesNotSpecifiedWithJsExtensions/a.ts",
|
||||
"DifferentNamesNotSpecifiedWithJsExtensions/b.js"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files and consumeJsFiles is true",
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesNotSpecifiedWithConsumeJsFiles",
|
||||
"project": "DifferentNamesNotSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesNotSpecifiedWithConsumeJsFiles/a.ts",
|
||||
"DifferentNamesNotSpecifiedWithConsumeJsFiles/b.js"
|
||||
"DifferentNamesNotSpecifiedWithJsExtensions/a.ts",
|
||||
"DifferentNamesNotSpecifiedWithJsExtensions/b.js"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
|
@ -0,0 +1,6 @@
|
|||
error TS6054: File 'DifferentNamesSpecified/b.js' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
||||
|
||||
|
||||
!!! error TS6054: File 'DifferentNamesSpecified/b.js' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
||||
==== DifferentNamesSpecified/a.ts (0 errors) ====
|
||||
var test = 10;
|
|
@ -6,8 +6,7 @@
|
|||
"project": "DifferentNamesSpecified",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesSpecified/a.ts",
|
||||
"DifferentNamesSpecified/b.js"
|
||||
"DifferentNamesSpecified/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
error TS6054: File 'DifferentNamesSpecified/b.js' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
||||
|
||||
|
||||
!!! error TS6054: File 'DifferentNamesSpecified/b.js' has unsupported extension. The only supported extensions are 'ts', 'tsx', 'd.ts'.
|
||||
==== DifferentNamesSpecified/a.ts (0 errors) ====
|
||||
var test = 10;
|
|
@ -6,8 +6,7 @@
|
|||
"project": "DifferentNamesSpecified",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesSpecified/a.ts",
|
||||
"DifferentNamesSpecified/b.js"
|
||||
"DifferentNamesSpecified/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"scenario": "Verify when different .ts and .js file exist and their names are specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesSpecifiedWithJsExtensions/a.ts",
|
||||
"DifferentNamesSpecifiedWithJsExtensions/b.js"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
||||
"test.d.ts"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"scenario": "Verify when different .ts and .js file exist and their names are specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"DifferentNamesSpecifiedWithJsExtensions/a.ts",
|
||||
"DifferentNamesSpecifiedWithJsExtensions/b.js"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"test.js",
|
||||
"test.d.ts"
|
||||
]
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"scenario": "Verify when same named .d.ts and .js file exists in the folder but no file is specified in tsconfig.json and consumeJsFiles is true",
|
||||
"scenario": "Verify when same named .d.ts and .js file exists in the folder but .d.ts file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameDTsNotSpecifiedWithConsumeJsFiles",
|
||||
"project": "SameNameDTsSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameDTsNotSpecifiedWithConsumeJsFiles/a.d.ts"
|
||||
"SameNameDTsSpecifiedWithJsExtensions/a.d.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"scenario": "Verify when same named .d.ts and .js file exists in the folder but no file is specified in tsconfig.json and consumeJsFiles is true",
|
||||
"scenario": "Verify when same named .d.ts and .js file exists in the folder but .d.ts file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameDTsNotSpecifiedWithConsumeJsFiles",
|
||||
"project": "SameNameDTsSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameDTsNotSpecifiedWithConsumeJsFiles/a.d.ts"
|
||||
"SameNameDTsSpecifiedWithJsExtensions/a.d.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"scenario": "Verify when same named .d.ts and .js file exists in the folder but no file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameDTsNotSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameDTsNotSpecifiedWithJsExtensions/a.d.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"scenario": "Verify when same named .d.ts and .js file exists in the folder but no file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameDTsNotSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameDTsNotSpecifiedWithJsExtensions/a.d.ts"
|
||||
],
|
||||
"emittedFiles": []
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"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"
|
||||
]
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"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 .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameFilesNotSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameFilesNotSpecifiedWithJsExtensions/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"SameNameFilesNotSpecifiedWithJsExtensions/a.js",
|
||||
"SameNameFilesNotSpecifiedWithJsExtensions/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 .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameFilesNotSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameFilesNotSpecifiedWithJsExtensions/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"SameNameFilesNotSpecifiedWithJsExtensions/a.js",
|
||||
"SameNameFilesNotSpecifiedWithJsExtensions/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 .ts file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameTsSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameTsSpecifiedWithJsExtensions/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"SameNameTsSpecifiedWithJsExtensions/a.js",
|
||||
"SameNameTsSpecifiedWithJsExtensions/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 .ts file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameTsSpecifiedWithJsExtensions",
|
||||
"resolvedInputFiles": [
|
||||
"lib.d.ts",
|
||||
"SameNameTsSpecifiedWithJsExtensions/a.ts"
|
||||
],
|
||||
"emittedFiles": [
|
||||
"SameNameTsSpecifiedWithJsExtensions/a.js",
|
||||
"SameNameTsSpecifiedWithJsExtensions/a.d.ts"
|
||||
]
|
||||
}
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
declare var v;
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
@internal class C { }
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
enum E { }
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
export = b;
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
class C implements D { }
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
import a = b;
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
interface I { }
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
module M { }
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
function F(p?) { }
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
class C { v }
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
class C {
|
||||
public foo() {
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
class C { constructor(public x) { }}
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
// @target: es6
|
||||
// @out: b.js
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
function F(): number { }
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
/**
|
||||
* @type {number}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
type a = b;
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
Foo<number>();
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
var v = <string>undefined;
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
function F(a: number) { }
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
class C<T> { }
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
function F<T>() { }
|
|
@ -1,2 +1,3 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.js
|
||||
var v: () => number;
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @out: tests/cases/compiler/b.js
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
// @filename: a.js
|
||||
declare var v;
|
|
@ -1,3 +1,4 @@
|
|||
// @jsExtensions: js
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
|
|
@ -1,7 +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",
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesNotSpecifiedWithConsumeJsFiles"
|
||||
"project": "DifferentNamesNotSpecifiedWithJsExtensions"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"scenario": "Verify when different .ts and .js file exist and their names are specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesSpecifiedWithJsExtensions"
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"scenario": "Verify when same named .d.ts and .js file exists in the folder but no file is specified in tsconfig.json and consumeJsFiles is true",
|
||||
"scenario": "Verify when same named .d.ts and .js file exists in the folder but .d.ts file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameDTsNotSpecifiedWithConsumeJsFiles"
|
||||
"project": "SameNameDTsSpecifiedWithJsExtensions"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"scenario": "Verify when same named .d.ts and .js file exists in the folder but no file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameDTsNotSpecifiedWithJsExtensions"
|
||||
}
|
|
@ -1,7 +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",
|
||||
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameFilesNotSpecifiedWithConsumeJsFiles"
|
||||
"project": "SameNameFilesNotSpecifiedWithJsExtensions"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"scenario": "Verify when same named .ts and .js file exists in the folder but .ts file is specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "SameNameTsSpecifiedWithJsExtensions"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"out": "test.js",
|
||||
"consumeJsFiles": true
|
||||
"jsExtensions": [ "js" ]
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
var test2 = 10; // Should get compiled
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"out": "test.js",
|
||||
"jsExtensions": [ "js" ]
|
||||
},
|
||||
"files": [ "a.ts", "b.js" ]
|
||||
}
|
1
tests/cases/projects/jsFileCompilation/SameNameDTsSpecifiedWithJsExtensions/a.d.ts
vendored
Normal file
1
tests/cases/projects/jsFileCompilation/SameNameDTsSpecifiedWithJsExtensions/a.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
declare var test: number;
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"compilerOptions": { "jsExtensions": [ "js" ] },
|
||||
"files": [ "a.d.ts" ]
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{ "compilerOptions": { "consumeJsFiles": true } }
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue