diff --git a/lib/tsc.js b/lib/tsc.js index 793d9e1f35c0a..23c9055413fa7 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -67,7 +67,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var ts; (function (ts) { ts.versionMajorMinor = "4.1"; - ts.version = "4.1.1-rc"; + ts.version = "4.1.2"; var NativeCollections; (function (NativeCollections) { function tryGetNativeMap() { @@ -5154,8 +5154,6 @@ var ts; Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."), Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), - Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true), @@ -10703,6 +10701,18 @@ var ts; }; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) { + return { + file: sourceFile, + start: 0, + length: 0, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText, + relatedInformation: relatedInformation + }; + } + ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain; function createDiagnosticForRange(sourceFile, range, message) { return { file: sourceFile, @@ -13195,16 +13205,7 @@ var ts; var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); var extensionless = removeFileExtension(relativePath); - if (referencePath) { - return ts.ensurePathIsNonModuleName(extensionless); - } - var options = host.getCompilerOptions(); - var rootPkgName = options.bundledPackageName || ""; - var newPath = ts.combinePaths(rootPkgName, extensionless); - if (rootPkgName && getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && ts.endsWith(newPath, "/index")) { - return newPath.slice(0, newPath.length - "/index".length); - } - return newPath; + return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless; } ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; function getOwnEmitOutputFilePath(fileName, host, extension) { @@ -29658,13 +29659,6 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, - { - name: "bundledPackageName", - type: "string", - affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Provides_a_root_package_name_when_using_outFile_with_declarations, - }, { name: "keyofStringsOnly", type: "boolean", @@ -36021,6 +36015,14 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { + if (location.pos < 0 || location.end < 0) { + if (!isError) { + return; + } + var file = ts.getSourceFileOfNode(location); + addErrorOrSuggestion(isError, "message" in message ? ts.createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForFileFromMessageChain(file, message)); + return; + } addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { @@ -38591,7 +38593,6 @@ var ts; getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); }, isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); }, fileExists: function (fileName) { return host.fileExists(fileName); }, - getCompilerOptions: function () { return host.getCompilerOptions(); } } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -39973,8 +39974,7 @@ var ts; var resolverHost = { getCanonicalFileName: getCanonicalFileName, getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); }, - getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }, - getCompilerOptions: function () { return context.tracker.moduleResolverHost.getCompilerOptions(); } + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } }; var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); return ts.factory.createStringLiteral(newName); @@ -88061,9 +88061,6 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile")); } } - if (outputFile && ts.getEmitDeclarations(options) && ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && !options.bundledPackageName) { - createDiagnosticForOptionName(ts.Diagnostics.The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit, options.out ? "out" : "outFile"); - } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); @@ -90458,7 +90455,7 @@ var ts; function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs, bundledPackageName = compilerOptions.bundledPackageName; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl && !paths || relativePreference === 0) { @@ -90469,9 +90466,8 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var bundledPkgReference = bundledPackageName ? ts.combinePaths(bundledPackageName, relativeToBaseUrl) : relativeToBaseUrl; - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(bundledPkgReference, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(bundledPkgReference), importRelativeToBaseUrl, paths); + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); + var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; if (!nonRelative) { return relativePath; diff --git a/lib/tsserver.js b/lib/tsserver.js index 215e80612aeac..8cee3c1063e0e 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -94,7 +94,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.1-rc"; + ts.version = "4.1.2"; /* @internal */ var Comparison; (function (Comparison) { @@ -7797,8 +7797,6 @@ var ts; Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."), Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), - Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -14047,6 +14045,18 @@ var ts; }; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) { + return { + file: sourceFile, + start: 0, + length: 0, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText, + relatedInformation: relatedInformation + }; + } + ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain; function createDiagnosticForRange(sourceFile, range, message) { return { file: sourceFile, @@ -16956,16 +16966,7 @@ var ts; var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = removeFileExtension(relativePath); - if (referencePath) { - return ts.ensurePathIsNonModuleName(extensionless); - } - var options = host.getCompilerOptions(); - var rootPkgName = options.bundledPackageName || ""; - var newPath = ts.combinePaths(rootPkgName, extensionless); - if (rootPkgName && getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && ts.endsWith(newPath, "/index")) { - return newPath.slice(0, newPath.length - "/index".length); - } - return newPath; + return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless; } ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; function getOwnEmitOutputFilePath(fileName, host, extension) { @@ -36547,13 +36548,6 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, - { - name: "bundledPackageName", - type: "string", - affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Provides_a_root_package_name_when_using_outFile_with_declarations, - }, { name: "keyofStringsOnly", type: "boolean", @@ -44115,6 +44109,16 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { + // Pseudo-synthesized input node + if (location.pos < 0 || location.end < 0) { + if (!isError) { + return; // Drop suggestions (we have no span to suggest on) + } + // Issue errors globally + var file = ts.getSourceFileOfNode(location); + addErrorOrSuggestion(isError, "message" in message ? ts.createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForFileFromMessageChain(file, message)); // eslint-disable-line no-in-operator + return; + } addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { @@ -47117,7 +47121,6 @@ var ts; getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); }, isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); }, fileExists: function (fileName) { return host.fileExists(fileName); }, - getCompilerOptions: function () { return host.getCompilerOptions(); } } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -48596,8 +48599,7 @@ var ts; var resolverHost = { getCanonicalFileName: getCanonicalFileName, getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); }, - getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }, - getCompilerOptions: function () { return context.tracker.moduleResolverHost.getCompilerOptions(); } + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } }; var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); return ts.factory.createStringLiteral(newName); @@ -107200,10 +107202,6 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile")); } } - // Without a package name, for multiple files being bundled into a .d.ts file you basically get a file which doesn't wrk - if (outputFile && ts.getEmitDeclarations(options) && ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && !options.bundledPackageName) { - createDiagnosticForOptionName(ts.Diagnostics.The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit, options.out ? "out" : "outFile"); - } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); @@ -110060,7 +110058,7 @@ var ts; function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs, bundledPackageName = compilerOptions.bundledPackageName; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { @@ -110071,9 +110069,8 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var bundledPkgReference = bundledPackageName ? ts.combinePaths(bundledPackageName, relativeToBaseUrl) : relativeToBaseUrl; - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(bundledPkgReference, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(bundledPkgReference), importRelativeToBaseUrl, paths); + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); + var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; if (!nonRelative) { return relativePath; @@ -114848,8 +114845,7 @@ var ts; getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); }, - isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); }, - getCompilerOptions: function () { return program.getCompilerOptions(); } + isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); } }; } ts.createModuleSpecifierResolutionHost = createModuleSpecifierResolutionHost; @@ -146864,7 +146860,7 @@ var ts; * This is a semantic operation. */ function getSignatureHelpItems(fileName, position, _a) { - var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; + var _b = _a === void 0 ? ts.emptyOptions : _a, triggerReason = _b.triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 95963d1ef5d46..f721c4ce0a8da 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -2790,7 +2790,6 @@ declare namespace ts { allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; - bundledPackageName?: string; charset?: string; checkJs?: boolean; declaration?: boolean; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 59218e40d5b76..b3b6235668eca 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -288,7 +288,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.1-rc"; + ts.version = "4.1.2"; /* @internal */ var Comparison; (function (Comparison) { @@ -7991,8 +7991,6 @@ var ts; Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."), Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), - Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -14241,6 +14239,18 @@ var ts; }; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) { + return { + file: sourceFile, + start: 0, + length: 0, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText, + relatedInformation: relatedInformation + }; + } + ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain; function createDiagnosticForRange(sourceFile, range, message) { return { file: sourceFile, @@ -17150,16 +17160,7 @@ var ts; var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = removeFileExtension(relativePath); - if (referencePath) { - return ts.ensurePathIsNonModuleName(extensionless); - } - var options = host.getCompilerOptions(); - var rootPkgName = options.bundledPackageName || ""; - var newPath = ts.combinePaths(rootPkgName, extensionless); - if (rootPkgName && getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && ts.endsWith(newPath, "/index")) { - return newPath.slice(0, newPath.length - "/index".length); - } - return newPath; + return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless; } ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; function getOwnEmitOutputFilePath(fileName, host, extension) { @@ -36741,13 +36742,6 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, - { - name: "bundledPackageName", - type: "string", - affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Provides_a_root_package_name_when_using_outFile_with_declarations, - }, { name: "keyofStringsOnly", type: "boolean", @@ -44309,6 +44303,16 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { + // Pseudo-synthesized input node + if (location.pos < 0 || location.end < 0) { + if (!isError) { + return; // Drop suggestions (we have no span to suggest on) + } + // Issue errors globally + var file = ts.getSourceFileOfNode(location); + addErrorOrSuggestion(isError, "message" in message ? ts.createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForFileFromMessageChain(file, message)); // eslint-disable-line no-in-operator + return; + } addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { @@ -47311,7 +47315,6 @@ var ts; getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); }, isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); }, fileExists: function (fileName) { return host.fileExists(fileName); }, - getCompilerOptions: function () { return host.getCompilerOptions(); } } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -48790,8 +48793,7 @@ var ts; var resolverHost = { getCanonicalFileName: getCanonicalFileName, getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); }, - getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }, - getCompilerOptions: function () { return context.tracker.moduleResolverHost.getCompilerOptions(); } + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } }; var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); return ts.factory.createStringLiteral(newName); @@ -107394,10 +107396,6 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile")); } } - // Without a package name, for multiple files being bundled into a .d.ts file you basically get a file which doesn't wrk - if (outputFile && ts.getEmitDeclarations(options) && ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && !options.bundledPackageName) { - createDiagnosticForOptionName(ts.Diagnostics.The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit, options.out ? "out" : "outFile"); - } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); @@ -110254,7 +110252,7 @@ var ts; function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs, bundledPackageName = compilerOptions.bundledPackageName; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { @@ -110265,9 +110263,8 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var bundledPkgReference = bundledPackageName ? ts.combinePaths(bundledPackageName, relativeToBaseUrl) : relativeToBaseUrl; - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(bundledPkgReference, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(bundledPkgReference), importRelativeToBaseUrl, paths); + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); + var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; if (!nonRelative) { return relativePath; @@ -115417,8 +115414,7 @@ var ts; getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); }, - isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); }, - getCompilerOptions: function () { return program.getCompilerOptions(); } + isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); } }; } ts.createModuleSpecifierResolutionHost = createModuleSpecifierResolutionHost; @@ -147433,7 +147429,7 @@ var ts; * This is a semantic operation. */ function getSignatureHelpItems(fileName, position, _a) { - var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; + var _b = _a === void 0 ? ts.emptyOptions : _a, triggerReason = _b.triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 2b6547e3c851c..7c6c6301d218b 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -2790,7 +2790,6 @@ declare namespace ts { allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; - bundledPackageName?: string; charset?: string; checkJs?: boolean; declaration?: boolean; diff --git a/lib/typescript.js b/lib/typescript.js index 53d2b9138ec33..19105fcde5d2f 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -288,7 +288,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.1-rc"; + ts.version = "4.1.2"; /* @internal */ var Comparison; (function (Comparison) { @@ -7991,8 +7991,6 @@ var ts; Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."), Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), - Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -14241,6 +14239,18 @@ var ts; }; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) { + return { + file: sourceFile, + start: 0, + length: 0, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText, + relatedInformation: relatedInformation + }; + } + ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain; function createDiagnosticForRange(sourceFile, range, message) { return { file: sourceFile, @@ -17150,16 +17160,7 @@ var ts; var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = removeFileExtension(relativePath); - if (referencePath) { - return ts.ensurePathIsNonModuleName(extensionless); - } - var options = host.getCompilerOptions(); - var rootPkgName = options.bundledPackageName || ""; - var newPath = ts.combinePaths(rootPkgName, extensionless); - if (rootPkgName && getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && ts.endsWith(newPath, "/index")) { - return newPath.slice(0, newPath.length - "/index".length); - } - return newPath; + return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless; } ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; function getOwnEmitOutputFilePath(fileName, host, extension) { @@ -36741,13 +36742,6 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, - { - name: "bundledPackageName", - type: "string", - affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Provides_a_root_package_name_when_using_outFile_with_declarations, - }, { name: "keyofStringsOnly", type: "boolean", @@ -44309,6 +44303,16 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { + // Pseudo-synthesized input node + if (location.pos < 0 || location.end < 0) { + if (!isError) { + return; // Drop suggestions (we have no span to suggest on) + } + // Issue errors globally + var file = ts.getSourceFileOfNode(location); + addErrorOrSuggestion(isError, "message" in message ? ts.createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForFileFromMessageChain(file, message)); // eslint-disable-line no-in-operator + return; + } addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { @@ -47311,7 +47315,6 @@ var ts; getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); }, isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); }, fileExists: function (fileName) { return host.fileExists(fileName); }, - getCompilerOptions: function () { return host.getCompilerOptions(); } } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -48790,8 +48793,7 @@ var ts; var resolverHost = { getCanonicalFileName: getCanonicalFileName, getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); }, - getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }, - getCompilerOptions: function () { return context.tracker.moduleResolverHost.getCompilerOptions(); } + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } }; var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); return ts.factory.createStringLiteral(newName); @@ -107394,10 +107396,6 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile")); } } - // Without a package name, for multiple files being bundled into a .d.ts file you basically get a file which doesn't wrk - if (outputFile && ts.getEmitDeclarations(options) && ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && !options.bundledPackageName) { - createDiagnosticForOptionName(ts.Diagnostics.The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit, options.out ? "out" : "outFile"); - } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); @@ -110254,7 +110252,7 @@ var ts; function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs, bundledPackageName = compilerOptions.bundledPackageName; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { @@ -110265,9 +110263,8 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var bundledPkgReference = bundledPackageName ? ts.combinePaths(bundledPackageName, relativeToBaseUrl) : relativeToBaseUrl; - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(bundledPkgReference, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(bundledPkgReference), importRelativeToBaseUrl, paths); + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); + var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; if (!nonRelative) { return relativePath; @@ -115417,8 +115414,7 @@ var ts; getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); }, - isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); }, - getCompilerOptions: function () { return program.getCompilerOptions(); } + isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); } }; } ts.createModuleSpecifierResolutionHost = createModuleSpecifierResolutionHost; @@ -147433,7 +147429,7 @@ var ts; * This is a semantic operation. */ function getSignatureHelpItems(fileName, position, _a) { - var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; + var _b = _a === void 0 ? ts.emptyOptions : _a, triggerReason = _b.triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index d3761ec495f84..9a8352c81e8b2 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -2790,7 +2790,6 @@ declare namespace ts { allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; - bundledPackageName?: string; charset?: string; checkJs?: boolean; declaration?: boolean; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index e668c5c75f80d..0d927b0a26d35 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -288,7 +288,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.1-rc"; + ts.version = "4.1.2"; /* @internal */ var Comparison; (function (Comparison) { @@ -7991,8 +7991,6 @@ var ts; Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."), Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), - Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -14241,6 +14239,18 @@ var ts; }; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) { + return { + file: sourceFile, + start: 0, + length: 0, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText, + relatedInformation: relatedInformation + }; + } + ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain; function createDiagnosticForRange(sourceFile, range, message) { return { file: sourceFile, @@ -17150,16 +17160,7 @@ var ts; var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = removeFileExtension(relativePath); - if (referencePath) { - return ts.ensurePathIsNonModuleName(extensionless); - } - var options = host.getCompilerOptions(); - var rootPkgName = options.bundledPackageName || ""; - var newPath = ts.combinePaths(rootPkgName, extensionless); - if (rootPkgName && getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && ts.endsWith(newPath, "/index")) { - return newPath.slice(0, newPath.length - "/index".length); - } - return newPath; + return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless; } ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; function getOwnEmitOutputFilePath(fileName, host, extension) { @@ -36741,13 +36742,6 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, - { - name: "bundledPackageName", - type: "string", - affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Provides_a_root_package_name_when_using_outFile_with_declarations, - }, { name: "keyofStringsOnly", type: "boolean", @@ -44309,6 +44303,16 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { + // Pseudo-synthesized input node + if (location.pos < 0 || location.end < 0) { + if (!isError) { + return; // Drop suggestions (we have no span to suggest on) + } + // Issue errors globally + var file = ts.getSourceFileOfNode(location); + addErrorOrSuggestion(isError, "message" in message ? ts.createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForFileFromMessageChain(file, message)); // eslint-disable-line no-in-operator + return; + } addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { @@ -47311,7 +47315,6 @@ var ts; getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); }, isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); }, fileExists: function (fileName) { return host.fileExists(fileName); }, - getCompilerOptions: function () { return host.getCompilerOptions(); } } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -48790,8 +48793,7 @@ var ts; var resolverHost = { getCanonicalFileName: getCanonicalFileName, getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); }, - getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }, - getCompilerOptions: function () { return context.tracker.moduleResolverHost.getCompilerOptions(); } + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } }; var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); return ts.factory.createStringLiteral(newName); @@ -107394,10 +107396,6 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile")); } } - // Without a package name, for multiple files being bundled into a .d.ts file you basically get a file which doesn't wrk - if (outputFile && ts.getEmitDeclarations(options) && ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && !options.bundledPackageName) { - createDiagnosticForOptionName(ts.Diagnostics.The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit, options.out ? "out" : "outFile"); - } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); @@ -110254,7 +110252,7 @@ var ts; function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs, bundledPackageName = compilerOptions.bundledPackageName; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { @@ -110265,9 +110263,8 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var bundledPkgReference = bundledPackageName ? ts.combinePaths(bundledPackageName, relativeToBaseUrl) : relativeToBaseUrl; - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(bundledPkgReference, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(bundledPkgReference), importRelativeToBaseUrl, paths); + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); + var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; if (!nonRelative) { return relativePath; @@ -115417,8 +115414,7 @@ var ts; getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); }, - isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); }, - getCompilerOptions: function () { return program.getCompilerOptions(); } + isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); } }; } ts.createModuleSpecifierResolutionHost = createModuleSpecifierResolutionHost; @@ -147433,7 +147429,7 @@ var ts; * This is a semantic operation. */ function getSignatureHelpItems(fileName, position, _a) { - var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; + var _b = _a === void 0 ? ts.emptyOptions : _a, triggerReason = _b.triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index b796d0f66ebff..c2fdee805487a 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -83,7 +83,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.1-rc"; + ts.version = "4.1.2"; /* @internal */ var Comparison; (function (Comparison) { @@ -7786,8 +7786,6 @@ var ts; Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."), Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), - Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -14036,6 +14034,18 @@ var ts; }; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) { + return { + file: sourceFile, + start: 0, + length: 0, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText, + relatedInformation: relatedInformation + }; + } + ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain; function createDiagnosticForRange(sourceFile, range, message) { return { file: sourceFile, @@ -16945,16 +16955,7 @@ var ts; var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = removeFileExtension(relativePath); - if (referencePath) { - return ts.ensurePathIsNonModuleName(extensionless); - } - var options = host.getCompilerOptions(); - var rootPkgName = options.bundledPackageName || ""; - var newPath = ts.combinePaths(rootPkgName, extensionless); - if (rootPkgName && getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && ts.endsWith(newPath, "/index")) { - return newPath.slice(0, newPath.length - "/index".length); - } - return newPath; + return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless; } ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; function getOwnEmitOutputFilePath(fileName, host, extension) { @@ -36536,13 +36537,6 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, - { - name: "bundledPackageName", - type: "string", - affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Provides_a_root_package_name_when_using_outFile_with_declarations, - }, { name: "keyofStringsOnly", type: "boolean", @@ -44104,6 +44098,16 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { + // Pseudo-synthesized input node + if (location.pos < 0 || location.end < 0) { + if (!isError) { + return; // Drop suggestions (we have no span to suggest on) + } + // Issue errors globally + var file = ts.getSourceFileOfNode(location); + addErrorOrSuggestion(isError, "message" in message ? ts.createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForFileFromMessageChain(file, message)); // eslint-disable-line no-in-operator + return; + } addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { @@ -47106,7 +47110,6 @@ var ts; getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); }, isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); }, fileExists: function (fileName) { return host.fileExists(fileName); }, - getCompilerOptions: function () { return host.getCompilerOptions(); } } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -48585,8 +48588,7 @@ var ts; var resolverHost = { getCanonicalFileName: getCanonicalFileName, getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); }, - getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }, - getCompilerOptions: function () { return context.tracker.moduleResolverHost.getCompilerOptions(); } + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } }; var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); return ts.factory.createStringLiteral(newName); @@ -107189,10 +107191,6 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile")); } } - // Without a package name, for multiple files being bundled into a .d.ts file you basically get a file which doesn't wrk - if (outputFile && ts.getEmitDeclarations(options) && ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeJs && !options.bundledPackageName) { - createDiagnosticForOptionName(ts.Diagnostics.The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit, options.out ? "out" : "outFile"); - } if (options.resolveJsonModule) { if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); @@ -110049,7 +110047,7 @@ var ts; function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs, bundledPackageName = compilerOptions.bundledPackageName; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { @@ -110060,9 +110058,8 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var bundledPkgReference = bundledPackageName ? ts.combinePaths(bundledPackageName, relativeToBaseUrl) : relativeToBaseUrl; - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(bundledPkgReference, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(bundledPkgReference), importRelativeToBaseUrl, paths); + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); + var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; if (!nonRelative) { return relativePath; diff --git a/package.json b/package.json index 8692d8475e4a6..c52de3d8a2a1d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.1.1-rc", + "version": "4.1.2", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 28d791da82668..a5f4eb2228a51 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -3,7 +3,7 @@ namespace ts { // If changing the text in this section, be sure to test `configurePrerelease` too. export const versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - export const version = "4.1.1-rc" as string; + export const version = "4.1.2" as string; /** * Type of objects whose values are all of the same type.