for both TV and TRV.
- text = text.replace(/\r\n?/g, "\n");
- return ts.setTextRange(ts.createLiteral(text), node);
+ return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.All);
}
/**
* Visits a TemplateExpression node.
@@ -183488,14 +189124,6 @@ var ts;
ts.createFileLevelUniqueName("_super")
]);
}
- function createTemplateObjectHelper(context, cooked, raw) {
- context.requestEmitHelper(ts.templateObjectHelper);
- return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"),
- /*typeArguments*/ undefined, [
- cooked,
- raw
- ]);
- }
ts.extendsHelper = {
name: "typescript:extends",
importName: "__extends",
@@ -183503,13 +189131,6 @@ var ts;
priority: 0,
text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();"
};
- ts.templateObjectHelper = {
- name: "typescript:makeTemplateObject",
- importName: "__makeTemplateObject",
- scoped: false,
- priority: 0,
- text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };"
- };
})(ts || (ts = {}));
/*@internal*/
var ts;
@@ -186327,16 +191948,14 @@ var ts;
if (shouldEmitUnderscoreUnderscoreESModule()) {
ts.append(statements, createUnderscoreUnderscoreESModule());
}
+ if (ts.length(currentModuleInfo.exportedNames)) {
+ ts.append(statements, ts.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(ts.idText(nextId))), prev); }, ts.createVoidZero())));
+ }
ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false);
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements));
- if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) {
- // If we have any `export * from ...` declarations
- // we need to inform the emitter to add the __export helper.
- ts.addEmitHelper(updated, exportStarHelper);
- }
ts.addEmitHelpers(updated, context.readEmitHelpers());
return updated;
}
@@ -186546,6 +192165,9 @@ var ts;
if (shouldEmitUnderscoreUnderscoreESModule()) {
ts.append(statements, createUnderscoreUnderscoreESModule());
}
+ if (ts.length(currentModuleInfo.exportedNames)) {
+ ts.append(statements, ts.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(ts.idText(nextId))), prev); }, ts.createVoidZero())));
+ }
// Visit each statement of the module body.
ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
if (moduleKind === ts.ModuleKind.AMD) {
@@ -186558,11 +192180,6 @@ var ts;
// and merge any new lexical declarations.
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
var body = ts.createBlock(statements, /*multiLine*/ true);
- if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) {
- // If we have any `export * from ...` declarations
- // we need to inform the emitter to add the __export helper.
- ts.addEmitHelper(body, exportStarHelper);
- }
if (needUMDDynamicImportHelper) {
ts.addEmitHelper(body, dynamicImportUMDHelper);
}
@@ -186619,9 +192236,9 @@ var ts;
return visitFunctionDeclaration(node);
case 245 /* ClassDeclaration */:
return visitClassDeclaration(node);
- case 327 /* MergeDeclarationMarker */:
+ case 328 /* MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 328 /* EndOfDeclarationMarker */:
+ case 329 /* EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
@@ -186979,8 +192596,13 @@ var ts;
}
for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) {
var specifier = _a[_i];
- var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name);
- statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier), specifier));
+ if (languageVersion === 0 /* ES3 */) {
+ statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createCreateBindingHelper(context, generatedName, ts.createLiteral(specifier.propertyName || specifier.name), specifier.propertyName ? ts.createLiteral(specifier.name) : undefined)), specifier), specifier));
+ }
+ else {
+ var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name);
+ statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier));
+ }
}
return ts.singleOrMany(statements);
}
@@ -187083,7 +192705,6 @@ var ts;
if (ts.hasModifier(node, 1 /* Export */)) {
var modifiers = void 0;
// If we're exporting these variables, then these just become assignments to 'exports.x'.
- // We only want to emit assignments for variables with initializers.
for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
var variable = _a[_i];
if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) {
@@ -187144,7 +192765,7 @@ var ts;
}
else {
return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name),
- /*location*/ node.name), ts.visitNode(node.initializer, moduleExpressionElementVisitor));
+ /*location*/ node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : ts.createVoidZero());
}
}
/**
@@ -187222,7 +192843,7 @@ var ts;
case 257 /* NamedImports */:
for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
var importBinding = _a[_i];
- statements = appendExportsOfDeclaration(statements, importBinding);
+ statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true);
}
break;
}
@@ -187319,13 +192940,13 @@ var ts;
* appended.
* @param decl The declaration to export.
*/
- function appendExportsOfDeclaration(statements, decl) {
+ function appendExportsOfDeclaration(statements, decl, liveBinding) {
var name = ts.getDeclarationName(decl);
var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name));
if (exportSpecifiers) {
for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) {
var exportSpecifier = exportSpecifiers_1[_i];
- statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name);
+ statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name, /* allowComments */ undefined, liveBinding);
}
}
return statements;
@@ -187342,8 +192963,8 @@ var ts;
* @param location The location to use for source maps and comments for the export.
* @param allowComments Whether to allow comments on the export.
*/
- function appendExportStatement(statements, exportName, expression, location, allowComments) {
- statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments));
+ function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) {
+ statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
return statements;
}
function createUnderscoreUnderscoreESModule() {
@@ -187372,8 +192993,8 @@ var ts;
* @param location The location to use for source maps and comments for the export.
* @param allowComments An optional value indicating whether to emit comments for the statement.
*/
- function createExportStatement(name, value, location, allowComments) {
- var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location);
+ function createExportStatement(name, value, location, allowComments, liveBinding) {
+ var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location);
ts.startOnNewLine(statement);
if (!allowComments) {
ts.setEmitFlags(statement, 1536 /* NoComments */);
@@ -187387,8 +193008,22 @@ var ts;
* @param value The exported value.
* @param location The location to use for source maps and comments for the export.
*/
- function createExportExpression(name, value, location) {
- return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location);
+ function createExportExpression(name, value, location, liveBinding) {
+ return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"),
+ /*typeArguments*/ undefined, [
+ ts.createIdentifier("exports"),
+ ts.createLiteral(name),
+ ts.createObjectLiteral([
+ ts.createPropertyAssignment("enumerable", ts.createLiteral(/*value*/ true)),
+ ts.createPropertyAssignment("get", ts.createFunctionExpression(
+ /*modifiers*/ undefined,
+ /*asteriskToken*/ undefined,
+ /*name*/ undefined,
+ /*typeParameters*/ undefined,
+ /*parameters*/ [],
+ /*type*/ undefined, ts.createBlock([ts.createReturn(value)])))
+ ])
+ ]) : ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location);
}
//
// Modifier Visitors
@@ -187613,17 +193248,36 @@ var ts;
}
}
ts.transformModule = transformModule;
+ ts.createBindingHelper = {
+ name: "typescript:commonjscreatebinding",
+ importName: "__createBinding",
+ scoped: false,
+ priority: 1,
+ text: "\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));"
+ };
+ function createCreateBindingHelper(context, module, inputName, outputName) {
+ context.requestEmitHelper(ts.createBindingHelper);
+ return ts.createCall(ts.getUnscopedHelperName("__createBinding"), /*typeArguments*/ undefined, __spreadArrays([ts.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : [])));
+ }
+ ts.setModuleDefaultHelper = {
+ name: "typescript:commonjscreatevalue",
+ importName: "__setModuleDefault",
+ scoped: false,
+ priority: 1,
+ text: "\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});"
+ };
// emit output for the __export helper function
var exportStarHelper = {
name: "typescript:export-star",
- scoped: true,
- text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }"
+ importName: "__exportStar",
+ scoped: false,
+ dependencies: [ts.createBindingHelper],
+ priority: 2,
+ text: "\n var __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);\n };"
};
function createExportStarHelper(context, module) {
- var compilerOptions = context.getCompilerOptions();
- return compilerOptions.importHelpers
- ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")])
- : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]);
+ context.requestEmitHelper(exportStarHelper);
+ return ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]);
}
// emit helper for dynamic import
var dynamicImportUMDHelper = {
@@ -187636,7 +193290,9 @@ var ts;
name: "typescript:commonjsimportstar",
importName: "__importStar",
scoped: false,
- text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};"
+ dependencies: [ts.createBindingHelper, ts.setModuleDefaultHelper],
+ priority: 2,
+ text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};"
};
// emit helper for `import Name from "foo"`
ts.importDefaultHelper = {
@@ -188100,7 +193756,7 @@ var ts;
return ts.singleOrMany(statements);
}
function visitExportDeclaration(node) {
- ts.Debug.assertDefined(node);
+ ts.Debug.assertIsDefined(node);
return undefined;
}
/**
@@ -188596,9 +194252,9 @@ var ts;
return visitCatchClause(node);
case 223 /* Block */:
return visitBlock(node);
- case 327 /* MergeDeclarationMarker */:
+ case 328 /* MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 328 /* EndOfDeclarationMarker */:
+ case 329 /* EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return destructuringAndImportCallVisitor(node);
@@ -189741,7 +195397,8 @@ var ts;
reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError,
moduleResolverHost: host,
trackReferencedAmbientModule: trackReferencedAmbientModule,
- trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode
+ trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
+ reportNonlocalAugmentation: reportNonlocalAugmentation
};
var errorNameNode;
var currentSourceFile;
@@ -189832,6 +195489,14 @@ var ts;
context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier));
}
}
+ function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) {
+ var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
+ var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
+ for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
+ var augmentations = augmentingDeclarations_1[_i];
+ context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file)));
+ }
+ }
function transformDeclarationsForJS(sourceFile, bundled) {
var oldDiag = getSymbolAccessibilityDiagnostic;
getSymbolAccessibilityDiagnostic = function (s) { return ({
@@ -189970,8 +195635,8 @@ var ts;
declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName;
}
if (declFileName) {
- var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, host.getSourceFiles(),
- /*preferences*/ undefined, host.redirectTargetsMap);
+ var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host,
+ /*preferences*/ undefined);
if (!ts.pathIsRelative(specifier)) {
// If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration
// via a non-relative name, emit a type reference directive to that non-relative name, rather than
@@ -189986,7 +195651,7 @@ var ts;
}
// omit references to files from node_modules (npm may disambiguate module
// references when installing this package, making the path is unreliable).
- if (ts.startsWith(fileName, "node_modules/") || fileName.indexOf("/node_modules/") !== -1) {
+ if (ts.startsWith(fileName, "node_modules/") || ts.pathContainsNodeModules(fileName)) {
return;
}
references.push({ pos: -1, end: -1, fileName: fileName });
@@ -190259,6 +195924,12 @@ var ts;
return ts.updateImportDeclaration(decl,
/*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, bindingList && bindingList.length ? ts.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
}
+ // Augmentation of export depends on import
+ if (resolver.isImportRequiredByAugmentation(decl)) {
+ return ts.updateImportDeclaration(decl,
+ /*decorators*/ undefined, decl.modifiers,
+ /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
+ }
// Nothing visible
}
function transformAndReplaceLatePaintedStatements(statements) {
@@ -191092,11 +196763,15 @@ var ts;
* @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files.
*/
function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) {
- var enabledSyntaxKindFeatures = new Array(330 /* Count */);
+ var enabledSyntaxKindFeatures = new Array(331 /* Count */);
var lexicalEnvironmentVariableDeclarations;
var lexicalEnvironmentFunctionDeclarations;
+ var lexicalEnvironmentStatements;
+ var lexicalEnvironmentFlags = 0 /* None */;
var lexicalEnvironmentVariableDeclarationsStack = [];
var lexicalEnvironmentFunctionDeclarationsStack = [];
+ var lexicalEnvironmentStatementsStack = [];
+ var lexicalEnvironmentFlagsStack = [];
var lexicalEnvironmentStackOffset = 0;
var lexicalEnvironmentSuspended = false;
var emitHelpers;
@@ -191114,8 +196789,11 @@ var ts;
suspendLexicalEnvironment: suspendLexicalEnvironment,
resumeLexicalEnvironment: resumeLexicalEnvironment,
endLexicalEnvironment: endLexicalEnvironment,
+ setLexicalEnvironmentFlags: setLexicalEnvironmentFlags,
+ getLexicalEnvironmentFlags: getLexicalEnvironmentFlags,
hoistVariableDeclaration: hoistVariableDeclaration,
hoistFunctionDeclaration: hoistFunctionDeclaration,
+ addInitializationStatement: addInitializationStatement,
requestEmitHelper: requestEmitHelper,
readEmitHelpers: readEmitHelpers,
enableSubstitution: enableSubstitution,
@@ -191245,6 +196923,9 @@ var ts;
else {
lexicalEnvironmentVariableDeclarations.push(decl);
}
+ if (lexicalEnvironmentFlags & 1 /* InParameters */) {
+ lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */;
+ }
}
/**
* Records a hoisted function declaration within a lexical environment.
@@ -191252,6 +196933,7 @@ var ts;
function hoistFunctionDeclaration(func) {
ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization.");
ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
+ ts.setEmitFlags(func, 1048576 /* CustomPrologue */);
if (!lexicalEnvironmentFunctionDeclarations) {
lexicalEnvironmentFunctionDeclarations = [func];
}
@@ -191259,6 +196941,20 @@ var ts;
lexicalEnvironmentFunctionDeclarations.push(func);
}
}
+ /**
+ * Adds an initialization statement to the top of the lexical environment.
+ */
+ function addInitializationStatement(node) {
+ ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization.");
+ ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
+ ts.setEmitFlags(node, 1048576 /* CustomPrologue */);
+ if (!lexicalEnvironmentStatements) {
+ lexicalEnvironmentStatements = [node];
+ }
+ else {
+ lexicalEnvironmentStatements.push(node);
+ }
+ }
/**
* Starts a new lexical environment. Any existing hoisted variable or function declarations
* are pushed onto a stack, and the related storage variables are reset.
@@ -191273,9 +196969,13 @@ var ts;
// transformation.
lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
+ lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements;
+ lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags;
lexicalEnvironmentStackOffset++;
lexicalEnvironmentVariableDeclarations = undefined;
lexicalEnvironmentFunctionDeclarations = undefined;
+ lexicalEnvironmentStatements = undefined;
+ lexicalEnvironmentFlags = 0 /* None */;
}
/** Suspends the current lexical environment, usually after visiting a parameter list. */
function suspendLexicalEnvironment() {
@@ -191300,7 +197000,9 @@ var ts;
ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
var statements;
- if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) {
+ if (lexicalEnvironmentVariableDeclarations ||
+ lexicalEnvironmentFunctionDeclarations ||
+ lexicalEnvironmentStatements) {
if (lexicalEnvironmentFunctionDeclarations) {
statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations);
}
@@ -191315,21 +197017,47 @@ var ts;
statements.push(statement);
}
}
+ if (lexicalEnvironmentStatements) {
+ if (!statements) {
+ statements = __spreadArrays(lexicalEnvironmentStatements);
+ }
+ else {
+ statements = __spreadArrays(statements, lexicalEnvironmentStatements);
+ }
+ }
}
// Restore the previous lexical environment.
lexicalEnvironmentStackOffset--;
lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
+ lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
+ lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
if (lexicalEnvironmentStackOffset === 0) {
lexicalEnvironmentVariableDeclarationsStack = [];
lexicalEnvironmentFunctionDeclarationsStack = [];
+ lexicalEnvironmentStatementsStack = [];
+ lexicalEnvironmentFlagsStack = [];
}
return statements;
}
+ function setLexicalEnvironmentFlags(flags, value) {
+ lexicalEnvironmentFlags = value ?
+ lexicalEnvironmentFlags | flags :
+ lexicalEnvironmentFlags & ~flags;
+ }
+ function getLexicalEnvironmentFlags() {
+ return lexicalEnvironmentFlags;
+ }
function requestEmitHelper(helper) {
ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization.");
ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed.");
ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
+ if (helper.dependencies) {
+ for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) {
+ var h = _a[_i];
+ requestEmitHelper(h);
+ }
+ }
emitHelpers = ts.append(emitHelpers, helper);
}
function readEmitHelpers() {
@@ -191493,7 +197221,7 @@ var ts;
}
ts.getOutputExtension = getOutputExtension;
function rootDirOfOptions(configFile) {
- return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath));
+ return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.checkDefined(configFile.options.configFilePath));
}
function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) {
return outputDir ?
@@ -191515,7 +197243,7 @@ var ts;
ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ?
".jsx" /* Jsx */ :
".js" /* Js */);
- return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.assertDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ?
+ return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ?
outputFileName :
undefined;
}
@@ -191590,7 +197318,7 @@ var ts;
function getFirstProjectOutput(configFile, ignoreCase) {
if (configFile.options.outFile || configFile.options.out) {
var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath;
- return ts.Debug.assertDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output");
+ return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output");
}
for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
var inputFileName = _b[_a];
@@ -191878,7 +197606,7 @@ var ts;
var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText);
return "data:application/json;base64," + base64SourceMapText;
}
- var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.assertDefined(sourceMapFilePath)));
+ var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath)));
if (mapOptions.mapRoot) {
var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
if (sourceFile) {
@@ -191953,6 +197681,7 @@ var ts;
getSymbolOfExternalModuleSpecifier: ts.notImplemented,
isBindingCapturedByNode: ts.notImplemented,
getDeclarationStatementsForSourceFile: ts.notImplemented,
+ isImportRequiredByAugmentation: ts.notImplemented,
};
function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
var sourceFiles = bundle.sourceFiles.map(function (fileName) {
@@ -191962,7 +197691,7 @@ var ts;
sourceFile.statements = ts.createNodeArray();
return sourceFile;
});
- var jsBundle = ts.Debug.assertDefined(bundle.js);
+ var jsBundle = ts.Debug.checkDefined(bundle.js);
ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) {
var sourceFile = sourceFiles[prologueInfo.file];
sourceFile.text = prologueInfo.text;
@@ -191979,10 +197708,10 @@ var ts;
/*@internal*/
function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
- var buildInfoText = host.readFile(ts.Debug.assertDefined(buildInfoPath));
+ var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
if (!buildInfoText)
return buildInfoPath;
- var jsFileText = host.readFile(ts.Debug.assertDefined(jsFilePath));
+ var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
if (!jsFileText)
return jsFilePath;
var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
@@ -192019,6 +197748,7 @@ var ts;
getLibFileFromReference: ts.notImplemented,
isSourceFileFromExternalLibrary: ts.returnFalse,
getResolvedProjectReferenceToRedirect: ts.returnUndefined,
+ getProjectReferenceRedirect: ts.returnUndefined,
isSourceOfProjectReferenceRedirect: ts.returnFalse,
writeFile: function (name, text, writeByteOrderMark) {
switch (name) {
@@ -192058,7 +197788,6 @@ var ts;
isEmitBlocked: ts.returnFalse,
readFile: function (f) { return host.readFile(f); },
fileExists: function (f) { return host.fileExists(f); },
- directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }),
useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
getProgramBuildInfo: ts.returnUndefined,
getSourceFileFromReference: ts.returnUndefined,
@@ -192093,12 +197822,13 @@ var ts;
var tempFlags; // TempFlags for the current name generation scope.
var reservedNamesStack; // Stack of TempFlags reserved in enclosing name generation scopes.
var reservedNames; // TempFlags to reserve in nested name generation scopes.
+ var preserveSourceNewlines = printerOptions.preserveSourceNewlines; // Can be overridden inside nodes with the `IgnoreSourceNewlines` emit flag.
var writer;
var ownWriter; // Reusable `EmitTextWriter` for basic printing.
var write = writeBase;
var isOwnFileEmit;
var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined;
- var relativeToBuildInfo = bundleFileInfo ? ts.Debug.assertDefined(printerOptions.relativeToBuildInfo) : undefined;
+ var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
var recordInternalSection = printerOptions.recordInternalSection;
var sourceFileTextPos = 0;
var sourceFileTextKind = "text" /* Text */;
@@ -192375,14 +198105,19 @@ var ts;
function pipelineEmit(emitHint, node) {
var savedLastNode = lastNode;
var savedLastSubstitution = lastSubstitution;
+ var savedPreserveSourceNewlines = preserveSourceNewlines;
lastNode = node;
lastSubstitution = undefined;
+ if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) {
+ preserveSourceNewlines = false;
+ }
var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node);
pipelinePhase(emitHint, node);
ts.Debug.assert(lastNode === node);
var substitute = lastSubstitution;
lastNode = savedLastNode;
lastSubstitution = savedLastSubstitution;
+ preserveSourceNewlines = savedPreserveSourceNewlines;
return substitute || node;
}
function getPipelinePhase(phase, emitHint, node) {
@@ -192692,27 +198427,28 @@ var ts;
case 284 /* EnumMember */:
return emitEnumMember(node);
// JSDoc nodes (only used in codefixes currently)
- case 316 /* JSDocParameterTag */:
- case 322 /* JSDocPropertyTag */:
+ case 317 /* JSDocParameterTag */:
+ case 323 /* JSDocPropertyTag */:
return emitJSDocPropertyLikeTag(node);
- case 317 /* JSDocReturnTag */:
- case 319 /* JSDocTypeTag */:
- case 318 /* JSDocThisTag */:
- case 315 /* JSDocEnumTag */:
+ case 318 /* JSDocReturnTag */:
+ case 320 /* JSDocTypeTag */:
+ case 319 /* JSDocThisTag */:
+ case 316 /* JSDocEnumTag */:
return emitJSDocSimpleTypedTag(node);
+ case 308 /* JSDocImplementsTag */:
case 307 /* JSDocAugmentsTag */:
- return emitJSDocAugmentsTag(node);
- case 320 /* JSDocTemplateTag */:
+ return emitJSDocHeritageTag(node);
+ case 321 /* JSDocTemplateTag */:
return emitJSDocTemplateTag(node);
- case 321 /* JSDocTypedefTag */:
+ case 322 /* JSDocTypedefTag */:
return emitJSDocTypedefTag(node);
- case 314 /* JSDocCallbackTag */:
+ case 315 /* JSDocCallbackTag */:
return emitJSDocCallbackTag(node);
case 305 /* JSDocSignature */:
return emitJSDocSignature(node);
case 304 /* JSDocTypeLiteral */:
return emitJSDocTypeLiteral(node);
- case 309 /* JSDocClassTag */:
+ case 310 /* JSDocClassTag */:
case 306 /* JSDocTag */:
return emitJSDocSimpleTag(node);
case 303 /* JSDocComment */:
@@ -192814,9 +198550,9 @@ var ts;
case 270 /* JsxFragment */:
return emitJsxFragment(node);
// Transformation nodes
- case 325 /* PartiallyEmittedExpression */:
+ case 326 /* PartiallyEmittedExpression */:
return emitPartiallyEmittedExpression(node);
- case 326 /* CommaListExpression */:
+ case 327 /* CommaListExpression */:
return emitCommaList(node);
}
}
@@ -193367,10 +199103,10 @@ var ts;
}
function emitPropertyAccessExpression(node) {
var expression = ts.cast(emitExpression(node.expression), ts.isExpression);
- var token = ts.getDotOrQuestionDotToken(node);
- var indentBeforeDot = needsIndentation(node, node.expression, token);
- var indentAfterDot = needsIndentation(node, token, node.name);
- increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false);
+ var token = node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos);
+ var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
+ var linesAfterDot = getLinesBetweenNodes(node, token, node.name);
+ writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false);
var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ &&
mayNeedDotDotForPropertyAccess(expression) &&
!writer.hasTrailingComment() &&
@@ -193378,10 +199114,15 @@ var ts;
if (shouldEmitDotDot) {
writePunctuation(".");
}
- emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
- increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false);
+ if (node.questionDotToken) {
+ emit(token);
+ }
+ else {
+ emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
+ }
+ writeLinesAndIndent(linesAfterDot, /*writeSpaceIfNotIndenting*/ false);
emit(node.name);
- decreaseIndentIf(indentBeforeDot, indentAfterDot);
+ decreaseIndentIf(linesBeforeDot, linesAfterDot);
}
// 1..toString is a valid property access, emit a dot after the literal
// Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal
@@ -193436,7 +199177,10 @@ var ts;
}
function emitParenthesizedExpression(node) {
var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node);
+ var indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
emitExpression(node.expression);
+ writeLineSeparatorsAfter(node.expression, node);
+ decreaseIndentIf(indented);
emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
}
function emitFunctionExpression(node) {
@@ -193528,20 +199272,20 @@ var ts;
}
case 1 /* EmitRight */: {
var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */;
- var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken);
- var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right);
- increaseIndentIf(indentBeforeOperator, isCommaOperator);
+ var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
+ var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
+ writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
emitLeadingCommentsOfPosition(node.operatorToken.pos);
writeTokenNode(node.operatorToken, node.operatorToken.kind === 97 /* InKeyword */ ? writeKeyword : writeOperator);
emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts
- increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true);
+ writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true);
maybePipelineEmitExpression(node.right);
break;
}
case 2 /* FinishEmit */: {
- var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken);
- var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right);
- decreaseIndentIf(indentBeforeOperator, indentAfterOperator);
+ var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
+ var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
+ decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
stackIndex--;
break;
}
@@ -193577,21 +199321,21 @@ var ts;
}
}
function emitConditionalExpression(node) {
- var indentBeforeQuestion = needsIndentation(node, node.condition, node.questionToken);
- var indentAfterQuestion = needsIndentation(node, node.questionToken, node.whenTrue);
- var indentBeforeColon = needsIndentation(node, node.whenTrue, node.colonToken);
- var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse);
+ var linesBeforeQuestion = getLinesBetweenNodes(node, node.condition, node.questionToken);
+ var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue);
+ var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken);
+ var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse);
emitExpression(node.condition);
- increaseIndentIf(indentBeforeQuestion, /*writeSpaceIfNotIndenting*/ true);
+ writeLinesAndIndent(linesBeforeQuestion, /*writeSpaceIfNotIndenting*/ true);
emit(node.questionToken);
- increaseIndentIf(indentAfterQuestion, /*writeSpaceIfNotIndenting*/ true);
+ writeLinesAndIndent(linesAfterQuestion, /*writeSpaceIfNotIndenting*/ true);
emitExpression(node.whenTrue);
- decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion);
- increaseIndentIf(indentBeforeColon, /*writeSpaceIfNotIndenting*/ true);
+ decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion);
+ writeLinesAndIndent(linesBeforeColon, /*writeSpaceIfNotIndenting*/ true);
emit(node.colonToken);
- increaseIndentIf(indentAfterColon, /*writeSpaceIfNotIndenting*/ true);
+ writeLinesAndIndent(linesAfterColon, /*writeSpaceIfNotIndenting*/ true);
emitExpression(node.whenFalse);
- decreaseIndentIf(indentBeforeColon, indentAfterColon);
+ decreaseIndentIf(linesBeforeColon, linesAfterColon);
}
function emitTemplateExpression(node) {
emit(node.head);
@@ -193932,14 +199676,14 @@ var ts;
if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
return false;
}
- if (shouldWriteLeadingLineTerminator(body, body.statements, 2 /* PreserveLines */)
- || shouldWriteClosingLineTerminator(body, body.statements, 2 /* PreserveLines */)) {
+ if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)
+ || getClosingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)) {
return false;
}
var previousStatement;
for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
var statement = _b[_a];
- if (shouldWriteSeparatingLineTerminator(previousStatement, statement, 2 /* PreserveLines */)) {
+ if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) {
return false;
}
previousStatement = statement;
@@ -194232,12 +199976,15 @@ var ts;
function emitJsxOpeningElementOrFragment(node) {
writePunctuation("<");
if (ts.isJsxOpeningElement(node)) {
+ var indented = writeLineSeparatorsAndIndentBefore(node.tagName, node);
emitJsxTagName(node.tagName);
emitTypeArguments(node, node.typeArguments);
if (node.attributes.properties && node.attributes.properties.length > 0) {
writeSpace();
}
emit(node.attributes);
+ writeLineSeparatorsAfter(node.attributes, node);
+ decreaseIndentIf(indented);
}
writePunctuation(">");
}
@@ -194387,7 +200134,7 @@ var ts;
}
}
if (node.tags) {
- if (node.tags.length === 1 && node.tags[0].kind === 319 /* JSDocTypeTag */ && !node.comment) {
+ if (node.tags.length === 1 && node.tags[0].kind === 320 /* JSDocTypeTag */ && !node.comment) {
writeSpace();
emit(node.tags[0]);
}
@@ -194403,7 +200150,7 @@ var ts;
emitJSDocTypeExpression(tag.typeExpression);
emitJSDocComment(tag.comment);
}
- function emitJSDocAugmentsTag(tag) {
+ function emitJSDocHeritageTag(tag) {
emitJSDocTagName(tag.tagName);
writeSpace();
writePunctuation("{");
@@ -194574,8 +200321,8 @@ var ts;
bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName });
writeLine();
}
- for (var _d = 0, types_21 = types; _d < types_21.length; _d++) {
- var directive = types_21[_d];
+ for (var _d = 0, types_22 = types; _d < types_22.length; _d++) {
+ var directive = types_22[_d];
var pos = writer.getTextPos();
writeComment("/// ");
if (bundleFileInfo)
@@ -194802,7 +200549,7 @@ var ts;
}
}
function emitDecorators(parentNode, decorators) {
- emitList(parentNode, decorators, 49153 /* Decorators */);
+ emitList(parentNode, decorators, 2146305 /* Decorators */);
}
function emitTypeArguments(parentNode, typeArguments) {
emitList(parentNode, typeArguments, 53776 /* TypeArguments */);
@@ -194901,7 +200648,7 @@ var ts;
}
if (isEmpty) {
// Write a line terminator if the parent node was multi-line
- if (format & 1 /* MultiLine */) {
+ if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) {
writeLine();
}
else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) {
@@ -194912,8 +200659,9 @@ var ts;
// Write the opening line terminator or leading whitespace.
var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0;
var shouldEmitInterveningComments = mayEmitInterveningComments;
- if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217
- writeLine();
+ var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); // TODO: GH#18217
+ if (leadingLineTerminatorCount) {
+ writeLine(leadingLineTerminatorCount);
shouldEmitInterveningComments = false;
}
else if (format & 256 /* SpaceBetweenBraces */) {
@@ -194948,14 +200696,15 @@ var ts;
writeDelimiter(format);
recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
// Write either a line terminator or whitespace to separate the elements.
- if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) {
+ var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format);
+ if (separatingLineTerminatorCount > 0) {
// If a synthesized node in a single-line list starts on a new
// line, we should increase the indent.
if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) {
increaseIndent();
shouldDecreaseIndentAfterEmit = true;
}
- writeLine();
+ writeLine(separatingLineTerminatorCount);
shouldEmitInterveningComments = false;
}
else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) {
@@ -195000,10 +200749,11 @@ var ts;
}
recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
// Write the closing line terminator or closing whitespace.
- if (shouldWriteClosingLineTerminator(parentNode, children, format)) {
- writeLine();
+ var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format);
+ if (closingLineTerminatorCount) {
+ writeLine(closingLineTerminatorCount);
}
- else if (format & 256 /* SpaceBetweenBraces */) {
+ else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) {
writeSpace();
}
}
@@ -195055,8 +200805,11 @@ var ts;
function writeProperty(s) {
writer.writeProperty(s);
}
- function writeLine() {
- writer.writeLine();
+ function writeLine(count) {
+ if (count === void 0) { count = 1; }
+ for (var i = 0; i < count; i++) {
+ writer.writeLine(i > 0);
+ }
}
function increaseIndent() {
writer.increaseIndent();
@@ -195103,10 +200856,10 @@ var ts;
}
}
}
- function increaseIndentIf(value, writeSpaceIfNotIndenting) {
- if (value) {
+ function writeLinesAndIndent(lineCount, writeSpaceIfNotIndenting) {
+ if (lineCount) {
increaseIndent();
- writeLine();
+ writeLine(lineCount);
}
else if (writeSpaceIfNotIndenting) {
writeSpace();
@@ -195124,69 +200877,113 @@ var ts;
decreaseIndent();
}
}
- function shouldWriteLeadingLineTerminator(parentNode, children, format) {
- if (format & 1 /* MultiLine */) {
- return true;
- }
- if (format & 2 /* PreserveLines */) {
+ function getLeadingLineTerminatorCount(parentNode, children, format) {
+ if (format & 2 /* PreserveLines */ || preserveSourceNewlines) {
if (format & 65536 /* PreferNewLine */) {
- return true;
+ return 1;
}
- var firstChild = children[0];
- if (firstChild === undefined) {
- return !ts.rangeIsOnSingleLine(parentNode, currentSourceFile);
+ var firstChild_1 = children[0];
+ if (firstChild_1 === undefined) {
+ return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
}
- else if (ts.positionIsSynthesized(parentNode.pos) || ts.nodeIsSynthesized(firstChild)) {
- return synthesizedNodeStartsOnNewLine(firstChild, format);
+ if (firstChild_1.kind === 11 /* JsxText */) {
+ // JsxText will be written with its leading whitespace, so don't add more manually.
+ return 0;
}
- else {
- return !ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild, currentSourceFile);
+ if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || firstChild_1.parent === parentNode)) {
+ if (preserveSourceNewlines) {
+ return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); });
+ }
+ return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1;
+ }
+ if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) {
+ return 1;
}
}
- else {
- return false;
- }
+ return format & 1 /* MultiLine */ ? 1 : 0;
}
- function shouldWriteSeparatingLineTerminator(previousNode, nextNode, format) {
- if (format & 1 /* MultiLine */) {
- return true;
- }
- else if (format & 2 /* PreserveLines */) {
+ function getSeparatingLineTerminatorCount(previousNode, nextNode, format) {
+ if (format & 2 /* PreserveLines */ || preserveSourceNewlines) {
if (previousNode === undefined || nextNode === undefined) {
- return false;
+ return 0;
}
- else if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) {
- return synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format);
+ if (nextNode.kind === 11 /* JsxText */) {
+ // JsxText will be written with its leading whitespace, so don't add more manually.
+ return 0;
}
- else {
- return !ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile);
+ else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) {
+ if (preserveSourceNewlines) {
+ return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
+ }
+ return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1;
+ }
+ else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
+ return 1;
}
}
- else {
- return ts.getStartsOnNewLine(nextNode);
+ else if (ts.getStartsOnNewLine(nextNode)) {
+ return 1;
}
+ return format & 1 /* MultiLine */ ? 1 : 0;
}
- function shouldWriteClosingLineTerminator(parentNode, children, format) {
- if (format & 1 /* MultiLine */) {
- return (format & 131072 /* NoTrailingNewLine */) === 0;
- }
- else if (format & 2 /* PreserveLines */) {
+ function getClosingLineTerminatorCount(parentNode, children, format) {
+ if (format & 2 /* PreserveLines */ || preserveSourceNewlines) {
if (format & 65536 /* PreferNewLine */) {
- return true;
+ return 1;
}
- var lastChild = ts.lastOrUndefined(children);
- if (lastChild === undefined) {
- return !ts.rangeIsOnSingleLine(parentNode, currentSourceFile);
+ var lastChild_1 = ts.lastOrUndefined(children);
+ if (lastChild_1 === undefined) {
+ return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
}
- else if (ts.positionIsSynthesized(parentNode.pos) || ts.nodeIsSynthesized(lastChild)) {
- return synthesizedNodeStartsOnNewLine(lastChild, format);
+ if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild_1) && (!lastChild_1.parent || lastChild_1.parent === parentNode)) {
+ if (preserveSourceNewlines) {
+ return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(lastChild_1.end, parentNode.end, currentSourceFile, includeComments); });
+ }
+ return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild_1, currentSourceFile) ? 0 : 1;
}
- else {
- return !ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild, currentSourceFile);
+ if (synthesizedNodeStartsOnNewLine(lastChild_1, format)) {
+ return 1;
}
}
- else {
- return false;
+ if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) {
+ return 1;
+ }
+ return 0;
+ }
+ function getEffectiveLines(getLineDifference) {
+ // If 'preserveSourceNewlines' is disabled, we should never call this function
+ // because it could be more expensive than alternative approximations.
+ ts.Debug.assert(!!preserveSourceNewlines);
+ // We start by measuring the line difference from a position to its adjacent comments,
+ // so that this is counted as a one-line difference, not two:
+ //
+ // node1;
+ // // NODE2 COMMENT
+ // node2;
+ var lines = getLineDifference(/*includeComments*/ true);
+ if (lines === 0) {
+ // However, if the line difference considering comments was 0, we might have this:
+ //
+ // node1; // NODE2 COMMENT
+ // node2;
+ //
+ // in which case we should be ignoring node2's comment, so this too is counted as
+ // a one-line difference, not zero.
+ return getLineDifference(/*includeComments*/ false);
+ }
+ return lines;
+ }
+ function writeLineSeparatorsAndIndentBefore(node, parent) {
+ var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* None */);
+ if (leadingNewlines) {
+ writeLinesAndIndent(leadingNewlines, /*writeLinesIfNotIndenting*/ false);
+ }
+ return !!leadingNewlines;
+ }
+ function writeLineSeparatorsAfter(node, parent) {
+ var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* None */);
+ if (trailingNewlines) {
+ writeLine(trailingNewlines);
}
}
function synthesizedNodeStartsOnNewLine(node, format) {
@@ -195199,21 +200996,24 @@ var ts;
}
return (format & 65536 /* PreferNewLine */) !== 0;
}
- function needsIndentation(parent, node1, node2) {
+ function getLinesBetweenNodes(parent, node1, node2) {
if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) {
- return false;
+ return 0;
}
parent = skipSynthesizedParentheses(parent);
node1 = skipSynthesizedParentheses(node1);
node2 = skipSynthesizedParentheses(node2);
// Always use a newline for synthesized code if the synthesizer desires it.
if (ts.getStartsOnNewLine(node2)) {
- return true;
+ return 1;
+ }
+ if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
+ if (preserveSourceNewlines) {
+ return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
+ }
+ return ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1;
}
- return !ts.nodeIsSynthesized(parent)
- && !ts.nodeIsSynthesized(node1)
- && !ts.nodeIsSynthesized(node2)
- && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile);
+ return 0;
}
function isEmptyBlock(block) {
return block.statements.length === 0
@@ -195622,7 +201422,7 @@ var ts;
hasWrittenComment = false;
var emitFlags = ts.getEmitFlags(node);
var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end;
- var isEmittedNode = node.kind !== 324 /* NotEmittedStatement */;
+ var isEmittedNode = node.kind !== 325 /* NotEmittedStatement */;
// We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation.
// It is expensive to walk entire tree just to set one kind of node to have no comments.
var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */;
@@ -195905,7 +201705,7 @@ var ts;
else {
var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b;
var emitFlags = ts.getEmitFlags(node);
- if (node.kind !== 324 /* NotEmittedStatement */
+ if (node.kind !== 325 /* NotEmittedStatement */
&& (emitFlags & 16 /* NoLeadingSourceMap */) === 0
&& pos >= 0) {
emitSourcePos(source, skipSourceTrivia(source, pos));
@@ -195918,7 +201718,7 @@ var ts;
else {
pipelinePhase(hint, node);
}
- if (node.kind !== 324 /* NotEmittedStatement */
+ if (node.kind !== 325 /* NotEmittedStatement */
&& (emitFlags & 32 /* NoTrailingSourceMap */) === 0
&& end >= 0) {
emitSourcePos(source, end);
@@ -196378,7 +202178,6 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
- var ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/;
function findConfigFile(searchPath, fileExists, configName) {
if (configName === void 0) { configName = "tsconfig.json"; }
return ts.forEachAncestorDirectory(searchPath, function (ancestor) {
@@ -196703,12 +202502,6 @@ var ts;
return formatStyle + text + resetEscapeSequence;
}
ts.formatColorAndReset = formatColorAndReset;
- function padLeft(s, length) {
- while (s.length < length) {
- s = " " + s;
- }
- return s;
- }
function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
@@ -196724,7 +202517,7 @@ var ts;
// If the error spans over 5 lines, we'll only show the first 2 and last 2 lines,
// so we'll skip ahead to the second-to-last line.
if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
- context += indent + formatColorAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
+ context += indent + formatColorAndReset(ts.padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
i = lastLine - 1;
}
var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
@@ -196733,10 +202526,10 @@ var ts;
lineContent = lineContent.replace(/\s+$/g, ""); // trim from end
lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces
// Output the gutter and the actual contents of the line.
- context += indent + formatColorAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
+ context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
context += lineContent + host.getNewLine();
// Output the gutter and the error span for the line using tildes.
- context += indent + formatColorAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
+ context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
context += squiggleColor;
if (i === firstLine) {
// If we're on the last line, then limit it to the last character of the last line.
@@ -196788,11 +202581,11 @@ var ts;
if (diagnostic.relatedInformation) {
output += host.getNewLine();
for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
- var _c = _b[_a], file = _c.file, start = _c.start, length_7 = _c.length, messageText = _c.messageText;
+ var _c = _b[_a], file = _c.file, start = _c.start, length_8 = _c.length, messageText = _c.messageText;
if (file) {
output += host.getNewLine();
output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217
- output += formatCodeSpan(file, start, length_7, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217
+ output += formatCodeSpan(file, start, length_8, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217
}
output += host.getNewLine();
output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
@@ -196895,7 +202688,7 @@ var ts;
hasInvalidatedResolution(sourceFile.path);
}
function sourceFileVersionUptoDate(sourceFile) {
- return sourceFile.version === getSourceVersion(sourceFile.resolvedPath);
+ return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
}
function projectReferenceUptoDate(oldRef, newRef, index) {
if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) {
@@ -196954,6 +202747,7 @@ var ts;
};
}
function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
+ var _a;
var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
var oldProgram = createProgramOptions.oldProgram;
@@ -197000,10 +202794,10 @@ var ts;
var hasEmitBlockingDiagnostics = ts.createMap();
var _compilerOptionsObjectLiteralSyntax;
var moduleResolutionCache;
- var resolveModuleNamesWorker;
+ var actualResolveModuleNamesWorker;
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
if (host.resolveModuleNames) {
- resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) {
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) {
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
if (!resolved || resolved.extension !== undefined) {
return resolved;
@@ -197016,15 +202810,15 @@ var ts;
else {
moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options);
var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217
- resolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_1); };
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); };
}
- var resolveTypeReferenceDirectiveNamesWorker;
+ var actualResolveTypeReferenceDirectiveNamesWorker;
if (host.resolveTypeReferenceDirectives) {
- resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
}
else {
var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217
- resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
}
// Map from a stringified PackageId to the source file with that id.
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
@@ -197050,7 +202844,16 @@ var ts;
var projectReferenceRedirects;
var mapFromFileToProjectReferenceRedirects;
var mapFromToProjectReferenceRedirectSource;
- var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect();
+ var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) &&
+ !options.disableSourceOfProjectReferenceRedirect;
+ var _b = updateHostForUseSourceOfProjectReferenceRedirect({
+ compilerHost: host,
+ useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
+ toPath: toPath,
+ getResolvedProjectReferences: getResolvedProjectReferences,
+ getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
+ forEachResolvedProjectReference: forEachResolvedProjectReference
+ }), onProgramCreateComplete = _b.onProgramCreateComplete, fileExists = _b.fileExists;
var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
// We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks
// `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`.
@@ -197063,12 +202866,6 @@ var ts;
if (!resolvedProjectReferences) {
resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
}
- if (host.setResolvedProjectReferenceCallbacks) {
- host.setResolvedProjectReferenceCallbacks({
- getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
- forEachResolvedProjectReference: forEachResolvedProjectReference
- });
- }
if (rootNames.length) {
for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) {
var parsedRef = resolvedProjectReferences_1[_i];
@@ -197077,8 +202874,8 @@ var ts;
var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out;
if (useSourceOfProjectReferenceRedirect) {
if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
- for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) {
- var fileName = _b[_a];
+ for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) {
+ var fileName = _d[_c];
processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
}
}
@@ -197088,8 +202885,8 @@ var ts;
processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
}
else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
- for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) {
- var fileName = _d[_c];
+ for (var _e = 0, _f = parsedRef.commandLine.fileNames; _e < _f.length; _e++) {
+ var fileName = _f[_e];
if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
}
@@ -197141,8 +202938,8 @@ var ts;
// not part of the new program.
if (oldProgram && host.onReleaseOldSourceFile) {
var oldSourceFiles = oldProgram.getSourceFiles();
- for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) {
- var oldSourceFile = oldSourceFiles_1[_e];
+ for (var _g = 0, oldSourceFiles_1 = oldSourceFiles; _g < oldSourceFiles_1.length; _g++) {
+ var oldSourceFile = oldSourceFiles_1[_g];
var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
if (shouldCreateNewSourceFile || !newFile ||
// old file wasnt redirect but new file is
@@ -197185,6 +202982,7 @@ var ts;
getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
+ getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
@@ -197206,12 +203004,29 @@ var ts;
forEachResolvedProjectReference: forEachResolvedProjectReference,
isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
emitBuildInfo: emitBuildInfo,
- getProbableSymlinks: getProbableSymlinks
+ fileExists: fileExists,
+ getProbableSymlinks: getProbableSymlinks,
+ useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
};
+ onProgramCreateComplete();
verifyCompilerOptions();
ts.performance.mark("afterProgram");
ts.performance.measure("Program", "beforeProgram", "afterProgram");
return program;
+ function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference) {
+ ts.performance.mark("beforeResolveModule");
+ var result = actualResolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference);
+ ts.performance.mark("afterResolveModule");
+ ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
+ return result;
+ }
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference) {
+ ts.performance.mark("beforeResolveTypeReference");
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference);
+ ts.performance.mark("afterResolveTypeReference");
+ ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
+ return result;
+ }
function compareDefaultLibFiles(a, b) {
return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b));
}
@@ -197285,13 +203100,13 @@ var ts;
// which per above occurred during the current program creation.
// Since we assume the filesystem does not change during program creation,
// it is safe to reuse resolutions from the earlier call.
- var result_8 = [];
+ var result_11 = [];
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
var moduleName = moduleNames_1[_i];
var resolvedModule = file.resolvedModules.get(moduleName);
- result_8.push(resolvedModule);
+ result_11.push(resolvedModule);
}
- return result_8;
+ return result_11;
}
// At this point, we know at least one of the following hold:
// - file has local declarations for ambient modules
@@ -197439,12 +203254,6 @@ var ts;
}
if (projectReferences) {
resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
- if (host.setResolvedProjectReferenceCallbacks) {
- host.setResolvedProjectReferenceCallbacks({
- getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
- forEachResolvedProjectReference: forEachResolvedProjectReference
- });
- }
}
// check if program source files has changed in the way that can affect structure of the program
var newSourceFiles = [];
@@ -197639,11 +203448,26 @@ var ts;
return oldProgram.structureIsReused = 2 /* Completely */;
}
function getEmitHost(writeFileCallback) {
- return __assign(__assign({ getPrependNodes: getPrependNodes,
- getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
+ return {
+ getPrependNodes: getPrependNodes,
+ getCanonicalFileName: getCanonicalFileName,
+ getCommonSourceDirectory: program.getCommonSourceDirectory,
+ getCompilerOptions: program.getCompilerOptions,
+ getCurrentDirectory: function () { return currentDirectory; },
+ getNewLine: function () { return host.getNewLine(); },
+ getSourceFile: program.getSourceFile,
+ getSourceFileByPath: program.getSourceFileByPath,
+ getSourceFiles: program.getSourceFiles,
+ getLibFileFromReference: program.getLibFileFromReference,
+ isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
+ getProjectReferenceRedirect: getProjectReferenceRedirect,
isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
- getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) {
+ getProbableSymlinks: getProbableSymlinks,
+ writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
+ isEmitBlocked: isEmitBlocked,
+ readFile: function (f) { return host.readFile(f); },
+ fileExists: function (f) {
// Use local caches
var path = toPath(f);
if (getSourceFileByPath(path))
@@ -197652,7 +203476,12 @@ var ts;
return false;
// Before falling back to the host
return host.fileExists(f);
- } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap });
+ },
+ useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
+ getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); },
+ getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
+ redirectTargetsMap: redirectTargetsMap,
+ };
}
function emitBuildInfo(writeFileCallback) {
ts.Debug.assert(!options.out && !options.outFile);
@@ -197768,19 +203597,19 @@ var ts;
}
var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
- var diagnostics;
- for (var _i = 0, _a = [fileProcessingDiagnosticsInFile, programDiagnosticsInFile]; _i < _a.length; _i++) {
- var diags = _a[_i];
- if (diags) {
- for (var _b = 0, diags_4 = diags; _b < diags_4.length; _b++) {
- var diag = diags_4[_b];
- if (shouldReportDiagnostic(diag)) {
- diagnostics = ts.append(diagnostics, diag);
- }
- }
- }
+ return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile);
+ }
+ function getMergedProgramDiagnostics(sourceFile) {
+ var _a;
+ var allDiagnostics = [];
+ for (var _i = 1; _i < arguments.length; _i++) {
+ allDiagnostics[_i - 1] = arguments[_i];
}
- return diagnostics || ts.emptyArray;
+ var flatDiagnostics = ts.flatten(allDiagnostics);
+ if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
+ return flatDiagnostics;
+ }
+ return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics).diagnostics;
}
function getDeclarationDiagnostics(sourceFile, cancellationToken) {
var options = program.getCompilerOptions();
@@ -197844,57 +203673,74 @@ var ts;
sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
- var diagnostics;
- for (var _i = 0, _a = [bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined]; _i < _a.length; _i++) {
- var diags = _a[_i];
- if (diags) {
- for (var _b = 0, diags_5 = diags; _b < diags_5.length; _b++) {
- var diag = diags_5[_b];
- if (shouldReportDiagnostic(diag)) {
- diagnostics = ts.append(diagnostics, diag);
- }
- }
- }
- }
- return diagnostics || ts.emptyArray;
+ return getMergedBindAndCheckDiagnostics(sourceFile, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
});
}
+ function getMergedBindAndCheckDiagnostics(sourceFile) {
+ var _a;
+ var allDiagnostics = [];
+ for (var _i = 1; _i < arguments.length; _i++) {
+ allDiagnostics[_i - 1] = arguments[_i];
+ }
+ var flatDiagnostics = ts.flatten(allDiagnostics);
+ if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
+ return flatDiagnostics;
+ }
+ var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives;
+ for (var _c = 0, _d = directives.getUnusedExpectations(); _c < _d.length; _c++) {
+ var errorExpectation = _d[_c];
+ diagnostics.push(ts.createDiagnosticForRange(sourceFile, errorExpectation.range, ts.Diagnostics.Unused_ts_expect_error_directive));
+ }
+ return diagnostics;
+ }
+ /**
+ * Creates a map of comment directives along with the diagnostics immediately preceded by one of them.
+ * Comments that match to any of those diagnostics are marked as used.
+ */
+ function getDiagnosticsWithPrecedingDirectives(sourceFile, commentDirectives, flatDiagnostics) {
+ // Diagnostics are only reported if there is no comment directive preceding them
+ // This will modify the directives map by marking "used" ones with a corresponding diagnostic
+ var directives = ts.createCommentDirectivesMap(sourceFile, commentDirectives);
+ var diagnostics = flatDiagnostics.filter(function (diagnostic) { return markPrecedingCommentDirectiveLine(diagnostic, directives) === -1; });
+ return { diagnostics: diagnostics, directives: directives };
+ }
function getSuggestionDiagnostics(sourceFile, cancellationToken) {
return runWithCancellationToken(function () {
return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
});
}
/**
- * Skip errors if previous line start with '// @ts-ignore' comment, not counting non-empty non-comment lines
+ * @returns The line index marked as preceding the diagnostic, or -1 if none was.
*/
- function shouldReportDiagnostic(diagnostic) {
+ function markPrecedingCommentDirectiveLine(diagnostic, directives) {
var file = diagnostic.file, start = diagnostic.start;
- if (file) {
- var lineStarts = ts.getLineStarts(file);
- var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; // TODO: GH#18217
- while (line > 0) {
- var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]);
- var result = ignoreDiagnosticCommentRegEx.exec(previousLineText);
- if (!result) {
- // non-empty line
- return true;
- }
- if (result[3]) {
- // @ts-ignore
- return false;
- }
- line--;
+ if (!file) {
+ return -1;
+ }
+ // Start out with the line just before the text
+ var lineStarts = ts.getLineStarts(file);
+ var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line - 1; // TODO: GH#18217
+ while (line >= 0) {
+ // As soon as that line is known to have a comment directive, use that
+ if (directives.markUsed(line)) {
+ return line;
+ }
+ // Stop searching if the line is not empty and not a comment
+ var lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim();
+ if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) {
+ return -1;
}
+ line--;
}
- return true;
+ return -1;
}
function getJSSyntacticDiagnosticsForFile(sourceFile) {
return runWithCancellationToken(function () {
var diagnostics = [];
- var parent = sourceFile;
- walk(sourceFile);
+ walk(sourceFile, sourceFile);
+ ts.forEachChildRecursively(sourceFile, walk, walkArray);
return diagnostics;
- function walk(node) {
+ function walk(node, parent) {
// Return directly from the case if the given node doesnt want to visit each child
// Otherwise break to visit each child
switch (parent.kind) {
@@ -197903,7 +203749,7 @@ var ts;
case 161 /* MethodDeclaration */:
if (parent.questionToken === node) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
- return;
+ return "skip";
}
// falls through
case 160 /* MethodSignature */:
@@ -197917,70 +203763,66 @@ var ts;
// type annotation
if (parent.type === node) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
}
}
switch (node.kind) {
case 255 /* ImportClause */:
if (node.isTypeOnly) {
diagnostics.push(createDiagnosticForNode(node.parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type"));
- return;
+ return "skip";
}
break;
case 260 /* ExportDeclaration */:
if (node.isTypeOnly) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type"));
- return;
+ return "skip";
}
break;
case 253 /* ImportEqualsDeclaration */:
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
case 259 /* ExportAssignment */:
if (node.isExportEquals) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
}
break;
case 279 /* HeritageClause */:
var heritageClause = node;
if (heritageClause.token === 113 /* ImplementsKeyword */) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
}
break;
case 246 /* InterfaceDeclaration */:
var interfaceKeyword = ts.tokenToString(114 /* InterfaceKeyword */);
- ts.Debug.assertDefined(interfaceKeyword);
+ ts.Debug.assertIsDefined(interfaceKeyword);
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
- return;
+ return "skip";
case 249 /* ModuleDeclaration */:
var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(136 /* NamespaceKeyword */) : ts.tokenToString(135 /* ModuleKeyword */);
- ts.Debug.assertDefined(moduleKeyword);
+ ts.Debug.assertIsDefined(moduleKeyword);
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword));
- return;
+ return "skip";
case 247 /* TypeAliasDeclaration */:
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
case 248 /* EnumDeclaration */:
- var enumKeyword = ts.Debug.assertDefined(ts.tokenToString(88 /* EnumKeyword */));
+ var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(88 /* EnumKeyword */));
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword));
- return;
+ return "skip";
case 218 /* NonNullExpression */:
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
case 217 /* AsExpression */:
diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
case 199 /* TypeAssertionExpression */:
ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX.
}
- var prevParent = parent;
- parent = node;
- ts.forEachChild(node, walk, walkArray);
- parent = prevParent;
}
- function walkArray(nodes) {
+ function walkArray(nodes, parent) {
if (parent.decorators === nodes && !options.experimentalDecorators) {
diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning));
}
@@ -197997,13 +203839,14 @@ var ts;
// Check type parameters
if (nodes === parent.typeParameters) {
diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
}
// falls through
case 225 /* VariableStatement */:
// Check modifiers
if (nodes === parent.modifiers) {
- return checkModifiers(parent.modifiers, parent.kind === 225 /* VariableStatement */);
+ checkModifiers(parent.modifiers, parent.kind === 225 /* VariableStatement */);
+ return "skip";
}
break;
case 159 /* PropertyDeclaration */:
@@ -198015,14 +203858,14 @@ var ts;
diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
}
}
- return;
+ return "skip";
}
break;
case 156 /* Parameter */:
// Check modifiers of parameter declaration
if (nodes === parent.modifiers) {
diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
}
break;
case 196 /* CallExpression */:
@@ -198034,14 +203877,10 @@ var ts;
// Check type arguments
if (nodes === parent.typeArguments) {
diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files));
- return;
+ return "skip";
}
break;
}
- for (var _b = 0, nodes_6 = nodes; _b < nodes_6.length; _b++) {
- var node = nodes_6[_b];
- walk(node);
- }
}
function checkModifiers(modifiers, isConstValid) {
for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
@@ -198304,7 +204143,7 @@ var ts;
}
var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); });
if (fail && !sourceFileWithAddedExtension)
- fail(ts.Diagnostics.File_0_not_found, fileName + ".ts" /* Ts */);
+ fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
return sourceFileWithAddedExtension;
}
}
@@ -198836,7 +204675,7 @@ var ts;
projectReferenceRedirects.set(sourceFilePath, false);
return undefined;
}
- sourceFile = ts.Debug.assertDefined(commandLine.options.configFile);
+ sourceFile = ts.Debug.checkDefined(commandLine.options.configFile);
ts.Debug.assert(!sourceFile.path || sourceFile.path === sourceFilePath);
addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined);
}
@@ -199100,7 +204939,7 @@ var ts;
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
- var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file));
+ var refFile = ts.Debug.checkDefined(getSourceFileByPath(refPathToReportErrorOn.file));
var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index;
var pos, end;
switch (kind) {
@@ -199299,6 +205138,156 @@ var ts;
}
}
ts.createProgram = createProgram;
+ function updateHostForUseSourceOfProjectReferenceRedirect(host) {
+ var mapOfDeclarationDirectories;
+ var symlinkedDirectories;
+ var symlinkedFiles;
+ var originalFileExists = host.compilerHost.fileExists;
+ var originalDirectoryExists = host.compilerHost.directoryExists;
+ var originalGetDirectories = host.compilerHost.getDirectories;
+ var originalRealpath = host.compilerHost.realpath;
+ if (!host.useSourceOfProjectReferenceRedirect)
+ return { onProgramCreateComplete: ts.noop, fileExists: fileExists };
+ host.compilerHost.fileExists = fileExists;
+ if (originalDirectoryExists) {
+ // This implementation of directoryExists checks if the directory being requested is
+ // directory of .d.ts file for the referenced Project.
+ // If it is it returns true irrespective of whether that directory exists on host
+ host.compilerHost.directoryExists = function (path) {
+ if (originalDirectoryExists.call(host.compilerHost, path)) {
+ handleDirectoryCouldBeSymlink(path);
+ return true;
+ }
+ if (!host.getResolvedProjectReferences())
+ return false;
+ if (!mapOfDeclarationDirectories) {
+ mapOfDeclarationDirectories = ts.createMap();
+ host.forEachResolvedProjectReference(function (ref) {
+ if (!ref)
+ return;
+ var out = ref.commandLine.options.outFile || ref.commandLine.options.out;
+ if (out) {
+ mapOfDeclarationDirectories.set(ts.getDirectoryPath(host.toPath(out)), true);
+ }
+ else {
+ // Set declaration's in different locations only, if they are next to source the directory present doesnt change
+ var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir;
+ if (declarationDir) {
+ mapOfDeclarationDirectories.set(host.toPath(declarationDir), true);
+ }
+ }
+ });
+ }
+ return fileOrDirectoryExistsUsingSource(path, /*isFile*/ false);
+ };
+ }
+ if (originalGetDirectories) {
+ // Call getDirectories only if directory actually present on the host
+ // This is needed to ensure that we arent getting directories that we fake about presence for
+ host.compilerHost.getDirectories = function (path) {
+ return !host.getResolvedProjectReferences() || (originalDirectoryExists && originalDirectoryExists.call(host.compilerHost, path)) ?
+ originalGetDirectories.call(host.compilerHost, path) :
+ [];
+ };
+ }
+ // This is something we keep for life time of the host
+ if (originalRealpath) {
+ host.compilerHost.realpath = function (s) {
+ return (symlinkedFiles === null || symlinkedFiles === void 0 ? void 0 : symlinkedFiles.get(host.toPath(s))) ||
+ originalRealpath.call(host.compilerHost, s);
+ };
+ }
+ return { onProgramCreateComplete: onProgramCreateComplete, fileExists: fileExists };
+ function onProgramCreateComplete() {
+ host.compilerHost.fileExists = originalFileExists;
+ host.compilerHost.directoryExists = originalDirectoryExists;
+ host.compilerHost.getDirectories = originalGetDirectories;
+ // DO not revert realpath as it could be used later
+ }
+ // This implementation of fileExists checks if the file being requested is
+ // .d.ts file for the referenced Project.
+ // If it is it returns true irrespective of whether that file exists on host
+ function fileExists(file) {
+ if (originalFileExists.call(host.compilerHost, file))
+ return true;
+ if (!host.getResolvedProjectReferences())
+ return false;
+ if (!ts.isDeclarationFileName(file))
+ return false;
+ // Project references go to source file instead of .d.ts file
+ return fileOrDirectoryExistsUsingSource(file, /*isFile*/ true);
+ }
+ function fileExistsIfProjectReferenceDts(file) {
+ var source = host.getSourceOfProjectReferenceRedirect(file);
+ return source !== undefined ?
+ ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true :
+ undefined;
+ }
+ function directoryExistsIfProjectReferenceDeclDir(dir) {
+ var dirPath = host.toPath(dir);
+ var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator;
+ return ts.forEachKey(mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath ||
+ // Any parent directory of declaration dir
+ ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) ||
+ // Any directory inside declaration dir
+ ts.startsWith(dirPath, declDirPath + "/"); });
+ }
+ function handleDirectoryCouldBeSymlink(directory) {
+ if (!host.getResolvedProjectReferences())
+ return;
+ // Because we already watch node_modules, handle symlinks in there
+ if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart))
+ return;
+ if (!symlinkedDirectories)
+ symlinkedDirectories = ts.createMap();
+ var directoryPath = ts.ensureTrailingDirectorySeparator(host.toPath(directory));
+ if (symlinkedDirectories.has(directoryPath))
+ return;
+ var real = ts.normalizePath(originalRealpath.call(host.compilerHost, directory));
+ var realPath;
+ if (real === directory ||
+ (realPath = ts.ensureTrailingDirectorySeparator(host.toPath(real))) === directoryPath) {
+ // not symlinked
+ symlinkedDirectories.set(directoryPath, false);
+ return;
+ }
+ symlinkedDirectories.set(directoryPath, {
+ real: ts.ensureTrailingDirectorySeparator(real),
+ realPath: realPath
+ });
+ }
+ function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) {
+ var fileOrDirectoryExistsUsingSource = isFile ?
+ function (file) { return fileExistsIfProjectReferenceDts(file); } :
+ function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); };
+ // Check current directory or file
+ var result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
+ if (result !== undefined)
+ return result;
+ if (!symlinkedDirectories)
+ return false;
+ var fileOrDirectoryPath = host.toPath(fileOrDirectory);
+ if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart))
+ return false;
+ if (isFile && symlinkedFiles && symlinkedFiles.has(fileOrDirectoryPath))
+ return true;
+ // If it contains node_modules check if its one of the symlinked path we know of
+ return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) {
+ var directoryPath = _a[0], symlinkedDirectory = _a[1];
+ if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath))
+ return undefined;
+ var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath));
+ if (isFile && result) {
+ if (!symlinkedFiles)
+ symlinkedFiles = ts.createMap();
+ // Store the real path for the file'
+ var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory());
+ symlinkedFiles.set(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), ""));
+ }
+ return result;
+ }) || false;
+ }
+ }
/*@internal*/
function handleNoEmitOptions(program, sourceFile, cancellationToken) {
var options = program.getCompilerOptions();
@@ -199325,7 +205314,7 @@ var ts;
return {
fileExists: function (f) { return directoryStructureHost.fileExists(f); },
readDirectory: function (root, extensions, excludes, includes, depth) {
- ts.Debug.assertDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
+ ts.Debug.assertIsDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
return directoryStructureHost.readDirectory(root, extensions, excludes, includes, depth);
},
readFile: function (f) { return directoryStructureHost.readFile(f); },
@@ -199413,8 +205402,8 @@ var ts;
(function (ts) {
function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
var outputFiles = [];
- var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit);
- return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit };
+ var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
+ return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
function writeFile(fileName, text, writeByteOrderMark) {
outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
}
@@ -199543,7 +205532,7 @@ var ts;
// Create the reference map, and set the file infos
for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
- var version_1 = ts.Debug.assertDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
+ var version_1 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
if (referencedMap) {
var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
@@ -199558,7 +205547,7 @@ var ts;
}
}
}
- fileInfos.set(sourceFile.resolvedPath, { version: version_1, signature: oldInfo && oldInfo.signature });
+ fileInfos.set(sourceFile.resolvedPath, { version: version_1, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
}
return {
fileInfos: fileInfos,
@@ -199622,12 +205611,14 @@ var ts;
* This should be called whenever it is safe to commit the state of the builder
*/
function updateSignaturesFromCache(state, signatureCache) {
- signatureCache.forEach(function (signature, path) {
- state.fileInfos.get(path).signature = signature;
- state.hasCalledUpdateShapeSignature.set(path, true);
- });
+ signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
}
BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
+ function updateSignatureOfFile(state, signature, path) {
+ state.fileInfos.get(path).signature = signature;
+ state.hasCalledUpdateShapeSignature.set(path, true);
+ }
+ BuilderState.updateSignatureOfFile = updateSignatureOfFile;
/**
* Returns if the shape of the signature has changed since last emit
*/
@@ -199806,7 +205797,8 @@ var ts;
return state.allFilesExcludingDefaultLibraryFile;
}
var result;
- addSourceFile(firstSourceFile);
+ if (firstSourceFile)
+ addSourceFile(firstSourceFile);
for (var _i = 0, _a = programOfThisState.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
if (sourceFile !== firstSourceFile) {
@@ -199821,6 +205813,7 @@ var ts;
}
}
}
+ BuilderState.getAllFilesExcludingDefaultLibraryFile = getAllFilesExcludingDefaultLibraryFile;
/**
* When program emits non modular code, gets the files affected by the sourceFile whose shape has changed
*/
@@ -199919,6 +205912,7 @@ var ts;
state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind);
state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
+ state.seenAffectedFiles = ts.createMap();
}
}
// Update changed files and copy semantic diagnostics if we can
@@ -199961,11 +205955,16 @@ var ts;
}
}
});
- if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
+ // If the global file is removed, add all files as changed
+ if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
+ .forEach(function (file) { return state.changedFilesSet.set(file.resolvedPath, true); });
+ }
+ else if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
// Add all files to affectedFilesPendingEmit since emit changed
newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
- ts.Debug.assert(state.seenAffectedFiles === undefined);
- state.seenAffectedFiles = ts.createMap();
+ ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
+ state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap();
}
state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit;
return state;
@@ -200070,7 +206069,7 @@ var ts;
}
// With --out or --outFile all outputs go into single file
// so operations are performed directly on program, return program
- var program = ts.Debug.assertDefined(state.program);
+ var program = ts.Debug.checkDefined(state.program);
var compilerOptions = program.getCompilerOptions();
if (compilerOptions.outFile || compilerOptions.out) {
ts.Debug.assert(!state.semanticDiagnosticsPerFile);
@@ -200095,10 +206094,10 @@ var ts;
if (affectedFilesPendingEmit) {
var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap());
for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) {
- var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
+ var affectedFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
if (affectedFile) {
var seenKind = seenEmittedFiles.get(affectedFile.resolvedPath);
- var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath));
+ var emitKind = ts.Debug.checkDefined(ts.Debug.checkDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath));
if (seenKind === undefined || seenKind < emitKind) {
// emit this file
state.affectedFilesPendingEmitIndex = i;
@@ -200122,7 +206121,7 @@ var ts;
if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
if (!state.cleanedDiagnosticsOfLibFiles) {
state.cleanedDiagnosticsOfLibFiles = true;
- var program_1 = ts.Debug.assertDefined(state.program);
+ var program_1 = ts.Debug.checkDefined(state.program);
var options_2 = program_1.getCompilerOptions();
ts.forEach(program_1.getSourceFiles(), function (f) {
return program_1.isSourceFileDefaultLibrary(f) &&
@@ -200143,14 +206142,14 @@ var ts;
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
removeSemanticDiagnosticsOf(state, path);
if (!state.changedFilesSet.has(path)) {
- var program = ts.Debug.assertDefined(state.program);
+ var program = ts.Debug.checkDefined(state.program);
var sourceFile = program.getSourceFileByPath(path);
if (sourceFile) {
// Even though the js emit doesnt change and we are already handling dts emit and semantic diagnostics
// we need to update the signature to reflect correctness of the signature(which is output d.ts emit) of this file
// This ensures that we dont later during incremental builds considering wrong signature.
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
// If not dts emit, nothing more to do
if (ts.getEmitDeclarations(state.compilerOptions)) {
addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -200172,8 +206171,8 @@ var ts;
return !state.semanticDiagnosticsFromOldState.size;
}
function isChangedSignagure(state, path) {
- var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path);
- var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature;
+ var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
+ var oldSignagure = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
return newSignature !== oldSignagure;
}
/**
@@ -200199,7 +206198,7 @@ var ts;
seenFileNamesMap.set(currentPath, true);
var result = fn(state, currentPath);
if (result && isChangedSignagure(state, currentPath)) {
- var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath);
+ var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
}
}
@@ -200312,7 +206311,7 @@ var ts;
* bindAndCheckDiagnostics (from cache) and program diagnostics
*/
function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
- return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.assertDefined(state.program).getProgramDiagnostics(sourceFile));
+ return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile));
}
/**
* Gets the binder and checker diagnostics either from cache if present, or otherwise from program and caches it
@@ -200328,7 +206327,7 @@ var ts;
}
}
// Diagnostics werent cached, get them from program, and cache the result
- var diagnostics = ts.Debug.assertDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
+ var diagnostics = ts.Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
if (state.semanticDiagnosticsPerFile) {
state.semanticDiagnosticsPerFile.set(path, diagnostics);
}
@@ -200340,49 +206339,54 @@ var ts;
function getProgramBuildInfo(state, getCanonicalFileName) {
if (state.compilerOptions.outFile || state.compilerOptions.out)
return undefined;
- var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory();
+ var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
var fileInfos = {};
state.fileInfos.forEach(function (value, key) {
var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
- fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature };
+ fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope };
});
var result = {
fileInfos: fileInfos,
options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath)
};
if (state.referencedMap) {
- var referencedMap_1 = {};
- state.referencedMap.forEach(function (value, key) {
- referencedMap_1[relativeToBuildInfo(key)] = ts.arrayFrom(value.keys(), relativeToBuildInfo);
- });
- result.referencedMap = referencedMap_1;
+ var referencedMap = {};
+ for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
+ var key = _a[_i];
+ referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
+ }
+ result.referencedMap = referencedMap;
}
if (state.exportedModulesMap) {
- var exportedModulesMap_1 = {};
- state.exportedModulesMap.forEach(function (value, key) {
+ var exportedModulesMap = {};
+ for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
+ var key = _c[_b];
var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key);
// Not in temporary cache, use existing value
if (newValue === undefined)
- exportedModulesMap_1[relativeToBuildInfo(key)] = ts.arrayFrom(value.keys(), relativeToBuildInfo);
+ exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
// Value in cache and has updated value map, use that
else if (newValue)
- exportedModulesMap_1[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo);
- });
- result.exportedModulesMap = exportedModulesMap_1;
+ exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
+ }
+ result.exportedModulesMap = exportedModulesMap;
}
if (state.semanticDiagnosticsPerFile) {
- var semanticDiagnosticsPerFile_1 = [];
- // Currently not recording actual errors since those mean no emit for tsc --build
- state.semanticDiagnosticsPerFile.forEach(function (value, key) { return semanticDiagnosticsPerFile_1.push(value.length ?
- [
- relativeToBuildInfo(key),
- state.hasReusableDiagnostic ?
- value :
- convertToReusableDiagnostics(value, relativeToBuildInfo)
- ] :
- relativeToBuildInfo(key)); });
- result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile_1;
+ var semanticDiagnosticsPerFile = [];
+ for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
+ var key = _e[_d];
+ var value = state.semanticDiagnosticsPerFile.get(key);
+ semanticDiagnosticsPerFile.push(value.length ?
+ [
+ relativeToBuildInfo(key),
+ state.hasReusableDiagnostic ?
+ value :
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
+ ] :
+ relativeToBuildInfo(key));
+ }
+ result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
}
return result;
function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -200506,10 +206510,10 @@ var ts;
backupState = cloneBuilderProgramState(state);
};
builderProgram.restoreState = function () {
- state = ts.Debug.assertDefined(backupState);
+ state = ts.Debug.checkDefined(backupState);
backupState = undefined;
};
- builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.assertDefined(state.program), sourceFile); };
+ builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
builderProgram.emit = emit;
builderProgram.releaseProgram = function () {
@@ -200543,7 +206547,7 @@ var ts;
if (state.emittedBuildInfo) {
return undefined;
}
- var affected_1 = ts.Debug.assertDefined(state.program);
+ var affected_1 = ts.Debug.checkDefined(state.program);
return toAffectedFileEmitResult(state,
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
// Otherwise just affected file
@@ -200555,7 +206559,7 @@ var ts;
isPendingEmitFile = true;
}
else {
- var program = ts.Debug.assertDefined(state.program);
+ var program = ts.Debug.checkDefined(state.program);
if (state.programEmitComplete)
return undefined;
affected = program;
@@ -200564,7 +206568,7 @@ var ts;
return toAffectedFileEmitResult(state,
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
// Otherwise just affected file
- ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
}
/**
* Emits the JavaScript and declaration files.
@@ -200604,7 +206608,7 @@ var ts;
};
}
}
- return ts.Debug.assertDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
}
/**
* Return the semantic diagnostics for the next affected file or undefined if iteration is complete
@@ -200644,11 +206648,11 @@ var ts;
*/
function getSemanticDiagnostics(sourceFile, cancellationToken) {
assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
- var compilerOptions = ts.Debug.assertDefined(state.program).getCompilerOptions();
+ var compilerOptions = ts.Debug.checkDefined(state.program).getCompilerOptions();
if (compilerOptions.outFile || compilerOptions.out) {
ts.Debug.assert(!state.semanticDiagnosticsPerFile);
// We dont need to cache the diagnostics just return them from program
- return ts.Debug.assertDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
+ return ts.Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
}
if (sourceFile) {
return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
@@ -200659,7 +206663,7 @@ var ts;
while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
}
var diagnostics;
- for (var _i = 0, _a = ts.Debug.assertDefined(state.program).getSourceFiles(); _i < _a.length; _i++) {
+ for (var _i = 0, _a = ts.Debug.checkDefined(state.program).getSourceFiles(); _i < _a.length; _i++) {
var sourceFile_1 = _a[_i];
diagnostics = ts.addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile_1, cancellationToken));
}
@@ -200767,7 +206771,7 @@ var ts;
close: ts.noop,
};
function getProgram() {
- return ts.Debug.assertDefined(state.program);
+ return ts.Debug.checkDefined(state.program);
}
}
ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram;
@@ -200845,13 +206849,13 @@ var ts;
return true;
}
ts.canWatchDirectory = canWatchDirectory;
- ts.maxNumberOfFilesToIterateForInvalidation = 256;
function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
var filesWithChangedSetOfUnresolvedImports;
var filesWithInvalidatedResolutions;
var filesWithInvalidatedNonRelativeUnresolvedImports;
- var allFilesHaveInvalidatedResolution = false;
var nonRelativeExternalModuleResolutions = ts.createMultiMap();
+ var resolutionsWithFailedLookups = [];
+ var resolvedFileToResolution = ts.createMultiMap();
var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217
var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
// The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file.
@@ -200915,7 +206919,8 @@ var ts;
closeTypeRootsWatch();
resolvedModuleNames.clear();
resolvedTypeReferenceDirectives.clear();
- allFilesHaveInvalidatedResolution = false;
+ resolvedFileToResolution.clear();
+ resolutionsWithFailedLookups.length = 0;
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
clearPerDirectoryResolutions();
@@ -200937,7 +206942,7 @@ var ts;
return !!value && !!value.length;
}
function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
- if (allFilesHaveInvalidatedResolution || forceAllFilesAsInvalidated) {
+ if (forceAllFilesAsInvalidated) {
// Any file asked would have invalidated resolution
filesWithInvalidatedResolutions = undefined;
return ts.returnTrue;
@@ -200955,7 +206960,6 @@ var ts;
nonRelativeExternalModuleResolutions.clear();
}
function finishCachingPerDirectoryResolution() {
- allFilesHaveInvalidatedResolution = false;
filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
clearPerDirectoryResolutions();
directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
@@ -200966,6 +206970,7 @@ var ts;
});
}
function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
+ var _a;
var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
if (!resolutionHost.getGlobalCache) {
@@ -200976,15 +206981,20 @@ var ts;
if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
// create different collection of failed lookup locations for second pass
// if it will fail and we've already found something during the first pass - we don't want to pollute its results
- var _a = ts.loadModuleFromGlobalCache(ts.Debug.assertDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations;
+ var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
if (resolvedModule) {
- return { resolvedModule: resolvedModule, failedLookupLocations: ts.addRange(primaryResult.failedLookupLocations, failedLookupLocations) };
+ // Modify existing resolution so its saved in the directory cache as well
+ primaryResult.resolvedModule = resolvedModule;
+ (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
+ return primaryResult;
}
}
// Default return the result from the first pass
return primaryResult;
}
- function resolveNamesWithLocalCache(names, containingFile, redirectedReference, cache, perDirectoryCacheWithRedirects, loader, getResolutionWithResolvedFileName, shouldRetryResolution, reusedNames, logChanges) {
+ function resolveNamesWithLocalCache(_a) {
+ var _b;
+ var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges;
var path = resolutionHost.toPath(containingFile);
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path);
var dirPath = ts.getDirectoryPath(path);
@@ -201009,7 +207019,7 @@ var ts;
var resolution = resolutionsInFile.get(name);
// Resolution is valid if it is present and not invalidated
if (!seenNamesInFile.has(name) &&
- allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated ||
+ unmatchedRedirects || !resolution || resolution.isInvalidated ||
// If the name is unresolved import that was invalidated, recalculate
(hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
var existingResolution = resolution;
@@ -201018,13 +207028,13 @@ var ts;
resolution = resolutionInDirectory;
}
else {
- resolution = loader(name, containingFile, compilerOptions, resolutionHost, redirectedReference);
+ resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference);
perDirectoryResolution.set(name, resolution);
}
resolutionsInFile.set(name, resolution);
- watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution);
+ watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
if (existingResolution) {
- stopWatchFailedLookupLocationOfResolution(existingResolution);
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
}
if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
filesWithChangedSetOfUnresolvedImports.push(path);
@@ -201039,7 +207049,7 @@ var ts;
// Stop watching and remove the unused name
resolutionsInFile.forEach(function (resolution, name) {
if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
- stopWatchFailedLookupLocationOfResolution(resolution);
+ stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
resolutionsInFile.delete(name);
}
});
@@ -201063,21 +207073,35 @@ var ts;
}
}
function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
- return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, redirectedReference, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective,
- /*shouldRetryResolution*/ function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
- /*reusedNames*/ undefined, /*logChanges*/ false);
+ return resolveNamesWithLocalCache({
+ names: typeDirectiveNames,
+ containingFile: containingFile,
+ redirectedReference: redirectedReference,
+ cache: resolvedTypeReferenceDirectives,
+ perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
+ loader: ts.resolveTypeReferenceDirective,
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
+ shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
+ });
}
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
- return resolveNamesWithLocalCache(moduleNames, containingFile, redirectedReference, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule,
- /*shouldRetryResolution*/ function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, reusedNames, logChangesWhenResolvingModule);
+ return resolveNamesWithLocalCache({
+ names: moduleNames,
+ containingFile: containingFile,
+ redirectedReference: redirectedReference,
+ cache: resolvedModuleNames,
+ perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
+ loader: resolveModuleName,
+ getResolutionWithResolvedFileName: getResolvedModule,
+ shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
+ reusedNames: reusedNames,
+ logChanges: logChangesWhenResolvingModule
+ });
}
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
return cache && cache.get(moduleName);
}
- function isNodeModulesDirectory(dirPath) {
- return ts.endsWith(dirPath, "/node_modules");
- }
function isNodeModulesAtTypesDirectory(dirPath) {
return ts.endsWith(dirPath, "/node_modules/@types");
}
@@ -201113,7 +207137,7 @@ var ts;
dirPath = ts.getDirectoryPath(dirPath);
}
// If the directory is node_modules use it to watch, always watch it recursively
- if (isNodeModulesDirectory(dirPath)) {
+ if (ts.isNodeModulesDirectory(dirPath)) {
return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
}
var nonRecursive = true;
@@ -201137,26 +207161,33 @@ var ts;
function isPathWithDefaultFailedLookupExtension(path) {
return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
}
- function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution) {
- // No need to set the resolution refCount
- if (resolution.failedLookupLocations && resolution.failedLookupLocations.length) {
- if (resolution.refCount) {
- resolution.refCount++;
+ function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
+ if (resolution.refCount) {
+ resolution.refCount++;
+ ts.Debug.assertDefined(resolution.files);
+ }
+ else {
+ resolution.refCount = 1;
+ ts.Debug.assert(resolution.files === undefined);
+ if (ts.isExternalModuleNameRelative(name)) {
+ watchFailedLookupLocationOfResolution(resolution);
}
else {
- resolution.refCount = 1;
- if (ts.isExternalModuleNameRelative(name)) {
- watchFailedLookupLocationOfResolution(resolution);
- }
- else {
- nonRelativeExternalModuleResolutions.add(name, resolution);
- }
+ nonRelativeExternalModuleResolutions.add(name, resolution);
+ }
+ var resolved = getResolutionWithResolvedFileName(resolution);
+ if (resolved && resolved.resolvedFileName) {
+ resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
}
}
+ (resolution.files || (resolution.files = [])).push(filePath);
}
function watchFailedLookupLocationOfResolution(resolution) {
ts.Debug.assert(!!resolution.refCount);
var failedLookupLocations = resolution.failedLookupLocations;
+ if (!failedLookupLocations.length)
+ return;
+ resolutionsWithFailedLookups.push(resolution);
var setAtRoot = false;
for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
var failedLookupLocation = failedLookupLocations_1[_i];
@@ -201184,14 +207215,11 @@ var ts;
setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217
}
}
- function setRefCountToUndefined(resolution) {
- resolution.refCount = undefined;
- }
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
var program = resolutionHost.getCurrentProgram();
- var updateResolution = program && program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name) ?
- setRefCountToUndefined : watchFailedLookupLocationOfResolution;
- resolutions.forEach(updateResolution);
+ if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
+ resolutions.forEach(watchFailedLookupLocationOfResolution);
+ }
}
function setDirectoryWatcher(dir, dirPath, nonRecursive) {
var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
@@ -201203,14 +207231,20 @@ var ts;
directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
}
}
- function stopWatchFailedLookupLocationOfResolution(resolution) {
- if (!resolution.refCount) {
- return;
- }
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
+ ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
resolution.refCount--;
if (resolution.refCount) {
return;
}
+ var resolved = getResolutionWithResolvedFileName(resolution);
+ if (resolved && resolved.resolvedFileName) {
+ resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
+ }
+ if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
+ // If not watching failed lookups, it wont be there in resolutionsWithFailedLookups
+ return;
+ }
var failedLookupLocations = resolution.failedLookupLocations;
var removeAtRoot = false;
for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
@@ -201253,16 +207287,16 @@ var ts;
// Since the file existence changed, update the sourceFiles cache
cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
}
- if (!allFilesHaveInvalidatedResolution && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
+ if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
resolutionHost.onInvalidatedResolution();
}
}, nonRecursive ? 0 /* None */ : 1 /* Recursive */);
}
- function removeResolutionsOfFileFromCache(cache, filePath) {
+ function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
// Deleted file, stop watching failed lookups for all the resolutions in the file
var resolutions = cache.get(filePath);
if (resolutions) {
- resolutions.forEach(stopWatchFailedLookupLocationOfResolution);
+ resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
cache.delete(filePath);
}
}
@@ -201283,57 +207317,26 @@ var ts;
resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
}
function removeResolutionsOfFile(filePath) {
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath);
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath);
- }
- function invalidateResolutionCache(cache, isInvalidatedResolution, getResolutionWithResolvedFileName) {
- var seen = ts.createMap();
- cache.forEach(function (resolutions, containingFilePath) {
- var dirPath = ts.getDirectoryPath(containingFilePath);
- var seenInDir = seen.get(dirPath);
- if (!seenInDir) {
- seenInDir = ts.createMap();
- seen.set(dirPath, seenInDir);
- }
- resolutions.forEach(function (resolution, name) {
- if (seenInDir.has(name)) {
- return;
- }
- seenInDir.set(name, true);
- if (!resolution.isInvalidated && isInvalidatedResolution(resolution, getResolutionWithResolvedFileName)) {
- // Mark the file as needing re-evaluation of module resolution instead of using it blindly.
- resolution.isInvalidated = true;
- (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true);
- // When its a file with inferred types resolution, invalidate type reference directive resolution
- if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) {
- resolutionHost.onChangedAutomaticTypeDirectiveNames();
- }
- }
- });
- });
- }
- function hasReachedResolutionIterationLimit() {
- var maxSize = resolutionHost.maxNumberOfFilesToIterateForInvalidation || ts.maxNumberOfFilesToIterateForInvalidation;
- return resolvedModuleNames.size > maxSize || resolvedTypeReferenceDirectives.size > maxSize;
- }
- function invalidateResolutions(isInvalidatedResolution) {
- // If more than maxNumberOfFilesToIterateForInvalidation present,
- // just invalidated all files and recalculate the resolutions for files instead
- if (hasReachedResolutionIterationLimit()) {
- allFilesHaveInvalidatedResolution = true;
- return;
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
+ }
+ function invalidateResolution(resolution) {
+ resolution.isInvalidated = true;
+ var changedInAutoTypeReferenced = false;
+ for (var _i = 0, _a = ts.Debug.assertDefined(resolution.files); _i < _a.length; _i++) {
+ var containingFilePath = _a[_i];
+ (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true);
+ // When its a file with inferred types resolution, invalidate type reference directive resolution
+ changedInAutoTypeReferenced = changedInAutoTypeReferenced || containingFilePath.endsWith(ts.inferredTypesContainingFile);
+ }
+ if (changedInAutoTypeReferenced) {
+ resolutionHost.onChangedAutomaticTypeDirectiveNames();
}
- invalidateResolutionCache(resolvedModuleNames, isInvalidatedResolution, getResolvedModule);
- invalidateResolutionCache(resolvedTypeReferenceDirectives, isInvalidatedResolution, getResolvedTypeReferenceDirective);
}
function invalidateResolutionOfFile(filePath) {
removeResolutionsOfFile(filePath);
- invalidateResolutions(
// Resolution is invalidated if the resulting file name is same as the deleted file path
- function (resolution, getResolutionWithResolvedFileName) {
- var result = getResolutionWithResolvedFileName(resolution);
- return !!result && resolutionHost.toPath(result.resolvedFileName) === filePath; // TODO: GH#18217
- });
+ ts.forEach(resolvedFileToResolution.get(filePath), invalidateResolution);
}
function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
@@ -201359,8 +207362,8 @@ var ts;
// Some file or directory in the watching directory is created
// Return early if it does not have any of the watching extension or not the custom failed lookup path
var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath);
- if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || isNodeModulesDirectory(fileOrDirectoryPath) ||
- isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || isNodeModulesDirectory(dirOfFileOrDirectory)) {
+ if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
+ isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
// Invalidate any resolution from this directory
isChangedFailedLookupLocation = function (location) {
var locationPath = resolutionHost.toPath(location);
@@ -201379,20 +207382,21 @@ var ts;
isChangedFailedLookupLocation = function (location) { return resolutionHost.toPath(location) === fileOrDirectoryPath; };
}
}
- var hasChangedFailedLookupLocation = function (resolution) { return ts.some(resolution.failedLookupLocations, isChangedFailedLookupLocation); };
- var invalidatedFilesCount = filesWithInvalidatedResolutions && filesWithInvalidatedResolutions.size;
- invalidateResolutions(
+ var invalidated = false;
// Resolution is invalidated if the resulting file name is same as the deleted file path
- hasChangedFailedLookupLocation);
- return allFilesHaveInvalidatedResolution || filesWithInvalidatedResolutions && filesWithInvalidatedResolutions.size !== invalidatedFilesCount;
+ for (var _i = 0, resolutionsWithFailedLookups_1 = resolutionsWithFailedLookups; _i < resolutionsWithFailedLookups_1.length; _i++) {
+ var resolution = resolutionsWithFailedLookups_1[_i];
+ if (resolution.failedLookupLocations.some(isChangedFailedLookupLocation)) {
+ invalidateResolution(resolution);
+ invalidated = true;
+ }
+ }
+ return invalidated;
}
function closeTypeRootsWatch() {
ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
}
function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
- if (allFilesHaveInvalidatedResolution) {
- return undefined;
- }
if (isInDirectoryPath(rootPath, typeRootPath)) {
return rootPath;
}
@@ -201500,39 +207504,39 @@ var ts;
ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */,
};
}
- function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) {
- var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferencesForUpdate(compilerOptions, oldImportSpecifier));
+ function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
+ var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier));
if (res === oldImportSpecifier)
return undefined;
return res;
}
moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier;
// Note: importingSourceFile is just for usesJsExtensionOnImports
- function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences, redirectTargetsMap) {
+ function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) {
if (preferences === void 0) { preferences = {}; }
- return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile));
+ return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile));
}
moduleSpecifiers.getModuleSpecifier = getModuleSpecifier;
- function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) {
+ function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) {
var info = getInfo(importingSourceFileName, host);
- var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap);
+ var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host);
return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); });
}
moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName;
- function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) {
+ function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) {
var info = getInfo(importingSourceFileName, host);
- var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap);
+ var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host);
return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) ||
getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences);
}
/** Returns an import for each symlink and for the realpath. */
- function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) {
+ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) {
var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol);
if (ambient)
return [ambient];
var info = getInfo(importingSourceFile.path, host);
var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol));
- var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap);
+ var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host);
var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); });
return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); });
@@ -201591,45 +207595,67 @@ var ts;
function comparePathsByNumberOfDirectorySeparators(a, b) {
return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b));
}
- /**
- * Looks for existing imports that use symlinks to this module.
- * Symlinks will be returned first so they are preferred over the real path.
- */
- function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) {
- var redirects = redirectTargetsMap.get(importedFileName);
- var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName];
- var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : "";
+ function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
+ var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
+ var cwd = host.getCurrentDirectory();
+ var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
+ var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray;
+ var importedFileNames = __spreadArrays((referenceRedirect ? [referenceRedirect] : ts.emptyArray), [importedFileName], redirects);
var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
+ if (!preferSymlinks) {
+ var result_12 = ts.forEach(targets, cb);
+ if (result_12)
+ return result_12;
+ }
var links = host.getProbableSymlinks
- ? host.getProbableSymlinks(files)
- : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd);
- var result = [];
+ ? host.getProbableSymlinks(host.getSourceFiles())
+ : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd);
var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive;
- links.forEach(function (resolved, path) {
+ var result = ts.forEachEntry(links, function (resolved, path) {
if (ts.startsWithDirectory(importingFileName, resolved, getCanonicalFileName)) {
- return; // Don't want to a package to globally import from itself
+ return undefined; // Don't want to a package to globally import from itself
}
var target = ts.find(targets, function (t) { return compareStrings(t.slice(0, resolved.length + 1), resolved + "/") === 0 /* EqualTo */; });
if (target === undefined)
- return;
+ return undefined;
var relative = ts.getRelativePathFromDirectory(resolved, target, getCanonicalFileName);
var option = ts.resolvePath(path, relative);
if (!host.fileExists || host.fileExists(option)) {
- result.push(option);
+ var result_13 = cb(option);
+ if (result_13)
+ return result_13;
}
});
- result.push.apply(result, targets);
- if (result.length < 2)
- return result;
+ return result ||
+ (preferSymlinks ? ts.forEach(targets, cb) : undefined);
+ }
+ moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule;
+ /**
+ * Looks for existing imports that use symlinks to this module.
+ * Symlinks will be returned first so they are preferred over the real path.
+ */
+ function getAllModulePaths(importingFileName, importedFileName, host) {
+ var cwd = host.getCurrentDirectory();
+ var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
+ var allFileNames = ts.createMap();
+ var importedFileFromNodeModules = false;
+ forEachFileNameOfModule(importingFileName, importedFileName, host,
+ /*preferSymlinks*/ true, function (path) {
+ // dont return value, so we collect everything
+ allFileNames.set(path, getCanonicalFileName(path));
+ importedFileFromNodeModules = importedFileFromNodeModules || ts.pathContainsNodeModules(path);
+ });
// Sort by paths closest to importing file Name directory
- var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName);
var sortedPaths = [];
- var _loop_18 = function (directory) {
+ var _loop_20 = function (directory) {
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
var pathsInDirectory;
allFileNames.forEach(function (canonicalFileName, fileName) {
if (ts.startsWith(canonicalFileName, directoryStart)) {
- (pathsInDirectory || (pathsInDirectory = [])).push(fileName);
+ // If the importedFile is from node modules, use only paths in node_modules folder as option
+ if (!importedFileFromNodeModules || ts.pathContainsNodeModules(fileName)) {
+ (pathsInDirectory || (pathsInDirectory = [])).push(fileName);
+ }
allFileNames.delete(fileName);
}
});
@@ -201647,9 +207673,9 @@ var ts;
};
var out_directory_1;
for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
- var state_7 = _loop_18(directory);
+ var state_8 = _loop_20(directory);
directory = out_directory_1;
- if (state_7 === "break")
+ if (state_8 === "break")
break;
}
if (allFileNames.size) {
@@ -201709,27 +207735,28 @@ var ts;
if (!parts) {
return undefined;
}
- var packageJsonContent;
- var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex);
+ // Simplify the full file path to something that can be resolved by Node.
+ var moduleSpecifier = moduleFileName;
if (!packageNameOnly) {
- var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
- packageJsonContent = host.fileExists(packageJsonPath)
- ? JSON.parse(host.readFile(packageJsonPath))
- : undefined;
- var versionPaths = packageJsonContent && packageJsonContent.typesVersions
- ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
- : undefined;
- if (versionPaths) {
- var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1);
- var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths);
- if (fromPaths !== undefined) {
- moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths);
+ var packageRootIndex = parts.packageRootIndex;
+ var moduleFileNameForExtensionless = void 0;
+ while (true) {
+ // If the module could be imported by a directory name, use that directory's name
+ var _b = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _b.moduleFileToTry, packageRootPath = _b.packageRootPath;
+ if (packageRootPath) {
+ moduleSpecifier = packageRootPath;
+ break;
+ }
+ if (!moduleFileNameForExtensionless)
+ moduleFileNameForExtensionless = moduleFileToTry;
+ // try with next level of directory
+ packageRootIndex = moduleFileName.indexOf(ts.directorySeparator, packageRootIndex + 1);
+ if (packageRootIndex === -1) {
+ moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
+ break;
}
}
}
- // Simplify the full file path to something that can be resolved by Node.
- // If the module could be imported by a directory name, use that directory's name
- var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName);
var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
// Get a path that's relative to node_modules or the importing file's path
// if node_modules folder is in this folder or any of its parent folders, no need to keep it.
@@ -201742,17 +207769,34 @@ var ts;
var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
// For classic resolution, only allow importing from node_modules/@types, not other node_modules
return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
- function getDirectoryOrExtensionlessFileName(path) {
- // If the file is the main module, it can be imported by the package name
- if (packageJsonContent) {
+ function tryDirectoryWithPackageJson(packageRootIndex) {
+ var packageRootPath = moduleFileName.substring(0, packageRootIndex);
+ var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
+ var moduleFileToTry = moduleFileName;
+ if (host.fileExists(packageJsonPath)) {
+ var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
+ var versionPaths = packageJsonContent.typesVersions
+ ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
+ : undefined;
+ if (versionPaths) {
+ var subModuleName = moduleFileName.slice(packageRootPath.length + 1);
+ var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths);
+ if (fromPaths !== undefined) {
+ moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
+ }
+ }
+ // If the file is the main module, it can be imported by the package name
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
if (ts.isString(mainFileRelative)) {
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
- if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(path))) {
- return packageRootPath;
+ if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
+ return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
}
}
}
+ return { moduleFileToTry: moduleFileToTry };
+ }
+ function getExtensionlessFileName(path) {
// We still have a file name - remove the extension
var fullModulePathWithoutExtension = ts.removeFileExtension(path);
// If the file is /index, it can be imported by its directory name
@@ -202157,10 +208201,6 @@ var ts;
*/
function createProgramHost(system, createProgram) {
var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); });
- var host = system;
- // TODO: `host` is unused!
- // eslint-disable-next-line no-unused-expressions
- host;
return {
useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
getNewLine: function () { return system.newLine; },
@@ -202177,7 +208217,6 @@ var ts;
trace: function (s) { return system.write(s + system.newLine); },
createDirectory: function (path) { return system.createDirectory(path); },
writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); },
- onCachedDirectoryStructureHostCreate: function (cacheHost) { return host = cacheHost || system; },
createHash: ts.maybeBind(system, system.createHash),
createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram
};
@@ -202208,20 +208247,23 @@ var ts;
/**
* Creates the watch compiler host from system for config file in watch mode
*/
- function createWatchCompilerHostOfConfigFile(configFileName, optionsToExtend, watchOptionsToExtend, system, createProgram, reportDiagnostic, reportWatchStatus) {
+ function createWatchCompilerHostOfConfigFile(_a) {
+ var configFileName = _a.configFileName, optionsToExtend = _a.optionsToExtend, watchOptionsToExtend = _a.watchOptionsToExtend, extraFileExtensions = _a.extraFileExtensions, system = _a.system, createProgram = _a.createProgram, reportDiagnostic = _a.reportDiagnostic, reportWatchStatus = _a.reportWatchStatus;
var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system);
var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus);
host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); };
host.configFileName = configFileName;
host.optionsToExtend = optionsToExtend;
host.watchOptionsToExtend = watchOptionsToExtend;
+ host.extraFileExtensions = extraFileExtensions;
return host;
}
ts.createWatchCompilerHostOfConfigFile = createWatchCompilerHostOfConfigFile;
/**
* Creates the watch compiler host from system for compiling root files and options in watch mode
*/
- function createWatchCompilerHostOfFilesAndCompilerOptions(rootFiles, options, watchOptions, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferences) {
+ function createWatchCompilerHostOfFilesAndCompilerOptions(_a) {
+ var rootFiles = _a.rootFiles, options = _a.options, watchOptions = _a.watchOptions, projectReferences = _a.projectReferences, system = _a.system, createProgram = _a.createProgram, reportDiagnostic = _a.reportDiagnostic, reportWatchStatus = _a.reportWatchStatus;
var host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus);
host.rootFiles = rootFiles;
host.options = options;
@@ -202277,12 +208319,30 @@ var ts;
return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
}
ts.createIncrementalProgram = createIncrementalProgram;
- function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptions) {
+ function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptionsOrExtraFileExtensions) {
if (ts.isArray(rootFilesOrConfigFileName)) {
- return ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFilesOrConfigFileName, options, watchOptions, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend); // TODO: GH#18217
+ return ts.createWatchCompilerHostOfFilesAndCompilerOptions({
+ rootFiles: rootFilesOrConfigFileName,
+ options: options,
+ watchOptions: watchOptionsOrExtraFileExtensions,
+ projectReferences: projectReferencesOrWatchOptionsToExtend,
+ system: system,
+ createProgram: createProgram,
+ reportDiagnostic: reportDiagnostic,
+ reportWatchStatus: reportWatchStatus,
+ });
}
else {
- return ts.createWatchCompilerHostOfConfigFile(rootFilesOrConfigFileName, options, projectReferencesOrWatchOptionsToExtend, system, createProgram, reportDiagnostic, reportWatchStatus);
+ return ts.createWatchCompilerHostOfConfigFile({
+ configFileName: rootFilesOrConfigFileName,
+ optionsToExtend: options,
+ watchOptionsToExtend: projectReferencesOrWatchOptionsToExtend,
+ extraFileExtensions: watchOptionsOrExtraFileExtensions,
+ system: system,
+ createProgram: createProgram,
+ reportDiagnostic: reportDiagnostic,
+ reportWatchStatus: reportWatchStatus,
+ });
}
}
ts.createWatchCompilerHost = createWatchCompilerHost;
@@ -202298,16 +208358,13 @@ var ts;
var hasChangedAutomaticTypeDirectiveNames = false; // True if the automatic type directives have changed
var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
var currentDirectory = host.getCurrentDirectory();
- var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, createProgram = host.createProgram;
+ var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, extraFileExtensions = host.extraFileExtensions, createProgram = host.createProgram;
var rootFileNames = host.rootFiles, compilerOptions = host.options, watchOptions = host.watchOptions, projectReferences = host.projectReferences;
var configFileSpecs;
var configFileParsingDiagnostics;
var canConfigFileJsonReportNoInputFiles = false;
var hasChangedConfigFileParsingErrors = false;
var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames);
- if (cachedDirectoryStructureHost && host.onCachedDirectoryStructureHostCreate) {
- host.onCachedDirectoryStructureHostCreate(cachedDirectoryStructureHost);
- }
var directoryStructureHost = cachedDirectoryStructureHost || host;
var parseConfigFileHost = ts.parseConfigHostFromCompilerHostLike(host, directoryStructureHost);
// From tsc we want to get already parsed result and hence check for rootFileNames
@@ -202348,6 +208405,7 @@ var ts;
// Members for ResolutionCacheHost
compilerHost.toPath = toPath;
compilerHost.getCompilationSettings = function () { return compilerOptions; };
+ compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
@@ -202357,7 +208415,6 @@ var ts;
scheduleProgramUpdate();
};
compilerHost.fileIsOpen = ts.returnFalse;
- compilerHost.maxNumberOfFilesToIterateForInvalidation = host.maxNumberOfFilesToIterateForInvalidation;
compilerHost.getCurrentProgram = getCurrentProgram;
compilerHost.writeLog = writeLog;
// Cache for the module resolution
@@ -202390,8 +208447,8 @@ var ts;
// Update the wild card directory watch
watchConfigFileWildCardDirectories();
return configFileName ?
- { getCurrentProgram: getCurrentBuilderProgram, getProgram: synchronizeProgram, close: close } :
- { getCurrentProgram: getCurrentBuilderProgram, getProgram: synchronizeProgram, updateRootFileNames: updateRootFileNames, close: close };
+ { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } :
+ { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close };
function close() {
resolutionCache.clear();
ts.clearMap(sourceFilesCache, function (value) {
@@ -202439,7 +208496,7 @@ var ts;
else {
createNewProgram(hasInvalidatedResolution);
}
- if (host.afterProgramCreate) {
+ if (host.afterProgramCreate && program !== builderProgram) {
host.afterProgramCreate(builderProgram);
}
return builderProgram;
@@ -202455,6 +208512,7 @@ var ts;
resolutionCache.startCachingPerDirectoryResolution();
compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
+ hasChangedAutomaticTypeDirectiveNames = false;
builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
resolutionCache.finishCachingPerDirectoryResolution();
// Update watches
@@ -202499,7 +208557,7 @@ var ts;
// If file is missing on host from cache, we can definitely say file doesnt exist
// otherwise we need to ensure from the disk
if (isFileMissingOnHost(sourceFilesCache.get(path))) {
- return true;
+ return false;
}
return directoryStructureHost.fileExists(fileName);
}
@@ -202596,16 +208654,19 @@ var ts;
host.clearTimeout(timerToUpdateProgram);
}
writeLog("Scheduling update");
- timerToUpdateProgram = host.setTimeout(updateProgram, 250);
+ timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
}
function scheduleProgramReload() {
ts.Debug.assert(!!configFileName);
reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
scheduleProgramUpdate();
}
- function updateProgram() {
+ function updateProgramWithWatchStatus() {
timerToUpdateProgram = undefined;
reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
+ updateProgram();
+ }
+ function updateProgram() {
switch (reloadLevel) {
case ts.ConfigFileProgramReloadLevel.Partial:
ts.perfLogger.logStartUpdateProgram("PartialConfigReload");
@@ -202621,6 +208682,7 @@ var ts;
break;
}
ts.perfLogger.logStopUpdateProgram("Done");
+ return getCurrentBuilderProgram();
}
function reloadFileNamesFromConfigFile() {
writeLog("Reloading new file names and options");
@@ -202645,7 +208707,7 @@ var ts;
watchConfigFileWildCardDirectories();
}
function parseConfigFile() {
- setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend)); // TODO: GH#18217
+ setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217
}
function setConfigFileParsingResult(configFileParseResult) {
rootFileNames = configFileParseResult.fileNames;
@@ -202885,7 +208947,7 @@ var ts;
if (!compilerHost.resolveModuleNames) {
var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
- return ts.loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_3);
+ return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3);
};
}
var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchFilePath = _a.watchFilePath, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
@@ -203295,14 +209357,14 @@ var ts;
}
}
function getSyntaxDiagnostics(cancellationToken) {
- ts.Debug.assertDefined(program);
+ ts.Debug.assertIsDefined(program);
handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic");
}
function getSemanticDiagnostics(cancellationToken) {
- handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic");
+ handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic");
}
function emit(writeFileCallback, cancellationToken, customTransformers) {
- ts.Debug.assertDefined(program);
+ ts.Debug.assertIsDefined(program);
ts.Debug.assert(step === Step.Emit);
// Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
program.backupState();
@@ -203436,11 +209498,11 @@ var ts;
emitBundle(writeFile, customTransformers);
break;
case Step.BuildInvalidatedProjectOfBundle:
- ts.Debug.assertDefined(invalidatedProjectOfBundle).done(cancellationToken);
+ ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken);
step = Step.Done;
break;
case Step.QueueReferencingProjects:
- queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.assertDefined(buildResult));
+ queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.checkDefined(buildResult));
step++;
break;
// Should never be done
@@ -204695,6 +210757,7 @@ var ts;
placeOpenBraceOnNewLineForFunctions: false,
placeOpenBraceOnNewLineForControlBlocks: false,
semicolons: SemicolonPreference.Ignore,
+ trimTrailingWhitespace: true
};
}
ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings;
@@ -204949,7 +211012,7 @@ var ts;
case 247 /* TypeAliasDeclaration */:
case 173 /* TypeLiteral */:
return 2 /* Type */;
- case 321 /* JSDocTypedefTag */:
+ case 322 /* JSDocTypedefTag */:
// If it has no name node, it shares the name with the value declaration below it.
return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */;
case 284 /* EnumMember */:
@@ -204985,7 +211048,11 @@ var ts;
if (node.kind === 290 /* SourceFile */) {
return 1 /* Value */;
}
- else if (node.parent.kind === 259 /* ExportAssignment */ || node.parent.kind === 265 /* ExternalModuleReference */) {
+ else if (node.parent.kind === 259 /* ExportAssignment */
+ || node.parent.kind === 265 /* ExternalModuleReference */
+ || node.parent.kind === 258 /* ImportSpecifier */
+ || node.parent.kind === 255 /* ImportClause */
+ || ts.isImportEqualsDeclaration(node.parent) && node === node.parent.name) {
return 7 /* All */;
}
else if (isInRightSideOfInternalImportEqualsDeclaration(node)) {
@@ -205266,8 +211333,8 @@ var ts;
return "class" /* classElement */;
case 246 /* InterfaceDeclaration */: return "interface" /* interfaceElement */;
case 247 /* TypeAliasDeclaration */:
- case 314 /* JSDocCallbackTag */:
- case 321 /* JSDocTypedefTag */:
+ case 315 /* JSDocCallbackTag */:
+ case 322 /* JSDocTypedefTag */:
return "type" /* typeElement */;
case 248 /* EnumDeclaration */: return "enum" /* enumElement */;
case 242 /* VariableDeclaration */:
@@ -206181,7 +212248,7 @@ var ts;
function getPossibleGenericSignatures(called, typeArgumentCount, checker) {
var type = checker.getTypeAtLocation(called);
if (ts.isOptionalChain(called.parent)) {
- type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true);
+ type = removeOptionality(type, ts.isOptionalChainRoot(called.parent), /*isOptionalChain*/ true);
}
var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures();
return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; });
@@ -206404,10 +212471,28 @@ var ts;
var range = isInComment(sourceFile, position, /*tokenAtPosition*/ undefined);
return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end));
}
+ function getReplacementSpanForContextToken(contextToken) {
+ if (!contextToken)
+ return undefined;
+ switch (contextToken.kind) {
+ case 10 /* StringLiteral */:
+ case 14 /* NoSubstitutionTemplateLiteral */:
+ return createTextSpanFromStringLiteralLikeContent(contextToken);
+ default:
+ return createTextSpanFromNode(contextToken);
+ }
+ }
+ ts.getReplacementSpanForContextToken = getReplacementSpanForContextToken;
function createTextSpanFromNode(node, sourceFile, endNode) {
return ts.createTextSpanFromBounds(node.getStart(sourceFile), (endNode || node).getEnd());
}
ts.createTextSpanFromNode = createTextSpanFromNode;
+ function createTextSpanFromStringLiteralLikeContent(node) {
+ if (node.isUnterminated)
+ return undefined;
+ return ts.createTextSpanFromBounds(node.getStart() + 1, node.getEnd() - 1);
+ }
+ ts.createTextSpanFromStringLiteralLikeContent = createTextSpanFromStringLiteralLikeContent;
function createTextRangeFromNode(node, sourceFile) {
return ts.createRange(node.getStart(sourceFile), node.end);
}
@@ -206492,6 +212577,10 @@ var ts;
: ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name);
}
ts.getNameFromPropertyName = getNameFromPropertyName;
+ function programContainsModules(program) {
+ return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!(s.externalModuleIndicator || s.commonJsModuleIndicator); });
+ }
+ ts.programContainsModules = programContainsModules;
function programContainsEs6Modules(program) {
return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator; });
}
@@ -206500,14 +212589,27 @@ var ts;
return !!compilerOptions.module || compilerOptions.target >= 2 /* ES2015 */ || !!compilerOptions.noEmit;
}
ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules;
- function hostUsesCaseSensitiveFileNames(host) {
- return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false;
+ function createModuleSpecifierResolutionHost(program, host) {
+ // Mix in `getProbableSymlinks` from Program when host doesn't have it
+ // in order for non-Project hosts to have a symlinks cache.
+ return {
+ fileExists: function (fileName) { return program.fileExists(fileName); },
+ getCurrentDirectory: function () { return host.getCurrentDirectory(); },
+ readFile: ts.maybeBind(host, host.readFile),
+ useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
+ getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || (function () { return program.getProbableSymlinks(); }),
+ getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation),
+ getSourceFiles: function () { return program.getSourceFiles(); },
+ redirectTargetsMap: program.redirectTargetsMap,
+ getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); },
+ isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); },
+ };
}
- ts.hostUsesCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames;
- function hostGetCanonicalFileName(host) {
- return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host));
+ ts.createModuleSpecifierResolutionHost = createModuleSpecifierResolutionHost;
+ function getModuleSpecifierResolverHost(program, host) {
+ return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } });
}
- ts.hostGetCanonicalFileName = hostGetCanonicalFileName;
+ ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost;
function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) {
return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined;
}
@@ -206628,16 +212730,26 @@ var ts;
return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; });
}
ts.findModifier = findModifier;
- function insertImport(changes, sourceFile, importDecl, blankLineBetween) {
- var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax);
+ function insertImports(changes, sourceFile, imports, blankLineBetween) {
+ var decl = ts.isArray(imports) ? imports[0] : imports;
+ var importKindPredicate = decl.kind === 225 /* VariableStatement */ ? ts.isRequireVariableDeclarationStatement : ts.isAnyImportSyntax;
+ var lastImportDeclaration = ts.findLast(sourceFile.statements, function (statement) { return importKindPredicate(statement); });
if (lastImportDeclaration) {
- changes.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl);
+ if (ts.isArray(imports)) {
+ changes.insertNodesAfter(sourceFile, lastImportDeclaration, imports);
+ }
+ else {
+ changes.insertNodeAfter(sourceFile, lastImportDeclaration, imports);
+ }
+ }
+ else if (ts.isArray(imports)) {
+ changes.insertNodesAtTopOfFile(sourceFile, imports, blankLineBetween);
}
else {
- changes.insertNodeAtTopOfFile(sourceFile, importDecl, blankLineBetween);
+ changes.insertNodeAtTopOfFile(sourceFile, imports, blankLineBetween);
}
}
- ts.insertImport = insertImport;
+ ts.insertImports = insertImports;
function getTypeKeywordOfTypeOnlyImport(importClause, sourceFile) {
ts.Debug.assert(importClause.isTypeOnly);
return ts.cast(importClause.getChildAt(0, sourceFile), isTypeKeywordToken);
@@ -206853,8 +212965,8 @@ var ts;
* The default is CRLF.
*/
function getNewLineOrDefaultFromHost(host, formatSettings) {
- return (formatSettings && formatSettings.newLineCharacter) ||
- (host.getNewLine && host.getNewLine()) ||
+ var _a;
+ return (formatSettings === null || formatSettings === void 0 ? void 0 : formatSettings.newLineCharacter) || ((_a = host.getNewLine) === null || _a === void 0 ? void 0 : _a.call(host)) ||
carriageReturnLineFeed;
}
ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost;
@@ -206971,14 +213083,14 @@ var ts;
var symbol = checker.getSymbolAtLocation(node.name);
var renameInfo = symbol && renameMap.get(String(ts.getSymbolId(symbol)));
if (renameInfo && renameInfo.text !== (node.name || node.propertyName).getText()) {
- clone = ts.createBindingElement(node.dotDotDotToken, node.propertyName || node.name, renameInfo, node.initializer);
+ clone = ts.setOriginalNode(ts.createBindingElement(node.dotDotDotToken, node.propertyName || node.name, renameInfo, node.initializer), node);
}
}
else if (renameMap && checker && ts.isIdentifier(node)) {
var symbol = checker.getSymbolAtLocation(node);
var renameInfo = symbol && renameMap.get(String(ts.getSymbolId(symbol)));
if (renameInfo) {
- clone = ts.createIdentifier(renameInfo.text);
+ clone = ts.setOriginalNode(ts.createIdentifier(renameInfo.text), node);
}
}
if (!clone) {
@@ -207042,6 +213154,27 @@ var ts;
addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild);
}
ts.suppressTrailingTrivia = suppressTrailingTrivia;
+ function copyComments(sourceNode, targetNode) {
+ var sourceFile = sourceNode.getSourceFile();
+ var text = sourceFile.text;
+ if (hasLeadingLineBreak(sourceNode, text)) {
+ copyLeadingComments(sourceNode, targetNode, sourceFile);
+ }
+ else {
+ copyTrailingAsLeadingComments(sourceNode, targetNode, sourceFile);
+ }
+ copyTrailingComments(sourceNode, targetNode, sourceFile);
+ }
+ ts.copyComments = copyComments;
+ function hasLeadingLineBreak(node, text) {
+ var start = node.getFullStart();
+ var end = node.getStart();
+ for (var i = start; i < end; i++) {
+ if (text.charCodeAt(i) === 10 /* lineFeed */)
+ return true;
+ }
+ return false;
+ }
function addEmitFlagsRecursively(node, flag, getChild) {
ts.addEmitFlags(node, flag);
var child = getChild(node);
@@ -207135,6 +213268,11 @@ var ts;
idx = change.indexOf('"' + name);
return idx === -1 ? -1 : idx + 1;
}
+ /* @internal */
+ function needsParentheses(expression) {
+ return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression);
+ }
+ ts.needsParentheses = needsParentheses;
function getContextualTypeFromParent(node, checker) {
var parent = node.parent;
switch (parent.kind) {
@@ -207154,9 +213292,6 @@ var ts;
}
ts.getContextualTypeFromParent = getContextualTypeFromParent;
function quote(text, preferences) {
- if (/^\d+$/.test(text)) {
- return text;
- }
// Editors can pass in undefined or empty string - we want to infer the preference in those cases.
var quotePreference = preferences.quotePreference || "auto";
var quoted = JSON.stringify(text);
@@ -207204,6 +213339,7 @@ var ts;
return checker.getTypeAtLocation(caseClause.parent.parent.expression);
}
ts.getSwitchedType = getSwitchedType;
+ ts.ANONYMOUS = "anonymous function";
function getTypeNodeIfAccessible(type, enclosingScope, program, host) {
var checker = program.getTypeChecker();
var typeIsAccessible = true;
@@ -207215,14 +213351,7 @@ var ts;
reportInaccessibleThisError: notAccessible,
reportPrivateInBaseOfClassExpression: notAccessible,
reportInaccessibleUniqueSymbolError: notAccessible,
- moduleResolverHost: {
- readFile: host.readFile,
- fileExists: host.fileExists,
- directoryExists: host.directoryExists,
- getSourceFiles: program.getSourceFiles,
- getCurrentDirectory: program.getCurrentDirectory,
- getCommonSourceDirectory: program.getCommonSourceDirectory,
- }
+ moduleResolverHost: getModuleSpecifierResolverHost(program, host)
});
return typeIsAccessible ? res : undefined;
}
@@ -207543,6 +213672,63 @@ var ts;
return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
}
ts.firstOrOnly = firstOrOnly;
+ function getNameForExportedSymbol(symbol, scriptTarget) {
+ if (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */) {
+ // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
+ return ts.firstDefined(symbol.declarations, function (d) { return ts.isExportAssignment(d) && ts.isIdentifier(d.expression) ? d.expression.text : undefined; })
+ || ts.codefix.moduleSymbolToValidIdentifier(ts.Debug.checkDefined(symbol.parent), scriptTarget);
+ }
+ return symbol.name;
+ }
+ ts.getNameForExportedSymbol = getNameForExportedSymbol;
+ /**
+ * Useful to check whether a string contains another string at a specific index
+ * without allocating another string or traversing the entire contents of the outer string.
+ *
+ * This function is useful in place of either of the following:
+ *
+ * ```ts
+ * // Allocates
+ * haystack.substr(startIndex, needle.length) === needle
+ *
+ * // Full traversal
+ * haystack.indexOf(needle, startIndex) === startIndex
+ * ```
+ *
+ * @param haystack The string that potentially contains `needle`.
+ * @param needle The string whose content might sit within `haystack`.
+ * @param startIndex The index within `haystack` to start searching for `needle`.
+ */
+ function stringContainsAt(haystack, needle, startIndex) {
+ var needleLength = needle.length;
+ if (needleLength + startIndex > haystack.length) {
+ return false;
+ }
+ for (var i = 0; i < needleLength; i++) {
+ if (needle.charCodeAt(i) !== haystack.charCodeAt(i + startIndex))
+ return false;
+ }
+ return true;
+ }
+ ts.stringContainsAt = stringContainsAt;
+ function startsWithUnderscore(name) {
+ return name.charCodeAt(0) === 95 /* _ */;
+ }
+ ts.startsWithUnderscore = startsWithUnderscore;
+ function isGlobalDeclaration(declaration) {
+ return !isNonGlobalDeclaration(declaration);
+ }
+ ts.isGlobalDeclaration = isGlobalDeclaration;
+ function isNonGlobalDeclaration(declaration) {
+ var sourceFile = declaration.getSourceFile();
+ // If the file is not a module, the declaration is global
+ if (!sourceFile.externalModuleIndicator && !sourceFile.commonJsModuleIndicator) {
+ return false;
+ }
+ // If the file is a module written in TypeScript, it still might be in a `declare global` augmentation
+ return ts.isInJSFile(declaration) || !ts.findAncestor(declaration, ts.isGlobalScopeAugmentation);
+ }
+ ts.isNonGlobalDeclaration = isNonGlobalDeclaration;
// #endregion
})(ts || (ts = {}));
var ts;
@@ -207673,7 +213859,7 @@ var ts;
if (templateStack.length > 0) {
var lastTemplateStackToken = ts.lastOrUndefined(templateStack);
if (lastTemplateStackToken === 15 /* TemplateHead */) {
- token = scanner.reScanTemplateToken();
+ token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false);
// Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us.
if (token === 17 /* TemplateTail */) {
templateStack.pop();
@@ -208204,18 +214390,18 @@ var ts;
pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param"
pos = tag.tagName.end;
switch (tag.kind) {
- case 316 /* JSDocParameterTag */:
+ case 317 /* JSDocParameterTag */:
processJSDocParameterTag(tag);
break;
- case 320 /* JSDocTemplateTag */:
+ case 321 /* JSDocTemplateTag */:
processJSDocTemplateTag(tag);
pos = tag.end;
break;
- case 319 /* JSDocTypeTag */:
+ case 320 /* JSDocTypeTag */:
processElement(tag.typeExpression);
pos = tag.end;
break;
- case 317 /* JSDocReturnTag */:
+ case 318 /* JSDocReturnTag */:
processElement(tag.typeExpression);
pos = tag.end;
break;
@@ -208519,11 +214705,11 @@ var ts;
if (!contextToken || !ts.isStringLiteralLike(contextToken))
return undefined;
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host);
- return convertStringLiteralCompletions(entries, sourceFile, checker, log, preferences);
+ return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, preferences);
}
}
StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions;
- function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) {
+ function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, preferences) {
if (completion === undefined) {
return undefined;
}
@@ -208532,11 +214718,17 @@ var ts;
return convertPathCompletions(completion.paths);
case 1 /* Properties */: {
var entries = [];
- Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary
+ Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries };
}
case 2 /* Types */: {
- var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); });
+ var entries = completion.types.map(function (type) { return ({
+ name: type.value,
+ kindModifiers: "" /* none */,
+ kind: "string" /* string */,
+ sortText: "0",
+ replacementSpan: ts.getReplacementSpanForContextToken(contextToken)
+ }); });
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries };
}
default:
@@ -208703,7 +214895,9 @@ var ts;
function stringLiteralCompletionsFromProperties(type) {
return type && {
kind: 1 /* Properties */,
- symbols: type.getApparentProperties().filter(function (prop) { return !ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration); }),
+ symbols: type.getApparentProperties().filter(function (prop) {
+ return !ts.isPrivateIdentifierPropertyDeclaration(ts.isTransientSymbol(prop) && prop.syntheticOrigin ? prop.syntheticOrigin.valueDeclaration : prop.valueDeclaration);
+ }),
hasIndexSignature: ts.hasIndexSignature(type)
};
}
@@ -209135,6 +215329,22 @@ var ts;
SortText["AutoImportSuggestions"] = "5";
SortText["JavascriptIdentifiers"] = "6";
})(SortText = Completions.SortText || (Completions.SortText = {}));
+ /**
+ * Special values for `CompletionInfo['source']` used to disambiguate
+ * completion items with the same `name`. (Each completion item must
+ * have a unique name/source combination, because those two fields
+ * comprise `CompletionEntryIdentifier` in `getCompletionEntryDetails`.
+ *
+ * When the completion item is an auto-import suggestion, the source
+ * is the module specifier of the suggestion. To avoid collisions,
+ * the values here should not be a module specifier we would ever
+ * generate for an auto-import.
+ */
+ var CompletionSource;
+ (function (CompletionSource) {
+ /** Completions that require `this.` insertion text */
+ CompletionSource["ThisProperty"] = "ThisProperty/";
+ })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
var SymbolOriginInfoKind;
(function (SymbolOriginInfoKind) {
SymbolOriginInfoKind[SymbolOriginInfoKind["ThisType"] = 1] = "ThisType";
@@ -209152,7 +215362,7 @@ var ts;
return !!(origin.kind & 2 /* SymbolMember */);
}
function originIsExport(origin) {
- return !!(origin.kind & 4 /* Export */);
+ return !!(origin && origin.kind & 4 /* Export */);
}
function originIsPromise(origin) {
return !!(origin.kind & 8 /* Promise */);
@@ -209282,14 +215492,16 @@ var ts;
}
var entries = [];
if (isUncheckedFile(sourceFile, compilerOptions)) {
- var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
+ /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217
}
else {
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
return undefined;
}
- getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
+ getCompletionEntriesFromSymbols(symbols, entries,
+ /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap);
}
if (keywordFilters !== 0 /* None */) {
var entryNames = ts.arrayToSet(entries, function (e) { return e.name; });
@@ -209302,7 +215514,7 @@ var ts;
}
for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
var literal = literals_1[_b];
- entries.push(createCompletionEntryForLiteral(literal));
+ entries.push(createCompletionEntryForLiteral(literal, preferences));
}
return { isGlobalCompletion: isInSnippetScope, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation: isNewIdentifierLocation, entries: entries };
}
@@ -209326,7 +215538,8 @@ var ts;
return;
}
var realName = ts.unescapeLeadingUnderscores(name);
- if (ts.addToSeen(uniqueNames, realName) && ts.isIdentifierText(realName, target)) {
+ if (!uniqueNames.has(realName) && ts.isIdentifierText(realName, target)) {
+ uniqueNames.add(realName);
entries.push({
name: realName,
kind: "warning" /* warning */,
@@ -209337,26 +215550,27 @@ var ts;
}
});
}
- var completionNameForLiteral = function (literal) {
- return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal);
- };
- function createCompletionEntryForLiteral(literal) {
- return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
+ function completionNameForLiteral(literal, preferences) {
+ return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" :
+ ts.isString(literal) ? ts.quote(literal, preferences) : JSON.stringify(literal);
}
- function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
+ function createCompletionEntryForLiteral(literal, preferences) {
+ return { name: completionNameForLiteral(literal, preferences), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
+ }
+ function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) {
var insertText;
- var replacementSpan;
+ var replacementSpan = ts.getReplacementSpanForContextToken(contextToken);
var insertQuestionDot = origin && originIsNullableMember(origin);
var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
if (origin && originIsThisType(origin)) {
insertText = needsConvertPropertyAccess
- ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]"
+ ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(name, preferences) + "]"
: "this" + (insertQuestionDot ? "?." : ".") + name;
}
// We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790.
// Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro.
else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) {
- insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name;
+ insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(name, preferences) + "]" : "[" + name + "]" : name;
if (insertQuestionDot || propertyAccessToConvert.questionDotToken) {
insertText = "?." + insertText;
}
@@ -209411,43 +215625,59 @@ var ts;
replacementSpan: replacementSpan,
};
}
+ function quotePropertyName(name, preferences) {
+ if (/^\d+$/.test(name)) {
+ return name;
+ }
+ return ts.quote(name, preferences);
+ }
function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) {
return localSymbol === recommendedCompletion ||
!!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion;
}
function getSourceFromOrigin(origin) {
- return origin && originIsExport(origin) ? ts.stripQuotes(origin.moduleSymbol.name) : undefined;
+ if (originIsExport(origin)) {
+ return ts.stripQuotes(origin.moduleSymbol.name);
+ }
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
+ return CompletionSource.ThisProperty;
+ }
}
- function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) {
+ function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) {
var start = ts.timestamp();
// Tracks unique names.
- // We don't set this for global variables or completions from external module exports, because we can have multiple of those.
- // Based on the order we add things we will always see locals first, then globals, then module exports.
+ // Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
+ // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
// So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name.
var uniques = ts.createMap();
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
var symbol = symbols_1[_i];
var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined;
- var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind);
+ var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
if (!info) {
continue;
}
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
- if (uniques.has(name)) {
+ if (uniques.get(name)) {
continue;
}
- var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
+ var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences);
if (!entry) {
continue;
}
- // Latter case tests whether this is a global variable.
- if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { // TODO: GH#18217
- uniques.set(name, true);
- }
+ /** True for locals; false for globals, module exports from other files, `this.` completions. */
+ var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
+ uniques.set(name, shouldShadowLaterSymbols);
entries.push(entry);
}
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start));
- return uniques;
+ // Prevent consumers of this map from having to worry about
+ // the boolean value. Externally, it should be seen as the
+ // set of all names.
+ return {
+ has: function (name) { return uniques.has(name); },
+ add: function (name) { return uniques.set(name, true); },
+ };
}
Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
function getLabelCompletionAtPosition(node) {
@@ -209480,7 +215710,7 @@ var ts;
}
return entries;
}
- function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) {
+ function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) {
var compilerOptions = program.getCompilerOptions();
var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host);
if (!completionData) {
@@ -209490,7 +215720,7 @@ var ts;
return { type: "request", request: completionData };
}
var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation;
- var literal = ts.find(literals, function (l) { return completionNameForLiteral(l) === entryId.name; });
+ var literal = ts.find(literals, function (l) { return completionNameForLiteral(l, preferences) === entryId.name; });
if (literal !== undefined)
return { type: "literal", literal: literal };
// Find the symbol with the matching entry name.
@@ -209499,20 +215729,12 @@ var ts;
// completion entry.
return ts.firstDefined(symbols, function (symbol) {
var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)];
- var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind);
+ var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind, completionData.isJsxIdentifierExpected);
return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source
? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
: undefined;
}) || { type: "none" };
}
- function getSymbolName(symbol, origin, target) {
- return origin && originIsExport(origin) && ((origin.isDefaultExport && symbol.escapedName === "default" /* Default */) ||
- (symbol.escapedName === "export=" /* ExportEquals */))
- // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
- ? ts.firstDefined(symbol.declarations, function (d) { return ts.isExportAssignment(d) && ts.isIdentifier(d.expression) ? d.expression.text : undefined; })
- || ts.codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target)
- : symbol.name;
- }
function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) {
var typeChecker = program.getTypeChecker();
var compilerOptions = program.getCompilerOptions();
@@ -209522,7 +215744,7 @@ var ts;
return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken);
}
// Compute all the completion symbols again.
- var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host);
+ var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
switch (symbolCompletion.type) {
case "request": {
var request = symbolCompletion.request;
@@ -209544,7 +215766,7 @@ var ts;
}
case "literal": {
var literal = symbolCompletion.literal;
- return createSimpleDetails(completionNameForLiteral(literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral);
+ return createSimpleDetails(completionNameForLiteral(literal, preferences), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral);
}
case "none":
// Didn't find a symbol with this name. See if we can find a keyword instead.
@@ -209575,11 +215797,11 @@ var ts;
}
var moduleSymbol = symbolOriginInfo.moduleSymbol;
var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
- var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction;
+ var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction;
return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
}
- function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) {
- var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host);
+ function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host, preferences) {
+ var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
return completion.type === "symbol" ? completion.symbol : undefined;
}
Completions.getCompletionEntrySymbol = getCompletionEntrySymbol;
@@ -209704,7 +215926,7 @@ var ts;
currentToken = ts.getTokenAtPosition(sourceFile, position);
if (!currentToken ||
(!ts.isDeclarationName(currentToken) &&
- (currentToken.parent.kind !== 322 /* JSDocPropertyTag */ ||
+ (currentToken.parent.kind !== 323 /* JSDocPropertyTag */ ||
currentToken.parent.name !== currentToken))) {
// Use as type location if inside tag's type expression
insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression);
@@ -209744,6 +215966,7 @@ var ts;
var isRightOfOpenTag = false;
var isStartingCloseTag = false;
var isJsxInitializer = false;
+ var isJsxIdentifierExpected = false;
var location = ts.getTouchingPropertyName(sourceFile, position);
if (contextToken) {
// Bail out if this is a known invalid completion location
@@ -209822,6 +216045,7 @@ var ts;
case 267 /* JsxSelfClosingElement */:
case 266 /* JsxElement */:
case 268 /* JsxOpeningElement */:
+ isJsxIdentifierExpected = true;
if (contextToken.kind === 29 /* LessThanToken */) {
isRightOfOpenTag = true;
location = contextToken;
@@ -209833,6 +216057,7 @@ var ts;
isJsxInitializer = true;
break;
case 75 /* Identifier */:
+ isJsxIdentifierExpected = true;
// For `` we don't want to treat this as a jsx inializer, instead it's the attribute name.
if (parent !== previousToken.parent &&
@@ -209859,7 +216084,8 @@ var ts;
getTypeScriptMemberSymbols();
}
else if (isRightOfOpenTag) {
- var tagSymbols = ts.Debug.assertEachDefined(typeChecker.getJsxIntrinsicTagNamesAt(location), "getJsxIntrinsicTagNames() should all be defined");
+ var tagSymbols = typeChecker.getJsxIntrinsicTagNamesAt(location);
+ ts.Debug.assertEachIsDefined(tagSymbols, "getJsxIntrinsicTagNames() should all be defined");
tryGetGlobalSymbols();
symbols = tagSymbols.concat(symbols);
completionKind = 3 /* MemberLike */;
@@ -209902,15 +216128,16 @@ var ts;
isJsxInitializer: isJsxInitializer,
insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
symbolToSortTextMap: symbolToSortTextMap,
- isTypeOnlyLocation: isTypeOnly
+ isTypeOnlyLocation: isTypeOnly,
+ isJsxIdentifierExpected: isJsxIdentifierExpected,
};
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
- case 316 /* JSDocParameterTag */:
- case 322 /* JSDocPropertyTag */:
- case 317 /* JSDocReturnTag */:
- case 319 /* JSDocTypeTag */:
- case 321 /* JSDocTypedefTag */:
+ case 317 /* JSDocParameterTag */:
+ case 323 /* JSDocPropertyTag */:
+ case 318 /* JSDocReturnTag */:
+ case 320 /* JSDocTypeTag */:
+ case 322 /* JSDocTypedefTag */:
return true;
default:
return false;
@@ -209935,7 +216162,8 @@ var ts;
symbol = ts.skipAlias(symbol, typeChecker);
if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) {
// Extract module or enum members
- var exportedSymbols = ts.Debug.assertEachDefined(typeChecker.getExportsOfModule(symbol), "getExportsOfModule() should all be defined");
+ var exportedSymbols = typeChecker.getExportsOfModule(symbol);
+ ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined");
var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : (node.parent), symbol.name); };
var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol); };
var isValidAccess = isNamespaceName
@@ -210078,6 +216306,7 @@ var ts;
function tryGetGlobalSymbols() {
var result = tryGetObjectLikeCompletionSymbols()
|| tryGetImportOrExportClauseCompletionSymbols()
+ || tryGetLocalNamedExportCompletionSymbols()
|| tryGetConstructorCompletion()
|| tryGetClassLikeCompletionSymbols()
|| tryGetJsxCompletionSymbols()
@@ -210147,7 +216376,8 @@ var ts;
var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
isInSnippetScope = isSnippetScope(scopeNode);
var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
- symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined");
+ symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings);
+ ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
var symbol = symbols_2[_i];
if (!typeChecker.isArgumentsSymbol(symbol) &&
@@ -210158,7 +216388,7 @@ var ts;
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 290 /* SourceFile */) {
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
- if (thisType) {
+ if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
var symbol = _b[_a];
symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ };
@@ -210192,20 +216422,17 @@ var ts;
filterGlobalCompletion(symbols);
}
function shouldOfferImportCompletions() {
- // If not already a module, must have modules enabled and not currently be in a commonjs module. (TODO: import completions for commonjs)
+ // If not already a module, must have modules enabled.
if (!preferences.includeCompletionsForModuleExports)
return false;
// If already using ES6 modules, OK to continue using them.
- if (sourceFile.externalModuleIndicator)
+ if (sourceFile.externalModuleIndicator || sourceFile.commonJsModuleIndicator)
return true;
- // If already using commonjs, don't introduce ES6.
- if (sourceFile.commonJsModuleIndicator)
- return false;
// If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK.
if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()))
return true;
// If some file is using ES6 modules, assume that it's OK to add more.
- return ts.programContainsEs6Modules(program);
+ return ts.programContainsModules(program);
}
function isSnippetScope(scopeNode) {
switch (scopeNode.kind) {
@@ -210348,6 +216575,7 @@ var ts;
var startTime = ts.timestamp();
log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : ""));
var seenResolvedModules = ts.createMap();
+ var seenExports = ts.createMap();
/** Bucket B */
var aliasesToAlreadyIncludedSymbols = ts.createMap();
/** Bucket C */
@@ -210368,17 +216596,20 @@ var ts;
}
// Don't add another completion for `export =` of a symbol that's already global.
// So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`.
- if (resolvedModuleSymbol !== moduleSymbol &&
- ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator && !ts.findAncestor(d, ts.isGlobalScopeAugmentation); })) {
+ if (resolvedModuleSymbol !== moduleSymbol && ts.every(resolvedModuleSymbol.declarations, ts.isNonGlobalDeclaration)) {
pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true);
}
- for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) {
+ for (var _i = 0, _a = typeChecker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
var symbol = _a[_i];
+ var symbolId = ts.getSymbolId(symbol).toString();
+ // `getExportsAndPropertiesOfModule` can include duplicates
+ if (!ts.addToSeen(seenExports, symbolId)) {
+ continue;
+ }
// If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion.
if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) {
continue;
}
- var symbolId = ts.getSymbolId(symbol).toString();
// If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols.
var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol;
// If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check).
@@ -210428,7 +216659,7 @@ var ts;
var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport };
results.push({
symbol: symbol,
- symbolName: getSymbolName(symbol, origin, target),
+ symbolName: ts.getNameForExportedSymbol(symbol, target),
origin: origin,
skipFilter: skipFilter,
});
@@ -210617,7 +216848,7 @@ var ts;
}
if (typeMembers && typeMembers.length > 0) {
// Add filtered items to the completion list
- symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers));
+ symbols = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
}
setSortTextToOptionalMember();
return 1 /* Success */;
@@ -210634,8 +216865,6 @@ var ts;
* export { | };
*
* Relevant symbols are stored in the captured 'symbols' variable.
- *
- * @returns true if 'symbols' was successfully populated; false otherwise.
*/
function tryGetImportOrExportClauseCompletionSymbols() {
// `import { |` or `import { a as 0, | }`
@@ -210643,9 +216872,10 @@ var ts;
? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : undefined;
if (!namedImportsOrExports)
return 0 /* Continue */;
- // cursor is in an import clause
- // try to show exported member for imported module
+ // try to show exported member for imported/re-exported module
var moduleSpecifier = (namedImportsOrExports.kind === 257 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier;
+ if (!moduleSpecifier)
+ return namedImportsOrExports.kind === 257 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */;
var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217
if (!moduleSpecifierSymbol)
return 2 /* Fail */;
@@ -210656,6 +216886,35 @@ var ts;
symbols = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.get(e.escapedName); });
return 1 /* Success */;
}
+ /**
+ * Adds local declarations for completions in named exports:
+ *
+ * export { | };
+ *
+ * Does not check for the absence of a module specifier (`export {} from "./other"`)
+ * because `tryGetImportOrExportClauseCompletionSymbols` runs first and handles that,
+ * preventing this function from running.
+ */
+ function tryGetLocalNamedExportCompletionSymbols() {
+ var _a;
+ var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */)
+ ? ts.tryCast(contextToken.parent, ts.isNamedExports)
+ : undefined;
+ if (!namedExports) {
+ return 0 /* Continue */;
+ }
+ var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration));
+ completionKind = 5 /* None */;
+ isNewIdentifierLocation = false;
+ (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) {
+ var _a, _b;
+ symbols.push(symbol);
+ if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) {
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.OptionalMember;
+ }
+ });
+ return 1 /* Success */;
+ }
/**
* Aggregates relevant symbols for completion in class declaration
* Relevant symbols are stored in the captured 'symbols' variable.
@@ -210884,7 +217143,6 @@ var ts;
case 96 /* ImportKeyword */:
case 115 /* LetKeyword */:
case 81 /* ConstKeyword */:
- case 121 /* YieldKeyword */:
case 145 /* TypeKeyword */: // type htm|
return true;
case 41 /* AsteriskToken */:
@@ -210921,7 +217179,6 @@ var ts;
case 119 /* PublicKeyword */:
case 120 /* StaticKeyword */:
case 109 /* VarKeyword */:
- case 121 /* YieldKeyword */:
return true;
case 126 /* AsyncKeyword */:
return ts.isPropertyDeclaration(contextToken.parent);
@@ -211008,7 +217265,7 @@ var ts;
});
}
}
- // Set SortText to OptionalMember if it is an optinoal member
+ // Set SortText to OptionalMember if it is an optional member
function setSortTextToOptionalMember() {
symbols.forEach(function (m) {
if (m.flags & 16777216 /* Optional */) {
@@ -211064,7 +217321,8 @@ var ts;
return baseSymbols.filter(function (propertySymbol) {
return !existingMemberNames.has(propertySymbol.escapedName) &&
!!propertySymbol.declarations &&
- !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */);
+ !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) &&
+ !ts.isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration);
});
}
/**
@@ -211097,8 +217355,8 @@ var ts;
return node.getStart(sourceFile) <= position && position <= node.getEnd();
}
}
- function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind) {
- var name = getSymbolName(symbol, origin, target);
+ function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) {
+ var name = originIsExport(origin) ? ts.getNameForExportedSymbol(symbol, target) : symbol.name;
if (name === undefined
// If the symbol is external module, don't show it in the completion list
// (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there)
@@ -211108,7 +217366,7 @@ var ts;
return undefined;
}
var validNameResult = { name: name, needsConvertPropertyAccess: false };
- if (ts.isIdentifierText(name, target) || symbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
+ if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
return validNameResult;
}
switch (kind) {
@@ -211273,8 +217531,8 @@ var ts;
*/
function getPropertiesForCompletion(type, checker) {
return type.isUnion()
- ? ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined")
- : ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined");
+ ? ts.Debug.checkEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined")
+ : ts.Debug.checkEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined");
}
/**
* Returns the immediate owning class declaration of a context token,
@@ -211283,7 +217541,7 @@ var ts;
function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) {
// class c { method() { } | method2() { } }
switch (location.kind) {
- case 323 /* SyntaxList */:
+ case 324 /* SyntaxList */:
return ts.tryCast(location.parent, ts.isObjectTypeDeclaration);
case 1 /* EndOfFileToken */:
var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration);
@@ -211291,10 +217549,16 @@ var ts;
return cls;
}
break;
- case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| }
+ case 75 /* Identifier */: {
+ // class c { public prop = c| }
+ if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) {
+ return undefined;
+ }
+ // class c extends React.Component { a: () => 1\n compon| }
if (isFromObjectTypeDeclaration(location)) {
return ts.findAncestor(location, ts.isObjectTypeDeclaration);
}
+ }
}
if (!contextToken)
return undefined;
@@ -211362,6 +217626,24 @@ var ts;
}
}
}
+ /** Determines if a type is exactly the same type resolved by the global 'self', 'global', or 'globalThis'. */
+ function isProbablyGlobalType(type, sourceFile, checker) {
+ // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in
+ // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists.
+ var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false);
+ if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) {
+ return true;
+ }
+ var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false);
+ if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) {
+ return true;
+ }
+ var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false);
+ if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) {
+ return true;
+ }
+ return false;
+ }
})(Completions = ts.Completions || (ts.Completions = {}));
})(ts || (ts = {}));
var ts;
@@ -211902,7 +218184,7 @@ var ts;
return releaseDocumentWithKey(path, key);
}
function releaseDocumentWithKey(path, key) {
- var bucket = ts.Debug.assertDefined(buckets.get(key));
+ var bucket = ts.Debug.checkDefined(buckets.get(key));
var entry = bucket.get(path);
entry.languageServiceRefCount--;
ts.Debug.assert(entry.languageServiceRefCount >= 0);
@@ -212368,7 +218650,7 @@ var ts;
}
function getExportAssignmentExport(ex) {
// Get the symbol for the `export =` node; its parent is the module it's the export of.
- var exportingModuleSymbol = ts.Debug.assertDefined(ex.symbol.parent, "Expected export symbol to have a parent");
+ var exportingModuleSymbol = ts.Debug.checkDefined(ex.symbol.parent, "Expected export symbol to have a parent");
var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */;
return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } };
}
@@ -212384,11 +218666,7 @@ var ts;
default:
return undefined;
}
- var sym = useLhsSymbol ? checker.getSymbolAtLocation(ts.cast(node.left, ts.isPropertyAccessExpression).name) : symbol;
- // Better detection for GH#20803
- if (sym && !(checker.getMergedSymbol(sym.parent).flags & 1536 /* Module */)) {
- ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.formatSymbol(sym) + ", parent is " + ts.Debug.formatSymbol(sym.parent));
- }
+ var sym = useLhsSymbol ? checker.getSymbolAtLocation(ts.getNameOfAccessExpression(ts.cast(node.left, ts.isAccessExpression))) : symbol;
return sym && exportInfo(sym, kind);
}
}
@@ -212426,17 +218704,17 @@ var ts;
FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol;
function getExportEqualsLocalSymbol(importedSymbol, checker) {
if (importedSymbol.flags & 2097152 /* Alias */) {
- return ts.Debug.assertDefined(checker.getImmediateAliasedSymbol(importedSymbol));
+ return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol));
}
var decl = importedSymbol.valueDeclaration;
if (ts.isExportAssignment(decl)) { // `export = class {}`
- return ts.Debug.assertDefined(decl.expression.symbol);
+ return ts.Debug.checkDefined(decl.expression.symbol);
}
else if (ts.isBinaryExpression(decl)) { // `module.exports = class {}`
- return ts.Debug.assertDefined(decl.right.symbol);
+ return ts.Debug.checkDefined(decl.right.symbol);
}
else if (ts.isSourceFile(decl)) { // json module
- return ts.Debug.assertDefined(decl.symbol);
+ return ts.Debug.checkDefined(decl.symbol);
}
return ts.Debug.fail();
}
@@ -212693,7 +218971,29 @@ var ts;
FindAllReferences.findReferencedSymbols = findReferencedSymbols;
function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
var node = ts.getTouchingPropertyName(sourceFile, position);
- var referenceEntries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position);
+ var referenceEntries;
+ var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position);
+ if (node.parent.kind === 194 /* PropertyAccessExpression */
+ || node.parent.kind === 191 /* BindingElement */
+ || node.parent.kind === 195 /* ElementAccessExpression */
+ || node.kind === 102 /* SuperKeyword */) {
+ referenceEntries = entries && __spreadArrays(entries);
+ }
+ else {
+ var queue = entries && __spreadArrays(entries);
+ var seenNodes = ts.createMap();
+ while (queue && queue.length) {
+ var entry = queue.shift();
+ if (!ts.addToSeen(seenNodes, ts.getNodeId(entry.node))) {
+ continue;
+ }
+ referenceEntries = ts.append(referenceEntries, entry);
+ var entries_1 = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, entry.node, entry.node.pos);
+ if (entries_1) {
+ queue.push.apply(queue, entries_1);
+ }
+ }
+ }
var checker = program.getTypeChecker();
return ts.map(referenceEntries, function (entry) { return toImplementationLocation(entry, checker); });
}
@@ -212934,8 +219234,8 @@ var ts;
case 253 /* ImportEqualsDeclaration */:
case 258 /* ImportSpecifier */:
case 246 /* InterfaceDeclaration */:
- case 314 /* JSDocCallbackTag */:
- case 321 /* JSDocTypedefTag */:
+ case 315 /* JSDocCallbackTag */:
+ case 322 /* JSDocTypedefTag */:
case 273 /* JsxAttribute */:
case 249 /* ModuleDeclaration */:
case 252 /* NamespaceExportDeclaration */:
@@ -212961,8 +219261,8 @@ var ts;
return !!decl.initializer || ts.isCatchClause(decl.parent);
case 160 /* MethodSignature */:
case 158 /* PropertySignature */:
- case 322 /* JSDocPropertyTag */:
- case 316 /* JSDocParameterTag */:
+ case 323 /* JSDocPropertyTag */:
+ case 317 /* JSDocParameterTag */:
return false;
default:
return ts.Debug.failBadSyntaxKind(decl);
@@ -213119,20 +219419,22 @@ var ts;
};
}
});
- for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
- var decl = _a[_i];
- switch (decl.kind) {
- case 290 /* SourceFile */:
- // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.)
- break;
- case 249 /* ModuleDeclaration */:
- if (sourceFilesSet.has(decl.getSourceFile().fileName)) {
- references.push(nodeEntry(decl.name));
- }
- break;
- default:
- // This may be merged with something.
- ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration.");
+ if (symbol.declarations) {
+ for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
+ var decl = _a[_i];
+ switch (decl.kind) {
+ case 290 /* SourceFile */:
+ // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.)
+ break;
+ case 249 /* ModuleDeclaration */:
+ if (sourceFilesSet.has(decl.getSourceFile().fileName)) {
+ references.push(nodeEntry(decl.name));
+ }
+ break;
+ default:
+ // This may be merged with something.
+ ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration.");
+ }
}
}
var exported = symbol.exports.get("export=" /* ExportEquals */);
@@ -213143,7 +219445,7 @@ var ts;
if (sourceFilesSet.has(sourceFile.fileName)) {
// At `module.exports = ...`, reference node is `module`
var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression :
- ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 89 /* ExportKeyword */, sourceFile)) :
+ ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 89 /* ExportKeyword */, sourceFile)) :
ts.getNameOfDeclaration(decl) || decl;
references.push(nodeEntry(node));
}
@@ -213206,7 +219508,7 @@ var ts;
}
else if (node && node.kind === 84 /* DefaultKeyword */) {
addReference(node, symbol, state);
- searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state);
+ searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.checkDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state);
}
else {
var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] });
@@ -213440,6 +219742,8 @@ var ts;
}
// Go to the symbol we imported from and find references for it.
function searchForImportedSymbol(symbol, state) {
+ if (!symbol.declarations)
+ return;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
var exportingFile = declaration.getSourceFile();
@@ -213525,17 +219829,19 @@ var ts;
return exposedByParent ? scope.getSourceFile() : scope; // TODO: GH#18217
}
/** Used as a quick check for whether a symbol is used at all in a file (besides its definition). */
- function isSymbolReferencedInFile(definition, checker, sourceFile) {
- return eachSymbolReferenceInFile(definition, checker, sourceFile, function () { return true; }) || false;
+ function isSymbolReferencedInFile(definition, checker, sourceFile, searchContainer) {
+ if (searchContainer === void 0) { searchContainer = sourceFile; }
+ return eachSymbolReferenceInFile(definition, checker, sourceFile, function () { return true; }, searchContainer) || false;
}
Core.isSymbolReferencedInFile = isSymbolReferencedInFile;
- function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) {
+ function eachSymbolReferenceInFile(definition, checker, sourceFile, cb, searchContainer) {
+ if (searchContainer === void 0) { searchContainer = sourceFile; }
var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent)
? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text))
: checker.getSymbolAtLocation(definition);
if (!symbol)
return undefined;
- for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) {
+ for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name, searchContainer); _i < _a.length; _i++) {
var token = _a[_i];
if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText)
continue;
@@ -213553,7 +219859,7 @@ var ts;
function eachSignatureCall(signature, sourceFiles, checker, cb) {
if (!signature.name || !ts.isIdentifier(signature.name))
return;
- var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name));
+ var symbol = ts.Debug.checkDefined(checker.getSymbolAtLocation(signature.name));
for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) {
var sourceFile = sourceFiles_3[_i];
for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) {
@@ -213740,7 +220046,7 @@ var ts;
addRef();
}
if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) {
- addReference(name, ts.Debug.assertDefined(exportSpecifier.symbol), state);
+ addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state);
}
}
else {
@@ -213753,7 +220059,7 @@ var ts;
var isDefaultExport = referenceLocation.originalKeywordKind === 84 /* DefaultKeyword */
|| exportSpecifier.name.originalKeywordKind === 84 /* DefaultKeyword */;
var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */;
- var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol);
+ var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol);
var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker);
if (exportInfo) {
searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state);
@@ -213875,7 +220181,7 @@ var ts;
*/
function findOwnConstructorReferences(classSymbol, sourceFile, addNode) {
var constructorSymbol = getClassConstructorSymbol(classSymbol);
- if (constructorSymbol) {
+ if (constructorSymbol && constructorSymbol.declarations) {
for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
var ctrKeyword = ts.findChildOfKind(decl, 129 /* ConstructorKeyword */, sourceFile);
@@ -213905,7 +220211,7 @@ var ts;
/** Find references to `super` in the constructor of an extending class. */
function findSuperConstructorAccesses(classDeclaration, addNode) {
var constructor = getClassConstructorSymbol(classDeclaration.symbol);
- if (!constructor) {
+ if (!(constructor && constructor.declarations)) {
return;
}
for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) {
@@ -214030,7 +220336,7 @@ var ts;
}
// Set the key so that we don't infinitely recurse
cachedResults.set(key, false);
- var inherits = symbol.declarations.some(function (declaration) {
+ var inherits = !!symbol.declarations && symbol.declarations.some(function (declaration) {
return ts.getAllSuperTypeNodes(declaration).some(function (typeReference) {
var type = checker.getTypeAtLocation(typeReference);
return !!type && !!type.symbol && explicitlyInheritsFrom(type.symbol, parent, cachedResults, checker);
@@ -214415,7 +220721,7 @@ var ts;
return node.name;
if (isConstNamedExpression(node))
return node.parent.name;
- return ts.Debug.assertDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier));
+ return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier));
}
function isDefaultModifier(node) {
return node.kind === 84 /* DefaultKeyword */;
@@ -214437,7 +220743,7 @@ var ts;
}
}
var declName = isConstNamedExpression(node) ? node.parent.name :
- ts.Debug.assertDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name");
+ ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name");
var text = ts.isIdentifier(declName) ? ts.idText(declName) :
ts.isStringOrNumericLiteralLike(declName) ? declName.text :
ts.isComputedPropertyName(declName) ?
@@ -214844,8 +221150,8 @@ var ts;
var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; });
var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory);
// If there isn't some include for this, add a new one.
- if (ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) &&
- !ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) {
+ if (ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) &&
+ !ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) {
changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath)));
}
}
@@ -214924,7 +221230,7 @@ var ts;
: getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);
// Need an update if the imported file moved, or the importing file moved and was using a relative path.
return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text)))
- ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), newImportFromPath, toImport.newFileName, host, allFiles, program.redirectTargetsMap, importLiteral.text)
+ ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), newImportFromPath, toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
: undefined;
});
};
@@ -215249,7 +221555,7 @@ var ts;
function getConstructSignatureDefinition() {
// Applicable only if we are in a new expression, or we are on a constructor declaration
// and in either case the symbol has a construct signature definition, i.e. class
- if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 129 /* ConstructorKeyword */)) {
+ if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 129 /* ConstructorKeyword */)) {
var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration");
return getSignatureDefinition(cls.members, /*selectConstructors*/ true);
}
@@ -215442,11 +221748,11 @@ var ts;
JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations;
function getCommentHavingNodes(declaration) {
switch (declaration.kind) {
- case 316 /* JSDocParameterTag */:
- case 322 /* JSDocPropertyTag */:
+ case 317 /* JSDocParameterTag */:
+ case 323 /* JSDocPropertyTag */:
return [declaration];
- case 314 /* JSDocCallbackTag */:
- case 321 /* JSDocTypedefTag */:
+ case 315 /* JSDocCallbackTag */:
+ case 322 /* JSDocTypedefTag */:
return [declaration, declaration.parent];
default:
return ts.getJSDocCommentsAndTags(declaration);
@@ -215467,16 +221773,18 @@ var ts;
function getCommentText(tag) {
var comment = tag.comment;
switch (tag.kind) {
+ case 308 /* JSDocImplementsTag */:
+ return withNode(tag.class);
case 307 /* JSDocAugmentsTag */:
return withNode(tag.class);
- case 320 /* JSDocTemplateTag */:
+ case 321 /* JSDocTemplateTag */:
return withList(tag.typeParameters);
- case 319 /* JSDocTypeTag */:
+ case 320 /* JSDocTypeTag */:
return withNode(tag.typeExpression);
- case 321 /* JSDocTypedefTag */:
- case 314 /* JSDocCallbackTag */:
- case 322 /* JSDocPropertyTag */:
- case 316 /* JSDocParameterTag */:
+ case 322 /* JSDocTypedefTag */:
+ case 315 /* JSDocCallbackTag */:
+ case 323 /* JSDocPropertyTag */:
+ case 317 /* JSDocParameterTag */:
var name = tag.name;
return name ? withNode(name) : comment;
default:
@@ -215676,6 +221984,8 @@ var ts;
// then we must be somewhere within a dotted namespace name; however we don't
// want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'.
return commentOwner.parent.kind === 249 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner };
+ case 226 /* ExpressionStatement */:
+ return getCommentOwnerInfoWorker(commentOwner.expression);
case 209 /* BinaryExpression */: {
var be = commentOwner;
if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) {
@@ -215684,6 +221994,11 @@ var ts;
var parameters_2 = ts.isFunctionLike(be.right) ? be.right.parameters : ts.emptyArray;
return { commentOwner: commentOwner, parameters: parameters_2 };
}
+ case 159 /* PropertyDeclaration */:
+ var init = commentOwner.initializer;
+ if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) {
+ return { commentOwner: commentOwner, parameters: init.parameters };
+ }
}
}
/**
@@ -216507,8 +222822,8 @@ var ts;
case 249 /* ModuleDeclaration */:
case 290 /* SourceFile */:
case 247 /* TypeAliasDeclaration */:
- case 321 /* JSDocTypedefTag */:
- case 314 /* JSDocCallbackTag */:
+ case 322 /* JSDocTypedefTag */:
+ case 315 /* JSDocCallbackTag */:
return true;
case 202 /* ArrowFunction */:
case 244 /* FunctionDeclaration */:
@@ -216745,7 +223060,7 @@ var ts;
}
// Delete any subsequent imports.
for (var i = 1; i < oldImportDecls.length; i++) {
- changeTracker.delete(sourceFile, oldImportDecls[i]);
+ changeTracker.deleteNode(sourceFile, oldImportDecls[i]);
}
}
}
@@ -216881,7 +223196,9 @@ var ts;
: namedImports.length === 0
? ts.createNamedImports(sortedImportSpecifiers)
: ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217
- // Type-only imports are not allowed to combine
+ // Type-only imports are not allowed to mix default, namespace, and named imports in any combination.
+ // We could rewrite a default import as a named import (`import { default as name }`), but we currently
+ // choose not to as a stylistic preference.
if (isTypeOnly && newDefaultImport && newNamedImports) {
coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, /*namedBindings*/ undefined));
coalescedImports.push(updateImportDeclarationAndClause((_a = namedImports[0]) !== null && _a !== void 0 ? _a : importDecl, /*name*/ undefined, newNamedImports));
@@ -217212,7 +223529,11 @@ var ts;
case 246 /* InterfaceDeclaration */:
case 248 /* EnumDeclaration */:
case 251 /* CaseBlock */:
+ case 173 /* TypeLiteral */:
return spanForNode(n);
+ case 277 /* CaseClause */:
+ case 278 /* DefaultClause */:
+ return spanForNodeArray(n.statements);
case 193 /* ObjectLiteralExpression */:
return spanForObjectOrArrayLiteral(n);
case 192 /* ArrayLiteralExpression */:
@@ -217267,6 +223588,9 @@ var ts;
var closeToken = ts.findChildOfKind(n, close, sourceFile);
return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart);
}
+ function spanForNodeArray(nodeArray) {
+ return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined;
+ }
}
function functionSpan(node, body, sourceFile) {
var openToken = ts.isNodeArrayMultiLine(node.parameters, sourceFile)
@@ -217833,7 +224157,7 @@ var ts;
token = nextToken();
if (token === 20 /* OpenParenToken */) {
token = nextToken();
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) {
// import("mod");
recordModuleName();
return true;
@@ -217845,6 +224169,18 @@ var ts;
return true;
}
else {
+ if (token === 145 /* TypeKeyword */) {
+ var skipTypeKeyword = ts.scanner.lookAhead(function () {
+ var token = ts.scanner.scan();
+ return token !== 149 /* FromKeyword */ && (token === 41 /* AsteriskToken */ ||
+ token === 18 /* OpenBraceToken */ ||
+ token === 75 /* Identifier */ ||
+ ts.isKeyword(token));
+ });
+ if (skipTypeKeyword) {
+ token = nextToken();
+ }
+ }
if (token === 75 /* Identifier */ || ts.isKeyword(token)) {
token = nextToken();
if (token === 149 /* FromKeyword */) {
@@ -217915,6 +224251,16 @@ var ts;
if (token === 89 /* ExportKeyword */) {
markAsExternalModuleIfTopLevel();
token = nextToken();
+ if (token === 145 /* TypeKeyword */) {
+ var skipTypeKeyword = ts.scanner.lookAhead(function () {
+ var token = ts.scanner.scan();
+ return token === 41 /* AsteriskToken */ ||
+ token === 18 /* OpenBraceToken */;
+ });
+ if (skipTypeKeyword) {
+ token = nextToken();
+ }
+ }
if (token === 18 /* OpenBraceToken */) {
token = nextToken();
// consume "{ a as B, c, d as D}" clauses
@@ -217946,6 +224292,16 @@ var ts;
}
else if (token === 96 /* ImportKeyword */) {
token = nextToken();
+ if (token === 145 /* TypeKeyword */) {
+ var skipTypeKeyword = ts.scanner.lookAhead(function () {
+ var token = ts.scanner.scan();
+ return token === 75 /* Identifier */ ||
+ ts.isKeyword(token);
+ });
+ if (skipTypeKeyword) {
+ token = nextToken();
+ }
+ }
if (token === 75 /* Identifier */ || ts.isKeyword(token)) {
token = nextToken();
if (token === 62 /* EqualsToken */) {
@@ -217959,13 +224315,15 @@ var ts;
}
return false;
}
- function tryConsumeRequireCall(skipCurrentToken) {
+ function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) {
+ if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; }
var token = skipCurrentToken ? nextToken() : ts.scanner.getToken();
if (token === 139 /* RequireKeyword */) {
token = nextToken();
if (token === 20 /* OpenParenToken */) {
token = nextToken();
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* StringLiteral */ ||
+ allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) {
// require("mod");
recordModuleName();
}
@@ -217982,7 +224340,7 @@ var ts;
return true;
}
token = nextToken();
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) {
// looks like define ("modname", ... - skip string literal and comma
token = nextToken();
if (token === 27 /* CommaToken */) {
@@ -218002,7 +224360,7 @@ var ts;
// scan until ']' or EOF
while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) {
// record string literals as module names
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) {
recordModuleName();
}
token = nextToken();
@@ -218037,7 +224395,8 @@ var ts;
if (tryConsumeDeclare() ||
tryConsumeImport() ||
tryConsumeExport() ||
- (detectJavaScriptImports && (tryConsumeRequireCall(/*skipCurrentToken*/ false) || tryConsumeDefine()))) {
+ (detectJavaScriptImports && (tryConsumeRequireCall(/*skipCurrentToken*/ false, /*allowTemplateLiterals*/ true) ||
+ tryConsumeDefine()))) {
continue;
}
else {
@@ -218113,7 +224472,7 @@ var ts;
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library);
}
// Cannot rename `default` as in `import { default as foo } from "./someModule";
- if (ts.isIdentifier(node) && node.originalKeywordKind === 84 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) {
+ if (ts.isIdentifier(node) && node.originalKeywordKind === 84 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) {
return undefined;
}
if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
@@ -218327,7 +224686,7 @@ var ts;
// few keystrokes.
if (ts.isMappedTypeNode(node)) {
var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1);
- var closeBraceToken = ts.Debug.assertDefined(children.pop());
+ var closeBraceToken = ts.Debug.checkDefined(children.pop());
ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */);
ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */);
// Group `-/+readonly` and `-/+?`
@@ -218446,7 +224805,7 @@ var ts;
}
function createSyntaxList(children) {
ts.Debug.assertGreaterThanOrEqual(children.length, 1);
- var syntaxList = ts.createNode(323 /* SyntaxList */, children[0].pos, ts.last(children).end);
+ var syntaxList = ts.createNode(324 /* SyntaxList */, children[0].pos, ts.last(children).end);
syntaxList._children = children;
return syntaxList;
}
@@ -218977,7 +225336,7 @@ var ts;
var printer = ts.createPrinter({ removeComments: true });
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) {
- var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration); }));
+ var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); }));
printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer);
}
});
@@ -218994,7 +225353,7 @@ var ts;
}
function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) {
var displayParts = ts.mapToDisplayParts(function (writer) {
- var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration);
+ var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags);
printer.writeNode(4 /* Unspecified */, param, sourceFile, writer);
});
return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false };
@@ -219189,23 +225548,8 @@ var ts;
return diags.sort(function (d1, d2) { return d1.start - d2.start; });
function check(node) {
if (isJsFile) {
- switch (node.kind) {
- case 201 /* FunctionExpression */:
- var decl = ts.getDeclarationOfExpando(node);
- if (decl) {
- var symbol_1 = decl.symbol;
- if (symbol_1 && (symbol_1.exports && symbol_1.exports.size || symbol_1.members && symbol_1.members.size)) {
- diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration));
- break;
- }
- }
- // falls through if no diagnostic was created
- case 244 /* FunctionDeclaration */:
- var symbol = node.symbol;
- if (symbol.members && (symbol.members.size > 0)) {
- diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration));
- }
- break;
+ if (canBeConvertedToClass(node)) {
+ diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration));
}
}
else {
@@ -219312,7 +225656,18 @@ var ts;
}
ts.isFixablePromiseHandler = isFixablePromiseHandler;
function isPromiseHandler(node) {
- return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") || ts.hasPropertyAccessExpressionWithName(node, "catch"));
+ return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") && hasSupportedNumberOfArguments(node) ||
+ ts.hasPropertyAccessExpressionWithName(node, "catch"));
+ }
+ function hasSupportedNumberOfArguments(node) {
+ if (node.arguments.length > 2)
+ return false;
+ if (node.arguments.length < 2)
+ return true;
+ return ts.some(node.arguments, function (arg) {
+ return arg.kind === 100 /* NullKeyword */ ||
+ ts.isIdentifier(arg) && arg.text === "undefined";
+ });
}
// should be kept up to date with getTransformationBody in convertToAsyncFunction.ts
function isFixablePromiseArgument(arg) {
@@ -219332,12 +225687,28 @@ var ts;
function getKeyFromNode(exp) {
return exp.pos.toString() + ":" + exp.end.toString();
}
+ function canBeConvertedToClass(node) {
+ var _a, _b, _c, _d;
+ if (node.kind === 201 /* FunctionExpression */) {
+ if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) {
+ return true;
+ }
+ var decl = ts.getDeclarationOfExpando(node);
+ var symbol = decl === null || decl === void 0 ? void 0 : decl.symbol;
+ return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size)));
+ }
+ if (node.kind === 244 /* FunctionDeclaration */) {
+ return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size);
+ }
+ return false;
+ }
})(ts || (ts = {}));
/* @internal */
var ts;
(function (ts) {
var SymbolDisplay;
(function (SymbolDisplay) {
+ var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
// TODO(drosen): use contextual SemanticMeaning.
function getSymbolKind(typeChecker, symbol, location) {
var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location);
@@ -219782,7 +226153,7 @@ var ts;
// If the type is type parameter, format it specially
if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration);
+ var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags);
getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer);
});
ts.addRange(displayParts, typeParameterParts);
@@ -219924,7 +226295,7 @@ var ts;
}
function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration);
+ var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags);
getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer);
});
ts.addRange(displayParts, typeParameterParts);
@@ -220098,11 +226469,11 @@ var ts;
this.options = options;
}
FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) {
- this.currentTokenSpan = ts.Debug.assertDefined(currentRange);
- this.currentTokenParent = ts.Debug.assertDefined(currentTokenParent);
- this.nextTokenSpan = ts.Debug.assertDefined(nextRange);
- this.nextTokenParent = ts.Debug.assertDefined(nextTokenParent);
- this.contextNode = ts.Debug.assertDefined(commonParent);
+ this.currentTokenSpan = ts.Debug.checkDefined(currentRange);
+ this.currentTokenParent = ts.Debug.checkDefined(currentTokenParent);
+ this.nextTokenSpan = ts.Debug.checkDefined(nextRange);
+ this.nextTokenParent = ts.Debug.checkDefined(nextTokenParent);
+ this.contextNode = ts.Debug.checkDefined(commonParent);
// drop cached results
this.contextNodeAllOnSameLine = undefined;
this.nextNodeAllOnSameLine = undefined;
@@ -220353,7 +226724,7 @@ var ts;
case 3 /* RescanTemplateToken */:
if (token === 19 /* CloseBraceToken */) {
lastScanAction = 3 /* RescanTemplateToken */;
- return scanner.reScanTemplateToken();
+ return scanner.reScanTemplateToken(/* isTaggedTemplate */ false);
}
break;
case 4 /* RescanJsxIdentifier */:
@@ -220545,7 +226916,7 @@ var ts;
rule("SpaceAfterVoidOperator", 110 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */),
// Async-await
rule("SpaceBetweenAsyncAndOpenParen", 126 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceBetweenAsyncAndFunctionKeyword", 126 /* AsyncKeyword */, 94 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
+ rule("SpaceBetweenAsyncAndFunctionKeyword", 126 /* AsyncKeyword */, [94 /* FunctionKeyword */, 75 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
// Template string
rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
// JSX opening elements
@@ -220628,7 +226999,7 @@ var ts;
// Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses
rule("SpaceAfterConstructor", 129 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
rule("NoSpaceAfterConstructor", 129 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */),
+ rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */),
rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */),
// Insert space after function keyword for anonymous functions
rule("SpaceAfterAnonymousFunctionKeyword", [94 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */),
@@ -220655,6 +227026,9 @@ var ts;
rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */),
rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ // Insert a space after opening and before closing empty brace brackets
+ rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */),
+ rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
// Insert space after opening and before closing template string braces
rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
@@ -220977,6 +227351,9 @@ var ts;
function isNextTokenNotCloseBracket(context) {
return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */;
}
+ function isNextTokenNotCloseParen(context) {
+ return context.nextTokenSpan.kind !== 21 /* CloseParenToken */;
+ }
function isArrowFunctionContext(context) {
return context.contextNode.kind === 202 /* ArrowFunction */;
}
@@ -221153,8 +227530,8 @@ var ts;
(function (ts) {
var formatting;
(function (formatting) {
- function getFormatContext(options) {
- return { options: options, getRules: getRulesMap() };
+ function getFormatContext(options, host) {
+ return { options: options, getRules: getRulesMap(), host: host };
}
formatting.getFormatContext = getFormatContext;
var rulesMapCache;
@@ -221567,7 +227944,7 @@ var ts;
return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); });
}
function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) {
- var options = _a.options, getRules = _a.getRules;
+ var options = _a.options, getRules = _a.getRules, host = _a.host;
// formatting context is used by rules provider
var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options);
var previousRange;
@@ -221589,7 +227966,9 @@ var ts;
var leadingTrivia = formattingScanner.getCurrentLeadingTrivia();
if (leadingTrivia) {
indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); });
- trimTrailingWhitespacesForRemainingRange();
+ if (options.trimTrailingWhitespace !== false) {
+ trimTrailingWhitespacesForRemainingRange();
+ }
}
}
return edits;
@@ -221706,8 +228085,8 @@ var ts;
},
getIndentation: function () { return indentation; },
getDelta: getDelta,
- recomputeIndentation: function (lineAdded) {
- if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(options, node.parent, node, sourceFile)) {
+ recomputeIndentation: function (lineAdded, parent) {
+ if (formatting.SmartIndenter.shouldIndentChildNode(options, parent, node, sourceFile)) {
indentation += lineAdded ? options.indentSize : -options.indentSize;
delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0;
}
@@ -221908,8 +228287,11 @@ var ts;
if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken()) {
var tokenInfo = formattingScanner.readTokenInfo(parent);
if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
- formattingScanner.advance();
- tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
+ var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
+ if (startLine !== commaTokenLine) {
+ formattingScanner.advance();
+ tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
+ }
}
// consume the list end token only if it is still belong to the parent
// there might be the case when current token matches end token but does not considered as one
@@ -222026,7 +228408,7 @@ var ts;
function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) {
formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode);
var rules = getRules(formattingContext);
- var trimTrailingWhitespaces = false;
+ var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false;
var lineAction = 0 /* None */;
if (rules) {
// Apply rules in reverse order so that higher priority rules (which are first in the array)
@@ -222038,7 +228420,7 @@ var ts;
// Handle the case where the next line is moved to be the end of this line.
// In this case we don't indent the next line in the next pass.
if (currentParent.getStart(sourceFile) === currentItem.pos) {
- dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false);
+ dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode);
}
break;
case 1 /* LineAdded */:
@@ -222046,18 +228428,18 @@ var ts;
// In this case we indent token2 in the next pass but we set
// sameLineIndent flag to notify the indenter that the indentation is within the line.
if (currentParent.getStart(sourceFile) === currentItem.pos) {
- dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true);
+ dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true, contextNode);
}
break;
default:
ts.Debug.assert(lineAction === 0 /* None */);
}
// We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line
- trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */;
+ trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */;
});
}
else {
- trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */;
+ trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */;
}
if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) {
// We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line
@@ -222232,7 +228614,7 @@ var ts;
// edit should not be applied if we have one line feed between elements
var lineDelta = currentStartLine - previousStartLine;
if (lineDelta !== 1) {
- recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.newLineCharacter);
+ recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options));
return onLaterLine ? 0 /* None */ : 1 /* LineAdded */;
}
break;
@@ -222704,7 +229086,7 @@ var ts;
case 214 /* ClassExpression */:
case 246 /* InterfaceDeclaration */:
case 247 /* TypeAliasDeclaration */:
- case 320 /* JSDocTemplateTag */:
+ case 321 /* JSDocTemplateTag */:
return getList(node.typeParameters);
case 197 /* NewExpression */:
case 196 /* CallExpression */:
@@ -222966,6 +229348,15 @@ var ts;
* include all trivia between the node and the previous token
*/
LeadingTriviaOption[LeadingTriviaOption["IncludeAll"] = 1] = "IncludeAll";
+ /**
+ * Include attached JSDoc comments
+ */
+ LeadingTriviaOption[LeadingTriviaOption["JSDoc"] = 2] = "JSDoc";
+ /**
+ * Only delete trivia on the same line as getStart().
+ * Used to avoid deleting leading comments
+ */
+ LeadingTriviaOption[LeadingTriviaOption["StartLine"] = 3] = "StartLine";
})(LeadingTriviaOption = textChanges_3.LeadingTriviaOption || (textChanges_3.LeadingTriviaOption = {}));
var TrailingTriviaOption;
(function (TrailingTriviaOption) {
@@ -223008,6 +229399,15 @@ var ts;
if (leadingTriviaOption === LeadingTriviaOption.Exclude) {
return node.getStart(sourceFile);
}
+ if (leadingTriviaOption === LeadingTriviaOption.StartLine) {
+ return ts.getLineStartPositionForPosition(node.getStart(sourceFile), sourceFile);
+ }
+ if (leadingTriviaOption === LeadingTriviaOption.JSDoc) {
+ var JSDocComments = ts.getJSDocCommentRanges(node, sourceFile.text);
+ if (JSDocComments === null || JSDocComments === void 0 ? void 0 : JSDocComments.length) {
+ return ts.getLineStartPositionForPosition(JSDocComments[0].pos, sourceFile);
+ }
+ }
var fullStart = node.getFullStart();
var start = node.getStart(sourceFile);
if (fullStart === start) {
@@ -223097,6 +229497,10 @@ var ts;
ChangeTracker.prototype.delete = function (sourceFile, node) {
this.deletedNodes.push({ sourceFile: sourceFile, node: node });
};
+ ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
+ if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
+ this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
+ };
ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) {
this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) });
};
@@ -223156,15 +229560,36 @@ var ts;
this.replaceRangeWithNodes(sourceFile, ts.createRange(pos), newNodes, options);
};
ChangeTracker.prototype.insertNodeAtTopOfFile = function (sourceFile, newNode, blankLineBetween) {
+ this.insertAtTopOfFile(sourceFile, newNode, blankLineBetween);
+ };
+ ChangeTracker.prototype.insertNodesAtTopOfFile = function (sourceFile, newNodes, blankLineBetween) {
+ this.insertAtTopOfFile(sourceFile, newNodes, blankLineBetween);
+ };
+ ChangeTracker.prototype.insertAtTopOfFile = function (sourceFile, insert, blankLineBetween) {
var pos = getInsertionPositionAtSourceFileTop(sourceFile);
- this.insertNodeAt(sourceFile, pos, newNode, {
+ var options = {
prefix: pos === 0 ? undefined : this.newLineCharacter,
suffix: (ts.isLineBreak(sourceFile.text.charCodeAt(pos)) ? "" : this.newLineCharacter) + (blankLineBetween ? this.newLineCharacter : ""),
- });
+ };
+ if (ts.isArray(insert)) {
+ this.insertNodesAt(sourceFile, pos, insert, options);
+ }
+ else {
+ this.insertNodeAt(sourceFile, pos, insert, options);
+ }
+ };
+ ChangeTracker.prototype.insertFirstParameter = function (sourceFile, parameters, newParam) {
+ var p0 = ts.firstOrUndefined(parameters);
+ if (p0) {
+ this.insertNodeBefore(sourceFile, p0, newParam);
+ }
+ else {
+ this.insertNodeAt(sourceFile, parameters.pos, newParam);
+ }
};
ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, blankLineBetween) {
if (blankLineBetween === void 0) { blankLineBetween = false; }
- this.insertNodeAt(sourceFile, getAdjustedStartPosition(sourceFile, before, {}), newNode, this.getOptionsForInsertNodeBefore(before, blankLineBetween));
+ this.insertNodeAt(sourceFile, getAdjustedStartPosition(sourceFile, before, {}), newNode, this.getOptionsForInsertNodeBefore(before, newNode, blankLineBetween));
};
ChangeTracker.prototype.insertModifierBefore = function (sourceFile, modifier, before) {
var pos = before.getStart(sourceFile);
@@ -223214,6 +229639,7 @@ var ts;
};
/** Prefer this over replacing a node with another that has a type annotation, as it avoids reformatting the other parts of the node. */
ChangeTracker.prototype.tryInsertTypeAnnotation = function (sourceFile, node, type) {
+ var _a;
var endNode;
if (ts.isFunctionLike(node)) {
endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile);
@@ -223225,7 +229651,7 @@ var ts;
}
}
else {
- endNode = node.kind !== 242 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name;
+ endNode = (_a = (node.kind === 242 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name;
}
this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " });
return true;
@@ -223240,7 +229666,7 @@ var ts;
var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile);
this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">" });
};
- ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, doubleNewlines) {
+ ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, doubleNewlines) {
if (ts.isStatement(before) || ts.isClassElement(before)) {
return { suffix: doubleNewlines ? this.newLineCharacter + this.newLineCharacter : this.newLineCharacter };
}
@@ -223248,7 +229674,7 @@ var ts;
return { suffix: ", " };
}
else if (ts.isParameter(before)) {
- return {};
+ return ts.isParameter(inserted) ? { suffix: ", " } : {};
}
else if (ts.isStringLiteral(before) && ts.isImportDeclaration(before.parent) || ts.isNamedImports(before)) {
return { suffix: ", " };
@@ -223630,7 +230056,7 @@ var ts;
var changesToText;
(function (changesToText) {
function getTextChangesFromChanges(changes, newLineCharacter, formatContext, validate) {
- return ts.group(changes, function (c) { return c.sourceFile.path; }).map(function (changesInFile) {
+ return ts.mapDefined(ts.group(changes, function (c) { return c.sourceFile.path; }), function (changesInFile) {
var sourceFile = changesInFile[0].sourceFile;
// order changes by start position
// If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa.
@@ -223644,10 +230070,16 @@ var ts;
for (var i = 0; i < normalized.length - 1; i++) {
_loop_10(i);
}
- var textChanges = normalized.map(function (c) {
- return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate));
+ var textChanges = ts.mapDefined(normalized, function (c) {
+ var span = ts.createTextSpanFromRange(c.range);
+ var newText = computeNewText(c, sourceFile, newLineCharacter, formatContext, validate);
+ // Filter out redundant changes.
+ if (span.length === newText.length && ts.stringContainsAt(sourceFile.text, newText, span.start)) {
+ return undefined;
+ }
+ return ts.createTextChange(span, newText);
});
- return { fileName: sourceFile.fileName, textChanges: textChanges };
+ return textChanges.length > 0 ? { fileName: sourceFile.fileName, textChanges: textChanges } : undefined;
});
}
changesToText.getTextChangesFromChanges = getTextChangesFromChanges;
@@ -223678,7 +230110,9 @@ var ts;
: format(change.node);
// strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line
var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, "");
- return (options.prefix || "") + noIndent + (options.suffix || "");
+ return (options.prefix || "") + noIndent
+ + ((!options.suffix || ts.endsWith(noIndent, options.suffix))
+ ? "" : options.suffix);
}
function getFormatCodeSettingsForWriting(_a, sourceFile) {
var options = _a.options;
@@ -223707,7 +230141,7 @@ var ts;
function getNonformattedText(node, sourceFile, newLineCharacter) {
var writer = createWriter(newLineCharacter);
var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
- ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer);
+ ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, preserveSourceNewlines: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer);
return { text: writer.getText(), node: assignPositionsToNode(node) };
}
changesToText.getNonformattedText = getNonformattedText;
@@ -223828,8 +230262,8 @@ var ts;
writer.writeSymbol(s, sym);
setLastNonTriviaPosition(s, /*force*/ false);
}
- function writeLine() {
- writer.writeLine();
+ function writeLine(force) {
+ writer.writeLine(force);
}
function increaseIndent() {
writer.increaseIndent();
@@ -224006,10 +230440,10 @@ var ts;
break;
}
case 254 /* ImportDeclaration */:
- var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isImportDeclaration);
- deleteNode(changes, sourceFile, node,
- // For first import, leave header comment in place
- isFirstImport ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined);
+ case 253 /* ImportEqualsDeclaration */:
+ var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax);
+ // For first import, leave header comment in place, otherwise only delete JSDoc comments
+ deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine });
break;
case 191 /* BindingElement */:
var pattern = node.parent;
@@ -224039,15 +230473,25 @@ var ts;
case 256 /* NamespaceImport */:
deleteImportBinding(changes, sourceFile, node);
break;
+ case 26 /* SemicolonToken */:
+ deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude });
+ break;
+ case 94 /* FunctionKeyword */:
+ deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude });
+ break;
+ case 245 /* ClassDeclaration */:
+ case 244 /* FunctionDeclaration */:
+ deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine });
+ break;
default:
if (ts.isImportClause(node.parent) && node.parent.name === node) {
deleteDefaultImport(changes, sourceFile, node.parent);
}
- else if (ts.isCallLikeExpression(node.parent)) {
+ else if (ts.isCallExpression(node.parent) && ts.contains(node.parent.arguments, node)) {
deleteNodeInList(changes, deletedNodesInLists, sourceFile, node);
}
else {
- deleteNode(changes, sourceFile, node, node.kind === 26 /* SemicolonToken */ ? { trailingTriviaOption: TrailingTriviaOption.Exclude } : undefined);
+ deleteNode(changes, sourceFile, node);
}
}
}
@@ -224076,7 +230520,7 @@ var ts;
// Delete named imports while preserving the default import
// import d|, * as ns| from './file'
// import d|, { a }| from './file'
- var previousToken = ts.Debug.assertDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1));
+ var previousToken = ts.Debug.checkDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1));
changes.deleteRange(sourceFile, { pos: previousToken.getStart(sourceFile), end: node.end });
}
else {
@@ -224108,7 +230552,7 @@ var ts;
deleteNode(changes, sourceFile, parent);
break;
case 225 /* VariableStatement */:
- deleteNode(changes, sourceFile, gp);
+ deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine });
break;
default:
ts.Debug.assertNever(gp);
@@ -224125,7 +230569,7 @@ var ts;
}
textChanges_3.deleteNode = deleteNode;
function deleteNodeInList(changes, deletedNodesInLists, sourceFile, node) {
- var containingList = ts.Debug.assertDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile));
+ var containingList = ts.Debug.checkDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile));
var index = ts.indexOfNode(containingList, node);
ts.Debug.assert(index !== -1);
if (containingList.length === 1) {
@@ -224236,7 +230680,7 @@ var ts;
codefix.eachDiagnostic = eachDiagnostic;
function getDiagnostics(_a) {
var program = _a.program, sourceFile = _a.sourceFile, cancellationToken = _a.cancellationToken;
- return program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken));
+ return __spreadArrays(program.getSemanticDiagnostics(sourceFile, cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken));
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -224284,7 +230728,7 @@ var ts;
});
function makeChange(changeTracker, sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
- var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression");
+ var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression");
var replacement = ts.isAsExpression(assertion)
? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(148 /* UnknownKeyword */))
: ts.createTypeAssertion(ts.createKeywordTypeNode(148 /* UnknownKeyword */), assertion.expression);
@@ -224316,6 +230760,87 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixId = "addMissingAsync";
+ var errorCodes = [
+ ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code,
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
+ ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code
+ ];
+ codefix.registerCodeFix({
+ fixIds: [fixId],
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, errorCode = context.errorCode, cancellationToken = context.cancellationToken, program = context.program, span = context.span;
+ var diagnostic = ts.find(program.getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile, cancellationToken), getIsMatchingAsyncError(span, errorCode));
+ var directSpan = diagnostic && diagnostic.relatedInformation && ts.find(diagnostic.relatedInformation, function (r) { return r.code === ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async.code; });
+ var decl = getFixableErrorSpanDeclaration(sourceFile, directSpan);
+ if (!decl) {
+ return;
+ }
+ var trackChanges = function (cb) { return ts.textChanges.ChangeTracker.with(context, cb); };
+ return [getFix(context, decl, trackChanges)];
+ },
+ getAllCodeActions: function (context) {
+ var sourceFile = context.sourceFile;
+ var fixedDeclarations = ts.createMap();
+ return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) {
+ var span = diagnostic.relatedInformation && ts.find(diagnostic.relatedInformation, function (r) { return r.code === ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async.code; });
+ var decl = getFixableErrorSpanDeclaration(sourceFile, span);
+ if (!decl) {
+ return;
+ }
+ var trackChanges = function (cb) { return (cb(t), []); };
+ return getFix(context, decl, trackChanges, fixedDeclarations);
+ });
+ },
+ });
+ function getFix(context, decl, trackChanges, fixedDeclarations) {
+ var changes = trackChanges(function (t) { return makeChange(t, context.sourceFile, decl, fixedDeclarations); });
+ return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers);
+ }
+ function makeChange(changeTracker, sourceFile, insertionSite, fixedDeclarations) {
+ if (fixedDeclarations) {
+ if (fixedDeclarations.has(ts.getNodeId(insertionSite).toString())) {
+ return;
+ }
+ }
+ fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.set(ts.getNodeId(insertionSite).toString(), true);
+ var cloneWithModifier = ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true);
+ cloneWithModifier.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(ts.getModifierFlags(insertionSite) | 256 /* Async */));
+ cloneWithModifier.modifierFlagsCache = 0;
+ changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier);
+ }
+ function getFixableErrorSpanDeclaration(sourceFile, span) {
+ if (!span)
+ return undefined;
+ var token = ts.getTokenAtPosition(sourceFile, span.start);
+ // Checker has already done work to determine that async might be possible, and has attached
+ // related info to the node, so start by finding the signature that exactly matches up
+ // with the diagnostic range.
+ var decl = ts.findAncestor(token, function (node) {
+ if (node.getStart(sourceFile) < span.start || node.getEnd() > ts.textSpanEnd(span)) {
+ return "quit";
+ }
+ return (ts.isArrowFunction(node) || ts.isMethodDeclaration(node) || ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) && ts.textSpansEqual(span, ts.createTextSpanFromNode(node, sourceFile));
+ });
+ return decl;
+ }
+ function getIsMatchingAsyncError(span, errorCode) {
+ return function (_a) {
+ var start = _a.start, length = _a.length, relatedInformation = _a.relatedInformation, code = _a.code;
+ return ts.isNumber(start) && ts.isNumber(length) && ts.textSpansEqual({ start: start, length: length }, span) &&
+ code === errorCode &&
+ !!relatedInformation &&
+ ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async.code; });
+ };
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -224500,7 +231025,7 @@ var ts;
reference;
var diagnostic = ts.find(diagnostics, function (diagnostic) {
return diagnostic.start === errorNode.getStart(sourceFile) &&
- diagnostic.start + diagnostic.length === errorNode.getEnd();
+ (diagnostic.start + diagnostic.length) === errorNode.getEnd();
});
return diagnostic && ts.contains(errorCodes, diagnostic.code) ||
// A Promise is usually not correct in a binary expression (it’s not valid
@@ -224834,7 +231359,7 @@ var ts;
}
}
else {
- var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix
+ var jsdocType = ts.Debug.checkDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix
ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix.
changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType));
}
@@ -224933,989 +231458,6 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
-(function (ts) {
- var codefix;
- (function (codefix) {
- var fixId = "inferFromUsage";
- var errorCodes = [
- // Variable declarations
- ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
- // Variable uses
- ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code,
- // Parameter declarations
- ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code,
- ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code,
- // Get Accessor declarations
- ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code,
- ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code,
- // Set Accessor declarations
- ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code,
- // Property declarations
- ts.Diagnostics.Member_0_implicitly_has_an_1_type.code,
- //// Suggestions
- // Variable declarations
- ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code,
- // Variable uses
- ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code,
- // Parameter declarations
- ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code,
- ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code,
- // Get Accessor declarations
- ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code,
- ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code,
- // Set Accessor declarations
- ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code,
- // Property declarations
- ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code,
- // Function expressions and declarations
- ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code,
- ];
- codefix.registerCodeFix({
- errorCodes: errorCodes,
- getCodeActions: function (context) {
- var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences;
- var token = ts.getTokenAtPosition(sourceFile, start);
- var declaration;
- var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, formatContext, preferences); });
- var name = declaration && ts.getNameOfDeclaration(declaration);
- return !name || changes.length === 0 ? undefined
- : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
- },
- fixIds: [fixId],
- getAllCodeActions: function (context) {
- var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences;
- var markSeen = ts.nodeSeenTracker();
- return codefix.codeFixAll(context, errorCodes, function (changes, err) {
- doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, formatContext, preferences);
- });
- },
- });
- function getDiagnostic(errorCode, token) {
- switch (errorCode) {
- case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code:
- case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code:
- return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217
- case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code:
- case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code:
- return ts.Diagnostics.Infer_parameter_types_from_usage;
- case ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code:
- return ts.Diagnostics.Infer_this_type_of_0_from_usage;
- default:
- return ts.Diagnostics.Infer_type_of_0_from_usage;
- }
- }
- /** Map suggestion code to error code */
- function mapSuggestionDiagnostic(errorCode) {
- switch (errorCode) {
- case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code:
- return ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code;
- case ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code:
- return ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code;
- case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code:
- return ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code;
- case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code:
- return ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code;
- case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code:
- return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code;
- case ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code:
- return ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code;
- case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code:
- return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code;
- case ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code:
- return ts.Diagnostics.Member_0_implicitly_has_an_1_type.code;
- }
- return errorCode;
- }
- function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, formatContext, preferences) {
- if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 104 /* ThisKeyword */) {
- return undefined;
- }
- var parent = token.parent;
- errorCode = mapSuggestionDiagnostic(errorCode);
- switch (errorCode) {
- // Variable and Property declarations
- case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code:
- case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code:
- if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location
- annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken, formatContext, preferences);
- return parent;
- }
- if (ts.isPropertyAccessExpression(parent)) {
- var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken);
- var typeNode = ts.getTypeNodeIfAccessible(type, parent, program, host);
- if (typeNode) {
- // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags
- var typeTag = ts.createJSDocTypeTag(ts.createJSDocTypeExpression(typeNode), /*comment*/ "");
- addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]);
- }
- return parent;
- }
- return undefined;
- case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: {
- var symbol = program.getTypeChecker().getSymbolAtLocation(token);
- if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) {
- annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken, formatContext, preferences);
- return symbol.valueDeclaration;
- }
- return undefined;
- }
- }
- var containingFunction = ts.getContainingFunction(token);
- if (containingFunction === undefined) {
- return undefined;
- }
- switch (errorCode) {
- // Parameter declarations
- case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code:
- if (ts.isSetAccessorDeclaration(containingFunction)) {
- annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences);
- return containingFunction;
- }
- // falls through
- case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code:
- if (markSeen(containingFunction)) {
- var param = ts.cast(parent, ts.isParameter);
- annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken, formatContext, preferences);
- return param;
- }
- return undefined;
- // Get Accessor declarations
- case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code:
- case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code:
- if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) {
- annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host, formatContext, preferences);
- return containingFunction;
- }
- return undefined;
- // Set Accessor declarations
- case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code:
- if (ts.isSetAccessorDeclaration(containingFunction)) {
- annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences);
- return containingFunction;
- }
- return undefined;
- // Function 'this'
- case ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code:
- if (ts.textChanges.isThisTypeAnnotatable(containingFunction) && markSeen(containingFunction)) {
- annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken);
- return containingFunction;
- }
- return undefined;
- default:
- return ts.Debug.fail(String(errorCode));
- }
- }
- function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken, formatContext, preferences) {
- if (ts.isIdentifier(declaration.name)) {
- annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host, formatContext, preferences);
- }
- }
- function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken, formatContext, preferences) {
- if (!ts.isIdentifier(parameterDeclaration.name)) {
- return;
- }
- var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken);
- ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match");
- if (ts.isInJSFile(containingFunction)) {
- annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host);
- }
- else {
- var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile);
- if (needParens)
- changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.createToken(20 /* OpenParenToken */));
- for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) {
- var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type;
- if (declaration && !declaration.type && !declaration.initializer) {
- annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences);
- }
- }
- if (needParens)
- changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.createToken(21 /* CloseParenToken */));
- }
- }
- function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) {
- var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken);
- if (!references || !references.length) {
- return;
- }
- var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter();
- var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host);
- if (!typeNode) {
- return;
- }
- if (ts.isInJSFile(containingFunction)) {
- annotateJSDocThis(changes, sourceFile, containingFunction, typeNode);
- }
- else {
- changes.tryInsertThisTypeAnnotation(sourceFile, containingFunction, typeNode);
- }
- }
- function annotateJSDocThis(changes, sourceFile, containingFunction, typeNode) {
- addJSDocTags(changes, sourceFile, containingFunction, [
- ts.createJSDocThisTag(ts.createJSDocTypeExpression(typeNode)),
- ]);
- }
- function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken, formatContext, preferences) {
- var param = ts.firstOrUndefined(setAccessorDeclaration.parameters);
- if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) {
- var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken);
- if (type === program.getTypeChecker().getAnyType()) {
- type = inferTypeForVariableFromUsage(param.name, program, cancellationToken);
- }
- if (ts.isInJSFile(setAccessorDeclaration)) {
- annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host);
- }
- else {
- annotate(changes, sourceFile, param, type, program, host, formatContext, preferences);
- }
- }
- }
- function annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences) {
- var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host);
- if (typeNode) {
- if (ts.isInJSFile(sourceFile) && declaration.kind !== 158 /* PropertySignature */) {
- var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration;
- if (!parent) {
- return;
- }
- var typeExpression = ts.createJSDocTypeExpression(typeNode);
- var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, "");
- addJSDocTags(changes, sourceFile, parent, [typeTag]);
- }
- else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences)) {
- changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode);
- }
- }
- }
- function tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences) {
- var _a;
- if (ts.isLiteralImportTypeNode(typeNode) && typeNode.qualifier && type.symbol) {
- // Replace 'import("./a").SomeType' with 'SomeType' and an actual import if possible
- var moduleSymbol = (_a = ts.find(type.symbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) === null || _a === void 0 ? void 0 : _a.getSourceFile().symbol;
- // Symbol for the left-most thing after the dot
- if (moduleSymbol) {
- var symbol = ts.getFirstIdentifier(typeNode.qualifier).symbol;
- var action = codefix.getImportCompletionAction(symbol, moduleSymbol, sourceFile, symbol.name, host, program, formatContext, declaration.pos, preferences);
- if (action.codeAction.changes.length && changes.tryInsertTypeAnnotation(sourceFile, declaration, ts.createTypeReferenceNode(typeNode.qualifier, typeNode.typeArguments))) {
- for (var _i = 0, _b = action.codeAction.changes; _i < _b.length; _i++) {
- var change = _b[_i];
- var file = sourceFile.fileName === change.fileName ? sourceFile : ts.Debug.assertDefined(program.getSourceFile(change.fileName));
- changes.pushRaw(file, change);
- }
- return true;
- }
- }
- }
- return false;
- }
- function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) {
- var signature = parameterInferences.length && parameterInferences[0].declaration.parent;
- if (!signature) {
- return;
- }
- var paramTags = ts.mapDefined(parameterInferences, function (inference) {
- var param = inference.declaration;
- // only infer parameters that have (1) no type and (2) an accessible inferred type
- if (param.initializer || ts.getJSDocType(param) || !ts.isIdentifier(param.name))
- return;
- var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host);
- var name = ts.getSynthesizedClone(param.name);
- ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
- return typeNode && ts.createJSDocParamTag(name, !!inference.isOptional, ts.createJSDocTypeExpression(typeNode), "");
- });
- addJSDocTags(changes, sourceFile, signature, paramTags);
- }
- function addJSDocTags(changes, sourceFile, parent, newTags) {
- var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; });
- var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
- var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) {
- var merged = tryMergeJsdocTags(tag, newTag);
- if (merged)
- oldTags[i] = merged;
- return !!merged;
- }); });
- var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags)));
- var jsDocNode = parent.kind === 202 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent;
- jsDocNode.jsDoc = parent.jsDoc;
- jsDocNode.jsDocCache = parent.jsDocCache;
- changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag);
- }
- function getJsDocNodeForArrowFunction(signature) {
- if (signature.parent.kind === 159 /* PropertyDeclaration */) {
- return signature.parent;
- }
- return signature.parent.parent;
- }
- function tryMergeJsdocTags(oldTag, newTag) {
- if (oldTag.kind !== newTag.kind) {
- return undefined;
- }
- switch (oldTag.kind) {
- case 316 /* JSDocParameterTag */: {
- var oldParam = oldTag;
- var newParam = newTag;
- return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
- ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment)
- : undefined;
- }
- case 317 /* JSDocReturnTag */:
- return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment);
- }
- }
- function getReferences(token, program, cancellationToken) {
- // Position shouldn't matter since token is not a SourceFile.
- return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) {
- return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined;
- });
- }
- function inferTypeForVariableFromUsage(token, program, cancellationToken) {
- var references = getReferences(token, program, cancellationToken);
- return inferTypeFromReferences(program, references, cancellationToken).single();
- }
- function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) {
- var references = getFunctionReferences(func, sourceFile, program, cancellationToken);
- return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) ||
- func.parameters.map(function (p) { return ({
- declaration: p,
- type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType()
- }); });
- }
- function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) {
- var searchToken;
- switch (containingFunction.kind) {
- case 162 /* Constructor */:
- searchToken = ts.findChildOfKind(containingFunction, 129 /* ConstructorKeyword */, sourceFile);
- break;
- case 202 /* ArrowFunction */:
- case 201 /* FunctionExpression */:
- var parent = containingFunction.parent;
- searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ?
- parent.name :
- containingFunction.name;
- break;
- case 244 /* FunctionDeclaration */:
- case 161 /* MethodDeclaration */:
- searchToken = containingFunction.name;
- break;
- }
- if (!searchToken) {
- return undefined;
- }
- return getReferences(searchToken, program, cancellationToken);
- }
- function inferTypeFromReferences(program, references, cancellationToken) {
- var checker = program.getTypeChecker();
- var builtinConstructors = {
- string: function () { return checker.getStringType(); },
- number: function () { return checker.getNumberType(); },
- Array: function (t) { return checker.createArrayType(t); },
- Promise: function (t) { return checker.createPromiseType(t); },
- };
- var builtins = [
- checker.getStringType(),
- checker.getNumberType(),
- checker.createArrayType(checker.getAnyType()),
- checker.createPromiseType(checker.getAnyType()),
- ];
- return {
- single: single,
- parameters: parameters,
- thisParameter: thisParameter,
- };
- function createEmptyUsage() {
- return {
- isNumber: undefined,
- isString: undefined,
- isNumberOrString: undefined,
- candidateTypes: undefined,
- properties: undefined,
- calls: undefined,
- constructs: undefined,
- numberIndex: undefined,
- stringIndex: undefined,
- candidateThisTypes: undefined,
- inferredTypes: undefined,
- };
- }
- function combineUsages(usages) {
- var combinedProperties = ts.createUnderscoreEscapedMap();
- for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) {
- var u = usages_1[_i];
- if (u.properties) {
- u.properties.forEach(function (p, name) {
- if (!combinedProperties.has(name)) {
- combinedProperties.set(name, []);
- }
- combinedProperties.get(name).push(p);
- });
- }
- }
- var properties = ts.createUnderscoreEscapedMap();
- combinedProperties.forEach(function (ps, name) {
- properties.set(name, combineUsages(ps));
- });
- return {
- isNumber: usages.some(function (u) { return u.isNumber; }),
- isString: usages.some(function (u) { return u.isString; }),
- isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }),
- candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }),
- properties: properties,
- calls: ts.flatMap(usages, function (u) { return u.calls; }),
- constructs: ts.flatMap(usages, function (u) { return u.constructs; }),
- numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }),
- stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }),
- candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }),
- inferredTypes: undefined,
- };
- }
- function single() {
- return combineTypes(inferTypesFromReferencesSingle(references));
- }
- function parameters(declaration) {
- if (references.length === 0 || !declaration.parameters) {
- return undefined;
- }
- var usage = createEmptyUsage();
- for (var _i = 0, references_2 = references; _i < references_2.length; _i++) {
- var reference = references_2[_i];
- cancellationToken.throwIfCancellationRequested();
- calculateUsageOfNode(reference, usage);
- }
- var calls = __spreadArrays(usage.constructs || [], usage.calls || []);
- return declaration.parameters.map(function (parameter, parameterIndex) {
- var types = [];
- var isRest = ts.isRestParameter(parameter);
- var isOptional = false;
- for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) {
- var call = calls_1[_i];
- if (call.argumentTypes.length <= parameterIndex) {
- isOptional = ts.isInJSFile(declaration);
- types.push(checker.getUndefinedType());
- }
- else if (isRest) {
- for (var i = parameterIndex; i < call.argumentTypes.length; i++) {
- types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i]));
- }
- }
- else {
- types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex]));
- }
- }
- if (ts.isIdentifier(parameter.name)) {
- var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken));
- types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred));
- }
- var type = combineTypes(types);
- return {
- type: isRest ? checker.createArrayType(type) : type,
- isOptional: isOptional && !isRest,
- declaration: parameter
- };
- });
- }
- function thisParameter() {
- var usage = createEmptyUsage();
- for (var _i = 0, references_3 = references; _i < references_3.length; _i++) {
- var reference = references_3[_i];
- cancellationToken.throwIfCancellationRequested();
- calculateUsageOfNode(reference, usage);
- }
- return combineTypes(usage.candidateThisTypes || ts.emptyArray);
- }
- function inferTypesFromReferencesSingle(references) {
- var usage = createEmptyUsage();
- for (var _i = 0, references_4 = references; _i < references_4.length; _i++) {
- var reference = references_4[_i];
- cancellationToken.throwIfCancellationRequested();
- calculateUsageOfNode(reference, usage);
- }
- return inferTypes(usage);
- }
- function calculateUsageOfNode(node, usage) {
- while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) {
- node = node.parent;
- }
- switch (node.parent.kind) {
- case 226 /* ExpressionStatement */:
- addCandidateType(usage, checker.getVoidType());
- break;
- case 208 /* PostfixUnaryExpression */:
- usage.isNumber = true;
- break;
- case 207 /* PrefixUnaryExpression */:
- inferTypeFromPrefixUnaryExpression(node.parent, usage);
- break;
- case 209 /* BinaryExpression */:
- inferTypeFromBinaryExpression(node, node.parent, usage);
- break;
- case 277 /* CaseClause */:
- case 278 /* DefaultClause */:
- inferTypeFromSwitchStatementLabel(node.parent, usage);
- break;
- case 196 /* CallExpression */:
- case 197 /* NewExpression */:
- if (node.parent.expression === node) {
- inferTypeFromCallExpression(node.parent, usage);
- }
- else {
- inferTypeFromContextualType(node, usage);
- }
- break;
- case 194 /* PropertyAccessExpression */:
- inferTypeFromPropertyAccessExpression(node.parent, usage);
- break;
- case 195 /* ElementAccessExpression */:
- inferTypeFromPropertyElementExpression(node.parent, node, usage);
- break;
- case 281 /* PropertyAssignment */:
- case 282 /* ShorthandPropertyAssignment */:
- inferTypeFromPropertyAssignment(node.parent, usage);
- break;
- case 159 /* PropertyDeclaration */:
- inferTypeFromPropertyDeclaration(node.parent, usage);
- break;
- case 242 /* VariableDeclaration */: {
- var _a = node.parent, name = _a.name, initializer = _a.initializer;
- if (node === name) {
- if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error.
- addCandidateType(usage, checker.getTypeAtLocation(initializer));
- }
- break;
- }
- }
- // falls through
- default:
- return inferTypeFromContextualType(node, usage);
- }
- }
- function inferTypeFromContextualType(node, usage) {
- if (ts.isExpressionNode(node)) {
- addCandidateType(usage, checker.getContextualType(node));
- }
- }
- function inferTypeFromPrefixUnaryExpression(node, usage) {
- switch (node.operator) {
- case 45 /* PlusPlusToken */:
- case 46 /* MinusMinusToken */:
- case 40 /* MinusToken */:
- case 54 /* TildeToken */:
- usage.isNumber = true;
- break;
- case 39 /* PlusToken */:
- usage.isNumberOrString = true;
- break;
- // case SyntaxKind.ExclamationToken:
- // no inferences here;
- }
- }
- function inferTypeFromBinaryExpression(node, parent, usage) {
- switch (parent.operatorToken.kind) {
- // ExponentiationOperator
- case 42 /* AsteriskAsteriskToken */:
- // MultiplicativeOperator
- // falls through
- case 41 /* AsteriskToken */:
- case 43 /* SlashToken */:
- case 44 /* PercentToken */:
- // ShiftOperator
- // falls through
- case 47 /* LessThanLessThanToken */:
- case 48 /* GreaterThanGreaterThanToken */:
- case 49 /* GreaterThanGreaterThanGreaterThanToken */:
- // BitwiseOperator
- // falls through
- case 50 /* AmpersandToken */:
- case 51 /* BarToken */:
- case 52 /* CaretToken */:
- // CompoundAssignmentOperator
- // falls through
- case 64 /* MinusEqualsToken */:
- case 66 /* AsteriskAsteriskEqualsToken */:
- case 65 /* AsteriskEqualsToken */:
- case 67 /* SlashEqualsToken */:
- case 68 /* PercentEqualsToken */:
- case 72 /* AmpersandEqualsToken */:
- case 73 /* BarEqualsToken */:
- case 74 /* CaretEqualsToken */:
- case 69 /* LessThanLessThanEqualsToken */:
- case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 70 /* GreaterThanGreaterThanEqualsToken */:
- // AdditiveOperator
- // falls through
- case 40 /* MinusToken */:
- // RelationalOperator
- // falls through
- case 29 /* LessThanToken */:
- case 32 /* LessThanEqualsToken */:
- case 31 /* GreaterThanToken */:
- case 33 /* GreaterThanEqualsToken */:
- var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left);
- if (operandType.flags & 1056 /* EnumLike */) {
- addCandidateType(usage, operandType);
- }
- else {
- usage.isNumber = true;
- }
- break;
- case 63 /* PlusEqualsToken */:
- case 39 /* PlusToken */:
- var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left);
- if (otherOperandType.flags & 1056 /* EnumLike */) {
- addCandidateType(usage, otherOperandType);
- }
- else if (otherOperandType.flags & 296 /* NumberLike */) {
- usage.isNumber = true;
- }
- else if (otherOperandType.flags & 132 /* StringLike */) {
- usage.isString = true;
- }
- else if (otherOperandType.flags & 1 /* Any */) {
- // do nothing, maybe we'll learn something elsewhere
- }
- else {
- usage.isNumberOrString = true;
- }
- break;
- // AssignmentOperators
- case 62 /* EqualsToken */:
- case 34 /* EqualsEqualsToken */:
- case 36 /* EqualsEqualsEqualsToken */:
- case 37 /* ExclamationEqualsEqualsToken */:
- case 35 /* ExclamationEqualsToken */:
- addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left));
- break;
- case 97 /* InKeyword */:
- if (node === parent.left) {
- usage.isString = true;
- }
- break;
- // LogicalOperator Or NullishCoalescing
- case 56 /* BarBarToken */:
- case 60 /* QuestionQuestionToken */:
- if (node === parent.left &&
- (node.parent.parent.kind === 242 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) {
- // var x = x || {};
- // TODO: use getFalsyflagsOfType
- addCandidateType(usage, checker.getTypeAtLocation(parent.right));
- }
- break;
- case 55 /* AmpersandAmpersandToken */:
- case 27 /* CommaToken */:
- case 98 /* InstanceOfKeyword */:
- // nothing to infer here
- break;
- }
- }
- function inferTypeFromSwitchStatementLabel(parent, usage) {
- addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression));
- }
- function inferTypeFromCallExpression(parent, usage) {
- var call = {
- argumentTypes: [],
- return_: createEmptyUsage()
- };
- if (parent.arguments) {
- for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) {
- var argument = _a[_i];
- call.argumentTypes.push(checker.getTypeAtLocation(argument));
- }
- }
- calculateUsageOfNode(parent, call.return_);
- if (parent.kind === 196 /* CallExpression */) {
- (usage.calls || (usage.calls = [])).push(call);
- }
- else {
- (usage.constructs || (usage.constructs = [])).push(call);
- }
- }
- function inferTypeFromPropertyAccessExpression(parent, usage) {
- var name = ts.escapeLeadingUnderscores(parent.name.text);
- if (!usage.properties) {
- usage.properties = ts.createUnderscoreEscapedMap();
- }
- var propertyUsage = usage.properties.get(name) || createEmptyUsage();
- calculateUsageOfNode(parent, propertyUsage);
- usage.properties.set(name, propertyUsage);
- }
- function inferTypeFromPropertyElementExpression(parent, node, usage) {
- if (node === parent.argumentExpression) {
- usage.isNumberOrString = true;
- return;
- }
- else {
- var indexType = checker.getTypeAtLocation(parent.argumentExpression);
- var indexUsage = createEmptyUsage();
- calculateUsageOfNode(parent, indexUsage);
- if (indexType.flags & 296 /* NumberLike */) {
- usage.numberIndex = indexUsage;
- }
- else {
- usage.stringIndex = indexUsage;
- }
- }
- }
- function inferTypeFromPropertyAssignment(assignment, usage) {
- var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ?
- assignment.parent.parent :
- assignment.parent;
- addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType));
- }
- function inferTypeFromPropertyDeclaration(declaration, usage) {
- addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent));
- }
- function removeLowPriorityInferences(inferences, priorities) {
- var toRemove = [];
- for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
- var i = inferences_1[_i];
- for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) {
- var _b = priorities_1[_a], high = _b.high, low = _b.low;
- if (high(i)) {
- ts.Debug.assert(!low(i), "Priority can't have both low and high");
- toRemove.push(low);
- }
- }
- }
- return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); });
- }
- function combineFromUsage(usage) {
- return combineTypes(inferTypes(usage));
- }
- function combineTypes(inferences) {
- if (!inferences.length)
- return checker.getAnyType();
- // 1. string or number individually override string | number
- // 2. non-any, non-void overrides any or void
- // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types
- var stringNumber = checker.getUnionType([checker.getStringType(), checker.getNumberType()]);
- var priorities = [
- {
- high: function (t) { return t === checker.getStringType() || t === checker.getNumberType(); },
- low: function (t) { return t === stringNumber; }
- },
- {
- high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); },
- low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); }
- },
- {
- high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); },
- low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); }
- }
- ];
- var good = removeLowPriorityInferences(inferences, priorities);
- var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; });
- if (anons.length) {
- good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); });
- good.push(combineAnonymousTypes(anons));
- }
- return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */));
- }
- function combineAnonymousTypes(anons) {
- if (anons.length === 1) {
- return anons[0];
- }
- var calls = [];
- var constructs = [];
- var stringIndices = [];
- var numberIndices = [];
- var stringIndexReadonly = false;
- var numberIndexReadonly = false;
- var props = ts.createMultiMap();
- for (var _i = 0, anons_1 = anons; _i < anons_1.length; _i++) {
- var anon = anons_1[_i];
- for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) {
- var p = _b[_a];
- props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration));
- }
- calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */));
- constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */));
- if (anon.stringIndexInfo) {
- stringIndices.push(anon.stringIndexInfo.type);
- stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly;
- }
- if (anon.numberIndexInfo) {
- numberIndices.push(anon.numberIndexInfo.type);
- numberIndexReadonly = numberIndexReadonly || anon.numberIndexInfo.isReadonly;
- }
- }
- var members = ts.mapEntries(props, function (name, types) {
- var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0;
- var s = checker.createSymbol(4 /* Property */ | isOptional, name);
- s.type = checker.getUnionType(types);
- return [name, s];
- });
- return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined);
- }
- function inferTypes(usage) {
- var types = [];
- if (usage.isNumber) {
- types.push(checker.getNumberType());
- }
- if (usage.isString) {
- types.push(checker.getStringType());
- }
- if (usage.isNumberOrString) {
- types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()]));
- }
- if (usage.numberIndex) {
- types.push(checker.createArrayType(combineFromUsage(usage.numberIndex)));
- }
- if (usage.properties && usage.properties.size
- || usage.calls && usage.calls.length
- || usage.constructs && usage.constructs.length
- || usage.stringIndex) {
- types.push(inferStructuralType(usage));
- }
- types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }));
- types.push.apply(types, inferNamedTypesFromProperties(usage));
- return types;
- }
- function inferStructuralType(usage) {
- var members = ts.createUnderscoreEscapedMap();
- if (usage.properties) {
- usage.properties.forEach(function (u, name) {
- var symbol = checker.createSymbol(4 /* Property */, name);
- symbol.type = combineFromUsage(u);
- members.set(name, symbol);
- });
- }
- var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : [];
- var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : [];
- var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false);
- return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217
- }
- function inferNamedTypesFromProperties(usage) {
- if (!usage.properties || !usage.properties.size)
- return [];
- var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); });
- if (0 < types.length && types.length < 3) {
- return types.map(function (t) { return inferInstantiationFromUsage(t, usage); });
- }
- return [];
- }
- function allPropertiesAreAssignableToUsage(type, usage) {
- if (!usage.properties)
- return false;
- return !ts.forEachEntry(usage.properties, function (propUsage, name) {
- var source = checker.getTypeOfPropertyOfType(type, name);
- if (!source) {
- return true;
- }
- if (propUsage.calls) {
- var sigs = checker.getSignaturesOfType(source, 0 /* Call */);
- return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls));
- }
- else {
- return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage));
- }
- });
- }
- /**
- * inference is limited to
- * 1. generic types with a single parameter
- * 2. inference to/from calls with a single signature
- */
- function inferInstantiationFromUsage(type, usage) {
- if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) {
- return type;
- }
- var generic = type.target;
- var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters);
- if (!singleTypeParameter)
- return type;
- var types = [];
- usage.properties.forEach(function (propUsage, name) {
- var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name);
- ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference.");
- types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter));
- });
- return builtinConstructors[type.symbol.escapedName](combineTypes(types));
- }
- function inferTypeParameters(genericType, usageType, typeParameter) {
- if (genericType === typeParameter) {
- return [usageType];
- }
- else if (genericType.flags & 3145728 /* UnionOrIntersection */) {
- return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); });
- }
- else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) {
- // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference
- var genericArgs = checker.getTypeArguments(genericType);
- var usageArgs = checker.getTypeArguments(usageType);
- var types = [];
- if (genericArgs && usageArgs) {
- for (var i = 0; i < genericArgs.length; i++) {
- if (usageArgs[i]) {
- types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter));
- }
- }
- }
- return types;
- }
- var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */);
- var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */);
- if (genericSigs.length === 1 && usageSigs.length === 1) {
- return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter);
- }
- return [];
- }
- function inferFromSignatures(genericSig, usageSig, typeParameter) {
- var types = [];
- for (var i = 0; i < genericSig.parameters.length; i++) {
- var genericParam = genericSig.parameters[i];
- var usageParam = usageSig.parameters[i];
- var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]);
- if (!usageParam) {
- break;
- }
- var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration);
- var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType);
- if (elementType) {
- genericParamType = elementType;
- }
- var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration);
- types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter));
- }
- var genericReturn = checker.getReturnTypeOfSignature(genericSig);
- var usageReturn = checker.getReturnTypeOfSignature(usageSig);
- types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter));
- return types;
- }
- function getFunctionFromCalls(calls) {
- return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined);
- }
- function getSignatureFromCalls(calls) {
- var parameters = [];
- var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
- var _loop_12 = function (i) {
- var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
- symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
- if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
- symbol.flags |= 16777216 /* Optional */;
- }
- parameters.push(symbol);
- };
- for (var i = 0; i < length; i++) {
- _loop_12(i);
- }
- var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
- // TODO: GH#18217
- return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
- }
- function addCandidateType(usage, type) {
- if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) {
- (usage.candidateTypes || (usage.candidateTypes = [])).push(type);
- }
- }
- function addCandidateThisType(usage, type) {
- if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) {
- (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type);
- }
- }
- }
- })(codefix = ts.codefix || (ts.codefix = {}));
-})(ts || (ts = {}));
-/* @internal */
-var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -225960,7 +231502,10 @@ var ts;
if (!newClassDeclaration) {
return undefined;
}
- ts.copyLeadingComments(ctorDeclaration, newClassDeclaration, sourceFile);
+ // Deleting a declaration only deletes JSDoc style comments, so only copy those to the new node.
+ if (ts.hasJSDocNodes(ctorDeclaration)) {
+ ts.copyLeadingComments(ctorDeclaration, newClassDeclaration, sourceFile);
+ }
// Because the preceding node could be touched, we need to insert nodes before delete nodes.
changes.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration);
function createClassElementsFromSymbol(symbol) {
@@ -226121,27 +231666,21 @@ var ts;
return;
}
var synthNamesMap = ts.createMap();
- var originalTypeMap = ts.createMap();
- var allVarNames = [];
var isInJavascript = ts.isInJSFile(functionToConvert);
var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker);
- var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context, setOfExpressionsToReturn, originalTypeMap, allVarNames);
- var constIdentifiers = getConstIdentifiers(synthNamesMap);
+ var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context.sourceFile);
var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray;
- var transformer = { checker: checker, synthNamesMap: synthNamesMap, allVarNames: allVarNames, setOfExpressionsToReturn: setOfExpressionsToReturn, constIdentifiers: constIdentifiers, originalTypeMap: originalTypeMap, isInJSFile: isInJavascript };
+ var transformer = { checker: checker, synthNamesMap: synthNamesMap, setOfExpressionsToReturn: setOfExpressionsToReturn, isInJSFile: isInJavascript };
if (!returnStatements.length) {
return;
}
// add the async keyword
changes.insertLastModifierBefore(sourceFile, 126 /* AsyncKeyword */, functionToConvert);
- function startTransformation(node, nodeToReplace) {
- var newNodes = transformExpression(node, transformer, node);
- changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes);
- }
- var _loop_13 = function (statement) {
- ts.forEachChild(statement, function visit(node) {
+ var _loop_12 = function (returnStatement) {
+ ts.forEachChild(returnStatement, function visit(node) {
if (ts.isCallExpression(node)) {
- startTransformation(node, statement);
+ var newNodes = transformExpression(node, transformer);
+ changes.replaceNodeWithNodes(sourceFile, returnStatement, newNodes);
}
else if (!ts.isFunctionLike(node)) {
ts.forEachChild(node, visit);
@@ -226149,8 +231688,8 @@ var ts;
});
};
for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
- var statement = returnStatements_1[_i];
- _loop_13(statement);
+ var returnStatement = returnStatements_1[_i];
+ _loop_12(returnStatement);
}
}
function getReturnStatementsWithPromiseHandlers(body) {
@@ -226161,16 +231700,6 @@ var ts;
});
return res;
}
- // Returns the identifiers that are never reassigned in the refactor
- function getConstIdentifiers(synthNamesMap) {
- var constIdentifiers = [];
- synthNamesMap.forEach(function (val) {
- if (val.numberOfAssignmentsOriginal === 0) {
- constIdentifiers.push(val.identifier);
- }
- });
- return constIdentifiers;
- }
/*
Finds all of the expressions of promise type that should not be saved in a variable during the refactor
*/
@@ -226180,16 +231709,16 @@ var ts;
}
var setOfExpressionsToReturn = ts.createMap();
ts.forEachChild(func.body, function visit(node) {
- if (isPromiseReturningExpression(node, checker, "then")) {
+ if (isPromiseReturningCallExpression(node, checker, "then")) {
setOfExpressionsToReturn.set(ts.getNodeId(node).toString(), true);
ts.forEach(node.arguments, visit);
}
- else if (isPromiseReturningExpression(node, checker, "catch")) {
+ else if (isPromiseReturningCallExpression(node, checker, "catch")) {
setOfExpressionsToReturn.set(ts.getNodeId(node).toString(), true);
// if .catch() is the last call in the chain, move leftward in the chain until we hit something else that should be returned
ts.forEachChild(node, visit);
}
- else if (isPromiseReturningExpression(node, checker)) {
+ else if (isPromiseTypedExpression(node, checker)) {
setOfExpressionsToReturn.set(ts.getNodeId(node).toString(), true);
// don't recurse here, since we won't refactor any children or arguments of the expression
}
@@ -226199,16 +231728,18 @@ var ts;
});
return setOfExpressionsToReturn;
}
- /*
- Returns true if node is a promise returning expression
- If name is not undefined, node is a promise returning call of name
- */
- function isPromiseReturningExpression(node, checker, name) {
- var isNodeExpression = name ? ts.isCallExpression(node) : ts.isExpression(node);
- var isExpressionOfName = isNodeExpression && (!name || ts.hasPropertyAccessExpressionWithName(node, name));
+ function isPromiseReturningCallExpression(node, checker, name) {
+ if (!ts.isCallExpression(node))
+ return false;
+ var isExpressionOfName = ts.hasPropertyAccessExpressionWithName(node, name);
var nodeType = isExpressionOfName && checker.getTypeAtLocation(node);
return !!(nodeType && checker.getPromisedTypeOfPromise(nodeType));
}
+ function isPromiseTypedExpression(node, checker) {
+ if (!ts.isExpression(node))
+ return false;
+ return !!checker.getPromisedTypeOfPromise(checker.getTypeAtLocation(node));
+ }
function declaredInFile(symbol, sourceFile) {
return symbol.valueDeclaration && symbol.valueDeclaration.getSourceFile() === sourceFile;
}
@@ -226217,31 +231748,34 @@ var ts;
This function collects all existing identifier names and names of identifiers that will be created in the refactor.
It then checks for any collisions and renames them through getSynthesizedDeepClone
*/
- function renameCollidingVarNames(nodeToRename, checker, synthNamesMap, context, setOfAllExpressionsToReturn, originalType, allVarNames) {
+ function renameCollidingVarNames(nodeToRename, checker, synthNamesMap, sourceFile) {
var identsToRenameMap = ts.createMap(); // key is the symbol id
- var collidingSymbolMap = ts.createMap();
+ var collidingSymbolMap = ts.createMultiMap();
ts.forEachChild(nodeToRename, function visit(node) {
if (!ts.isIdentifier(node)) {
ts.forEachChild(node, visit);
return;
}
var symbol = checker.getSymbolAtLocation(node);
- var isDefinedInFile = symbol && declaredInFile(symbol, context.sourceFile);
+ var isDefinedInFile = symbol && declaredInFile(symbol, sourceFile);
if (symbol && isDefinedInFile) {
var type = checker.getTypeAtLocation(node);
+ // Note - the choice of the last call signature is arbitrary
var lastCallSignature = getLastCallSignature(type, checker);
var symbolIdString = ts.getSymbolId(symbol).toString();
- // if the identifier refers to a function we want to add the new synthesized variable for the declaration (ex. blob in let blob = res(arg))
- // Note - the choice of the last call signature is arbitrary
+ // If the identifier refers to a function, we want to add the new synthesized variable for the declaration. Example:
+ // fetch('...').then(response => { ... })
+ // will eventually become
+ // const response = await fetch('...')
+ // so we push an entry for 'response'.
if (lastCallSignature && !ts.isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) {
var firstParameter = ts.firstOrUndefined(lastCallSignature.parameters);
var ident = firstParameter && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) || ts.createOptimisticUniqueName("result");
var synthName = getNewNameIfConflict(ident, collidingSymbolMap);
synthNamesMap.set(symbolIdString, synthName);
- allVarNames.push({ identifier: synthName.identifier, symbol: symbol });
- addNameToFrequencyMap(collidingSymbolMap, ident.text, symbol);
+ collidingSymbolMap.add(ident.text, symbol);
}
- // we only care about identifiers that are parameters, declarations, or binding elements (don't care about other uses)
+ // We only care about identifiers that are parameters, variable declarations, or binding elements
else if (node.parent && (ts.isParameter(node.parent) || ts.isVariableDeclaration(node.parent) || ts.isBindingElement(node.parent))) {
var originalName = node.text;
var collidingSymbols = collidingSymbolMap.get(originalName);
@@ -226250,96 +231784,60 @@ var ts;
var newName = getNewNameIfConflict(node, collidingSymbolMap);
identsToRenameMap.set(symbolIdString, newName.identifier);
synthNamesMap.set(symbolIdString, newName);
- allVarNames.push({ identifier: newName.identifier, symbol: symbol });
- addNameToFrequencyMap(collidingSymbolMap, originalName, symbol);
+ collidingSymbolMap.add(originalName, symbol);
}
else {
var identifier = ts.getSynthesizedDeepClone(node);
- identsToRenameMap.set(symbolIdString, identifier);
- synthNamesMap.set(symbolIdString, createSynthIdentifier(identifier, [], allVarNames.filter(function (elem) { return elem.identifier.text === node.text; }).length /*, numberOfAssignmentsSynthesized: 0*/));
- if ((ts.isParameter(node.parent) && isExpressionOrCallOnTypePromise(node.parent.parent)) || ts.isVariableDeclaration(node.parent)) {
- allVarNames.push({ identifier: identifier, symbol: symbol });
- addNameToFrequencyMap(collidingSymbolMap, originalName, symbol);
- }
+ synthNamesMap.set(symbolIdString, createSynthIdentifier(identifier));
+ collidingSymbolMap.add(originalName, symbol);
}
}
}
});
- return ts.getSynthesizedDeepCloneWithRenames(nodeToRename, /*includeTrivia*/ true, identsToRenameMap, checker, deepCloneCallback);
- function isExpressionOrCallOnTypePromise(child) {
- var node = child.parent;
- if (ts.isCallExpression(node) || ts.isIdentifier(node) && !setOfAllExpressionsToReturn.get(ts.getNodeId(node).toString())) {
- var nodeType = checker.getTypeAtLocation(node);
- var isPromise = nodeType && checker.getPromisedTypeOfPromise(nodeType);
- return !!isPromise;
- }
- return false;
- }
- function deepCloneCallback(node, clone) {
- if (ts.isIdentifier(node)) {
- var symbol = checker.getSymbolAtLocation(node);
- var symboldIdString = symbol && ts.getSymbolId(symbol).toString();
- var renameInfo = symbol && synthNamesMap.get(symboldIdString);
- if (renameInfo) {
- var type = checker.getTypeAtLocation(node);
- originalType.set(ts.getNodeId(clone).toString(), type);
- }
- }
- var val = setOfAllExpressionsToReturn.get(ts.getNodeId(node).toString());
- if (val !== undefined) {
- setOfAllExpressionsToReturn.delete(ts.getNodeId(node).toString());
- setOfAllExpressionsToReturn.set(ts.getNodeId(clone).toString(), val);
- }
- }
- }
- function addNameToFrequencyMap(renamedVarNameFrequencyMap, originalName, symbol) {
- if (renamedVarNameFrequencyMap.has(originalName)) {
- renamedVarNameFrequencyMap.get(originalName).push(symbol);
- }
- else {
- renamedVarNameFrequencyMap.set(originalName, [symbol]);
- }
+ return ts.getSynthesizedDeepCloneWithRenames(nodeToRename, /*includeTrivia*/ true, identsToRenameMap, checker);
}
function getNewNameIfConflict(name, originalNames) {
var numVarsSameName = (originalNames.get(name.text) || ts.emptyArray).length;
- var numberOfAssignmentsOriginal = 0;
var identifier = numVarsSameName === 0 ? name : ts.createIdentifier(name.text + "_" + numVarsSameName);
- return createSynthIdentifier(identifier, [], numberOfAssignmentsOriginal);
+ return createSynthIdentifier(identifier);
}
- // dispatch function to recursively build the refactoring
- // should be kept up to date with isFixablePromiseHandler in suggestionDiagnostics.ts
- function transformExpression(node, transformer, outermostParent, prevArgName) {
- if (!node) {
- return ts.emptyArray;
- }
- var originalType = ts.isIdentifier(node) && transformer.originalTypeMap.get(ts.getNodeId(node).toString());
- var nodeType = originalType || transformer.checker.getTypeAtLocation(node);
- if (ts.isCallExpression(node) && ts.hasPropertyAccessExpressionWithName(node, "then") && nodeType && !!transformer.checker.getPromisedTypeOfPromise(nodeType)) {
- return transformThen(node, transformer, outermostParent, prevArgName);
- }
- else if (ts.isCallExpression(node) && ts.hasPropertyAccessExpressionWithName(node, "catch") && nodeType && !!transformer.checker.getPromisedTypeOfPromise(nodeType)) {
+ function silentFail() {
+ codeActionSucceeded = false;
+ return ts.emptyArray;
+ }
+ // dispatch function to recursively build the refactoring
+ // should be kept up to date with isFixablePromiseHandler in suggestionDiagnostics.ts
+ function transformExpression(node, transformer, prevArgName) {
+ if (isPromiseReturningCallExpression(node, transformer.checker, "then")) {
+ if (node.arguments.length === 0)
+ return silentFail();
+ return transformThen(node, transformer, prevArgName);
+ }
+ if (isPromiseReturningCallExpression(node, transformer.checker, "catch")) {
+ if (node.arguments.length === 0)
+ return silentFail();
return transformCatch(node, transformer, prevArgName);
}
- else if (ts.isPropertyAccessExpression(node)) {
- return transformExpression(node.expression, transformer, outermostParent, prevArgName);
+ if (ts.isPropertyAccessExpression(node)) {
+ return transformExpression(node.expression, transformer, prevArgName);
}
- else if (nodeType && transformer.checker.getPromisedTypeOfPromise(nodeType)) {
- return transformPromiseCall(node, transformer, prevArgName);
+ var nodeType = transformer.checker.getTypeAtLocation(node);
+ if (nodeType && transformer.checker.getPromisedTypeOfPromise(nodeType)) {
+ ts.Debug.assertNode(node.original.parent, ts.isPropertyAccessExpression);
+ return transformPromiseExpressionOfPropertyAccess(node, transformer, prevArgName);
}
- codeActionSucceeded = false;
- return ts.emptyArray;
+ return silentFail();
}
function transformCatch(node, transformer, prevArgName) {
var func = node.arguments[0];
var argName = getArgBindingName(func, transformer);
- var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(node).toString());
var possibleNameForVarDecl;
/*
If there is another call in the chain after the .catch() we are transforming, we will need to save the result of both paths (try block and catch block)
To do this, we will need to synthesize a variable that we were not aware of while we were adding identifiers to the synthNamesMap
We will use the prevArgName and then update the synthNamesMap with a new variable name for the next transformation step
*/
- if (prevArgName && !shouldReturn) {
+ if (prevArgName && !shouldReturn(node, transformer)) {
if (isSynthIdentifier(prevArgName)) {
possibleNameForVarDecl = prevArgName;
transformer.synthNamesMap.forEach(function (val, key) {
@@ -226352,13 +231850,12 @@ var ts;
else {
possibleNameForVarDecl = createSynthIdentifier(ts.createOptimisticUniqueName("result"), prevArgName.types);
}
- possibleNameForVarDecl.numberOfAssignmentsOriginal = 2; // Try block and catch block
- // update the constIdentifiers list
- if (transformer.constIdentifiers.some(function (elem) { return elem.text === possibleNameForVarDecl.identifier.text; })) {
- transformer.constIdentifiers.push(createUniqueSynthName(possibleNameForVarDecl).identifier);
- }
+ // We are about to write a 'let' variable declaration, but `transformExpression` for both
+ // the try block and catch block will assign to this name. Setting this flag indicates
+ // that future assignments should be written as `name = value` instead of `const name = value`.
+ possibleNameForVarDecl.hasBeenDeclared = true;
}
- var tryBlock = ts.createBlock(transformExpression(node.expression, transformer, node, possibleNameForVarDecl));
+ var tryBlock = ts.createBlock(transformExpression(node.expression, transformer, possibleNameForVarDecl));
var transformationBody = getTransformationBody(func, possibleNameForVarDecl, argName, node, transformer);
var catchArg = argName ? isSynthIdentifier(argName) ? argName.identifier.text : argName.bindingPattern : "e";
var catchVariableDeclaration = ts.createVariableDeclaration(catchArg);
@@ -226368,11 +231865,11 @@ var ts;
*/
var varDeclList;
var varDeclIdentifier;
- if (possibleNameForVarDecl && !shouldReturn) {
+ if (possibleNameForVarDecl && !shouldReturn(node, transformer)) {
varDeclIdentifier = ts.getSynthesizedDeepClone(possibleNameForVarDecl.identifier);
var typeArray = possibleNameForVarDecl.types;
var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */);
- var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType);
+ var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined);
var varDecl = [ts.createVariableDeclaration(varDeclIdentifier, unionTypeNode)];
varDeclList = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList(varDecl, 1 /* Let */));
}
@@ -226381,68 +231878,62 @@ var ts;
&& ts.createVariableStatement(/* modifiers */ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(ts.getSynthesizedDeepCloneWithRenames(prevArgName.bindingPattern), /* type */ undefined, varDeclIdentifier)], 2 /* Const */));
return ts.compact([varDeclList, tryStatement, destructuredResult]);
}
- function getIdentifierTextsFromBindingName(bindingName) {
- if (ts.isIdentifier(bindingName))
- return [bindingName.text];
- return ts.flatMap(bindingName.elements, function (element) {
- if (ts.isOmittedExpression(element))
- return [];
- return getIdentifierTextsFromBindingName(element.name);
- });
- }
function createUniqueSynthName(prevArgName) {
var renamedPrevArg = ts.createOptimisticUniqueName(prevArgName.identifier.text);
return createSynthIdentifier(renamedPrevArg);
}
- function transformThen(node, transformer, outermostParent, prevArgName) {
- var _a = node.arguments, res = _a[0], rej = _a[1];
- if (!res) {
- return transformExpression(node.expression, transformer, outermostParent);
- }
- var argNameRes = getArgBindingName(res, transformer);
- var transformationBody = getTransformationBody(res, prevArgName, argNameRes, node, transformer);
- if (rej) {
- var argNameRej = getArgBindingName(rej, transformer);
- var tryBlock = ts.createBlock(transformExpression(node.expression, transformer, node, argNameRes).concat(transformationBody));
- var transformationBody2 = getTransformationBody(rej, prevArgName, argNameRej, node, transformer);
- var catchArg = argNameRej ? isSynthIdentifier(argNameRej) ? argNameRej.identifier.text : argNameRej.bindingPattern : "e";
+ function transformThen(node, transformer, prevArgName) {
+ var _a = node.arguments, onFulfilled = _a[0], onRejected = _a[1];
+ var onFulfilledArgumentName = getArgBindingName(onFulfilled, transformer);
+ var transformationBody = getTransformationBody(onFulfilled, prevArgName, onFulfilledArgumentName, node, transformer);
+ if (onRejected) {
+ var onRejectedArgumentName = getArgBindingName(onRejected, transformer);
+ var tryBlock = ts.createBlock(transformExpression(node.expression, transformer, onFulfilledArgumentName).concat(transformationBody));
+ var transformationBody2 = getTransformationBody(onRejected, prevArgName, onRejectedArgumentName, node, transformer);
+ var catchArg = onRejectedArgumentName ? isSynthIdentifier(onRejectedArgumentName) ? onRejectedArgumentName.identifier.text : onRejectedArgumentName.bindingPattern : "e";
var catchVariableDeclaration = ts.createVariableDeclaration(catchArg);
var catchClause = ts.createCatchClause(catchVariableDeclaration, ts.createBlock(transformationBody2));
return [ts.createTry(tryBlock, catchClause, /* finallyBlock */ undefined)];
}
- return transformExpression(node.expression, transformer, node, argNameRes).concat(transformationBody);
+ return transformExpression(node.expression, transformer, onFulfilledArgumentName).concat(transformationBody);
}
- function getFlagOfBindingName(bindingName, constIdentifiers) {
- var identifiers = getIdentifierTextsFromBindingName(getNode(bindingName));
- var inArr = constIdentifiers.some(function (elem) { return ts.contains(identifiers, elem.text); });
- return inArr ? 2 /* Const */ : 1 /* Let */;
- }
- function transformPromiseCall(node, transformer, prevArgName) {
- var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(node).toString());
- // the identifier is empty when the handler (.then()) ignores the argument - In this situation we do not need to save the result of the promise returning call
- var originalNodeParent = node.original ? node.original.parent : node.parent;
- if (prevArgName && !shouldReturn && (!originalNodeParent || ts.isPropertyAccessExpression(originalNodeParent))) {
- return createTransformedStatement(prevArgName, ts.createAwait(node), transformer);
- }
- else if (!prevArgName && !shouldReturn && (!originalNodeParent || ts.isPropertyAccessExpression(originalNodeParent))) {
- return [ts.createStatement(ts.createAwait(node))];
+ /**
+ * Transforms the 'x' part of `x.then(...)`, or the 'y()' part of `y().catch(...)`, where 'x' and 'y()' are Promises.
+ */
+ function transformPromiseExpressionOfPropertyAccess(node, transformer, prevArgName) {
+ if (shouldReturn(node, transformer)) {
+ return [ts.createReturn(ts.getSynthesizedDeepClone(node))];
}
- return [ts.createReturn(ts.getSynthesizedDeepClone(node))];
+ return createVariableOrAssignmentOrExpressionStatement(prevArgName, ts.createAwait(node), /*typeAnnotation*/ undefined);
}
- function createTransformedStatement(prevArgName, rightHandSide, transformer) {
- if (!prevArgName || isEmpty(prevArgName)) {
+ function createVariableOrAssignmentOrExpressionStatement(variableName, rightHandSide, typeAnnotation) {
+ if (!variableName || isEmptyBindingName(variableName)) {
// if there's no argName to assign to, there still might be side effects
- return [ts.createStatement(rightHandSide)];
+ return [ts.createExpressionStatement(rightHandSide)];
}
- if (isSynthIdentifier(prevArgName) && prevArgName.types.length < prevArgName.numberOfAssignmentsOriginal) {
+ if (isSynthIdentifier(variableName) && variableName.hasBeenDeclared) {
// if the variable has already been declared, we don't need "let" or "const"
- return [ts.createStatement(ts.createAssignment(ts.getSynthesizedDeepClone(prevArgName.identifier), rightHandSide))];
+ return [ts.createExpressionStatement(ts.createAssignment(ts.getSynthesizedDeepClone(variableName.identifier), rightHandSide))];
+ }
+ return [
+ ts.createVariableStatement(
+ /*modifiers*/ undefined, ts.createVariableDeclarationList([
+ ts.createVariableDeclaration(ts.getSynthesizedDeepClone(getNode(variableName)), typeAnnotation, rightHandSide)
+ ], 2 /* Const */))
+ ];
+ }
+ function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) {
+ if (typeAnnotation && expressionToReturn) {
+ var name = ts.createOptimisticUniqueName("result");
+ return __spreadArrays(createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), [
+ ts.createReturn(name)
+ ]);
}
- return [ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(ts.getSynthesizedDeepClone(getNode(prevArgName)), /*type*/ undefined, rightHandSide)], getFlagOfBindingName(prevArgName, transformer.constIdentifiers))))];
+ return [ts.createReturn(expressionToReturn)];
}
// should be kept up to date with isFixablePromiseArgument in suggestionDiagnostics.ts
function getTransformationBody(func, prevArgName, argName, parent, transformer) {
- var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString());
+ var _a, _b, _c, _d;
switch (func.kind) {
case 100 /* NullKeyword */:
// do not produce a transformed statement for a null argument
@@ -226453,18 +231944,17 @@ var ts;
break;
}
var synthCall = ts.createCall(ts.getSynthesizedDeepClone(func), /*typeArguments*/ undefined, isSynthIdentifier(argName) ? [argName.identifier] : []);
- if (shouldReturn) {
- return [ts.createReturn(synthCall)];
+ if (shouldReturn(parent, transformer)) {
+ return maybeAnnotateAndReturn(synthCall, (_a = parent.typeArguments) === null || _a === void 0 ? void 0 : _a[0]);
}
- var type = transformer.originalTypeMap.get(ts.getNodeId(func).toString()) || transformer.checker.getTypeAtLocation(func);
+ var type = transformer.checker.getTypeAtLocation(func);
var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */);
if (!callSignatures.length) {
// if identifier in handler has no call signatures, it's invalid
- codeActionSucceeded = false;
- break;
+ return silentFail();
}
var returnType = callSignatures[0].getReturnType();
- var varDeclOrAssignment = createTransformedStatement(prevArgName, ts.createAwait(synthCall), transformer);
+ var varDeclOrAssignment = createVariableOrAssignmentOrExpressionStatement(prevArgName, ts.createAwait(synthCall), (_b = parent.typeArguments) === null || _b === void 0 ? void 0 : _b[0]);
if (prevArgName) {
prevArgName.types.push(returnType);
}
@@ -226476,20 +231966,24 @@ var ts;
if (ts.isBlock(funcBody)) {
var refactoredStmts = [];
var seenReturnStatement = false;
- for (var _i = 0, _a = funcBody.statements; _i < _a.length; _i++) {
- var statement = _a[_i];
+ for (var _i = 0, _e = funcBody.statements; _i < _e.length; _i++) {
+ var statement = _e[_i];
if (ts.isReturnStatement(statement)) {
seenReturnStatement = true;
- }
- if (ts.isReturnStatementWithFixablePromiseHandler(statement)) {
- refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName));
+ if (ts.isReturnStatementWithFixablePromiseHandler(statement)) {
+ refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName));
+ }
+ else {
+ refactoredStmts.push.apply(refactoredStmts, maybeAnnotateAndReturn(statement.expression, (_c = parent.typeArguments) === null || _c === void 0 ? void 0 : _c[0]));
+ }
}
else {
refactoredStmts.push(statement);
}
}
- return shouldReturn ? refactoredStmts.map(function (s) { return ts.getSynthesizedDeepClone(s); }) :
- removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement);
+ return shouldReturn(parent, transformer)
+ ? refactoredStmts.map(function (s) { return ts.getSynthesizedDeepClone(s); })
+ : removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement);
}
else {
var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.createReturn(funcBody)] : ts.emptyArray;
@@ -226501,22 +231995,21 @@ var ts;
var returnType_1 = getLastCallSignature(type_1, transformer.checker).getReturnType();
var rightHandSide = ts.getSynthesizedDeepClone(funcBody);
var possiblyAwaitedRightHandSide = !!transformer.checker.getPromisedTypeOfPromise(returnType_1) ? ts.createAwait(rightHandSide) : rightHandSide;
- if (!shouldReturn) {
- var transformedStatement = createTransformedStatement(prevArgName, possiblyAwaitedRightHandSide, transformer);
+ if (!shouldReturn(parent, transformer)) {
+ var transformedStatement = createVariableOrAssignmentOrExpressionStatement(prevArgName, possiblyAwaitedRightHandSide, /*typeAnnotation*/ undefined);
if (prevArgName) {
prevArgName.types.push(returnType_1);
}
return transformedStatement;
}
else {
- return [ts.createReturn(possiblyAwaitedRightHandSide)];
+ return maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, (_d = parent.typeArguments) === null || _d === void 0 ? void 0 : _d[0]);
}
}
}
default:
// If no cases apply, we've found a transformation body we don't know how to handle, so the refactoring should no-op to avoid deleting code.
- codeActionSucceeded = false;
- break;
+ return silentFail();
}
return ts.emptyArray;
}
@@ -226530,12 +232023,12 @@ var ts;
var stmt = stmts_1[_i];
if (ts.isReturnStatement(stmt)) {
if (stmt.expression) {
- var possiblyAwaitedExpression = isPromiseReturningExpression(stmt.expression, transformer.checker) ? ts.createAwait(stmt.expression) : stmt.expression;
+ var possiblyAwaitedExpression = isPromiseTypedExpression(stmt.expression, transformer.checker) ? ts.createAwait(stmt.expression) : stmt.expression;
if (prevArgName === undefined) {
ret.push(ts.createExpressionStatement(possiblyAwaitedExpression));
}
else {
- ret.push(ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, possiblyAwaitedExpression)], getFlagOfBindingName(prevArgName, transformer.constIdentifiers)))));
+ ret.push(ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */))));
}
}
}
@@ -226545,7 +232038,7 @@ var ts;
}
// if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables
if (!seenReturnStatement && prevArgName !== undefined) {
- ret.push(ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, ts.createIdentifier("undefined"))], getFlagOfBindingName(prevArgName, transformer.constIdentifiers)))));
+ ret.push(ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, ts.createIdentifier("undefined"))], 2 /* Const */))));
}
return ret;
}
@@ -226555,7 +232048,7 @@ var ts;
var stmt = innerRetStmts_1[_i];
ts.forEachChild(stmt, function visit(node) {
if (ts.isCallExpression(node)) {
- var temp = transformExpression(node, transformer, node, prevArgName);
+ var temp = transformExpression(node, transformer, prevArgName);
innerCbBody = innerCbBody.concat(temp);
if (innerCbBody.length > 0) {
return;
@@ -226569,7 +232062,6 @@ var ts;
return innerCbBody;
}
function getArgBindingName(funcNode, transformer) {
- var numberOfAssignmentsOriginal = 0;
var types = [];
var name;
if (ts.isFunctionLikeDeclaration(funcNode)) {
@@ -226601,10 +232093,10 @@ var ts;
var originalNode = getOriginalNode(identifier);
var symbol = getSymbol(originalNode);
if (!symbol) {
- return createSynthIdentifier(identifier, types, numberOfAssignmentsOriginal);
+ return createSynthIdentifier(identifier, types);
}
var mapEntry = transformer.synthNamesMap.get(ts.getSymbolId(symbol).toString());
- return mapEntry || createSynthIdentifier(identifier, types, numberOfAssignmentsOriginal);
+ return mapEntry || createSynthIdentifier(identifier, types);
}
function getSymbol(node) {
return node.symbol ? node.symbol : transformer.checker.getSymbolAtLocation(node);
@@ -226613,22 +232105,21 @@ var ts;
return node.original ? node.original : node;
}
}
- function isEmpty(bindingName) {
+ function isEmptyBindingName(bindingName) {
if (!bindingName) {
return true;
}
if (isSynthIdentifier(bindingName)) {
return !bindingName.identifier.text;
}
- return ts.every(bindingName.elements, isEmpty);
+ return ts.every(bindingName.elements, isEmptyBindingName);
}
function getNode(bindingName) {
return isSynthIdentifier(bindingName) ? bindingName.identifier : bindingName.bindingPattern;
}
- function createSynthIdentifier(identifier, types, numberOfAssignmentsOriginal) {
+ function createSynthIdentifier(identifier, types) {
if (types === void 0) { types = []; }
- if (numberOfAssignmentsOriginal === void 0) { numberOfAssignmentsOriginal = 0; }
- return { kind: 0 /* Identifier */, identifier: identifier, types: types, numberOfAssignmentsOriginal: numberOfAssignmentsOriginal };
+ return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false };
}
function createSynthBindingPattern(bindingPattern, elements, types) {
if (elements === void 0) { elements = ts.emptyArray; }
@@ -226641,6 +232132,9 @@ var ts;
function isSynthBindingPattern(bindingName) {
return bindingName.kind === 1 /* BindingPattern */;
}
+ function shouldReturn(expression, transformer) {
+ return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original).toString());
+ }
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
/* @internal */
@@ -227175,6 +232669,54 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var errorCodes = [ts.Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is_set_to_error.code];
+ var fixId = "convertToTypeOnlyImport";
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) {
+ var importDeclaration = getImportDeclarationForDiagnosticSpan(context.span, context.sourceFile);
+ fixSingleImportDeclaration(t, importDeclaration, context);
+ });
+ if (changes.length) {
+ return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_type_only_import, fixId, ts.Diagnostics.Convert_all_imports_not_used_as_a_value_to_type_only_imports)];
+ }
+ },
+ fixIds: [fixId],
+ getAllCodeActions: function (context) {
+ return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ var importDeclaration = getImportDeclarationForDiagnosticSpan(diag, context.sourceFile);
+ fixSingleImportDeclaration(changes, importDeclaration, context);
+ });
+ }
+ });
+ function getImportDeclarationForDiagnosticSpan(span, sourceFile) {
+ return ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start).parent, ts.isImportDeclaration);
+ }
+ function fixSingleImportDeclaration(changes, importDeclaration, context) {
+ if (!(importDeclaration === null || importDeclaration === void 0 ? void 0 : importDeclaration.importClause)) {
+ return;
+ }
+ var importClause = importDeclaration.importClause;
+ // `changes.insertModifierBefore` produces a range that might overlap further changes
+ changes.insertText(context.sourceFile, importDeclaration.getStart() + "import".length, " type");
+ // `import type foo, { Bar }` is not allowed, so move `foo` to new declaration
+ if (importClause.name && importClause.namedBindings) {
+ changes.deleteNodeRangeExcludingEnd(context.sourceFile, importClause.name, importDeclaration.importClause.namedBindings);
+ changes.insertNodeBefore(context.sourceFile, importDeclaration, ts.updateImportDeclaration(importDeclaration,
+ /*decorators*/ undefined,
+ /*modifiers*/ undefined, ts.createImportClause(importClause.name,
+ /*namedBindings*/ undefined,
+ /*isTypeOnly*/ true), importDeclaration.moduleSpecifier));
+ }
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -227188,7 +232730,7 @@ var ts;
getCodeActions: function (context) {
var sourceFile = context.sourceFile, span = context.span;
var classDeclaration = getClass(sourceFile, span.start);
- return ts.mapDefined(ts.getClassImplementsHeritageClauseElements(classDeclaration), function (implementedTypeNode) {
+ return ts.mapDefined(ts.getEffectiveImplementsTypeNodes(classDeclaration), function (implementedTypeNode) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, t, context.preferences); });
return changes.length === 0 ? undefined : codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Implement_interface_0, implementedTypeNode.getText(sourceFile)], fixId, ts.Diagnostics.Implement_all_unimplemented_interfaces);
});
@@ -227199,7 +232741,7 @@ var ts;
return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
var classDeclaration = getClass(diag.file, diag.start);
if (ts.addToSeen(seenClassDeclarations, ts.getNodeId(classDeclaration))) {
- for (var _i = 0, _a = ts.getClassImplementsHeritageClauseElements(classDeclaration); _i < _a.length; _i++) {
+ for (var _i = 0, _a = ts.getEffectiveImplementsTypeNodes(classDeclaration); _i < _a.length; _i++) {
var implementedTypeNode = _a[_i];
addMissingDeclarations(context, implementedTypeNode, diag.file, classDeclaration, changes, context.preferences);
}
@@ -227208,7 +232750,7 @@ var ts;
},
});
function getClass(sourceFile, pos) {
- return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class");
+ return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class");
}
function symbolPointsToNonPrivateMember(symbol) {
return !symbol.valueDeclaration || !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */);
@@ -227229,7 +232771,9 @@ var ts;
if (!classType.getStringIndexType()) {
createMissingIndexSignatureDeclaration(implementedType, 0 /* String */);
}
- codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, context, preferences, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); });
+ var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host);
+ codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); });
+ importAdder.writeFixes(changeTracker);
function createMissingIndexSignatureDeclaration(type, kind) {
var indexInfoOfKind = checker.getIndexInfoOfType(type, kind);
if (indexInfoOfKind) {
@@ -227285,90 +232829,120 @@ var ts;
},
fixIds: [importFixId],
getAllCodeActions: function (context) {
- var sourceFile = context.sourceFile, preferences = context.preferences;
- // Namespace fixes don't conflict, so just build a list.
- var addToNamespace = [];
- var importType = [];
- // Keys are import clause node IDs.
- var addToExisting = ts.createMap();
- var newImports = ts.createMap();
- var lastModuleSpecifier;
- codefix.eachDiagnostic(context, errorCodes, function (diag) {
- var info = getFixesInfo(context, diag.code, diag.start);
- if (!info || !info.fixes.length)
- return;
- var fixes = info.fixes, symbolName = info.symbolName;
- var fix = ts.first(fixes);
- switch (fix.kind) {
- case 0 /* UseNamespace */:
- addToNamespace.push(fix);
- break;
- case 1 /* ImportType */:
- importType.push(fix);
- break;
- case 2 /* AddToExisting */: {
- var importClause = fix.importClause, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport;
- var key = String(ts.getNodeId(importClause));
- var entry = addToExisting.get(key);
- if (!entry) {
- addToExisting.set(key, entry = { importClause: importClause, defaultImport: undefined, namedImports: [], canUseTypeOnlyImport: canUseTypeOnlyImport });
- }
- if (importKind === 0 /* Named */) {
- ts.pushIfUnique(entry.namedImports, symbolName);
- }
- else {
- ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName");
- entry.defaultImport = symbolName;
- }
- break;
+ var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences, host = context.host;
+ var importAdder = createImportAdder(sourceFile, program, preferences, host);
+ codefix.eachDiagnostic(context, errorCodes, function (diag) { return importAdder.addImportFromDiagnostic(diag, context); });
+ return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, importAdder.writeFixes));
+ },
+ });
+ function createImportAdder(sourceFile, program, preferences, host) {
+ var compilerOptions = program.getCompilerOptions();
+ // Namespace fixes don't conflict, so just build a list.
+ var addToNamespace = [];
+ var importType = [];
+ // Keys are import clause node IDs.
+ var addToExisting = ts.createMap();
+ var newImports = ts.createMap();
+ return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes };
+ function addImportFromDiagnostic(diagnostic, context) {
+ var info = getFixesInfo(context, diagnostic.code, diagnostic.start);
+ if (!info || !info.fixes.length)
+ return;
+ addImport(info);
+ }
+ function addImportFromExportedSymbol(exportedSymbol, usageIsTypeOnly) {
+ var moduleSymbol = ts.Debug.checkDefined(exportedSymbol.parent);
+ var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
+ var checker = program.getTypeChecker();
+ var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
+ var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, sourceFile, compilerOptions, checker, program.getSourceFiles());
+ var preferTypeOnlyImport = !!usageIsTypeOnly && compilerOptions.importsNotUsedAsValues === 2 /* Error */;
+ var useRequire = shouldUseRequire(sourceFile, compilerOptions);
+ var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, preferTypeOnlyImport, useRequire, host, preferences);
+ addImport({ fixes: [fix], symbolName: symbolName });
+ }
+ function addImport(info) {
+ var fixes = info.fixes, symbolName = info.symbolName;
+ var fix = ts.first(fixes);
+ switch (fix.kind) {
+ case 0 /* UseNamespace */:
+ addToNamespace.push(fix);
+ break;
+ case 1 /* ImportType */:
+ importType.push(fix);
+ break;
+ case 2 /* AddToExisting */: {
+ var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport;
+ var key = String(ts.getNodeId(importClauseOrBindingPattern));
+ var entry = addToExisting.get(key);
+ if (!entry) {
+ addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: [], canUseTypeOnlyImport: canUseTypeOnlyImport });
}
- case 3 /* AddNew */: {
- var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind;
- var entry = newImports.get(moduleSpecifier);
- if (!entry) {
- newImports.set(moduleSpecifier, entry = { defaultImport: undefined, namedImports: [], namespaceLikeImport: undefined });
- lastModuleSpecifier = moduleSpecifier;
- }
- switch (importKind) {
- case 1 /* Default */:
- ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName");
- entry.defaultImport = symbolName;
- break;
- case 0 /* Named */:
- ts.pushIfUnique(entry.namedImports, symbolName);
- break;
- case 3 /* Equals */:
- case 2 /* Namespace */:
- ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName");
- entry.namespaceLikeImport = { importKind: importKind, name: symbolName };
- break;
- }
- break;
+ if (importKind === 0 /* Named */) {
+ ts.pushIfUnique(entry.namedImports, symbolName);
}
- default:
- ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
+ else {
+ ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName");
+ entry.defaultImport = symbolName;
+ }
+ break;
}
+ case 3 /* AddNew */: {
+ var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, typeOnly = fix.typeOnly;
+ var entry = newImports.get(moduleSpecifier);
+ if (!entry) {
+ newImports.set(moduleSpecifier, entry = { namedImports: [], namespaceLikeImport: undefined, typeOnly: typeOnly, useRequire: useRequire });
+ }
+ else {
+ // An import clause can only be type-only if every import fix contributing to it can be type-only.
+ entry.typeOnly = entry.typeOnly && typeOnly;
+ }
+ switch (importKind) {
+ case 1 /* Default */:
+ ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName");
+ entry.defaultImport = symbolName;
+ break;
+ case 0 /* Named */:
+ ts.pushIfUnique(entry.namedImports || (entry.namedImports = []), symbolName);
+ break;
+ case 3 /* CommonJS */:
+ case 2 /* Namespace */:
+ ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName");
+ entry.namespaceLikeImport = { importKind: importKind, name: symbolName };
+ break;
+ }
+ break;
+ }
+ default:
+ ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
+ }
+ }
+ function writeFixes(changeTracker) {
+ var quotePreference = ts.getQuotePreference(sourceFile, preferences);
+ for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) {
+ var fix = addToNamespace_1[_i];
+ addNamespaceQualifier(changeTracker, sourceFile, fix);
+ }
+ for (var _a = 0, importType_1 = importType; _a < importType_1.length; _a++) {
+ var fix = importType_1[_a];
+ addImportType(changeTracker, sourceFile, fix, quotePreference);
+ }
+ addToExisting.forEach(function (_a) {
+ var importClauseOrBindingPattern = _a.importClauseOrBindingPattern, defaultImport = _a.defaultImport, namedImports = _a.namedImports, canUseTypeOnlyImport = _a.canUseTypeOnlyImport;
+ doAddExistingFix(changeTracker, sourceFile, importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport);
});
- return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
- var quotePreference = ts.getQuotePreference(sourceFile, preferences);
- for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) {
- var fix = addToNamespace_1[_i];
- addNamespaceQualifier(changes, sourceFile, fix);
- }
- for (var _a = 0, importType_1 = importType; _a < importType_1.length; _a++) {
- var fix = importType_1[_a];
- addImportType(changes, sourceFile, fix, quotePreference);
- }
- addToExisting.forEach(function (_a) {
- var importClause = _a.importClause, defaultImport = _a.defaultImport, namedImports = _a.namedImports, canUseTypeOnlyImport = _a.canUseTypeOnlyImport;
- doAddExistingFix(changes, sourceFile, importClause, defaultImport, namedImports, canUseTypeOnlyImport);
- });
- newImports.forEach(function (imports, moduleSpecifier) {
- addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, imports, /*blankLineBetween*/ lastModuleSpecifier === moduleSpecifier);
- });
- }));
- },
- });
+ var newDeclarations;
+ newImports.forEach(function (_a, moduleSpecifier) {
+ var useRequire = _a.useRequire, imports = __rest(_a, ["useRequire"]);
+ var getDeclarations = useRequire ? getNewRequires : getNewImports;
+ newDeclarations = ts.combine(newDeclarations, getDeclarations(moduleSpecifier, quotePreference, imports));
+ });
+ if (newDeclarations) {
+ ts.insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true);
+ }
+ }
+ }
+ codefix.createImportAdder = createImportAdder;
// Sorted with the preferred fix coming first.
var ImportFixKind;
(function (ImportFixKind) {
@@ -227382,18 +232956,23 @@ var ts;
ImportKind[ImportKind["Named"] = 0] = "Named";
ImportKind[ImportKind["Default"] = 1] = "Default";
ImportKind[ImportKind["Namespace"] = 2] = "Namespace";
- ImportKind[ImportKind["Equals"] = 3] = "Equals";
- ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals";
+ ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS";
})(ImportKind || (ImportKind = {}));
function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
- var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles());
- ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
- // We sort the best codefixes first, so taking `first` is best for completions.
- var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier;
- var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences));
+ var compilerOptions = program.getCompilerOptions();
+ var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, compilerOptions, program.getTypeChecker(), program.getSourceFiles());
+ var useRequire = shouldUseRequire(sourceFile, compilerOptions);
+ var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !ts.isSourceFileJS(sourceFile) && ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
+ var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences)).moduleSpecifier;
+ var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences);
return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) };
}
codefix.getImportCompletionAction = getImportCompletionAction;
+ function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences) {
+ ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
+ // We sort the best codefixes first, so taking `first` is best.
+ return ts.first(getFixForImport(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences));
+ }
function codeFixActionToCodeAction(_a) {
var description = _a.description, changes = _a.changes, commands = _a.commands;
return { description: description, changes: changes, commands: commands };
@@ -227409,7 +232988,7 @@ var ts;
if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) {
result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) });
}
- for (var _i = 0, _a = checker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) {
+ for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
var exported = _a[_i];
if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol) {
result.push({ moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker) });
@@ -227426,13 +233005,13 @@ var ts;
}
function getFixForImport(exportInfos, symbolName,
/** undefined only for missing JSX namespace */
- position, program, sourceFile, host, preferences) {
+ position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences) {
var checker = program.getTypeChecker();
var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); });
var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker);
var addToExisting = tryAddToExistingImport(existingImports, position !== undefined && isTypeOnlyPosition(sourceFile, position));
// Don't bother providing an action to add a new import if we can add to an existing one.
- var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences);
+ var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences);
return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport);
}
function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) {
@@ -227450,58 +233029,91 @@ var ts;
// and it is up to the user to decide which one fits best.
return ts.firstDefined(existingImports, function (_a) {
var declaration = _a.declaration;
- var namespace = getNamespaceImportName(declaration);
- if (namespace) {
- var moduleSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace));
+ var namespacePrefix = getNamespaceLikeImportText(declaration);
+ if (namespacePrefix) {
+ var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
- return { kind: 0 /* UseNamespace */, namespacePrefix: namespace.text, position: position };
+ return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position };
}
}
});
}
+ function getTargetModuleFromNamespaceLikeImport(declaration, checker) {
+ var _a;
+ switch (declaration.kind) {
+ case 242 /* VariableDeclaration */:
+ return checker.resolveExternalModuleName(declaration.initializer.arguments[0]);
+ case 253 /* ImportEqualsDeclaration */:
+ return checker.getAliasedSymbol(declaration.symbol);
+ case 254 /* ImportDeclaration */:
+ var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport);
+ return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol);
+ default:
+ return ts.Debug.assertNever(declaration);
+ }
+ }
+ function getNamespaceLikeImportText(declaration) {
+ var _a, _b, _c;
+ switch (declaration.kind) {
+ case 242 /* VariableDeclaration */:
+ return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text;
+ case 253 /* ImportEqualsDeclaration */:
+ return declaration.name.text;
+ case 254 /* ImportDeclaration */:
+ return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text;
+ default:
+ return ts.Debug.assertNever(declaration);
+ }
+ }
function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) {
return ts.firstDefined(existingImports, function (_a) {
var declaration = _a.declaration, importKind = _a.importKind;
- if (declaration.kind !== 254 /* ImportDeclaration */)
+ if (declaration.kind === 253 /* ImportEqualsDeclaration */)
return undefined;
+ if (declaration.kind === 242 /* VariableDeclaration */) {
+ return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 189 /* ObjectBindingPattern */
+ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, canUseTypeOnlyImport: false }
+ : undefined;
+ }
var importClause = declaration.importClause;
if (!importClause)
return undefined;
var name = importClause.name, namedBindings = importClause.namedBindings;
return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 257 /* NamedImports */)
- ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind, canUseTypeOnlyImport: canUseTypeOnlyImport }
+ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.getText(), canUseTypeOnlyImport: canUseTypeOnlyImport }
: undefined;
});
}
- function getNamespaceImportName(declaration) {
- if (declaration.kind === 254 /* ImportDeclaration */) {
- var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings;
- return namedBindings && namedBindings.kind === 256 /* NamespaceImport */ ? namedBindings.name : undefined;
- }
- else {
- return declaration.name;
- }
- }
function getExistingImportDeclarations(_a, checker, sourceFile) {
var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly;
// Can't use an es6 import for a type in JS.
return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) {
var i = ts.importFromModuleSpecifier(moduleSpecifier);
- return (i.kind === 254 /* ImportDeclaration */ || i.kind === 253 /* ImportEqualsDeclaration */)
- && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, exportedSymbolIsTypeOnly: exportedSymbolIsTypeOnly } : undefined;
+ if (ts.isRequireVariableDeclaration(i.parent, /*requireStringLiteralLikeArgument*/ true)) {
+ return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined;
+ }
+ if (i.kind === 254 /* ImportDeclaration */ || i.kind === 253 /* ImportEqualsDeclaration */) {
+ return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined;
+ }
});
}
- function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) {
+ function shouldUseRequire(sourceFile, compilerOptions) {
+ return ts.isSourceFileJS(sourceFile)
+ && !sourceFile.externalModuleIndicator
+ && (!!sourceFile.commonJsModuleIndicator || ts.getEmitModuleKind(compilerOptions) < ts.ModuleKind.ES2015);
+ }
+ function getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) {
var isJs = ts.isSourceFileJS(sourceFile);
+ var compilerOptions = program.getCompilerOptions();
var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier;
var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) {
var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly;
- return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap)
+ return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, compilerOptions, sourceFile, ts.createModuleSpecifierResolutionHost(program, host), preferences)
.map(function (moduleSpecifier) {
// `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
return exportedSymbolIsTypeOnly && isJs
- ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") }
- : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind };
+ ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.checkDefined(position, "position should be defined") }
+ : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, useRequire: useRequire, typeOnly: preferTypeOnlyImport };
});
});
// Sort by presence in package.json, then shortest paths first
@@ -227517,19 +233129,18 @@ var ts;
return a.moduleSpecifier.length - b.moduleSpecifier.length;
});
}
- function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) {
- var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier);
- return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences);
+ function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences) {
+ var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, preferTypeOnlyImport, useRequire); });
+ return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences);
}
- function newImportInfoFromExistingSpecifier(_a) {
+ function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) {
var declaration = _a.declaration, importKind = _a.importKind;
- var expression = declaration.kind === 254 /* ImportDeclaration */
- ? declaration.moduleSpecifier
- : declaration.moduleReference.kind === 265 /* ExternalModuleReference */
- ? declaration.moduleReference.expression
- : undefined;
- return expression && ts.isStringLiteral(expression)
- ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind }
+ var moduleSpecifier = declaration.kind === 254 /* ImportDeclaration */ ? declaration.moduleSpecifier :
+ declaration.kind === 242 /* VariableDeclaration */ ? declaration.initializer.arguments[0] :
+ declaration.moduleReference.kind === 265 /* ExternalModuleReference */ ? declaration.moduleReference.expression :
+ undefined;
+ return moduleSpecifier && ts.isStringLiteral(moduleSpecifier)
+ ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier.text, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire }
: undefined;
}
function getFixesInfo(context, errorCode, pos) {
@@ -227548,7 +233159,8 @@ var ts;
var symbol = checker.getAliasedSymbol(umdSymbol);
var symbolName = umdSymbol.name;
var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }];
- var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences);
+ var useRequire = shouldUseRequire(sourceFile, program.getCompilerOptions());
+ var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences);
return { fixes: fixes, symbolName: symbolName };
}
function getUmdSymbol(token, checker) {
@@ -227574,9 +233186,9 @@ var ts;
case ts.ModuleKind.CommonJS:
case ts.ModuleKind.UMD:
if (ts.isInJSFile(importingFile)) {
- return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */;
+ return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 3 /* CommonJS */;
}
- return 3 /* Equals */;
+ return 3 /* CommonJS */;
case ts.ModuleKind.System:
case ts.ModuleKind.ES2015:
case ts.ModuleKind.ES2020:
@@ -227599,10 +233211,13 @@ var ts;
: symbolToken.text;
// "default" is a keyword and not a legal identifier for the import, so we don't expect it here
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
+ var compilerOptions = program.getCompilerOptions();
+ var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && ts.isValidTypeOnlyAliasUseSite(symbolToken);
+ var useRequire = shouldUseRequire(sourceFile, compilerOptions);
var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host);
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
var _ = _a[0], exportInfos = _a[1];
- return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences);
+ return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences);
}));
return { fixes: fixes, symbolName: symbolName };
}
@@ -227653,7 +233268,7 @@ var ts;
// 2. 'import =' will not work in JavaScript, so the decision is between a default
// and const/require.
if (ts.isInJSFile(importingFile)) {
- return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */;
+ return ts.isExternalModule(importingFile) ? 1 /* Default */ : 3 /* CommonJS */;
}
// 3. At this point the most correct choice is probably 'import =', but people
// really hate that, so look to see if the importing file has any precedent
@@ -227661,12 +233276,12 @@ var ts;
for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) {
var statement = _a[_i];
if (ts.isImportEqualsDeclaration(statement)) {
- return 3 /* Equals */;
+ return 3 /* CommonJS */;
}
}
// 4. We have no precedent to go on, so just use a default import if
// allowSyntheticDefaultImports/esModuleInterop is enabled.
- return allowSyntheticDefaults ? 1 /* Default */ : 3 /* Equals */;
+ return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
}
function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) {
var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport);
@@ -227677,7 +233292,7 @@ var ts;
return { symbolForMeaning: defaultExport, name: name };
if (defaultExport.flags & 2097152 /* Alias */) {
var aliased = checker.getImmediateAliasedSymbol(defaultExport);
- return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions);
+ return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.checkDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions);
}
if (defaultExport.escapedName !== "default" /* Default */ &&
defaultExport.escapedName !== "export=" /* ExportEquals */) {
@@ -227714,16 +233329,18 @@ var ts;
addImportType(changes, sourceFile, fix, quotePreference);
return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName];
case 2 /* AddToExisting */: {
- var importClause = fix.importClause, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport;
- doAddExistingFix(changes, sourceFile, importClause, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray, canUseTypeOnlyImport);
- var moduleSpecifierWithoutQuotes = ts.stripQuotes(importClause.parent.moduleSpecifier.getText());
+ var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport, moduleSpecifier = fix.moduleSpecifier;
+ doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray, canUseTypeOnlyImport);
+ var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
return [importKind === 1 /* Default */ ? ts.Diagnostics.Add_default_import_0_to_existing_import_declaration_from_1 : ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; // you too!
}
case 3 /* AddNew */: {
- var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier;
- addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, importKind === 1 /* Default */ ? { defaultImport: symbolName, namedImports: ts.emptyArray, namespaceLikeImport: undefined }
- : importKind === 0 /* Named */ ? { defaultImport: undefined, namedImports: [symbolName], namespaceLikeImport: undefined }
- : { defaultImport: undefined, namedImports: ts.emptyArray, namespaceLikeImport: { importKind: importKind, name: symbolName } }, /*blankLineBetween*/ true);
+ var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, typeOnly = fix.typeOnly, useRequire = fix.useRequire;
+ var getDeclarations = useRequire ? getNewRequires : getNewImports;
+ var importsCollection = importKind === 1 /* Default */ ? { defaultImport: symbolName, typeOnly: typeOnly } :
+ importKind === 0 /* Named */ ? { namedImports: [symbolName], typeOnly: typeOnly } :
+ { namespaceLikeImport: { importKind: importKind, name: symbolName }, typeOnly: typeOnly };
+ ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, importsCollection), /*blankLineBetween*/ true);
return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
}
default:
@@ -227731,6 +233348,16 @@ var ts;
}
}
function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) {
+ if (clause.kind === 189 /* ObjectBindingPattern */) {
+ if (defaultImport) {
+ addElementToBindingPattern(clause, defaultImport, "default");
+ }
+ for (var _i = 0, namedImports_1 = namedImports; _i < namedImports_1.length; _i++) {
+ var specifier = namedImports_1[_i];
+ addElementToBindingPattern(clause, specifier, /*propertyName*/ undefined);
+ }
+ return;
+ }
var convertTypeOnlyToRegular = !canUseTypeOnlyImport && clause.isTypeOnly;
if (defaultImport) {
ts.Debug.assert(!clause.name, "Cannot add a default import to an import clause that already has one");
@@ -227739,19 +233366,19 @@ var ts;
if (namedImports.length) {
var specifiers = namedImports.map(function (name) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); });
if (clause.namedBindings && ts.cast(clause.namedBindings, ts.isNamedImports).elements.length) {
- for (var _i = 0, specifiers_1 = specifiers; _i < specifiers_1.length; _i++) {
- var spec = specifiers_1[_i];
+ for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) {
+ var spec = specifiers_1[_a];
changes.insertNodeInListAfter(sourceFile, ts.last(ts.cast(clause.namedBindings, ts.isNamedImports).elements), spec);
}
}
else {
if (specifiers.length) {
- var namedImports_1 = ts.createNamedImports(specifiers);
+ var namedImports_2 = ts.createNamedImports(specifiers);
if (clause.namedBindings) {
- changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1);
+ changes.replaceNode(sourceFile, clause.namedBindings, namedImports_2);
}
else {
- changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Import clause must have either named imports or a default import"), namedImports_1);
+ changes.insertNodeAfter(sourceFile, ts.Debug.checkDefined(clause.name, "Import clause must have either named imports or a default import"), namedImports_2);
}
}
}
@@ -227759,6 +233386,15 @@ var ts;
if (convertTypeOnlyToRegular) {
changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(clause, sourceFile));
}
+ function addElementToBindingPattern(bindingPattern, name, propertyName) {
+ var element = ts.createBindingElement(/*dotDotDotToken*/ undefined, propertyName, name);
+ if (bindingPattern.elements.length) {
+ changes.insertNodeInListAfter(sourceFile, ts.last(bindingPattern.elements), element);
+ }
+ else {
+ changes.replaceNode(sourceFile, bindingPattern, ts.createObjectBindingPattern([element]));
+ }
+ }
}
function addNamespaceQualifier(changes, sourceFile, _a) {
var namespacePrefix = _a.namespacePrefix, position = _a.position;
@@ -227772,21 +233408,51 @@ var ts;
var quote = ts.getQuoteFromPreference(quotePreference);
return "import(" + quote + moduleSpecifier + quote + ").";
}
- function addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, _a, blankLineBetween) {
- var defaultImport = _a.defaultImport, namedImports = _a.namedImports, namespaceLikeImport = _a.namespaceLikeImport;
+ function getNewImports(moduleSpecifier, quotePreference, imports) {
+ var _a, _b;
var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference);
- if (defaultImport !== undefined || namedImports.length) {
- ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference), /*blankLineBetween*/ blankLineBetween);
+ var statements;
+ if (imports.defaultImport !== undefined || ((_a = imports.namedImports) === null || _a === void 0 ? void 0 : _a.length)) {
+ statements = ts.combine(statements, ts.makeImport(imports.defaultImport === undefined ? undefined : ts.createIdentifier(imports.defaultImport), (_b = imports.namedImports) === null || _b === void 0 ? void 0 : _b.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference, imports.typeOnly));
}
+ var namespaceLikeImport = imports.namespaceLikeImport, typeOnly = imports.typeOnly;
if (namespaceLikeImport) {
- ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) :
- namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) :
- ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier), /*blankLineBetween*/ blankLineBetween);
+ var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */
+ ? ts.createImportEqualsDeclaration(
+ /*decorators*/ undefined,
+ /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier))
+ : ts.createImportDeclaration(
+ /*decorators*/ undefined,
+ /*modifiers*/ undefined, ts.createImportClause(
+ /*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name)), typeOnly), quotedModuleSpecifier);
+ statements = ts.combine(statements, declaration);
}
+ return ts.Debug.checkDefined(statements);
+ }
+ function getNewRequires(moduleSpecifier, quotePreference, imports) {
+ var _a, _b;
+ var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference);
+ var statements;
+ // const { default: foo, bar, etc } = require('./mod');
+ if (imports.defaultImport || ((_a = imports.namedImports) === null || _a === void 0 ? void 0 : _a.length)) {
+ var bindingElements = ((_b = imports.namedImports) === null || _b === void 0 ? void 0 : _b.map(function (name) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name); })) || [];
+ if (imports.defaultImport) {
+ bindingElements.unshift(ts.createBindingElement(/*dotDotDotToken*/ undefined, "default", imports.defaultImport));
+ }
+ var declaration = createConstEqualsRequireDeclaration(ts.createObjectBindingPattern(bindingElements), quotedModuleSpecifier);
+ statements = ts.combine(statements, declaration);
+ }
+ // const foo = require('./mod');
+ if (imports.namespaceLikeImport) {
+ var declaration = createConstEqualsRequireDeclaration(imports.namespaceLikeImport.name, quotedModuleSpecifier);
+ statements = ts.combine(statements, declaration);
+ }
+ return ts.Debug.checkDefined(statements);
}
function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) {
- return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([
- ts.createVariableDeclaration(ts.createIdentifier(name),
+ return ts.createVariableStatement(
+ /*modifiers*/ undefined, ts.createVariableDeclarationList([
+ ts.createVariableDeclaration(typeof name === "string" ? ts.createIdentifier(name) : name,
/*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier]))
], 2 /* Const */));
}
@@ -227796,12 +233462,11 @@ var ts;
}
function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) {
var filteredCount = 0;
- var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host);
- var allSourceFiles = program.getSourceFiles();
- var globalTypingsCache = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
- forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) {
+ var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
+ var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host, moduleSpecifierResolutionHost);
+ forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, sourceFile) {
if (sourceFile === undefined) {
- if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) {
+ if (!packageJson || packageJson.allowsImportingAmbientModule(module)) {
cb(module);
}
else if (packageJson) {
@@ -227810,8 +233475,8 @@ var ts;
}
else if (sourceFile &&
sourceFile !== from &&
- isImportablePath(from.fileName, sourceFile.fileName, ts.hostGetCanonicalFileName(host), globalTypingsCache)) {
- if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) {
+ isImportableFile(program, from, sourceFile, moduleSpecifierResolutionHost)) {
+ if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile)) {
cb(module);
}
else if (packageJson) {
@@ -227836,6 +233501,19 @@ var ts;
}
}
}
+ function isImportableFile(program, from, to, moduleSpecifierResolutionHost) {
+ var _a;
+ var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost);
+ var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost);
+ return !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost,
+ /*preferSymlinks*/ false, function (toPath) {
+ var toFile = program.getSourceFile(toPath);
+ // Determine to import using toPath only if toPath is what we were looking at
+ // or there doesnt exist the file in the program by the symlink
+ return (toFile === to || !toFile) &&
+ isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache);
+ });
+ }
/**
* Don't include something from a `node_modules` that isn't actually reachable by a global import.
* A relative import to node_modules is usually a bad idea.
@@ -227879,22 +233557,12 @@ var ts;
return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res;
}
codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier;
- function createAutoImportFilter(fromFile, program, host) {
+ function createAutoImportFilter(fromFile, program, host, moduleSpecifierResolutionHost) {
+ if (moduleSpecifierResolutionHost === void 0) { moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); }
var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host);
var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */;
- // Mix in `getProbablySymlinks` from Program when host doesn't have it
- // in order for non-Project hosts to have a symlinks cache.
- var moduleSpecifierResolutionHost = {
- directoryExists: ts.maybeBind(host, host.directoryExists),
- fileExists: ts.maybeBind(host, host.fileExists),
- getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory),
- readFile: ts.maybeBind(host, host.readFile),
- useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
- getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks,
- getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation),
- };
var usesNodeCoreModules;
- return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier };
+ return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier, moduleSpecifierResolutionHost: moduleSpecifierResolutionHost };
function moduleSpecifierIsCoveredByPackageJson(specifier) {
var packageName = getNodeModuleRootSpecifier(specifier);
for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) {
@@ -227905,12 +233573,12 @@ var ts;
}
return false;
}
- function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) {
+ function allowsImportingAmbientModule(moduleSymbol) {
if (!packageJsons.length) {
return true;
}
var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile();
- var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles);
+ var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName);
if (typeof declaringNodeModuleName === "undefined") {
return true;
}
@@ -227921,11 +233589,11 @@ var ts;
return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName)
|| moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier);
}
- function allowsImportingSourceFile(sourceFile, allSourceFiles) {
+ function allowsImportingSourceFile(sourceFile) {
if (!packageJsons.length) {
return true;
}
- var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles);
+ var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName);
if (!moduleSpecifier) {
return true;
}
@@ -227960,11 +233628,11 @@ var ts;
}
return false;
}
- function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) {
+ function getNodeModulesPackageNameFromFileName(importedFileName) {
if (!ts.stringContains(importedFileName, "node_modules")) {
return undefined;
}
- var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap);
+ var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost);
if (!specifier) {
return undefined;
}
@@ -227987,6 +233655,68 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixId = "fixImplicitThis";
+ var errorCodes = [ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, program = context.program, span = context.span;
+ var diagnostic;
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) {
+ diagnostic = doChange(t, sourceFile, span.start, program.getTypeChecker());
+ });
+ return diagnostic ? [codefix.createCodeFixAction(fixId, changes, diagnostic, fixId, ts.Diagnostics.Fix_all_implicit_this_errors)] : ts.emptyArray;
+ },
+ fixIds: [fixId],
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ doChange(changes, diag.file, diag.start, context.program.getTypeChecker());
+ }); },
+ });
+ function doChange(changes, sourceFile, pos, checker) {
+ var token = ts.getTokenAtPosition(sourceFile, pos);
+ ts.Debug.assert(token.kind === 104 /* ThisKeyword */);
+ var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false);
+ if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
+ return undefined;
+ if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function
+ var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 94 /* FunctionKeyword */, sourceFile));
+ var name = fn.name;
+ var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression
+ if (ts.isFunctionExpression(fn)) {
+ if (name && ts.FindAllReferences.Core.isSymbolReferencedInFile(name, checker, sourceFile, body)) {
+ // Function expression references itself. To fix we would have to extract it to a const.
+ return undefined;
+ }
+ // `function() {}` --> `() => {}`
+ changes.delete(sourceFile, fnKeyword);
+ if (name) {
+ changes.delete(sourceFile, name);
+ }
+ changes.insertText(sourceFile, body.pos, " =>");
+ return [ts.Diagnostics.Convert_function_expression_0_to_arrow_function, name ? name.text : ts.ANONYMOUS];
+ }
+ else {
+ // `function f() {}` => `const f = () => {}`
+ // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`.
+ changes.replaceNode(sourceFile, fnKeyword, ts.createToken(81 /* ConstKeyword */));
+ changes.insertText(sourceFile, name.end, " = ");
+ changes.insertText(sourceFile, body.pos, " =>");
+ return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text];
+ }
+ }
+ // No outer 'this', add a @class tag if in a JS constructor function
+ else if (ts.isSourceFileJS(sourceFile) && ts.isPropertyAccessExpression(token.parent) && ts.isAssignmentExpression(token.parent.parent)) {
+ codefix.addJSDocTags(changes, sourceFile, fn, [ts.createJSDocClassTag()]);
+ return ts.Diagnostics.Add_class_tag;
+ }
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -228023,19 +233753,19 @@ var ts;
// this.speling = 1;
// ^^^^^^^
var node = ts.getTokenAtPosition(sourceFile, pos);
+ var parent = node.parent;
var checker = context.program.getTypeChecker();
var suggestedSymbol;
- if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) {
+ if (ts.isPropertyAccessExpression(parent) && parent.name === node) {
ts.Debug.assert(ts.isIdentifierOrPrivateIdentifier(node), "Expected an identifier for spelling (property access)");
- var containingType = checker.getTypeAtLocation(node.parent.expression);
- if (node.parent.flags & 32 /* OptionalChain */) {
+ var containingType = checker.getTypeAtLocation(parent.expression);
+ if (parent.flags & 32 /* OptionalChain */) {
containingType = checker.getNonNullableType(containingType);
}
- var name = node;
- suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(name, containingType);
+ suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType);
}
- else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) {
- ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)");
+ else if (ts.isImportSpecifier(parent) && parent.name === node) {
+ ts.Debug.assertNode(node, ts.isIdentifier, "Expected an identifier for spelling (import)");
var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration);
var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration);
if (resolvedSourceFile && resolvedSourceFile.symbol) {
@@ -228090,6 +233820,192 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixId = "returnValueCorrect";
+ var fixIdAddReturnStatement = "fixAddReturnStatement";
+ var fixIdRemoveBlockBodyBrace = "fixRemoveBlockBodyBrace";
+ var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
+ var errorCodes = [
+ ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
+ ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
+ ];
+ var ProblemKind;
+ (function (ProblemKind) {
+ ProblemKind[ProblemKind["MissingReturnStatement"] = 0] = "MissingReturnStatement";
+ ProblemKind[ProblemKind["MissingParentheses"] = 1] = "MissingParentheses";
+ })(ProblemKind || (ProblemKind = {}));
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ fixIds: [fixIdAddReturnStatement, fixIdRemoveBlockBodyBrace, fixIdWrapTheBlockWithParen],
+ getCodeActions: function (context) {
+ var program = context.program, sourceFile = context.sourceFile, start = context.span.start, errorCode = context.errorCode;
+ var info = getInfo(program.getTypeChecker(), sourceFile, start, errorCode);
+ if (!info)
+ return undefined;
+ if (info.kind === ProblemKind.MissingReturnStatement) {
+ return ts.append([getActionForfixAddReturnStatement(context, info.expression, info.statement)], ts.isArrowFunction(info.declaration) ? getActionForfixRemoveBlockBodyBrace(context, info.declaration, info.expression, info.commentSource) : undefined);
+ }
+ else {
+ return [getActionForfixWrapTheBlockWithParen(context, info.declaration, info.expression)];
+ }
+ },
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ var info = getInfo(context.program.getTypeChecker(), diag.file, diag.start, diag.code);
+ if (!info)
+ return undefined;
+ switch (context.fixId) {
+ case fixIdAddReturnStatement:
+ addReturnStatement(changes, diag.file, info.expression, info.statement);
+ break;
+ case fixIdRemoveBlockBodyBrace:
+ if (!ts.isArrowFunction(info.declaration))
+ return undefined;
+ removeBlockBodyBrace(changes, diag.file, info.declaration, info.expression, info.commentSource, /* withParen */ false);
+ break;
+ case fixIdWrapTheBlockWithParen:
+ if (!ts.isArrowFunction(info.declaration))
+ return undefined;
+ wrapBlockWithParen(changes, diag.file, info.declaration, info.expression);
+ break;
+ default:
+ ts.Debug.fail(JSON.stringify(context.fixId));
+ }
+ }); },
+ });
+ function getFixInfo(checker, declaration, expectType, isFunctionType) {
+ if (!declaration.body || !ts.isBlock(declaration.body) || ts.length(declaration.body.statements) !== 1)
+ return undefined;
+ var firstStatement = ts.first(declaration.body.statements);
+ if (ts.isExpressionStatement(firstStatement) && checkFixedAssignableTo(checker, declaration, firstStatement.expression, expectType, isFunctionType)) {
+ return {
+ declaration: declaration,
+ kind: ProblemKind.MissingReturnStatement,
+ expression: firstStatement.expression,
+ statement: firstStatement,
+ commentSource: firstStatement.expression
+ };
+ }
+ else if (ts.isLabeledStatement(firstStatement) && ts.isExpressionStatement(firstStatement.statement)) {
+ var node = ts.createObjectLiteral([ts.createPropertyAssignment(firstStatement.label, firstStatement.statement.expression)]);
+ if (checkFixedAssignableTo(checker, declaration, node, expectType, isFunctionType)) {
+ return ts.isArrowFunction(declaration) ? {
+ declaration: declaration,
+ kind: ProblemKind.MissingParentheses,
+ expression: node,
+ statement: firstStatement,
+ commentSource: firstStatement.statement.expression
+ } : {
+ declaration: declaration,
+ kind: ProblemKind.MissingReturnStatement,
+ expression: node,
+ statement: firstStatement,
+ commentSource: firstStatement.statement.expression
+ };
+ }
+ }
+ else if (ts.isBlock(firstStatement) && ts.length(firstStatement.statements) === 1) {
+ var firstBlockStatement = ts.first(firstStatement.statements);
+ if (ts.isLabeledStatement(firstBlockStatement) && ts.isExpressionStatement(firstBlockStatement.statement)) {
+ var node = ts.createObjectLiteral([ts.createPropertyAssignment(firstBlockStatement.label, firstBlockStatement.statement.expression)]);
+ if (checkFixedAssignableTo(checker, declaration, node, expectType, isFunctionType)) {
+ return {
+ declaration: declaration,
+ kind: ProblemKind.MissingReturnStatement,
+ expression: node,
+ statement: firstStatement,
+ commentSource: firstBlockStatement
+ };
+ }
+ }
+ }
+ return undefined;
+ }
+ function checkFixedAssignableTo(checker, declaration, expr, type, isFunctionType) {
+ return checker.isTypeAssignableTo(checker.getTypeAtLocation(isFunctionType ? ts.updateFunctionLikeBody(declaration, ts.createBlock([ts.createReturn(expr)])) : expr), type);
+ }
+ function getInfo(checker, sourceFile, position, errorCode) {
+ var node = ts.getTokenAtPosition(sourceFile, position);
+ if (!node.parent)
+ return undefined;
+ var declaration = ts.findAncestor(node.parent, ts.isFunctionLikeDeclaration);
+ switch (errorCode) {
+ case ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
+ if (!declaration || !declaration.body || !declaration.type || !ts.rangeContainsRange(declaration.type, node))
+ return undefined;
+ return getFixInfo(checker, declaration, checker.getTypeFromTypeNode(declaration.type), /* isFunctionType */ false);
+ case ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code:
+ if (!declaration || !ts.isCallExpression(declaration.parent) || !declaration.body)
+ return undefined;
+ var pos = declaration.parent.arguments.indexOf(declaration);
+ var type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
+ if (!type)
+ return undefined;
+ return getFixInfo(checker, declaration, type, /* isFunctionType */ true);
+ case ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code:
+ if (!ts.isDeclarationName(node) || !ts.isVariableLike(node.parent) && !ts.isJsxAttribute(node.parent))
+ return undefined;
+ var initializer = getVariableLikeInitializer(node.parent);
+ if (!initializer || !ts.isFunctionLikeDeclaration(initializer) || !initializer.body)
+ return undefined;
+ return getFixInfo(checker, initializer, checker.getTypeAtLocation(node.parent), /* isFunctionType */ true);
+ }
+ return undefined;
+ }
+ function getVariableLikeInitializer(declaration) {
+ switch (declaration.kind) {
+ case 242 /* VariableDeclaration */:
+ case 156 /* Parameter */:
+ case 191 /* BindingElement */:
+ case 159 /* PropertyDeclaration */:
+ case 281 /* PropertyAssignment */:
+ return declaration.initializer;
+ case 273 /* JsxAttribute */:
+ return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined);
+ case 282 /* ShorthandPropertyAssignment */:
+ case 158 /* PropertySignature */:
+ case 284 /* EnumMember */:
+ case 323 /* JSDocPropertyTag */:
+ case 317 /* JSDocParameterTag */:
+ return undefined;
+ }
+ }
+ function addReturnStatement(changes, sourceFile, expression, statement) {
+ ts.suppressLeadingAndTrailingTrivia(expression);
+ var probablyNeedSemi = ts.probablyUsesSemicolons(sourceFile);
+ changes.replaceNode(sourceFile, statement, ts.createReturn(expression), {
+ leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude,
+ trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Exclude,
+ suffix: probablyNeedSemi ? ";" : undefined
+ });
+ }
+ function removeBlockBodyBrace(changes, sourceFile, declaration, expression, commentSource, withParen) {
+ var newBody = (withParen || ts.needsParentheses(expression)) ? ts.createParen(expression) : expression;
+ ts.suppressLeadingAndTrailingTrivia(commentSource);
+ ts.copyComments(commentSource, newBody);
+ changes.replaceNode(sourceFile, declaration.body, newBody);
+ }
+ function wrapBlockWithParen(changes, sourceFile, declaration, expression) {
+ changes.replaceNode(sourceFile, declaration.body, ts.createParen(expression));
+ }
+ function getActionForfixAddReturnStatement(context, expression, statement) {
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addReturnStatement(t, context.sourceFile, expression, statement); });
+ return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, ts.Diagnostics.Add_all_missing_return_statement);
+ }
+ function getActionForfixRemoveBlockBodyBrace(context, declaration, expression, commentSource) {
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return removeBlockBodyBrace(t, context.sourceFile, declaration, expression, commentSource, /* withParen */ false); });
+ return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Remove_block_body_braces, fixIdRemoveBlockBodyBrace, ts.Diagnostics.Remove_all_incorrect_body_block_braces);
+ }
+ function getActionForfixWrapTheBlockWithParen(context, declaration, expression) {
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return wrapBlockWithParen(t, context.sourceFile, declaration, expression); });
+ return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal, fixIdWrapTheBlockWithParen, ts.Diagnostics.Wrap_all_object_literal_with_parentheses);
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -228114,7 +234030,7 @@ var ts;
return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_missing_enum_member_0, token_1.text], fixId, ts.Diagnostics.Add_all_missing_members)];
}
var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call;
- var methodCodeAction = call && getActionForMethodDeclaration(context, declSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences);
+ var methodCodeAction = call && getActionForMethodDeclaration(context, declSourceFile, parentDeclaration, token, call, makeStatic, inJs);
var addMember = inJs && !ts.isInterfaceDeclaration(parentDeclaration) ?
ts.singleElementArray(getActionsForAddMissingMemberInJavascriptFile(context, declSourceFile, parentDeclaration, token, makeStatic)) :
getActionsForAddMissingMemberInTypeScriptFile(context, declSourceFile, parentDeclaration, token, makeStatic);
@@ -228122,7 +234038,7 @@ var ts;
},
fixIds: [fixId],
getAllCodeActions: function (context) {
- var program = context.program, preferences = context.preferences;
+ var program = context.program;
var checker = program.getTypeChecker();
var seen = ts.createMap();
var typeDeclToMembers = new ts.NodeMap();
@@ -228145,7 +234061,7 @@ var ts;
});
typeDeclToMembers.forEach(function (infos, classDeclaration) {
var supers = getAllSupers(classDeclaration, checker);
- var _loop_14 = function (info) {
+ var _loop_13 = function (info) {
// If some superclass added this property, don't add it again.
if (supers.some(function (superClassOrInterface) {
var superInfos = typeDeclToMembers.get(superClassOrInterface);
@@ -228158,7 +234074,7 @@ var ts;
var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call;
// Always prefer to add a method declaration if possible.
if (call && !ts.isPrivateIdentifier(token)) {
- addMethodDeclaration(context, changes, declSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences);
+ addMethodDeclaration(context, changes, declSourceFile, parentDeclaration, token, call, makeStatic, inJs);
}
else {
if (inJs && !ts.isInterfaceDeclaration(parentDeclaration)) {
@@ -228166,13 +234082,13 @@ var ts;
}
else {
var typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token);
- addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, makeStatic);
+ addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, makeStatic ? 32 /* Static */ : 0);
}
}
};
for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
var info = infos_1[_i];
- _loop_14(info);
+ _loop_13(info);
}
});
}));
@@ -228211,18 +234127,18 @@ var ts;
var symbol = leftExpressionType.symbol;
if (!symbol || !symbol.declarations)
return undefined;
- var isClass = ts.find(symbol.declarations, ts.isClassLike);
+ var classDeclaration = ts.find(symbol.declarations, ts.isClassLike);
// Don't suggest adding private identifiers to anything other than a class.
- if (!isClass && ts.isPrivateIdentifier(token)) {
+ if (!classDeclaration && ts.isPrivateIdentifier(token)) {
return undefined;
}
// Prefer to change the class instead of the interface if they are merged
- var classOrInterface = isClass || ts.find(symbol.declarations, ts.isInterfaceDeclaration);
+ var classOrInterface = classDeclaration || ts.find(symbol.declarations, ts.isInterfaceDeclaration);
if (classOrInterface && !program.isSourceFileFromExternalLibrary(classOrInterface.getSourceFile())) {
var makeStatic = (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
- // Static private identifier properties are not supported yet.
- if (makeStatic && ts.isPrivateIdentifier(token))
+ if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(classOrInterface))) {
return undefined;
+ }
var declSourceFile = classOrInterface.getSourceFile();
var inJs = ts.isSourceFileJS(declSourceFile);
var call = ts.tryCast(parent.parent, ts.isCallExpression);
@@ -228282,8 +234198,15 @@ var ts;
}
function getActionsForAddMissingMemberInTypeScriptFile(context, declSourceFile, classDeclaration, token, makeStatic) {
var typeNode = getTypeNode(context.program.getTypeChecker(), classDeclaration, token);
- var addProp = createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, token.text, typeNode);
- return makeStatic || ts.isPrivateIdentifier(token) ? [addProp] : [addProp, createAddIndexSignatureAction(context, declSourceFile, classDeclaration, token.text, typeNode)];
+ var actions = [createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, token.text, typeNode, makeStatic ? 32 /* Static */ : 0)];
+ if (makeStatic || ts.isPrivateIdentifier(token)) {
+ return actions;
+ }
+ if (ts.startsWithUnderscore(token.text)) {
+ actions.unshift(createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, token.text, typeNode, 8 /* Private */));
+ }
+ actions.push(createAddIndexSignatureAction(context, declSourceFile, classDeclaration, token.text, typeNode));
+ return actions;
}
function getTypeNode(checker, classDeclaration, token) {
var typeNode;
@@ -228291,22 +234214,25 @@ var ts;
var binaryExpression = token.parent.parent;
var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left;
var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression)));
- typeNode = checker.typeToTypeNode(widenedType, classDeclaration);
+ typeNode = checker.typeToTypeNode(widenedType, classDeclaration, /*flags*/ undefined);
}
else {
var contextualType = checker.getContextualType(token.parent);
- typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined;
+ typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined) : undefined;
}
return typeNode || ts.createKeywordTypeNode(125 /* AnyKeyword */);
}
- function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) {
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); });
- return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, tokenName], fixId, ts.Diagnostics.Add_all_missing_members);
+ function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) {
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags); });
+ if (modifierFlags & 8 /* Private */) {
+ return codefix.createCodeFixActionWithoutFixAll(fixName, changes, [ts.Diagnostics.Declare_private_property_0, tokenName]);
+ }
+ return codefix.createCodeFixAction(fixName, changes, [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, tokenName], fixId, ts.Diagnostics.Add_all_missing_members);
}
- function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) {
+ function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) {
var property = ts.createProperty(
/*decorators*/ undefined,
- /*modifiers*/ makeStatic ? [ts.createToken(120 /* StaticKeyword */)] : undefined, tokenName,
+ /*modifiers*/ modifierFlags ? ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined, tokenName,
/*questionToken*/ undefined, typeNode,
/*initializer*/ undefined);
var lastProp = getNodeToInsertPropertyAfter(classDeclaration);
@@ -228344,16 +234270,17 @@ var ts;
// No fixId here because code-fix-all currently only works on adding individual named properties.
return codefix.createCodeFixActionWithoutFixAll(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]);
}
- function getActionForMethodDeclaration(context, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) {
+ function getActionForMethodDeclaration(context, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs) {
// Private methods are not implemented yet.
if (ts.isPrivateIdentifier(token)) {
return undefined;
}
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); });
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs); });
return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, token.text], fixId, ts.Diagnostics.Add_all_missing_members);
}
- function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) {
- var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl);
+ function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs) {
+ var importAdder = codefix.createImportAdder(declSourceFile, context.program, context.preferences, context.host);
+ var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, typeDecl, importAdder);
var containingMethodDeclaration = ts.getAncestor(callExpression, 161 /* MethodDeclaration */);
if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) {
changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration);
@@ -228361,6 +234288,7 @@ var ts;
else {
changeTracker.insertNodeAtClassStart(declSourceFile, typeDecl, methodDeclaration);
}
+ importAdder.writeFixes(changeTracker);
}
function addEnumMemberDeclaration(changes, checker, token, enumDeclaration) {
/**
@@ -228373,7 +234301,10 @@ var ts;
return !!(type && type.flags & 132 /* StringLike */);
});
var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined);
- changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember))));
+ changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember))), {
+ leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll,
+ trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Exclude
+ });
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -228418,7 +234349,7 @@ var ts;
(function (codefix) {
var fixName = "fixCannotFindModule";
var fixIdInstallTypesPackage = "installTypesPackage";
- var errorCodeCannotFindModule = ts.Diagnostics.Cannot_find_module_0.code;
+ var errorCodeCannotFindModule = ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code;
var errorCodes = [
errorCodeCannotFindModule,
ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code,
@@ -228513,7 +234444,9 @@ var ts;
// Note that this is ultimately derived from a map indexed by symbol names,
// so duplicates cannot occur.
var abstractAndNonPrivateExtendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType).filter(symbolPointsToNonPrivateAndAbstractMember);
- codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, context, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); });
+ var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host);
+ codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, context, preferences, importAdder, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); });
+ importAdder.writeFixes(changeTracker);
}
function symbolPointsToNonPrivateAndAbstractMember(symbol) {
// See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files
@@ -228601,7 +234534,7 @@ var ts;
});
function getNode(sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
- ts.Debug.assert(token.kind === 129 /* ConstructorKeyword */, "token should be at the constructor keyword");
+ ts.Debug.assert(ts.isConstructorDeclaration(token.parent), "token should be at the constructor declaration");
return token.parent;
}
function doChange(changes, sourceFile, ctr) {
@@ -228821,6 +234754,51 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixIdExpression = "fixInvalidJsxCharacters_expression";
+ var fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity";
+ var errorCodes = [
+ ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt.code,
+ ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code
+ ];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ fixIds: [fixIdExpression, fixIdHtmlEntity],
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, preferences = context.preferences, span = context.span;
+ var changeToExpression = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, preferences, sourceFile, span.start, /* useHtmlEntity */ false); });
+ var changeToHtmlEntity = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, preferences, sourceFile, span.start, /* useHtmlEntity */ true); });
+ return [
+ codefix.createCodeFixAction(fixIdExpression, changeToExpression, ts.Diagnostics.Wrap_invalid_character_in_an_expression_container, fixIdExpression, ts.Diagnostics.Wrap_all_invalid_characters_in_an_expression_container),
+ codefix.createCodeFixAction(fixIdHtmlEntity, changeToHtmlEntity, ts.Diagnostics.Convert_invalid_character_to_its_html_entity_code, fixIdHtmlEntity, ts.Diagnostics.Convert_all_invalid_characters_to_HTML_entity_code)
+ ];
+ },
+ getAllCodeActions: function (context) {
+ return codefix.codeFixAll(context, errorCodes, function (changes, diagnostic) { return doChange(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity); });
+ }
+ });
+ var htmlEntity = {
+ ">": ">",
+ "}": "}",
+ };
+ function isValidCharacter(character) {
+ return ts.hasProperty(htmlEntity, character);
+ }
+ function doChange(changes, preferences, sourceFile, start, useHtmlEntity) {
+ var character = sourceFile.getText()[start];
+ // sanity check
+ if (!isValidCharacter(character)) {
+ return;
+ }
+ var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(character, preferences) + "}";
+ changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement);
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -228935,7 +234913,7 @@ var ts;
return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations);
}
function deleteTypeParameters(changes, sourceFile, token) {
- changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist"));
+ changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist"));
}
// Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing.
function tryGetFullImport(token) {
@@ -228970,6 +234948,13 @@ var ts;
}
if (ts.isIdentifier(token) && canPrefix(token)) {
changes.replaceNode(sourceFile, token, ts.createIdentifier("_" + token.text));
+ if (ts.isParameter(token.parent)) {
+ ts.getJSDocParameterTags(token.parent).forEach(function (tag) {
+ if (ts.isIdentifier(tag.name)) {
+ changes.replaceNode(sourceFile, tag.name, ts.createIdentifier("_" + tag.name.text));
+ }
+ });
+ }
}
}
function canPrefix(token) {
@@ -229115,7 +235100,7 @@ var ts;
}
if (ts.isBlock(statement.parent)) {
var end_3 = start + length;
- var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last");
+ var lastStatement = ts.Debug.checkDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last");
changes.deleteNodeRange(sourceFile, statement, lastStatement);
}
else {
@@ -229207,7 +235192,7 @@ var ts;
}
});
function doChange(changes, sourceFile, oldTypeNode, newType, checker) {
- changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); // TODO: GH#18217
+ changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode, /*flags*/ undefined)); // TODO: GH#18217
}
function getInfo(sourceFile, pos, checker) {
var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), isTypeContainer);
@@ -229243,6 +235228,51 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixId = "fixMissingCallParentheses";
+ var errorCodes = [
+ ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code,
+ ];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ fixIds: [fixId],
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, span = context.span;
+ var callName = getCallName(sourceFile, span.start);
+ if (!callName)
+ return;
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, callName); });
+ return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_missing_call_parentheses, fixId, ts.Diagnostics.Add_all_missing_call_parentheses)];
+ },
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ var callName = getCallName(diag.file, diag.start);
+ if (callName)
+ doChange(changes, diag.file, callName);
+ }); }
+ });
+ function doChange(changes, sourceFile, name) {
+ changes.replaceNodeWithText(sourceFile, name, name.text + "()");
+ }
+ function getCallName(sourceFile, start) {
+ var token = ts.getTokenAtPosition(sourceFile, start);
+ if (ts.isPropertyAccessExpression(token.parent)) {
+ var current = token.parent;
+ while (ts.isPropertyAccessExpression(current.parent)) {
+ current = current.parent;
+ }
+ return current.name;
+ }
+ if (ts.isIdentifier(token)) {
+ return token;
+ }
+ return undefined;
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -229322,6 +235352,986 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixId = "inferFromUsage";
+ var errorCodes = [
+ // Variable declarations
+ ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
+ // Variable uses
+ ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code,
+ // Parameter declarations
+ ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code,
+ ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code,
+ // Get Accessor declarations
+ ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code,
+ ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code,
+ // Set Accessor declarations
+ ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code,
+ // Property declarations
+ ts.Diagnostics.Member_0_implicitly_has_an_1_type.code,
+ //// Suggestions
+ // Variable declarations
+ ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code,
+ // Variable uses
+ ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code,
+ // Parameter declarations
+ ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code,
+ ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code,
+ // Get Accessor declarations
+ ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code,
+ ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code,
+ // Set Accessor declarations
+ ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code,
+ // Property declarations
+ ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code,
+ // Function expressions and declarations
+ ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code,
+ ];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host, preferences = context.preferences;
+ var token = ts.getTokenAtPosition(sourceFile, start);
+ var declaration;
+ var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, preferences); });
+ var name = declaration && ts.getNameOfDeclaration(declaration);
+ return !name || changes.length === 0 ? undefined
+ : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
+ },
+ fixIds: [fixId],
+ getAllCodeActions: function (context) {
+ var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host, preferences = context.preferences;
+ var markSeen = ts.nodeSeenTracker();
+ return codefix.codeFixAll(context, errorCodes, function (changes, err) {
+ doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
+ });
+ },
+ });
+ function getDiagnostic(errorCode, token) {
+ switch (errorCode) {
+ case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code:
+ case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code:
+ return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217
+ case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code:
+ case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code:
+ return ts.Diagnostics.Infer_parameter_types_from_usage;
+ case ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code:
+ return ts.Diagnostics.Infer_this_type_of_0_from_usage;
+ default:
+ return ts.Diagnostics.Infer_type_of_0_from_usage;
+ }
+ }
+ /** Map suggestion code to error code */
+ function mapSuggestionDiagnostic(errorCode) {
+ switch (errorCode) {
+ case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code:
+ return ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code;
+ case ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code:
+ return ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code;
+ case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code:
+ return ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code;
+ case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code:
+ return ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code;
+ case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code:
+ return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code;
+ case ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code:
+ return ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code;
+ case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code:
+ return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code;
+ case ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code:
+ return ts.Diagnostics.Member_0_implicitly_has_an_1_type.code;
+ }
+ return errorCode;
+ }
+ function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) {
+ if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 104 /* ThisKeyword */) {
+ return undefined;
+ }
+ var parent = token.parent;
+ var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);
+ errorCode = mapSuggestionDiagnostic(errorCode);
+ switch (errorCode) {
+ // Variable and Property declarations
+ case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code:
+ case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code:
+ if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location
+ annotateVariableDeclaration(changes, importAdder, sourceFile, parent, program, host, cancellationToken);
+ importAdder.writeFixes(changes);
+ return parent;
+ }
+ if (ts.isPropertyAccessExpression(parent)) {
+ var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken);
+ var typeNode = ts.getTypeNodeIfAccessible(type, parent, program, host);
+ if (typeNode) {
+ // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags
+ var typeTag = ts.createJSDocTypeTag(ts.createJSDocTypeExpression(typeNode), /*comment*/ "");
+ addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]);
+ }
+ importAdder.writeFixes(changes);
+ return parent;
+ }
+ return undefined;
+ case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: {
+ var symbol = program.getTypeChecker().getSymbolAtLocation(token);
+ if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) {
+ annotateVariableDeclaration(changes, importAdder, sourceFile, symbol.valueDeclaration, program, host, cancellationToken);
+ importAdder.writeFixes(changes);
+ return symbol.valueDeclaration;
+ }
+ return undefined;
+ }
+ }
+ var containingFunction = ts.getContainingFunction(token);
+ if (containingFunction === undefined) {
+ return undefined;
+ }
+ var declaration;
+ switch (errorCode) {
+ // Parameter declarations
+ case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code:
+ if (ts.isSetAccessorDeclaration(containingFunction)) {
+ annotateSetAccessor(changes, importAdder, sourceFile, containingFunction, program, host, cancellationToken);
+ declaration = containingFunction;
+ break;
+ }
+ // falls through
+ case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code:
+ if (markSeen(containingFunction)) {
+ var param = ts.cast(parent, ts.isParameter);
+ annotateParameters(changes, importAdder, sourceFile, param, containingFunction, program, host, cancellationToken);
+ declaration = param;
+ }
+ break;
+ // Get Accessor declarations
+ case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code:
+ case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code:
+ if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) {
+ annotate(changes, importAdder, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host);
+ declaration = containingFunction;
+ }
+ break;
+ // Set Accessor declarations
+ case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code:
+ if (ts.isSetAccessorDeclaration(containingFunction)) {
+ annotateSetAccessor(changes, importAdder, sourceFile, containingFunction, program, host, cancellationToken);
+ declaration = containingFunction;
+ }
+ break;
+ // Function 'this'
+ case ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code:
+ if (ts.textChanges.isThisTypeAnnotatable(containingFunction) && markSeen(containingFunction)) {
+ annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken);
+ declaration = containingFunction;
+ }
+ break;
+ default:
+ return ts.Debug.fail(String(errorCode));
+ }
+ importAdder.writeFixes(changes);
+ return declaration;
+ }
+ function annotateVariableDeclaration(changes, importAdder, sourceFile, declaration, program, host, cancellationToken) {
+ if (ts.isIdentifier(declaration.name)) {
+ annotate(changes, importAdder, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host);
+ }
+ }
+ function annotateParameters(changes, importAdder, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) {
+ if (!ts.isIdentifier(parameterDeclaration.name)) {
+ return;
+ }
+ var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken);
+ ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match");
+ if (ts.isInJSFile(containingFunction)) {
+ annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host);
+ }
+ else {
+ var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile);
+ if (needParens)
+ changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.createToken(20 /* OpenParenToken */));
+ for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) {
+ var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type;
+ if (declaration && !declaration.type && !declaration.initializer) {
+ annotate(changes, importAdder, sourceFile, declaration, type, program, host);
+ }
+ }
+ if (needParens)
+ changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.createToken(21 /* CloseParenToken */));
+ }
+ }
+ function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) {
+ var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken);
+ if (!references || !references.length) {
+ return;
+ }
+ var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter();
+ var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host);
+ if (!typeNode) {
+ return;
+ }
+ if (ts.isInJSFile(containingFunction)) {
+ annotateJSDocThis(changes, sourceFile, containingFunction, typeNode);
+ }
+ else {
+ changes.tryInsertThisTypeAnnotation(sourceFile, containingFunction, typeNode);
+ }
+ }
+ function annotateJSDocThis(changes, sourceFile, containingFunction, typeNode) {
+ addJSDocTags(changes, sourceFile, containingFunction, [
+ ts.createJSDocThisTag(ts.createJSDocTypeExpression(typeNode)),
+ ]);
+ }
+ function annotateSetAccessor(changes, importAdder, sourceFile, setAccessorDeclaration, program, host, cancellationToken) {
+ var param = ts.firstOrUndefined(setAccessorDeclaration.parameters);
+ if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) {
+ var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken);
+ if (type === program.getTypeChecker().getAnyType()) {
+ type = inferTypeForVariableFromUsage(param.name, program, cancellationToken);
+ }
+ if (ts.isInJSFile(setAccessorDeclaration)) {
+ annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host);
+ }
+ else {
+ annotate(changes, importAdder, sourceFile, param, type, program, host);
+ }
+ }
+ }
+ function annotate(changes, importAdder, sourceFile, declaration, type, program, host) {
+ var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host);
+ if (typeNode) {
+ if (ts.isInJSFile(sourceFile) && declaration.kind !== 158 /* PropertySignature */) {
+ var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration;
+ if (!parent) {
+ return;
+ }
+ var typeExpression = ts.createJSDocTypeExpression(typeNode);
+ var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, "");
+ addJSDocTags(changes, sourceFile, parent, [typeTag]);
+ }
+ else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, type, sourceFile, changes, importAdder, ts.getEmitScriptTarget(program.getCompilerOptions()))) {
+ changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode);
+ }
+ }
+ }
+ function tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, type, sourceFile, changes, importAdder, scriptTarget) {
+ var importableReference = codefix.tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget);
+ if (importableReference && changes.tryInsertTypeAnnotation(sourceFile, declaration, importableReference.typeReference)) {
+ ts.forEach(importableReference.symbols, function (s) { return importAdder.addImportFromExportedSymbol(s, /*usageIsTypeOnly*/ true); });
+ return true;
+ }
+ return false;
+ }
+ function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) {
+ var signature = parameterInferences.length && parameterInferences[0].declaration.parent;
+ if (!signature) {
+ return;
+ }
+ var paramTags = ts.mapDefined(parameterInferences, function (inference) {
+ var param = inference.declaration;
+ // only infer parameters that have (1) no type and (2) an accessible inferred type
+ if (param.initializer || ts.getJSDocType(param) || !ts.isIdentifier(param.name))
+ return;
+ var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host);
+ var name = ts.getSynthesizedClone(param.name);
+ ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
+ return typeNode && ts.createJSDocParamTag(name, !!inference.isOptional, ts.createJSDocTypeExpression(typeNode), "");
+ });
+ addJSDocTags(changes, sourceFile, signature, paramTags);
+ }
+ function addJSDocTags(changes, sourceFile, parent, newTags) {
+ var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; });
+ var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
+ var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) {
+ var merged = tryMergeJsdocTags(tag, newTag);
+ if (merged)
+ oldTags[i] = merged;
+ return !!merged;
+ }); });
+ var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags)));
+ var jsDocNode = parent.kind === 202 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent;
+ jsDocNode.jsDoc = parent.jsDoc;
+ jsDocNode.jsDocCache = parent.jsDocCache;
+ changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag);
+ }
+ codefix.addJSDocTags = addJSDocTags;
+ function getJsDocNodeForArrowFunction(signature) {
+ if (signature.parent.kind === 159 /* PropertyDeclaration */) {
+ return signature.parent;
+ }
+ return signature.parent.parent;
+ }
+ function tryMergeJsdocTags(oldTag, newTag) {
+ if (oldTag.kind !== newTag.kind) {
+ return undefined;
+ }
+ switch (oldTag.kind) {
+ case 317 /* JSDocParameterTag */: {
+ var oldParam = oldTag;
+ var newParam = newTag;
+ return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
+ ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment)
+ : undefined;
+ }
+ case 318 /* JSDocReturnTag */:
+ return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment);
+ }
+ }
+ function getReferences(token, program, cancellationToken) {
+ // Position shouldn't matter since token is not a SourceFile.
+ return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) {
+ return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined;
+ });
+ }
+ function inferTypeForVariableFromUsage(token, program, cancellationToken) {
+ var references = getReferences(token, program, cancellationToken);
+ return inferTypeFromReferences(program, references, cancellationToken).single();
+ }
+ function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) {
+ var references = getFunctionReferences(func, sourceFile, program, cancellationToken);
+ return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) ||
+ func.parameters.map(function (p) { return ({
+ declaration: p,
+ type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType()
+ }); });
+ }
+ function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) {
+ var searchToken;
+ switch (containingFunction.kind) {
+ case 162 /* Constructor */:
+ searchToken = ts.findChildOfKind(containingFunction, 129 /* ConstructorKeyword */, sourceFile);
+ break;
+ case 202 /* ArrowFunction */:
+ case 201 /* FunctionExpression */:
+ var parent = containingFunction.parent;
+ searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ?
+ parent.name :
+ containingFunction.name;
+ break;
+ case 244 /* FunctionDeclaration */:
+ case 161 /* MethodDeclaration */:
+ searchToken = containingFunction.name;
+ break;
+ }
+ if (!searchToken) {
+ return undefined;
+ }
+ return getReferences(searchToken, program, cancellationToken);
+ }
+ function inferTypeFromReferences(program, references, cancellationToken) {
+ var checker = program.getTypeChecker();
+ var builtinConstructors = {
+ string: function () { return checker.getStringType(); },
+ number: function () { return checker.getNumberType(); },
+ Array: function (t) { return checker.createArrayType(t); },
+ Promise: function (t) { return checker.createPromiseType(t); },
+ };
+ var builtins = [
+ checker.getStringType(),
+ checker.getNumberType(),
+ checker.createArrayType(checker.getAnyType()),
+ checker.createPromiseType(checker.getAnyType()),
+ ];
+ return {
+ single: single,
+ parameters: parameters,
+ thisParameter: thisParameter,
+ };
+ function createEmptyUsage() {
+ return {
+ isNumber: undefined,
+ isString: undefined,
+ isNumberOrString: undefined,
+ candidateTypes: undefined,
+ properties: undefined,
+ calls: undefined,
+ constructs: undefined,
+ numberIndex: undefined,
+ stringIndex: undefined,
+ candidateThisTypes: undefined,
+ inferredTypes: undefined,
+ };
+ }
+ function combineUsages(usages) {
+ var combinedProperties = ts.createUnderscoreEscapedMap();
+ for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) {
+ var u = usages_1[_i];
+ if (u.properties) {
+ u.properties.forEach(function (p, name) {
+ if (!combinedProperties.has(name)) {
+ combinedProperties.set(name, []);
+ }
+ combinedProperties.get(name).push(p);
+ });
+ }
+ }
+ var properties = ts.createUnderscoreEscapedMap();
+ combinedProperties.forEach(function (ps, name) {
+ properties.set(name, combineUsages(ps));
+ });
+ return {
+ isNumber: usages.some(function (u) { return u.isNumber; }),
+ isString: usages.some(function (u) { return u.isString; }),
+ isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }),
+ candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }),
+ properties: properties,
+ calls: ts.flatMap(usages, function (u) { return u.calls; }),
+ constructs: ts.flatMap(usages, function (u) { return u.constructs; }),
+ numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }),
+ stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }),
+ candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }),
+ inferredTypes: undefined,
+ };
+ }
+ function single() {
+ return combineTypes(inferTypesFromReferencesSingle(references));
+ }
+ function parameters(declaration) {
+ if (references.length === 0 || !declaration.parameters) {
+ return undefined;
+ }
+ var usage = createEmptyUsage();
+ for (var _i = 0, references_2 = references; _i < references_2.length; _i++) {
+ var reference = references_2[_i];
+ cancellationToken.throwIfCancellationRequested();
+ calculateUsageOfNode(reference, usage);
+ }
+ var calls = __spreadArrays(usage.constructs || [], usage.calls || []);
+ return declaration.parameters.map(function (parameter, parameterIndex) {
+ var types = [];
+ var isRest = ts.isRestParameter(parameter);
+ var isOptional = false;
+ for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) {
+ var call = calls_1[_i];
+ if (call.argumentTypes.length <= parameterIndex) {
+ isOptional = ts.isInJSFile(declaration);
+ types.push(checker.getUndefinedType());
+ }
+ else if (isRest) {
+ for (var i = parameterIndex; i < call.argumentTypes.length; i++) {
+ types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i]));
+ }
+ }
+ else {
+ types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex]));
+ }
+ }
+ if (ts.isIdentifier(parameter.name)) {
+ var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken));
+ types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred));
+ }
+ var type = combineTypes(types);
+ return {
+ type: isRest ? checker.createArrayType(type) : type,
+ isOptional: isOptional && !isRest,
+ declaration: parameter
+ };
+ });
+ }
+ function thisParameter() {
+ var usage = createEmptyUsage();
+ for (var _i = 0, references_3 = references; _i < references_3.length; _i++) {
+ var reference = references_3[_i];
+ cancellationToken.throwIfCancellationRequested();
+ calculateUsageOfNode(reference, usage);
+ }
+ return combineTypes(usage.candidateThisTypes || ts.emptyArray);
+ }
+ function inferTypesFromReferencesSingle(references) {
+ var usage = createEmptyUsage();
+ for (var _i = 0, references_4 = references; _i < references_4.length; _i++) {
+ var reference = references_4[_i];
+ cancellationToken.throwIfCancellationRequested();
+ calculateUsageOfNode(reference, usage);
+ }
+ return inferTypes(usage);
+ }
+ function calculateUsageOfNode(node, usage) {
+ while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) {
+ node = node.parent;
+ }
+ switch (node.parent.kind) {
+ case 226 /* ExpressionStatement */:
+ inferTypeFromExpressionStatement(node, usage);
+ break;
+ case 208 /* PostfixUnaryExpression */:
+ usage.isNumber = true;
+ break;
+ case 207 /* PrefixUnaryExpression */:
+ inferTypeFromPrefixUnaryExpression(node.parent, usage);
+ break;
+ case 209 /* BinaryExpression */:
+ inferTypeFromBinaryExpression(node, node.parent, usage);
+ break;
+ case 277 /* CaseClause */:
+ case 278 /* DefaultClause */:
+ inferTypeFromSwitchStatementLabel(node.parent, usage);
+ break;
+ case 196 /* CallExpression */:
+ case 197 /* NewExpression */:
+ if (node.parent.expression === node) {
+ inferTypeFromCallExpression(node.parent, usage);
+ }
+ else {
+ inferTypeFromContextualType(node, usage);
+ }
+ break;
+ case 194 /* PropertyAccessExpression */:
+ inferTypeFromPropertyAccessExpression(node.parent, usage);
+ break;
+ case 195 /* ElementAccessExpression */:
+ inferTypeFromPropertyElementExpression(node.parent, node, usage);
+ break;
+ case 281 /* PropertyAssignment */:
+ case 282 /* ShorthandPropertyAssignment */:
+ inferTypeFromPropertyAssignment(node.parent, usage);
+ break;
+ case 159 /* PropertyDeclaration */:
+ inferTypeFromPropertyDeclaration(node.parent, usage);
+ break;
+ case 242 /* VariableDeclaration */: {
+ var _a = node.parent, name = _a.name, initializer = _a.initializer;
+ if (node === name) {
+ if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error.
+ addCandidateType(usage, checker.getTypeAtLocation(initializer));
+ }
+ break;
+ }
+ }
+ // falls through
+ default:
+ return inferTypeFromContextualType(node, usage);
+ }
+ }
+ function inferTypeFromContextualType(node, usage) {
+ if (ts.isExpressionNode(node)) {
+ addCandidateType(usage, checker.getContextualType(node));
+ }
+ }
+ function inferTypeFromExpressionStatement(node, usage) {
+ addCandidateType(usage, ts.isCallExpression(node) ? checker.getVoidType() : checker.getAnyType());
+ }
+ function inferTypeFromPrefixUnaryExpression(node, usage) {
+ switch (node.operator) {
+ case 45 /* PlusPlusToken */:
+ case 46 /* MinusMinusToken */:
+ case 40 /* MinusToken */:
+ case 54 /* TildeToken */:
+ usage.isNumber = true;
+ break;
+ case 39 /* PlusToken */:
+ usage.isNumberOrString = true;
+ break;
+ // case SyntaxKind.ExclamationToken:
+ // no inferences here;
+ }
+ }
+ function inferTypeFromBinaryExpression(node, parent, usage) {
+ switch (parent.operatorToken.kind) {
+ // ExponentiationOperator
+ case 42 /* AsteriskAsteriskToken */:
+ // MultiplicativeOperator
+ // falls through
+ case 41 /* AsteriskToken */:
+ case 43 /* SlashToken */:
+ case 44 /* PercentToken */:
+ // ShiftOperator
+ // falls through
+ case 47 /* LessThanLessThanToken */:
+ case 48 /* GreaterThanGreaterThanToken */:
+ case 49 /* GreaterThanGreaterThanGreaterThanToken */:
+ // BitwiseOperator
+ // falls through
+ case 50 /* AmpersandToken */:
+ case 51 /* BarToken */:
+ case 52 /* CaretToken */:
+ // CompoundAssignmentOperator
+ // falls through
+ case 64 /* MinusEqualsToken */:
+ case 66 /* AsteriskAsteriskEqualsToken */:
+ case 65 /* AsteriskEqualsToken */:
+ case 67 /* SlashEqualsToken */:
+ case 68 /* PercentEqualsToken */:
+ case 72 /* AmpersandEqualsToken */:
+ case 73 /* BarEqualsToken */:
+ case 74 /* CaretEqualsToken */:
+ case 69 /* LessThanLessThanEqualsToken */:
+ case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 70 /* GreaterThanGreaterThanEqualsToken */:
+ // AdditiveOperator
+ // falls through
+ case 40 /* MinusToken */:
+ // RelationalOperator
+ // falls through
+ case 29 /* LessThanToken */:
+ case 32 /* LessThanEqualsToken */:
+ case 31 /* GreaterThanToken */:
+ case 33 /* GreaterThanEqualsToken */:
+ var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left);
+ if (operandType.flags & 1056 /* EnumLike */) {
+ addCandidateType(usage, operandType);
+ }
+ else {
+ usage.isNumber = true;
+ }
+ break;
+ case 63 /* PlusEqualsToken */:
+ case 39 /* PlusToken */:
+ var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left);
+ if (otherOperandType.flags & 1056 /* EnumLike */) {
+ addCandidateType(usage, otherOperandType);
+ }
+ else if (otherOperandType.flags & 296 /* NumberLike */) {
+ usage.isNumber = true;
+ }
+ else if (otherOperandType.flags & 132 /* StringLike */) {
+ usage.isString = true;
+ }
+ else if (otherOperandType.flags & 1 /* Any */) {
+ // do nothing, maybe we'll learn something elsewhere
+ }
+ else {
+ usage.isNumberOrString = true;
+ }
+ break;
+ // AssignmentOperators
+ case 62 /* EqualsToken */:
+ case 34 /* EqualsEqualsToken */:
+ case 36 /* EqualsEqualsEqualsToken */:
+ case 37 /* ExclamationEqualsEqualsToken */:
+ case 35 /* ExclamationEqualsToken */:
+ addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left));
+ break;
+ case 97 /* InKeyword */:
+ if (node === parent.left) {
+ usage.isString = true;
+ }
+ break;
+ // LogicalOperator Or NullishCoalescing
+ case 56 /* BarBarToken */:
+ case 60 /* QuestionQuestionToken */:
+ if (node === parent.left &&
+ (node.parent.parent.kind === 242 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) {
+ // var x = x || {};
+ // TODO: use getFalsyflagsOfType
+ addCandidateType(usage, checker.getTypeAtLocation(parent.right));
+ }
+ break;
+ case 55 /* AmpersandAmpersandToken */:
+ case 27 /* CommaToken */:
+ case 98 /* InstanceOfKeyword */:
+ // nothing to infer here
+ break;
+ }
+ }
+ function inferTypeFromSwitchStatementLabel(parent, usage) {
+ addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression));
+ }
+ function inferTypeFromCallExpression(parent, usage) {
+ var call = {
+ argumentTypes: [],
+ return_: createEmptyUsage()
+ };
+ if (parent.arguments) {
+ for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) {
+ var argument = _a[_i];
+ call.argumentTypes.push(checker.getTypeAtLocation(argument));
+ }
+ }
+ calculateUsageOfNode(parent, call.return_);
+ if (parent.kind === 196 /* CallExpression */) {
+ (usage.calls || (usage.calls = [])).push(call);
+ }
+ else {
+ (usage.constructs || (usage.constructs = [])).push(call);
+ }
+ }
+ function inferTypeFromPropertyAccessExpression(parent, usage) {
+ var name = ts.escapeLeadingUnderscores(parent.name.text);
+ if (!usage.properties) {
+ usage.properties = ts.createUnderscoreEscapedMap();
+ }
+ var propertyUsage = usage.properties.get(name) || createEmptyUsage();
+ calculateUsageOfNode(parent, propertyUsage);
+ usage.properties.set(name, propertyUsage);
+ }
+ function inferTypeFromPropertyElementExpression(parent, node, usage) {
+ if (node === parent.argumentExpression) {
+ usage.isNumberOrString = true;
+ return;
+ }
+ else {
+ var indexType = checker.getTypeAtLocation(parent.argumentExpression);
+ var indexUsage = createEmptyUsage();
+ calculateUsageOfNode(parent, indexUsage);
+ if (indexType.flags & 296 /* NumberLike */) {
+ usage.numberIndex = indexUsage;
+ }
+ else {
+ usage.stringIndex = indexUsage;
+ }
+ }
+ }
+ function inferTypeFromPropertyAssignment(assignment, usage) {
+ var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ?
+ assignment.parent.parent :
+ assignment.parent;
+ addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType));
+ }
+ function inferTypeFromPropertyDeclaration(declaration, usage) {
+ addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent));
+ }
+ function removeLowPriorityInferences(inferences, priorities) {
+ var toRemove = [];
+ for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
+ var i = inferences_1[_i];
+ for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) {
+ var _b = priorities_1[_a], high = _b.high, low = _b.low;
+ if (high(i)) {
+ ts.Debug.assert(!low(i), "Priority can't have both low and high");
+ toRemove.push(low);
+ }
+ }
+ }
+ return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); });
+ }
+ function combineFromUsage(usage) {
+ return combineTypes(inferTypes(usage));
+ }
+ function combineTypes(inferences) {
+ if (!inferences.length)
+ return checker.getAnyType();
+ // 1. string or number individually override string | number
+ // 2. non-any, non-void overrides any or void
+ // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types
+ var stringNumber = checker.getUnionType([checker.getStringType(), checker.getNumberType()]);
+ var priorities = [
+ {
+ high: function (t) { return t === checker.getStringType() || t === checker.getNumberType(); },
+ low: function (t) { return t === stringNumber; }
+ },
+ {
+ high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); },
+ low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); }
+ },
+ {
+ high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); },
+ low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); }
+ }
+ ];
+ var good = removeLowPriorityInferences(inferences, priorities);
+ var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; });
+ if (anons.length) {
+ good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); });
+ good.push(combineAnonymousTypes(anons));
+ }
+ return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */));
+ }
+ function combineAnonymousTypes(anons) {
+ if (anons.length === 1) {
+ return anons[0];
+ }
+ var calls = [];
+ var constructs = [];
+ var stringIndices = [];
+ var numberIndices = [];
+ var stringIndexReadonly = false;
+ var numberIndexReadonly = false;
+ var props = ts.createMultiMap();
+ for (var _i = 0, anons_1 = anons; _i < anons_1.length; _i++) {
+ var anon = anons_1[_i];
+ for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) {
+ var p = _b[_a];
+ props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration));
+ }
+ calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */));
+ constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */));
+ if (anon.stringIndexInfo) {
+ stringIndices.push(anon.stringIndexInfo.type);
+ stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly;
+ }
+ if (anon.numberIndexInfo) {
+ numberIndices.push(anon.numberIndexInfo.type);
+ numberIndexReadonly = numberIndexReadonly || anon.numberIndexInfo.isReadonly;
+ }
+ }
+ var members = ts.mapEntries(props, function (name, types) {
+ var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0;
+ var s = checker.createSymbol(4 /* Property */ | isOptional, name);
+ s.type = checker.getUnionType(types);
+ return [name, s];
+ });
+ return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined);
+ }
+ function inferTypes(usage) {
+ var _a, _b, _c;
+ var types = [];
+ if (usage.isNumber) {
+ types.push(checker.getNumberType());
+ }
+ if (usage.isString) {
+ types.push(checker.getStringType());
+ }
+ if (usage.isNumberOrString) {
+ types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()]));
+ }
+ if (usage.numberIndex) {
+ types.push(checker.createArrayType(combineFromUsage(usage.numberIndex)));
+ }
+ if (((_a = usage.properties) === null || _a === void 0 ? void 0 : _a.size) || ((_b = usage.calls) === null || _b === void 0 ? void 0 : _b.length) || ((_c = usage.constructs) === null || _c === void 0 ? void 0 : _c.length) || usage.stringIndex) {
+ types.push(inferStructuralType(usage));
+ }
+ types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }));
+ types.push.apply(types, inferNamedTypesFromProperties(usage));
+ return types;
+ }
+ function inferStructuralType(usage) {
+ var members = ts.createUnderscoreEscapedMap();
+ if (usage.properties) {
+ usage.properties.forEach(function (u, name) {
+ var symbol = checker.createSymbol(4 /* Property */, name);
+ symbol.type = combineFromUsage(u);
+ members.set(name, symbol);
+ });
+ }
+ var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : [];
+ var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : [];
+ var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false);
+ return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined);
+ }
+ function inferNamedTypesFromProperties(usage) {
+ if (!usage.properties || !usage.properties.size)
+ return [];
+ var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); });
+ if (0 < types.length && types.length < 3) {
+ return types.map(function (t) { return inferInstantiationFromUsage(t, usage); });
+ }
+ return [];
+ }
+ function allPropertiesAreAssignableToUsage(type, usage) {
+ if (!usage.properties)
+ return false;
+ return !ts.forEachEntry(usage.properties, function (propUsage, name) {
+ var source = checker.getTypeOfPropertyOfType(type, name);
+ if (!source) {
+ return true;
+ }
+ if (propUsage.calls) {
+ var sigs = checker.getSignaturesOfType(source, 0 /* Call */);
+ return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls));
+ }
+ else {
+ return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage));
+ }
+ });
+ }
+ /**
+ * inference is limited to
+ * 1. generic types with a single parameter
+ * 2. inference to/from calls with a single signature
+ */
+ function inferInstantiationFromUsage(type, usage) {
+ if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) {
+ return type;
+ }
+ var generic = type.target;
+ var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters);
+ if (!singleTypeParameter)
+ return type;
+ var types = [];
+ usage.properties.forEach(function (propUsage, name) {
+ var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name);
+ ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference.");
+ types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter));
+ });
+ return builtinConstructors[type.symbol.escapedName](combineTypes(types));
+ }
+ function inferTypeParameters(genericType, usageType, typeParameter) {
+ if (genericType === typeParameter) {
+ return [usageType];
+ }
+ else if (genericType.flags & 3145728 /* UnionOrIntersection */) {
+ return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); });
+ }
+ else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) {
+ // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference
+ var genericArgs = checker.getTypeArguments(genericType);
+ var usageArgs = checker.getTypeArguments(usageType);
+ var types = [];
+ if (genericArgs && usageArgs) {
+ for (var i = 0; i < genericArgs.length; i++) {
+ if (usageArgs[i]) {
+ types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter));
+ }
+ }
+ }
+ return types;
+ }
+ var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */);
+ var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */);
+ if (genericSigs.length === 1 && usageSigs.length === 1) {
+ return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter);
+ }
+ return [];
+ }
+ function inferFromSignatures(genericSig, usageSig, typeParameter) {
+ var types = [];
+ for (var i = 0; i < genericSig.parameters.length; i++) {
+ var genericParam = genericSig.parameters[i];
+ var usageParam = usageSig.parameters[i];
+ var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]);
+ if (!usageParam) {
+ break;
+ }
+ var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration);
+ var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType);
+ if (elementType) {
+ genericParamType = elementType;
+ }
+ var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration);
+ types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter));
+ }
+ var genericReturn = checker.getReturnTypeOfSignature(genericSig);
+ var usageReturn = checker.getReturnTypeOfSignature(usageSig);
+ types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter));
+ return types;
+ }
+ function getFunctionFromCalls(calls) {
+ return checker.createAnonymousType(/*symbol*/ undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined);
+ }
+ function getSignatureFromCalls(calls) {
+ var parameters = [];
+ var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
+ var _loop_14 = function (i) {
+ var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
+ symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
+ if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
+ symbol.flags |= 16777216 /* Optional */;
+ }
+ parameters.push(symbol);
+ };
+ for (var i = 0; i < length; i++) {
+ _loop_14(i);
+ }
+ var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
+ // TODO: GH#18217
+ return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
+ }
+ function addCandidateType(usage, type) {
+ if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) {
+ (usage.candidateTypes || (usage.candidateTypes = [])).push(type);
+ }
+ }
+ function addCandidateThisType(usage, type) {
+ if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) {
+ (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type);
+ }
+ }
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var codefix;
(function (codefix) {
@@ -229338,12 +236348,13 @@ var ts;
if (!ts.isInJSFile(sourceFile) || !ts.isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
return undefined;
}
+ var newLineCharacter = sourceFile.checkJsDirective ? "" : ts.getNewLineOrDefaultFromHost(host, formatContext.options);
var fixes = [
// fixId unnecessary because adding `// @ts-nocheck` even once will ignore every error in the file.
codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [
ts.createTextChange(sourceFile.checkJsDirective
? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end)
- : ts.createTextSpan(0, 0), "// @ts-nocheck" + ts.getNewLineOrDefaultFromHost(host, formatContext.options)),
+ : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter),
])], ts.Diagnostics.Disable_checking_for_this_file),
];
if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) {
@@ -229379,45 +236390,36 @@ var ts;
* Finds members of the resolved type that are missing in the class pointed to by class decl
* and generates source code for the missing members.
* @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for.
+ * @param importAdder If provided, type annotations will use identifier type references instead of ImportTypeNodes, and the missing imports will be added to the importAdder.
* @returns Empty string iff there are no member insertions.
*/
- function createMissingMemberNodes(classDeclaration, possiblyMissingSymbols, context, preferences, out) {
+ function createMissingMemberNodes(classDeclaration, possiblyMissingSymbols, context, preferences, importAdder, addClassElement) {
var classMembers = classDeclaration.symbol.members;
for (var _i = 0, possiblyMissingSymbols_1 = possiblyMissingSymbols; _i < possiblyMissingSymbols_1.length; _i++) {
var symbol = possiblyMissingSymbols_1[_i];
if (!classMembers.has(symbol.escapedName)) {
- addNewNodeForMemberSymbol(symbol, classDeclaration, context, preferences, out);
+ addNewNodeForMemberSymbol(symbol, classDeclaration, context, preferences, importAdder, addClassElement);
}
}
}
codefix.createMissingMemberNodes = createMissingMemberNodes;
- function getModuleSpecifierResolverHost(context) {
- return {
- directoryExists: context.host.directoryExists ? function (d) { return context.host.directoryExists(d); } : undefined,
- fileExists: context.host.fileExists ? function (f) { return context.host.fileExists(f); } : undefined,
- getCurrentDirectory: context.host.getCurrentDirectory ? function () { return context.host.getCurrentDirectory(); } : undefined,
- readFile: context.host.readFile ? function (f) { return context.host.readFile(f); } : undefined,
- useCaseSensitiveFileNames: context.host.useCaseSensitiveFileNames ? function () { return context.host.useCaseSensitiveFileNames(); } : undefined,
- getSourceFiles: function () { return context.program.getSourceFiles(); },
- getCommonSourceDirectory: function () { return context.program.getCommonSourceDirectory(); },
- };
- }
function getNoopSymbolTrackerWithResolver(context) {
return {
trackSymbol: ts.noop,
- moduleResolverHost: getModuleSpecifierResolverHost(context),
+ moduleResolverHost: ts.getModuleSpecifierResolverHost(context.program, context.host),
};
}
codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver;
/**
* @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`.
*/
- function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, context, preferences, out) {
+ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, context, preferences, importAdder, addClassElement) {
var declarations = symbol.getDeclarations();
if (!(declarations && declarations.length)) {
return undefined;
}
var checker = context.program.getTypeChecker();
+ var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions());
var declaration = declarations[0];
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
var visibilityModifier = createVisibilityModifier(ts.getModifierFlags(declaration));
@@ -229430,28 +236432,42 @@ var ts;
case 159 /* PropertyDeclaration */:
var flags = preferences.quotePreference === "single" ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
- out(ts.createProperty(
+ if (importAdder) {
+ var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget);
+ if (importableReference) {
+ typeNode = importableReference.typeReference;
+ importSymbols(importAdder, importableReference.symbols);
+ }
+ }
+ addClassElement(ts.createProperty(
/*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode,
/*initializer*/ undefined));
break;
case 163 /* GetAccessor */:
case 164 /* SetAccessor */: {
- var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration);
var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
+ var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration);
var orderedAccessors = allAccessors.secondAccessor
? [allAccessors.firstAccessor, allAccessors.secondAccessor]
: [allAccessors.firstAccessor];
+ if (importAdder) {
+ var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode_1, type, scriptTarget);
+ if (importableReference) {
+ typeNode_1 = importableReference.typeReference;
+ importSymbols(importAdder, importableReference.symbols);
+ }
+ }
for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) {
var accessor = orderedAccessors_1[_i];
if (ts.isGetAccessorDeclaration(accessor)) {
- out(ts.createGetAccessor(
+ addClassElement(ts.createGetAccessor(
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences)));
}
else {
ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
var parameter = ts.getSetAccessorValueParameter(accessor);
var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined;
- out(ts.createSetAccessor(
+ addClassElement(ts.createSetAccessor(
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences)));
}
}
@@ -229488,23 +236504,61 @@ var ts;
}
else {
ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
- out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences));
+ addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences));
}
}
break;
}
function outputMethod(signature, modifiers, name, body) {
- var method = signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body);
+ var method = signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder);
if (method)
- out(method);
+ addClassElement(method);
}
}
- function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) {
+ function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder) {
var program = context.program;
- var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 161 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context));
+ var checker = program.getTypeChecker();
+ var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
+ var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 161 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context));
if (!signatureDeclaration) {
return undefined;
}
+ if (importAdder) {
+ if (signatureDeclaration.typeParameters) {
+ ts.forEach(signatureDeclaration.typeParameters, function (typeParameterDecl, i) {
+ var typeParameter = signature.typeParameters[i];
+ if (typeParameterDecl.constraint) {
+ var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeParameterDecl.constraint, typeParameter.constraint, scriptTarget);
+ if (importableReference) {
+ typeParameterDecl.constraint = importableReference.typeReference;
+ importSymbols(importAdder, importableReference.symbols);
+ }
+ }
+ if (typeParameterDecl.default) {
+ var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeParameterDecl.default, typeParameter.default, scriptTarget);
+ if (importableReference) {
+ typeParameterDecl.default = importableReference.typeReference;
+ importSymbols(importAdder, importableReference.symbols);
+ }
+ }
+ });
+ }
+ ts.forEach(signatureDeclaration.parameters, function (parameterDecl, i) {
+ var parameter = signature.parameters[i];
+ var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(parameterDecl.type, checker.getTypeAtLocation(parameter.valueDeclaration), scriptTarget);
+ if (importableReference) {
+ parameterDecl.type = importableReference.typeReference;
+ importSymbols(importAdder, importableReference.symbols);
+ }
+ });
+ if (signatureDeclaration.type) {
+ var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(signatureDeclaration.type, signature.resolvedReturnType, scriptTarget);
+ if (importableReference) {
+ signatureDeclaration.type = importableReference.typeReference;
+ importSymbols(importAdder, importableReference.symbols);
+ }
+ }
+ }
signatureDeclaration.decorators = undefined;
signatureDeclaration.modifiers = modifiers;
signatureDeclaration.name = name;
@@ -229512,14 +236566,14 @@ var ts;
signatureDeclaration.body = body;
return signatureDeclaration;
}
- function createMethodFromCallExpression(context, call, methodName, inJs, makeStatic, preferences, contextNode) {
+ function createMethodFromCallExpression(context, call, methodName, inJs, makeStatic, contextNode, importAdder) {
var body = !ts.isInterfaceDeclaration(contextNode);
var typeArguments = call.typeArguments, args = call.arguments, parent = call.parent;
+ var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions());
var checker = context.program.getTypeChecker();
var tracker = getNoopSymbolTrackerWithResolver(context);
var types = ts.map(args, function (arg) {
- // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
- return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker);
+ return typeToAutoImportableTypeNode(checker, importAdder, checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, scriptTarget, /*flags*/ undefined, tracker);
});
var names = ts.map(args, function (arg) {
return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined;
@@ -229535,9 +236589,21 @@ var ts;
return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i);
}),
/*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs),
- /*type*/ returnType, body ? createStubbedMethodBody(preferences) : undefined);
+ /*type*/ returnType, body ? createStubbedMethodBody(context.preferences) : undefined);
}
codefix.createMethodFromCallExpression = createMethodFromCallExpression;
+ function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
+ var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
+ if (typeNode && ts.isImportTypeNode(typeNode)) {
+ var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget);
+ if (importableReference) {
+ importSymbols(importAdder, importableReference.symbols);
+ return importableReference.typeReference;
+ }
+ }
+ return typeNode;
+ }
+ codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode;
function createDummyParameters(argCount, names, types, minArgumentCount, inJs) {
var parameters = [];
for (var i = 0; i < argCount; i++) {
@@ -229648,12 +236714,56 @@ var ts;
return ts.find(obj.properties, function (p) { return ts.isPropertyAssignment(p) && !!p.name && ts.isStringLiteral(p.name) && p.name.text === name; });
}
codefix.findJsonProperty = findJsonProperty;
- })(codefix = ts.codefix || (ts.codefix = {}));
-})(ts || (ts = {}));
-/* @internal */
-var ts;
-(function (ts) {
- var codefix;
+ /**
+ * Given an ImportTypeNode 'import("./a").SomeType>',
+ * returns an equivalent type reference node with any nested ImportTypeNodes also replaced
+ * with type references, and a list of symbols that must be imported to use the type reference.
+ */
+ function tryGetAutoImportableReferenceFromImportTypeNode(importTypeNode, type, scriptTarget) {
+ if (importTypeNode && ts.isLiteralImportTypeNode(importTypeNode) && importTypeNode.qualifier && (!type || type.symbol)) {
+ // Symbol for the left-most thing after the dot
+ var firstIdentifier = ts.getFirstIdentifier(importTypeNode.qualifier);
+ var name = ts.getNameForExportedSymbol(firstIdentifier.symbol, scriptTarget);
+ var qualifier = name !== firstIdentifier.text
+ ? replaceFirstIdentifierOfEntityName(importTypeNode.qualifier, ts.createIdentifier(name))
+ : importTypeNode.qualifier;
+ var symbols_4 = [firstIdentifier.symbol];
+ var typeArguments_1 = [];
+ if (importTypeNode.typeArguments) {
+ importTypeNode.typeArguments.forEach(function (arg) {
+ var ref = tryGetAutoImportableReferenceFromImportTypeNode(arg, /*undefined*/ type, scriptTarget);
+ if (ref) {
+ symbols_4.push.apply(symbols_4, ref.symbols);
+ typeArguments_1.push(ref.typeReference);
+ }
+ else {
+ typeArguments_1.push(arg);
+ }
+ });
+ }
+ return {
+ symbols: symbols_4,
+ typeReference: ts.createTypeReferenceNode(qualifier, typeArguments_1)
+ };
+ }
+ }
+ codefix.tryGetAutoImportableReferenceFromImportTypeNode = tryGetAutoImportableReferenceFromImportTypeNode;
+ function replaceFirstIdentifierOfEntityName(name, newIdentifier) {
+ if (name.kind === 75 /* Identifier */) {
+ return newIdentifier;
+ }
+ return ts.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right);
+ }
+ function importSymbols(importAdder, symbols) {
+ symbols.forEach(function (s) { return importAdder.addImportFromExportedSymbol(s, /*usageIsTypeOnly*/ true); });
+ }
+ codefix.importSymbols = importSymbols;
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
+(function (ts) {
+ var codefix;
(function (codefix) {
var fixName = "invalidImportSyntax";
function getCodeFixesForImportDeclaration(context, node) {
@@ -230111,7 +237221,7 @@ var ts;
if (!importDeclaration) {
return;
}
- var importClause = ts.Debug.assertDefined(importDeclaration.importClause);
+ var importClause = ts.Debug.checkDefined(importDeclaration.importClause);
changes.replaceNode(context.sourceFile, importDeclaration, ts.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.updateImportClause(importClause, importClause.name, /*namedBindings*/ undefined, importClause.isTypeOnly), importDeclaration.moduleSpecifier));
changes.insertNodeAfter(context.sourceFile, importDeclaration, ts.createImportDeclaration(
/*decorators*/ undefined,
@@ -230155,6 +237265,46 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixId = "fixExpectedComma";
+ var expectedErrorCode = ts.Diagnostics._0_expected.code;
+ var errorCodes = [expectedErrorCode];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile;
+ var info = getInfo(sourceFile, context.span.start, context.errorCode);
+ if (!info) {
+ return undefined;
+ }
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); });
+ return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Change_0_to_1, ";", ","], fixId, [ts.Diagnostics.Change_0_to_1, ";", ","])];
+ },
+ fixIds: [fixId],
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ var info = getInfo(diag.file, diag.start, diag.code);
+ if (info)
+ doChange(changes, context.sourceFile, info);
+ }); },
+ });
+ function getInfo(sourceFile, pos, _) {
+ var node = ts.getTokenAtPosition(sourceFile, pos);
+ return (node.kind === 26 /* SemicolonToken */ &&
+ node.parent &&
+ (ts.isObjectLiteralExpression(node.parent) ||
+ ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined;
+ }
+ function doChange(changes, sourceFile, _a) {
+ var node = _a.node;
+ var newNode = ts.createNode(27 /* CommaToken */);
+ changes.replaceNode(sourceFile, node, newNode);
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var refactor;
(function (refactor) {
@@ -230172,7 +237322,7 @@ var ts;
},
getEditsForAction: function (context, actionName) {
ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name");
- var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); });
+ var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.checkDefined(getInfo(context), "context must have info"), t, context.cancellationToken); });
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
},
});
@@ -230224,10 +237374,10 @@ var ts;
function changeExport(exportingSourceFile, _a, changes, checker) {
var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName;
if (wasDefault) {
- changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* DefaultKeyword */), "Should find a default keyword in modifier list"));
+ changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 84 /* DefaultKeyword */), "Should find a default keyword in modifier list"));
}
else {
- var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 89 /* ExportKeyword */), "Should find an export keyword in modifier list");
+ var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 89 /* ExportKeyword */), "Should find an export keyword in modifier list");
switch (exportNode.kind) {
case 244 /* FunctionDeclaration */:
case 245 /* ClassDeclaration */:
@@ -230238,7 +237388,7 @@ var ts;
// If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;`
if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) {
// We checked in `getInfo` that an initializer exists.
- changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present")));
+ changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.checkDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present")));
break;
}
// falls through
@@ -230257,7 +237407,7 @@ var ts;
function changeImports(program, _a, changes, cancellationToken) {
var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol;
var checker = program.getTypeChecker();
- var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol");
+ var exportSymbol = ts.Debug.checkDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol");
ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) {
var importingSourceFile = ref.getSourceFile();
if (wasDefault) {
@@ -230368,7 +237518,7 @@ var ts;
},
getEditsForAction: function (context, actionName) {
ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name");
- var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); });
+ var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.checkDefined(getImportToConvert(context), "Context must provide an import to convert")); });
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
}
});
@@ -231055,7 +238205,7 @@ var ts;
case 244 /* FunctionDeclaration */:
return scope.name
? "function '" + scope.name.text + "'"
- : "anonymous function";
+ : ts.ANONYMOUS;
case 202 /* ArrowFunction */:
return "arrow function";
case 161 /* MethodDeclaration */:
@@ -231090,6 +238240,8 @@ var ts;
function extractFunctionInScope(node, scope, _a, exposedVariableDeclarations, range, context) {
var usagesInScope = _a.usages, typeParameterUsages = _a.typeParameterUsages, substitutions = _a.substitutions;
var checker = context.program.getTypeChecker();
+ var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions());
+ var importAdder = ts.codefix.createImportAdder(context.file, context.program, context.preferences, context.host);
// Make a unique name for the extracted function
var file = scope.getSourceFile();
var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file);
@@ -231105,7 +238257,7 @@ var ts;
var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node);
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
type = checker.getBaseTypeOfLiteralType(type);
- typeNode = checker.typeToTypeNode(type, scope, 1 /* NoTruncation */);
+ typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */);
}
var paramDecl = ts.createParameter(
/*decorators*/ undefined,
@@ -231164,6 +238316,7 @@ var ts;
else {
changeTracker.insertNodeAtEndOfScope(context.file, scope, newFunction);
}
+ importAdder.writeFixes(changeTracker);
var newNodes = [];
// replace range with function call
var called = getCalledExpression(scope, range, functionNameText);
@@ -231626,7 +238779,7 @@ var ts;
return curr.parent.parent;
}
// There must be at least one statement since we started in one.
- return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set");
+ return ts.Debug.checkDefined(prevStatement, "prevStatement failed to get set");
}
ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope");
}
@@ -232071,7 +239224,7 @@ var ts;
},
getEditsForAction: function (context, actionName) {
var file = context.file;
- var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract");
+ var info = ts.Debug.checkDefined(getRangeToExtract(context), "Expected to find a range to extract");
var name = ts.getUniqueName("NewType", file);
var edits = ts.textChanges.ChangeTracker.with(context, function (changes) {
switch (actionName) {
@@ -232102,7 +239255,7 @@ var ts;
if (!selection || !ts.isTypeNode(selection))
return undefined;
var checker = context.program.getTypeChecker();
- var firstStatement = ts.Debug.assertDefined(ts.findAncestor(selection, ts.isStatement), "Should find a statement");
+ var firstStatement = ts.Debug.checkDefined(ts.findAncestor(selection, ts.isStatement), "Should find a statement");
var typeParameters = collectTypeParameters(checker, selection, firstStatement, file);
if (!typeParameters)
return undefined;
@@ -232184,7 +239337,7 @@ var ts;
var newTypeNode = ts.createTypeAliasDeclaration(
/* decorators */ undefined,
/* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection);
- changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true);
+ changes.insertNodeBefore(file, firstStatement, ts.ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true);
changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); })));
}
function doInterfaceChange(changes, file, name, info) {
@@ -232193,12 +239346,12 @@ var ts;
/* decorators */ undefined,
/* modifiers */ undefined, name, typeParameters,
/* heritageClauses */ undefined, typeElements);
- changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true);
+ changes.insertNodeBefore(file, firstStatement, ts.ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true);
changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); })));
}
function doTypedefChange(changes, file, name, info) {
var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters;
- var node = ts.createNode(321 /* JSDocTypedefTag */);
+ var node = ts.createNode(322 /* JSDocTypedefTag */);
node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539
node.fullName = ts.createIdentifier(name);
node.name = node.fullName;
@@ -232206,7 +239359,7 @@ var ts;
var templates = [];
ts.forEach(typeParameters, function (typeParameter) {
var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter);
- var template = ts.createNode(320 /* JSDocTemplateTag */);
+ var template = ts.createNode(321 /* JSDocTemplateTag */);
template.tagName = ts.createIdentifier("template");
template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression);
var parameter = ts.createNode(155 /* TypeParameter */);
@@ -232252,6 +239405,7 @@ var ts;
var changeTracker = ts.textChanges.ChangeTracker.fromContext(context);
var isStatic = fieldInfo.isStatic, isReadonly = fieldInfo.isReadonly, fieldName = fieldInfo.fieldName, accessorName = fieldInfo.accessorName, originalName = fieldInfo.originalName, type = fieldInfo.type, container = fieldInfo.container, declaration = fieldInfo.declaration, renameAccessor = fieldInfo.renameAccessor;
ts.suppressLeadingAndTrailingTrivia(fieldName);
+ ts.suppressLeadingAndTrailingTrivia(accessorName);
ts.suppressLeadingAndTrailingTrivia(declaration);
ts.suppressLeadingAndTrailingTrivia(container);
var isInClassLike = ts.isClassLike(container);
@@ -232303,9 +239457,6 @@ var ts;
var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(120 /* StaticKeyword */) : undefined);
return modifiers && ts.createNodeArray(modifiers);
}
- function startsWithUnderscore(name) {
- return name.charCodeAt(0) === 95 /* _ */;
- }
function getConvertibleFieldAtPosition(context) {
var file = context.file, startPosition = context.startPosition, endPosition = context.endPosition;
var node = ts.getTokenAtPosition(file, startPosition);
@@ -232316,7 +239467,7 @@ var ts;
|| !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning)
return undefined;
var name = declaration.name.text;
- var startWithUnderscore = startsWithUnderscore(name);
+ var startWithUnderscore = ts.startsWithUnderscore(name);
var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name);
var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name);
return {
@@ -232410,7 +239561,7 @@ var ts;
},
getEditsForAction: function (context, actionName) {
ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked");
- var statements = ts.Debug.assertDefined(getStatementsToMove(context));
+ var statements = ts.Debug.checkDefined(getStatementsToMove(context));
var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); });
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
}
@@ -232500,7 +239651,7 @@ var ts;
var quotePreference = ts.getQuotePreference(oldFile, preferences);
var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, quotePreference);
if (importsFromNewFile) {
- ts.insertImport(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true);
+ ts.insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true);
}
deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
deleteMovedStatements(oldFile, toMove.ranges, changes);
@@ -232667,7 +239818,7 @@ var ts;
return ts.flatMap(toMove, function (statement) {
if (isTopLevelDeclarationStatement(statement) &&
!isExported(sourceFile, statement, useEs6Exports) &&
- forEachTopLevelDeclaration(statement, function (d) { return needExport.has(ts.Debug.assertDefined(d.symbol)); })) {
+ forEachTopLevelDeclaration(statement, function (d) { return needExport.has(ts.Debug.checkDefined(d.symbol)); })) {
var exports = addExport(statement, useEs6Exports);
if (exports)
return exports;
@@ -232804,7 +239955,7 @@ var ts;
for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) {
var statement = toMove_1[_i];
forEachTopLevelDeclaration(statement, function (decl) {
- movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here"));
+ movedSymbols.add(ts.Debug.checkDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here"));
});
}
for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) {
@@ -232860,6 +240011,7 @@ var ts;
case 253 /* ImportEqualsDeclaration */:
case 258 /* ImportSpecifier */:
case 255 /* ImportClause */:
+ case 256 /* NamespaceImport */:
return true;
case 242 /* VariableDeclaration */:
return isVariableDeclarationInImport(decl);
@@ -233149,19 +240301,20 @@ var ts;
}
else if (actionName === removeBracesActionName && returnStatement) {
var actualExpression = expression || ts.createVoidZero();
- body = needsParentheses(actualExpression) ? ts.createParen(actualExpression) : actualExpression;
+ body = ts.needsParentheses(actualExpression) ? ts.createParen(actualExpression) : actualExpression;
ts.suppressLeadingAndTrailingTrivia(body);
+ ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
+ ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
}
else {
ts.Debug.fail("invalid action");
}
- var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func.body, body); });
+ var edits = ts.textChanges.ChangeTracker.with(context, function (t) {
+ t.replaceNode(file, func.body, body);
+ });
return { renameFilename: undefined, renameLocation: undefined, edits: edits };
}
- function needsParentheses(expression) {
- return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression);
- }
function getConvertibleArrowFunctionAtPosition(file, startPosition) {
var node = ts.getTokenAtPosition(file, startPosition);
var func = ts.getContainingFunction(node);
@@ -233518,7 +240671,7 @@ var ts;
ts.suppressLeadingAndTrailingTrivia(property.name);
if (ts.isPropertyAssignment(property))
ts.suppressLeadingAndTrailingTrivia(property.initializer);
- copyComments(arg, property);
+ ts.copyComments(arg, property);
return property;
});
if (hasRestParameter && functionArguments.length >= parameters.length) {
@@ -233553,10 +240706,10 @@ var ts;
/*dotDotDotToken*/ undefined, thisParameter.name,
/*questionToken*/ undefined, thisParameter.type);
ts.suppressLeadingAndTrailingTrivia(newThisParameter.name);
- copyComments(thisParameter.name, newThisParameter.name);
+ ts.copyComments(thisParameter.name, newThisParameter.name);
if (thisParameter.type) {
ts.suppressLeadingAndTrailingTrivia(newThisParameter.type);
- copyComments(thisParameter.type, newThisParameter.type);
+ ts.copyComments(thisParameter.type, newThisParameter.type);
}
return ts.createNodeArray([newThisParameter, objectParameter]);
}
@@ -233567,7 +240720,7 @@ var ts;
/*propertyName*/ undefined, getParameterName(parameterDeclaration), ts.isRestParameter(parameterDeclaration) && isOptionalParameter(parameterDeclaration) ? ts.createArrayLiteral() : parameterDeclaration.initializer);
ts.suppressLeadingAndTrailingTrivia(element);
if (parameterDeclaration.initializer && element.initializer) {
- copyComments(parameterDeclaration.initializer, element.initializer);
+ ts.copyComments(parameterDeclaration.initializer, element.initializer);
}
return element;
}
@@ -233585,9 +240738,9 @@ var ts;
/*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType,
/*initializer*/ undefined);
ts.suppressLeadingAndTrailingTrivia(propertySignature);
- copyComments(parameterDeclaration.name, propertySignature.name);
+ ts.copyComments(parameterDeclaration.name, propertySignature.name);
if (parameterDeclaration.type && propertySignature.type) {
- copyComments(parameterDeclaration.type, propertySignature.type);
+ ts.copyComments(parameterDeclaration.type, propertySignature.type);
}
return propertySignature;
}
@@ -233603,26 +240756,6 @@ var ts;
return checker.isOptionalParameter(parameterDeclaration);
}
}
- function copyComments(sourceNode, targetNode) {
- var sourceFile = sourceNode.getSourceFile();
- var text = sourceFile.text;
- if (hasLeadingLineBreak(sourceNode, text)) {
- ts.copyLeadingComments(sourceNode, targetNode, sourceFile);
- }
- else {
- ts.copyTrailingAsLeadingComments(sourceNode, targetNode, sourceFile);
- }
- ts.copyTrailingComments(sourceNode, targetNode, sourceFile);
- }
- function hasLeadingLineBreak(node, text) {
- var start = node.getFullStart();
- var end = node.getStart();
- for (var i = start; i < end; i++) {
- if (text.charCodeAt(i) === 10 /* lineFeed */)
- return true;
- }
- return false;
- }
function getParameterName(paramDeclaration) {
return ts.getTextOfIdentifierOrLiteral(paramDeclaration.name);
}
@@ -233634,7 +240767,7 @@ var ts;
return [classDeclaration.name];
// If the class declaration doesn't have a name, it should have a default modifier.
// We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault`
- var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 84 /* DefaultKeyword */), "Nameless class declaration should be a default export");
+ var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 84 /* DefaultKeyword */), "Nameless class declaration should be a default export");
return [defaultModifier];
case 214 /* ClassExpression */:
var classExpression = constructorDeclaration.parent;
@@ -233652,12 +240785,12 @@ var ts;
return [functionDeclaration.name];
// If the function declaration doesn't have a name, it should have a default modifier.
// We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault`
- var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 84 /* DefaultKeyword */), "Nameless function declaration should be a default export");
+ var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 84 /* DefaultKeyword */), "Nameless function declaration should be a default export");
return [defaultModifier];
case 161 /* MethodDeclaration */:
return [functionDeclaration.name];
case 162 /* Constructor */:
- var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 129 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword");
+ var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 129 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword");
if (functionDeclaration.parent.kind === 214 /* ClassExpression */) {
var variableDeclaration = functionDeclaration.parent.parent;
return [variableDeclaration.name, ctrKeyword];
@@ -233791,7 +240924,6 @@ var ts;
indexes.push(index);
index++;
}
- text = ts.escapeString(text);
return [index, text, indexes];
}
function nodesToTemplate(_a, file) {
@@ -233916,7 +241048,7 @@ var ts;
if (!children.length) {
return undefined;
}
- var child = ts.find(children, function (kid) { return kid.kind < 294 /* FirstJSDocNode */ || kid.kind > 322 /* LastJSDocNode */; });
+ var child = ts.find(children, function (kid) { return kid.kind < 294 /* FirstJSDocNode */ || kid.kind > 323 /* LastJSDocNode */; });
return child.kind < 153 /* FirstNode */ ?
child :
child.getFirstToken(sourceFile);
@@ -233986,7 +241118,7 @@ var ts;
}
}
function createSyntaxList(nodes, parent) {
- var list = createNode(323 /* SyntaxList */, nodes.pos, nodes.end, parent);
+ var list = createNode(324 /* SyntaxList */, nodes.pos, nodes.end, parent);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
@@ -234070,7 +241202,7 @@ var ts;
get: function () {
return ts.symbolName(this);
},
- enumerable: true,
+ enumerable: false,
configurable: true
});
SymbolObject.prototype.getEscapedName = function () {
@@ -234117,7 +241249,7 @@ var ts;
get: function () {
return ts.idText(this);
},
- enumerable: true,
+ enumerable: false,
configurable: true
});
return IdentifierObject;
@@ -234132,7 +241264,7 @@ var ts;
get: function () {
return ts.idText(this);
},
- enumerable: true,
+ enumerable: false,
configurable: true
});
return PrivateIdentifierObject;
@@ -234225,7 +241357,7 @@ var ts;
}
return undefined;
},
- enumerable: true,
+ enumerable: false,
configurable: true
});
return TypeObject;
@@ -234599,10 +241731,6 @@ var ts;
});
return names;
};
- HostCache.prototype.getVersion = function (path) {
- var file = this.getHostFileInformation(path);
- return (file && file.version); // TODO: GH#18217
- };
HostCache.prototype.getScriptSnapshot = function (path) {
var file = this.getHostFileInformation(path);
return (file && file.scriptSnapshot); // TODO: GH#18217
@@ -234786,6 +241914,7 @@ var ts;
return sourceFile;
}
function synchronizeHostData() {
+ var _a;
ts.Debug.assert(!syntaxOnly);
// perform fast check if host supports it
if (host.getProjectVersion) {
@@ -234809,7 +241938,7 @@ var ts;
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
var projectReferences = hostCache.getProjectReferences();
// If the program is already up-to-date, we can reuse it
- if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, !!host.hasChangedAutomaticTypeDirectiveNames, projectReferences)) {
+ if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, !!host.hasChangedAutomaticTypeDirectiveNames, projectReferences)) {
return;
}
// IMPORTANT - It is critical from this moment onward that we do not check
@@ -234839,7 +241968,7 @@ var ts;
return host.getDirectories ? host.getDirectories(path) : [];
},
readDirectory: function (path, extensions, exclude, include, depth) {
- ts.Debug.assertDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
+ ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
return host.readDirectory(path, extensions, exclude, include, depth);
},
onReleaseOldSourceFile: onReleaseOldSourceFile,
@@ -234867,12 +241996,10 @@ var ts;
return host.resolveTypeReferenceDirectives.apply(host, args);
};
}
- if (host.setResolvedProjectReferenceCallbacks) {
- compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); };
- }
if (host.useSourceOfProjectReferenceRedirect) {
compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); };
}
+ (_a = host.setCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host, compilerHost);
var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
var options = {
rootNames: rootFileNames,
@@ -234958,7 +242085,7 @@ var ts;
// We do not support the scenario where a host can modify a registered
// file's script kind, i.e. in one project some file is treated as ".ts"
// and in another as ".js"
- ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind.", path);
+ ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind.");
return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
}
// We didn't already have the file. Fall through and acquire it from the registry.
@@ -234981,8 +242108,10 @@ var ts;
}
function dispose() {
if (program) {
+ // Use paths to ensure we are using correct key and paths as document registry could bre created with different current directory than host
+ var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
ts.forEach(program.getSourceFiles(), function (f) {
- return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions());
+ return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1);
});
program = undefined; // TODO: GH#18217
}
@@ -235028,12 +242157,13 @@ var ts;
function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) {
if (preferences === void 0) { preferences = ts.emptyOptions; }
synchronizeHostData();
- return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217
+ return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217
preferences, cancellationToken);
}
- function getCompletionEntrySymbol(fileName, position, name, source) {
+ function getCompletionEntrySymbol(fileName, position, name, source, preferences) {
+ if (preferences === void 0) { preferences = ts.emptyOptions; }
synchronizeHostData();
- return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host);
+ return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, preferences);
}
function getQuickInfoAtPosition(fileName, position) {
synchronizeHostData();
@@ -235299,14 +242429,14 @@ var ts;
}
function getFormattingEditsForRange(fileName, start, end, options) {
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
- return ts.formatting.formatSelection(start, end, sourceFile, ts.formatting.getFormatContext(toEditorSettings(options)));
+ return ts.formatting.formatSelection(start, end, sourceFile, ts.formatting.getFormatContext(toEditorSettings(options), host));
}
function getFormattingEditsForDocument(fileName, options) {
- return ts.formatting.formatDocument(syntaxTreeCache.getCurrentSourceFile(fileName), ts.formatting.getFormatContext(toEditorSettings(options)));
+ return ts.formatting.formatDocument(syntaxTreeCache.getCurrentSourceFile(fileName), ts.formatting.getFormatContext(toEditorSettings(options), host));
}
function getFormattingEditsAfterKeystroke(fileName, position, key, options) {
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
- var formatContext = ts.formatting.getFormatContext(toEditorSettings(options));
+ var formatContext = ts.formatting.getFormatContext(toEditorSettings(options), host);
if (!ts.isInComment(sourceFile, position)) {
switch (key) {
case "{":
@@ -235326,7 +242456,7 @@ var ts;
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
var span = ts.createTextSpanFromBounds(start, end);
- var formatContext = ts.formatting.getFormatContext(formatOptions);
+ var formatContext = ts.formatting.getFormatContext(formatOptions, host);
return ts.flatMap(ts.deduplicate(errorCodes, ts.equateValues, ts.compareValues), function (errorCode) {
cancellationToken.throwIfCancellationRequested();
return ts.codefix.getFixes({ errorCode: errorCode, sourceFile: sourceFile, span: span, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
@@ -235337,7 +242467,7 @@ var ts;
synchronizeHostData();
ts.Debug.assert(scope.type === "file");
var sourceFile = getValidSourceFile(scope.fileName);
- var formatContext = ts.formatting.getFormatContext(formatOptions);
+ var formatContext = ts.formatting.getFormatContext(formatOptions, host);
return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
}
function organizeImports(scope, formatOptions, preferences) {
@@ -235345,12 +242475,12 @@ var ts;
synchronizeHostData();
ts.Debug.assert(scope.type === "file");
var sourceFile = getValidSourceFile(scope.fileName);
- var formatContext = ts.formatting.getFormatContext(formatOptions);
+ var formatContext = ts.formatting.getFormatContext(formatOptions, host);
return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences);
}
function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
if (preferences === void 0) { preferences = ts.emptyOptions; }
- return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences, sourceMapper);
+ return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions, host), preferences, sourceMapper);
}
function applyCodeActionCommand(fileName, actionOrFormatSettingsOrUndefined) {
var action = typeof fileName === "string" ? actionOrFormatSettingsOrUndefined : fileName;
@@ -235552,7 +242682,7 @@ var ts;
endPosition: endPosition,
program: getProgram(),
host: host,
- formatContext: ts.formatting.getFormatContext(formatOptions),
+ formatContext: ts.formatting.getFormatContext(formatOptions, host),
cancellationToken: cancellationToken,
preferences: preferences,
};
@@ -235644,6 +242774,7 @@ var ts;
getEditsForRefactor: getEditsForRefactor,
toLineColumnOffset: sourceMapper.toLineColumnOffset,
getSourceMapper: function () { return sourceMapper; },
+ clearSourceMapperCache: function () { return sourceMapper.clearCache(); },
prepareCallHierarchy: prepareCallHierarchy,
provideCallHierarchyIncomingCalls: provideCallHierarchyIncomingCalls,
provideCallHierarchyOutgoingCalls: provideCallHierarchyOutgoingCalls
@@ -236970,7 +244101,10 @@ var ts;
/// Emit
LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) {
var _this = this;
- return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); });
+ return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () {
+ var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]);
+ return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) });
+ });
};
LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) {
var _this = this;
@@ -237257,7 +244391,7 @@ var isPlainObject = _interopDefault(__webpack_require__(696));
var nodeFetch = _interopDefault(__webpack_require__(454));
var requestError = __webpack_require__(463);
-const VERSION = "5.4.2";
+const VERSION = "5.4.4";
function getBufferResponse(response) {
return response.arrayBuffer();
@@ -238711,7 +245845,27 @@ module.exports = exports.default;
/***/ }),
/* 766 */,
-/* 767 */,
+/* 767 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const SemVer = __webpack_require__(369)
+
+const inc = (version, release, options, identifier) => {
+ if (typeof (options) === 'string') {
+ identifier = options
+ options = undefined
+ }
+
+ try {
+ return new SemVer(version, options).inc(release, identifier).version
+ } catch (er) {
+ return null
+ }
+}
+module.exports = inc
+
+
+/***/ }),
/* 768 */
/***/ (function(module) {
@@ -238735,7 +245889,20 @@ module.exports = function (x) {
/***/ }),
/* 769 */,
-/* 770 */,
+/* 770 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const Range = __webpack_require__(986)
+
+// Mostly just for testing and legacy API reasons
+const toComparators = (range, options) =>
+ new Range(range, options).set
+ .map(comp => comp.map(c => c.value).join(' ').trim().split(' '))
+
+module.exports = toComparators
+
+
+/***/ }),
/* 771 */,
/* 772 */,
/* 773 */,
@@ -238850,7 +246017,92 @@ module.exports.sync = sync;
/***/ }),
/* 775 */,
-/* 776 */,
+/* 776 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const SemVer = __webpack_require__(243)
+const Comparator = __webpack_require__(456)
+const {ANY} = Comparator
+const Range = __webpack_require__(635)
+const satisfies = __webpack_require__(171)
+const gt = __webpack_require__(738)
+const lt = __webpack_require__(375)
+const lte = __webpack_require__(546)
+const gte = __webpack_require__(790)
+
+const outside = (version, range, hilo, options) => {
+ version = new SemVer(version, options)
+ range = new Range(range, options)
+
+ let gtfn, ltefn, ltfn, comp, ecomp
+ switch (hilo) {
+ case '>':
+ gtfn = gt
+ ltefn = lte
+ ltfn = lt
+ comp = '>'
+ ecomp = '>='
+ break
+ case '<':
+ gtfn = lt
+ ltefn = gte
+ ltfn = gt
+ comp = '<'
+ ecomp = '<='
+ break
+ default:
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
+ }
+
+ // If it satisifes the range it is not outside
+ if (satisfies(version, range, options)) {
+ return false
+ }
+
+ // From now on, variable terms are as if we're in "gtr" mode.
+ // but note that everything is flipped for the "ltr" function.
+
+ for (let i = 0; i < range.set.length; ++i) {
+ const comparators = range.set[i]
+
+ let high = null
+ let low = null
+
+ comparators.forEach((comparator) => {
+ if (comparator.semver === ANY) {
+ comparator = new Comparator('>=0.0.0')
+ }
+ high = high || comparator
+ low = low || comparator
+ if (gtfn(comparator.semver, high.semver, options)) {
+ high = comparator
+ } else if (ltfn(comparator.semver, low.semver, options)) {
+ low = comparator
+ }
+ })
+
+ // If the edge version comparator has a operator then our version
+ // isn't outside it
+ if (high.operator === comp || high.operator === ecomp) {
+ return false
+ }
+
+ // If the lowest version comparator has an operator and our version
+ // is less than it then it isn't higher than the range
+ if ((!low.operator || low.operator === comp) &&
+ ltefn(version, low.semver)) {
+ return false
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
+ return false
+ }
+ }
+ return true
+}
+
+module.exports = outside
+
+
+/***/ }),
/* 777 */
/***/ (function(module, __unusedexports, __webpack_require__) {
@@ -239502,7 +246754,7 @@ function () {
* throw new Error('This plugin works only with PostCSS 6')
* }
*/
- this.version = '7.0.29';
+ this.version = '7.0.31';
/**
* Plugins added to this processor.
*
@@ -239724,7 +246976,7 @@ var _default = Processor;
exports.default = _default;
module.exports = exports.default;
-//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByb2Nlc3Nvci5lczYiXSwibmFtZXMiOlsiUHJvY2Vzc29yIiwicGx1Z2lucyIsInZlcnNpb24iLCJub3JtYWxpemUiLCJ1c2UiLCJwbHVnaW4iLCJjb25jYXQiLCJwcm9jZXNzIiwiY3NzIiwib3B0cyIsImxlbmd0aCIsInBhcnNlciIsInN0cmluZ2lmaWVyIiwiZW52IiwiTk9ERV9FTlYiLCJjb25zb2xlIiwid2FybiIsIkxhenlSZXN1bHQiLCJub3JtYWxpemVkIiwiaSIsInBvc3Rjc3MiLCJBcnJheSIsImlzQXJyYXkiLCJwdXNoIiwicGFyc2UiLCJzdHJpbmdpZnkiLCJFcnJvciJdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQTs7OztBQUVBOzs7Ozs7Ozs7SUFTTUEsUzs7O0FBQ0o7Ozs7QUFJQSxxQkFBYUMsT0FBYixFQUEyQjtBQUFBLFFBQWRBLE9BQWM7QUFBZEEsTUFBQUEsT0FBYyxHQUFKLEVBQUk7QUFBQTs7QUFDekI7Ozs7Ozs7Ozs7QUFVQSxTQUFLQyxPQUFMLEdBQWUsUUFBZjtBQUNBOzs7Ozs7Ozs7O0FBU0EsU0FBS0QsT0FBTCxHQUFlLEtBQUtFLFNBQUwsQ0FBZUYsT0FBZixDQUFmO0FBQ0Q7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O1NBNkJBRyxHLEdBQUEsYUFBS0MsTUFBTCxFQUFhO0FBQ1gsU0FBS0osT0FBTCxHQUFlLEtBQUtBLE9BQUwsQ0FBYUssTUFBYixDQUFvQixLQUFLSCxTQUFMLENBQWUsQ0FBQ0UsTUFBRCxDQUFmLENBQXBCLENBQWY7QUFDQSxXQUFPLElBQVA7QUFDRDtBQUVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7U0FzQkFFLE87Ozs7Ozs7Ozs7SUFBQSxVQUFTQyxHQUFULEVBQWNDLElBQWQsRUFBMEI7QUFBQSxRQUFaQSxJQUFZO0FBQVpBLE1BQUFBLElBQVksR0FBTCxFQUFLO0FBQUE7O0FBQ3hCLFFBQUksS0FBS1IsT0FBTCxDQUFhUyxNQUFiLEtBQXdCLENBQXhCLElBQTZCRCxJQUFJLENBQUNFLE1BQUwsS0FBZ0JGLElBQUksQ0FBQ0csV0FBdEQsRUFBbUU7QUFDakUsVUFBSUwsT0FBTyxDQUFDTSxHQUFSLENBQVlDLFFBQVosS0FBeUIsWUFBN0IsRUFBMkM7QUFDekMsWUFBSSxPQUFPQyxPQUFQLEtBQW1CLFdBQW5CLElBQWtDQSxPQUFPLENBQUNDLElBQTlDLEVBQW9EO0FBQ2xERCxVQUFBQSxPQUFPLENBQUNDLElBQVIsQ0FDRSwwREFDQSw4REFEQSxHQUVBLGtFQUhGO0FBS0Q7QUFDRjtBQUNGOztBQUNELFdBQU8sSUFBSUMsbUJBQUosQ0FBZSxJQUFmLEVBQXFCVCxHQUFyQixFQUEwQkMsSUFBMUIsQ0FBUDtBQUNELEc7O1NBRUROLFMsR0FBQSxtQkFBV0YsT0FBWCxFQUFvQjtBQUNsQixRQUFJaUIsVUFBVSxHQUFHLEVBQWpCOztBQUNBLHlCQUFjakIsT0FBZCxrSEFBdUI7QUFBQTs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBOztBQUFBLFVBQWRrQixDQUFjO0FBQ3JCLFVBQUlBLENBQUMsQ0FBQ0MsT0FBTixFQUFlRCxDQUFDLEdBQUdBLENBQUMsQ0FBQ0MsT0FBTjs7QUFFZixVQUFJLE9BQU9ELENBQVAsS0FBYSxRQUFiLElBQXlCRSxLQUFLLENBQUNDLE9BQU4sQ0FBY0gsQ0FBQyxDQUFDbEIsT0FBaEIsQ0FBN0IsRUFBdUQ7QUFDckRpQixRQUFBQSxVQUFVLEdBQUdBLFVBQVUsQ0FBQ1osTUFBWCxDQUFrQmEsQ0FBQyxDQUFDbEIsT0FBcEIsQ0FBYjtBQUNELE9BRkQsTUFFTyxJQUFJLE9BQU9rQixDQUFQLEtBQWEsVUFBakIsRUFBNkI7QUFDbENELFFBQUFBLFVBQVUsQ0FBQ0ssSUFBWCxDQUFnQkosQ0FBaEI7QUFDRCxPQUZNLE1BRUEsSUFBSSxPQUFPQSxDQUFQLEtBQWEsUUFBYixLQUEwQkEsQ0FBQyxDQUFDSyxLQUFGLElBQVdMLENBQUMsQ0FBQ00sU0FBdkMsQ0FBSixFQUF1RDtBQUM1RCxZQUFJbEIsT0FBTyxDQUFDTSxHQUFSLENBQVlDLFFBQVosS0FBeUIsWUFBN0IsRUFBMkM7QUFDekMsZ0JBQU0sSUFBSVksS0FBSixDQUNKLHFFQUNBLDJEQURBLEdBRUEsdUNBSEksQ0FBTjtBQUtEO0FBQ0YsT0FSTSxNQVFBO0FBQ0wsY0FBTSxJQUFJQSxLQUFKLENBQVVQLENBQUMsR0FBRywwQkFBZCxDQUFOO0FBQ0Q7QUFDRjs7QUFDRCxXQUFPRCxVQUFQO0FBQ0QsRzs7Ozs7ZUFHWWxCLFM7QUFFZjs7Ozs7OztBQU9BOzs7Ozs7Ozs7O0FBVUE7Ozs7Ozs7Ozs7QUFVQTs7Ozs7O0FBTUE7Ozs7O0FBS0E7Ozs7OztBQU1BOzs7OztBQUtBIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IExhenlSZXN1bHQgZnJvbSAnLi9sYXp5LXJlc3VsdCdcblxuLyoqXG4gKiBDb250YWlucyBwbHVnaW5zIHRvIHByb2Nlc3MgQ1NTLiBDcmVhdGUgb25lIGBQcm9jZXNzb3JgIGluc3RhbmNlLFxuICogaW5pdGlhbGl6ZSBpdHMgcGx1Z2lucywgYW5kIHRoZW4gdXNlIHRoYXQgaW5zdGFuY2Ugb24gbnVtZXJvdXMgQ1NTIGZpbGVzLlxuICpcbiAqIEBleGFtcGxlXG4gKiBjb25zdCBwcm9jZXNzb3IgPSBwb3N0Y3NzKFthdXRvcHJlZml4ZXIsIHByZWNzc10pXG4gKiBwcm9jZXNzb3IucHJvY2Vzcyhjc3MxKS50aGVuKHJlc3VsdCA9PiBjb25zb2xlLmxvZyhyZXN1bHQuY3NzKSlcbiAqIHByb2Nlc3Nvci5wcm9jZXNzKGNzczIpLnRoZW4ocmVzdWx0ID0+IGNvbnNvbGUubG9nKHJlc3VsdC5jc3MpKVxuICovXG5jbGFzcyBQcm9jZXNzb3Ige1xuICAvKipcbiAgICogQHBhcmFtIHtBcnJheS48UGx1Z2lufHBsdWdpbkZ1bmN0aW9uPnxQcm9jZXNzb3J9IHBsdWdpbnMgUG9zdENTUyBwbHVnaW5zLlxuICAgKiAgICAgICAgU2VlIHtAbGluayBQcm9jZXNzb3IjdXNlfSBmb3IgcGx1Z2luIGZvcm1hdC5cbiAgICovXG4gIGNvbnN0cnVjdG9yIChwbHVnaW5zID0gW10pIHtcbiAgICAvKipcbiAgICAgKiBDdXJyZW50IFBvc3RDU1MgdmVyc2lvbi5cbiAgICAgKlxuICAgICAqIEB0eXBlIHtzdHJpbmd9XG4gICAgICpcbiAgICAgKiBAZXhhbXBsZVxuICAgICAqIGlmIChyZXN1bHQucHJvY2Vzc29yLnZlcnNpb24uc3BsaXQoJy4nKVswXSAhPT0gJzYnKSB7XG4gICAgICogICB0aHJvdyBuZXcgRXJyb3IoJ1RoaXMgcGx1Z2luIHdvcmtzIG9ubHkgd2l0aCBQb3N0Q1NTIDYnKVxuICAgICAqIH1cbiAgICAgKi9cbiAgICB0aGlzLnZlcnNpb24gPSAnNy4wLjI5J1xuICAgIC8qKlxuICAgICAqIFBsdWdpbnMgYWRkZWQgdG8gdGhpcyBwcm9jZXNzb3IuXG4gICAgICpcbiAgICAgKiBAdHlwZSB7cGx1Z2luRnVuY3Rpb25bXX1cbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogY29uc3QgcHJvY2Vzc29yID0gcG9zdGNzcyhbYXV0b3ByZWZpeGVyLCBwcmVjc3NdKVxuICAgICAqIHByb2Nlc3Nvci5wbHVnaW5zLmxlbmd0aCAvLz0+IDJcbiAgICAgKi9cbiAgICB0aGlzLnBsdWdpbnMgPSB0aGlzLm5vcm1hbGl6ZShwbHVnaW5zKVxuICB9XG5cbiAgLyoqXG4gICAqIEFkZHMgYSBwbHVnaW4gdG8gYmUgdXNlZCBhcyBhIENTUyBwcm9jZXNzb3IuXG4gICAqXG4gICAqIFBvc3RDU1MgcGx1Z2luIGNhbiBiZSBpbiA0IGZvcm1hdHM6XG4gICAqICogQSBwbHVnaW4gY3JlYXRlZCBieSB7QGxpbmsgcG9zdGNzcy5wbHVnaW59IG1ldGhvZC5cbiAgICogKiBBIGZ1bmN0aW9uLiBQb3N0Q1NTIHdpbGwgcGFzcyB0aGUgZnVuY3Rpb24gYSBAe2xpbmsgUm9vdH1cbiAgICogICBhcyB0aGUgZmlyc3QgYXJndW1lbnQgYW5kIGN1cnJlbnQge0BsaW5rIFJlc3VsdH0gaW5zdGFuY2VcbiAgICogICBhcyB0aGUgc2Vjb25kLlxuICAgKiAqIEFuIG9iamVjdCB3aXRoIGEgYHBvc3Rjc3NgIG1ldGhvZC4gUG9zdENTUyB3aWxsIHVzZSB0aGF0IG1ldGhvZFxuICAgKiAgIGFzIGRlc2NyaWJlZCBpbiAjMi5cbiAgICogKiBBbm90aGVyIHtAbGluayBQcm9jZXNzb3J9IGluc3RhbmNlLiBQb3N0Q1NTIHdpbGwgY29weSBwbHVnaW5zXG4gICAqICAgZnJvbSB0aGF0IGluc3RhbmNlIGludG8gdGhpcyBvbmUuXG4gICAqXG4gICAqIFBsdWdpbnMgY2FuIGFsc28gYmUgYWRkZWQgYnkgcGFzc2luZyB0aGVtIGFzIGFyZ3VtZW50cyB3aGVuIGNyZWF0aW5nXG4gICAqIGEgYHBvc3Rjc3NgIGluc3RhbmNlIChzZWUgW2Bwb3N0Y3NzKHBsdWdpbnMpYF0pLlxuICAgKlxuICAgKiBBc3luY2hyb25vdXMgcGx1Z2lucyBzaG91bGQgcmV0dXJuIGEgYFByb21pc2VgIGluc3RhbmNlLlxuICAgKlxuICAgKiBAcGFyYW0ge1BsdWdpbnxwbHVnaW5GdW5jdGlvbnxQcm9jZXNzb3J9IHBsdWdpbiBQb3N0Q1NTIHBsdWdpblxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvciB7QGxpbmsgUHJvY2Vzc29yfVxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoIHBsdWdpbnMuXG4gICAqXG4gICAqIEBleGFtcGxlXG4gICAqIGNvbnN0IHByb2Nlc3NvciA9IHBvc3Rjc3MoKVxuICAgKiAgIC51c2UoYXV0b3ByZWZpeGVyKVxuICAgKiAgIC51c2UocHJlY3NzKVxuICAgKlxuICAgKiBAcmV0dXJuIHtQcm9jZXNzZXN9IEN1cnJlbnQgcHJvY2Vzc29yIHRvIG1ha2UgbWV0aG9kcyBjaGFpbi5cbiAgICovXG4gIHVzZSAocGx1Z2luKSB7XG4gICAgdGhpcy5wbHVnaW5zID0gdGhpcy5wbHVnaW5zLmNvbmNhdCh0aGlzLm5vcm1hbGl6ZShbcGx1Z2luXSkpXG4gICAgcmV0dXJuIHRoaXNcbiAgfVxuXG4gIC8qKlxuICAgKiBQYXJzZXMgc291cmNlIENTUyBhbmQgcmV0dXJucyBhIHtAbGluayBMYXp5UmVzdWx0fSBQcm9taXNlIHByb3h5LlxuICAgKiBCZWNhdXNlIHNvbWUgcGx1Z2lucyBjYW4gYmUgYXN5bmNocm9ub3VzIGl0IGRvZXNu4oCZdCBtYWtlXG4gICAqIGFueSB0cmFuc2Zvcm1hdGlvbnMuIFRyYW5zZm9ybWF0aW9ucyB3aWxsIGJlIGFwcGxpZWRcbiAgICogaW4gdGhlIHtAbGluayBMYXp5UmVzdWx0fSBtZXRob2RzLlxuICAgKlxuICAgKiBAcGFyYW0ge3N0cmluZ3x0b1N0cmluZ3xSZXN1bHR9IGNzcyBTdHJpbmcgd2l0aCBpbnB1dCBDU1Mgb3IgYW55IG9iamVjdFxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoIGEgYHRvU3RyaW5nKClgIG1ldGhvZCxcbiAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlrZSBhIEJ1ZmZlci4gT3B0aW9uYWxseSwgc2VuZFxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhIHtAbGluayBSZXN1bHR9IGluc3RhbmNlXG4gICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuZCB0aGUgcHJvY2Vzc29yIHdpbGwgdGFrZVxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGUge0BsaW5rIFJvb3R9IGZyb20gaXQuXG4gICAqIEBwYXJhbSB7cHJvY2Vzc09wdGlvbnN9IFtvcHRzXSAgICAgIE9wdGlvbnMuXG4gICAqXG4gICAqIEByZXR1cm4ge0xhenlSZXN1bHR9IFByb21pc2UgcHJveHkuXG4gICAqXG4gICAqIEBleGFtcGxlXG4gICAqIHByb2Nlc3Nvci5wcm9jZXNzKGNzcywgeyBmcm9tOiAnYS5jc3MnLCB0bzogJ2Eub3V0LmNzcycgfSlcbiAgICogICAudGhlbihyZXN1bHQgPT4ge1xuICAgKiAgICAgIGNvbnNvbGUubG9nKHJlc3VsdC5jc3MpXG4gICAqICAgfSlcbiAgICovXG4gIHByb2Nlc3MgKGNzcywgb3B0cyA9IHsgfSkge1xuICAgIGlmICh0aGlzLnBsdWdpbnMubGVuZ3RoID09PSAwICYmIG9wdHMucGFyc2VyID09PSBvcHRzLnN0cmluZ2lmaWVyKSB7XG4gICAgICBpZiAocHJvY2Vzcy5lbnYuTk9ERV9FTlYgIT09ICdwcm9kdWN0aW9uJykge1xuICAgICAgICBpZiAodHlwZW9mIGNvbnNvbGUgIT09ICd1bmRlZmluZWQnICYmIGNvbnNvbGUud2Fybikge1xuICAgICAgICAgIGNvbnNvbGUud2FybihcbiAgICAgICAgICAgICdZb3UgZGlkIG5vdCBzZXQgYW55IHBsdWdpbnMsIHBhcnNlciwgb3Igc3RyaW5naWZpZXIuICcgK1xuICAgICAgICAgICAgJ1JpZ2h0IG5vdywgUG9zdENTUyBkb2VzIG5vdGhpbmcuIFBpY2sgcGx1Z2lucyBmb3IgeW91ciBjYXNlICcgK1xuICAgICAgICAgICAgJ29uIGh0dHBzOi8vd3d3LnBvc3Rjc3MucGFydHMvIGFuZCB1c2UgdGhlbSBpbiBwb3N0Y3NzLmNvbmZpZy5qcy4nXG4gICAgICAgICAgKVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiBuZXcgTGF6eVJlc3VsdCh0aGlzLCBjc3MsIG9wdHMpXG4gIH1cblxuICBub3JtYWxpemUgKHBsdWdpbnMpIHtcbiAgICBsZXQgbm9ybWFsaXplZCA9IFtdXG4gICAgZm9yIChsZXQgaSBvZiBwbHVnaW5zKSB7XG4gICAgICBpZiAoaS5wb3N0Y3NzKSBpID0gaS5wb3N0Y3NzXG5cbiAgICAgIGlmICh0eXBlb2YgaSA9PT0gJ29iamVjdCcgJiYgQXJyYXkuaXNBcnJheShpLnBsdWdpbnMpKSB7XG4gICAgICAgIG5vcm1hbGl6ZWQgPSBub3JtYWxpemVkLmNvbmNhdChpLnBsdWdpbnMpXG4gICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIG5vcm1hbGl6ZWQucHVzaChpKVxuICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaSA9PT0gJ29iamVjdCcgJiYgKGkucGFyc2UgfHwgaS5zdHJpbmdpZnkpKSB7XG4gICAgICAgIGlmIChwcm9jZXNzLmVudi5OT0RFX0VOViAhPT0gJ3Byb2R1Y3Rpb24nKSB7XG4gICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxuICAgICAgICAgICAgJ1Bvc3RDU1Mgc3ludGF4ZXMgY2Fubm90IGJlIHVzZWQgYXMgcGx1Z2lucy4gSW5zdGVhZCwgcGxlYXNlIHVzZSAnICtcbiAgICAgICAgICAgICdvbmUgb2YgdGhlIHN5bnRheC9wYXJzZXIvc3RyaW5naWZpZXIgb3B0aW9ucyBhcyBvdXRsaW5lZCAnICtcbiAgICAgICAgICAgICdpbiB5b3VyIFBvc3RDU1MgcnVubmVyIGRvY3VtZW50YXRpb24uJ1xuICAgICAgICAgIClcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGkgKyAnIGlzIG5vdCBhIFBvc3RDU1MgcGx1Z2luJylcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIG5vcm1hbGl6ZWRcbiAgfVxufVxuXG5leHBvcnQgZGVmYXVsdCBQcm9jZXNzb3JcblxuLyoqXG4gKiBAY2FsbGJhY2sgYnVpbGRlclxuICogQHBhcmFtIHtzdHJpbmd9IHBhcnQgICAgICAgICAgUGFydCBvZiBnZW5lcmF0ZWQgQ1NTIGNvbm5lY3RlZCB0byB0aGlzIG5vZGUuXG4gKiBAcGFyYW0ge05vZGV9ICAgbm9kZSAgICAgICAgICBBU1Qgbm9kZS5cbiAqIEBwYXJhbSB7XCJzdGFydFwifFwiZW5kXCJ9IFt0eXBlXSBOb2Rl4oCZcyBwYXJ0IHR5cGUuXG4gKi9cblxuLyoqXG4gKiBAY2FsbGJhY2sgcGFyc2VyXG4gKlxuICogQHBhcmFtIHtzdHJpbmd8dG9TdHJpbmd9IGNzcyAgIFN0cmluZyB3aXRoIGlucHV0IENTUyBvciBhbnkgb2JqZWN0XG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2l0aCB0b1N0cmluZygpIG1ldGhvZCwgbGlrZSBhIEJ1ZmZlci5cbiAqIEBwYXJhbSB7cHJvY2Vzc09wdGlvbnN9IFtvcHRzXSBPcHRpb25zIHdpdGggb25seSBgZnJvbWAgYW5kIGBtYXBgIGtleXMuXG4gKlxuICogQHJldHVybiB7Um9vdH0gUG9zdENTUyBBU1RcbiAqL1xuXG4vKipcbiAqIEBjYWxsYmFjayBzdHJpbmdpZmllclxuICpcbiAqIEBwYXJhbSB7Tm9kZX0gbm9kZSAgICAgICBTdGFydCBub2RlIGZvciBzdHJpbmdpZmluZy4gVXN1YWxseSB7QGxpbmsgUm9vdH0uXG4gKiBAcGFyYW0ge2J1aWxkZXJ9IGJ1aWxkZXIgRnVuY3Rpb24gdG8gY29uY2F0ZW5hdGUgQ1NTIGZyb20gbm9kZeKAmXMgcGFydHNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICBvciBnZW5lcmF0ZSBzdHJpbmcgYW5kIHNvdXJjZSBtYXAuXG4gKlxuICogQHJldHVybiB7dm9pZH1cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHN5bnRheFxuICogQHByb3BlcnR5IHtwYXJzZXJ9IHBhcnNlICAgICAgICAgIEZ1bmN0aW9uIHRvIGdlbmVyYXRlIEFTVCBieSBzdHJpbmcuXG4gKiBAcHJvcGVydHkge3N0cmluZ2lmaWVyfSBzdHJpbmdpZnkgRnVuY3Rpb24gdG8gZ2VuZXJhdGUgc3RyaW5nIGJ5IEFTVC5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHRvU3RyaW5nXG4gKiBAcHJvcGVydHkge2Z1bmN0aW9ufSB0b1N0cmluZ1xuICovXG5cbi8qKlxuICogQGNhbGxiYWNrIHBsdWdpbkZ1bmN0aW9uXG4gKiBAcGFyYW0ge1Jvb3R9IHJvb3QgICAgIFBhcnNlZCBpbnB1dCBDU1MuXG4gKiBAcGFyYW0ge1Jlc3VsdH0gcmVzdWx0IFJlc3VsdCB0byBzZXQgd2FybmluZ3Mgb3IgY2hlY2sgb3RoZXIgcGx1Z2lucy5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IFBsdWdpblxuICogQHByb3BlcnR5IHtmdW5jdGlvbn0gcG9zdGNzcyBQb3N0Q1NTIHBsdWdpbiBmdW5jdGlvbi5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHByb2Nlc3NPcHRpb25zXG4gKiBAcHJvcGVydHkge3N0cmluZ30gZnJvbSAgICAgICAgICAgICBUaGUgcGF0aCBvZiB0aGUgQ1NTIHNvdXJjZSBmaWxlLlxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWW91IHNob3VsZCBhbHdheXMgc2V0IGBmcm9tYCxcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlY2F1c2UgaXQgaXMgdXNlZCBpbiBzb3VyY2UgbWFwXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZW5lcmF0aW9uIGFuZCBzeW50YXggZXJyb3IgbWVzc2FnZXMuXG4gKiBAcHJvcGVydHkge3N0cmluZ30gdG8gICAgICAgICAgICAgICBUaGUgcGF0aCB3aGVyZSB5b3XigJlsbCBwdXQgdGhlIG91dHB1dFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ1NTIGZpbGUuIFlvdSBzaG91bGQgYWx3YXlzIHNldCBgdG9gXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0byBnZW5lcmF0ZSBjb3JyZWN0IHNvdXJjZSBtYXBzLlxuICogQHByb3BlcnR5IHtwYXJzZXJ9IHBhcnNlciAgICAgICAgICAgRnVuY3Rpb24gdG8gZ2VuZXJhdGUgQVNUIGJ5IHN0cmluZy5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5naWZpZXJ9IHN0cmluZ2lmaWVyIENsYXNzIHRvIGdlbmVyYXRlIHN0cmluZyBieSBBU1QuXG4gKiBAcHJvcGVydHkge3N5bnRheH0gc3ludGF4ICAgICAgICAgICBPYmplY3Qgd2l0aCBgcGFyc2VgIGFuZCBgc3RyaW5naWZ5YC5cbiAqIEBwcm9wZXJ0eSB7b2JqZWN0fSBtYXAgICAgICAgICAgICAgIFNvdXJjZSBtYXAgb3B0aW9ucy5cbiAqIEBwcm9wZXJ0eSB7Ym9vbGVhbn0gbWFwLmlubGluZSAgICAgICAgICAgICAgICAgICAgRG9lcyBzb3VyY2UgbWFwIHNob3VsZFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZSBlbWJlZGRlZCBpbiB0aGUgb3V0cHV0XG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENTUyBhcyBhIGJhc2U2NC1lbmNvZGVkXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1lbnQuXG4gKiBAcHJvcGVydHkge3N0cmluZ3xvYmplY3R8ZmFsc2V8ZnVuY3Rpb259IG1hcC5wcmV2IFNvdXJjZSBtYXAgY29udGVudFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tIGEgcHJldmlvdXNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2luZyBzdGVwXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChmb3IgZXhhbXBsZSwgU2FzcykuXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBvc3RDU1Mgd2lsbCB0cnkgdG8gZmluZFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2aW91cyBtYXAgYXV0b21hdGljYWxseSxcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc28geW91IGNvdWxkIGRpc2FibGUgaXQgYnlcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYGZhbHNlYCB2YWx1ZS5cbiAqIEBwcm9wZXJ0eSB7Ym9vbGVhbn0gbWFwLnNvdXJjZXNDb250ZW50ICAgICAgICAgICAgRG9lcyBQb3N0Q1NTIHNob3VsZCBzZXRcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhlIG9yaWdpbiBjb250ZW50IHRvIG1hcC5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5nfGZhbHNlfSBtYXAuYW5ub3RhdGlvbiAgICAgICAgICAgRG9lcyBQb3N0Q1NTIHNob3VsZCBzZXRcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbiBjb21tZW50IHRvIG1hcC5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5nfSBtYXAuZnJvbSAgICAgICAgICAgICAgICAgICAgICAgT3ZlcnJpZGUgYGZyb21gIGluIG1hcOKAmXNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlc2AuXG4gKi9cbiJdLCJmaWxlIjoicHJvY2Vzc29yLmpzIn0=
+//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByb2Nlc3Nvci5lczYiXSwibmFtZXMiOlsiUHJvY2Vzc29yIiwicGx1Z2lucyIsInZlcnNpb24iLCJub3JtYWxpemUiLCJ1c2UiLCJwbHVnaW4iLCJjb25jYXQiLCJwcm9jZXNzIiwiY3NzIiwib3B0cyIsImxlbmd0aCIsInBhcnNlciIsInN0cmluZ2lmaWVyIiwiZW52IiwiTk9ERV9FTlYiLCJjb25zb2xlIiwid2FybiIsIkxhenlSZXN1bHQiLCJub3JtYWxpemVkIiwiaSIsInBvc3Rjc3MiLCJBcnJheSIsImlzQXJyYXkiLCJwdXNoIiwicGFyc2UiLCJzdHJpbmdpZnkiLCJFcnJvciJdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQTs7OztBQUVBOzs7Ozs7Ozs7SUFTTUEsUzs7O0FBQ0o7Ozs7QUFJQSxxQkFBYUMsT0FBYixFQUEyQjtBQUFBLFFBQWRBLE9BQWM7QUFBZEEsTUFBQUEsT0FBYyxHQUFKLEVBQUk7QUFBQTs7QUFDekI7Ozs7Ozs7Ozs7QUFVQSxTQUFLQyxPQUFMLEdBQWUsUUFBZjtBQUNBOzs7Ozs7Ozs7O0FBU0EsU0FBS0QsT0FBTCxHQUFlLEtBQUtFLFNBQUwsQ0FBZUYsT0FBZixDQUFmO0FBQ0Q7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O1NBNkJBRyxHLEdBQUEsYUFBS0MsTUFBTCxFQUFhO0FBQ1gsU0FBS0osT0FBTCxHQUFlLEtBQUtBLE9BQUwsQ0FBYUssTUFBYixDQUFvQixLQUFLSCxTQUFMLENBQWUsQ0FBQ0UsTUFBRCxDQUFmLENBQXBCLENBQWY7QUFDQSxXQUFPLElBQVA7QUFDRDtBQUVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7U0FzQkFFLE87Ozs7Ozs7Ozs7SUFBQSxVQUFTQyxHQUFULEVBQWNDLElBQWQsRUFBMEI7QUFBQSxRQUFaQSxJQUFZO0FBQVpBLE1BQUFBLElBQVksR0FBTCxFQUFLO0FBQUE7O0FBQ3hCLFFBQUksS0FBS1IsT0FBTCxDQUFhUyxNQUFiLEtBQXdCLENBQXhCLElBQTZCRCxJQUFJLENBQUNFLE1BQUwsS0FBZ0JGLElBQUksQ0FBQ0csV0FBdEQsRUFBbUU7QUFDakUsVUFBSUwsT0FBTyxDQUFDTSxHQUFSLENBQVlDLFFBQVosS0FBeUIsWUFBN0IsRUFBMkM7QUFDekMsWUFBSSxPQUFPQyxPQUFQLEtBQW1CLFdBQW5CLElBQWtDQSxPQUFPLENBQUNDLElBQTlDLEVBQW9EO0FBQ2xERCxVQUFBQSxPQUFPLENBQUNDLElBQVIsQ0FDRSwwREFDQSw4REFEQSxHQUVBLGtFQUhGO0FBS0Q7QUFDRjtBQUNGOztBQUNELFdBQU8sSUFBSUMsbUJBQUosQ0FBZSxJQUFmLEVBQXFCVCxHQUFyQixFQUEwQkMsSUFBMUIsQ0FBUDtBQUNELEc7O1NBRUROLFMsR0FBQSxtQkFBV0YsT0FBWCxFQUFvQjtBQUNsQixRQUFJaUIsVUFBVSxHQUFHLEVBQWpCOztBQUNBLHlCQUFjakIsT0FBZCxrSEFBdUI7QUFBQTs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBOztBQUFBLFVBQWRrQixDQUFjO0FBQ3JCLFVBQUlBLENBQUMsQ0FBQ0MsT0FBTixFQUFlRCxDQUFDLEdBQUdBLENBQUMsQ0FBQ0MsT0FBTjs7QUFFZixVQUFJLE9BQU9ELENBQVAsS0FBYSxRQUFiLElBQXlCRSxLQUFLLENBQUNDLE9BQU4sQ0FBY0gsQ0FBQyxDQUFDbEIsT0FBaEIsQ0FBN0IsRUFBdUQ7QUFDckRpQixRQUFBQSxVQUFVLEdBQUdBLFVBQVUsQ0FBQ1osTUFBWCxDQUFrQmEsQ0FBQyxDQUFDbEIsT0FBcEIsQ0FBYjtBQUNELE9BRkQsTUFFTyxJQUFJLE9BQU9rQixDQUFQLEtBQWEsVUFBakIsRUFBNkI7QUFDbENELFFBQUFBLFVBQVUsQ0FBQ0ssSUFBWCxDQUFnQkosQ0FBaEI7QUFDRCxPQUZNLE1BRUEsSUFBSSxPQUFPQSxDQUFQLEtBQWEsUUFBYixLQUEwQkEsQ0FBQyxDQUFDSyxLQUFGLElBQVdMLENBQUMsQ0FBQ00sU0FBdkMsQ0FBSixFQUF1RDtBQUM1RCxZQUFJbEIsT0FBTyxDQUFDTSxHQUFSLENBQVlDLFFBQVosS0FBeUIsWUFBN0IsRUFBMkM7QUFDekMsZ0JBQU0sSUFBSVksS0FBSixDQUNKLHFFQUNBLDJEQURBLEdBRUEsdUNBSEksQ0FBTjtBQUtEO0FBQ0YsT0FSTSxNQVFBO0FBQ0wsY0FBTSxJQUFJQSxLQUFKLENBQVVQLENBQUMsR0FBRywwQkFBZCxDQUFOO0FBQ0Q7QUFDRjs7QUFDRCxXQUFPRCxVQUFQO0FBQ0QsRzs7Ozs7ZUFHWWxCLFM7QUFFZjs7Ozs7OztBQU9BOzs7Ozs7Ozs7O0FBVUE7Ozs7Ozs7Ozs7QUFVQTs7Ozs7O0FBTUE7Ozs7O0FBS0E7Ozs7OztBQU1BOzs7OztBQUtBIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IExhenlSZXN1bHQgZnJvbSAnLi9sYXp5LXJlc3VsdCdcblxuLyoqXG4gKiBDb250YWlucyBwbHVnaW5zIHRvIHByb2Nlc3MgQ1NTLiBDcmVhdGUgb25lIGBQcm9jZXNzb3JgIGluc3RhbmNlLFxuICogaW5pdGlhbGl6ZSBpdHMgcGx1Z2lucywgYW5kIHRoZW4gdXNlIHRoYXQgaW5zdGFuY2Ugb24gbnVtZXJvdXMgQ1NTIGZpbGVzLlxuICpcbiAqIEBleGFtcGxlXG4gKiBjb25zdCBwcm9jZXNzb3IgPSBwb3N0Y3NzKFthdXRvcHJlZml4ZXIsIHByZWNzc10pXG4gKiBwcm9jZXNzb3IucHJvY2Vzcyhjc3MxKS50aGVuKHJlc3VsdCA9PiBjb25zb2xlLmxvZyhyZXN1bHQuY3NzKSlcbiAqIHByb2Nlc3Nvci5wcm9jZXNzKGNzczIpLnRoZW4ocmVzdWx0ID0+IGNvbnNvbGUubG9nKHJlc3VsdC5jc3MpKVxuICovXG5jbGFzcyBQcm9jZXNzb3Ige1xuICAvKipcbiAgICogQHBhcmFtIHtBcnJheS48UGx1Z2lufHBsdWdpbkZ1bmN0aW9uPnxQcm9jZXNzb3J9IHBsdWdpbnMgUG9zdENTUyBwbHVnaW5zLlxuICAgKiAgICAgICAgU2VlIHtAbGluayBQcm9jZXNzb3IjdXNlfSBmb3IgcGx1Z2luIGZvcm1hdC5cbiAgICovXG4gIGNvbnN0cnVjdG9yIChwbHVnaW5zID0gW10pIHtcbiAgICAvKipcbiAgICAgKiBDdXJyZW50IFBvc3RDU1MgdmVyc2lvbi5cbiAgICAgKlxuICAgICAqIEB0eXBlIHtzdHJpbmd9XG4gICAgICpcbiAgICAgKiBAZXhhbXBsZVxuICAgICAqIGlmIChyZXN1bHQucHJvY2Vzc29yLnZlcnNpb24uc3BsaXQoJy4nKVswXSAhPT0gJzYnKSB7XG4gICAgICogICB0aHJvdyBuZXcgRXJyb3IoJ1RoaXMgcGx1Z2luIHdvcmtzIG9ubHkgd2l0aCBQb3N0Q1NTIDYnKVxuICAgICAqIH1cbiAgICAgKi9cbiAgICB0aGlzLnZlcnNpb24gPSAnNy4wLjMxJ1xuICAgIC8qKlxuICAgICAqIFBsdWdpbnMgYWRkZWQgdG8gdGhpcyBwcm9jZXNzb3IuXG4gICAgICpcbiAgICAgKiBAdHlwZSB7cGx1Z2luRnVuY3Rpb25bXX1cbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogY29uc3QgcHJvY2Vzc29yID0gcG9zdGNzcyhbYXV0b3ByZWZpeGVyLCBwcmVjc3NdKVxuICAgICAqIHByb2Nlc3Nvci5wbHVnaW5zLmxlbmd0aCAvLz0+IDJcbiAgICAgKi9cbiAgICB0aGlzLnBsdWdpbnMgPSB0aGlzLm5vcm1hbGl6ZShwbHVnaW5zKVxuICB9XG5cbiAgLyoqXG4gICAqIEFkZHMgYSBwbHVnaW4gdG8gYmUgdXNlZCBhcyBhIENTUyBwcm9jZXNzb3IuXG4gICAqXG4gICAqIFBvc3RDU1MgcGx1Z2luIGNhbiBiZSBpbiA0IGZvcm1hdHM6XG4gICAqICogQSBwbHVnaW4gY3JlYXRlZCBieSB7QGxpbmsgcG9zdGNzcy5wbHVnaW59IG1ldGhvZC5cbiAgICogKiBBIGZ1bmN0aW9uLiBQb3N0Q1NTIHdpbGwgcGFzcyB0aGUgZnVuY3Rpb24gYSBAe2xpbmsgUm9vdH1cbiAgICogICBhcyB0aGUgZmlyc3QgYXJndW1lbnQgYW5kIGN1cnJlbnQge0BsaW5rIFJlc3VsdH0gaW5zdGFuY2VcbiAgICogICBhcyB0aGUgc2Vjb25kLlxuICAgKiAqIEFuIG9iamVjdCB3aXRoIGEgYHBvc3Rjc3NgIG1ldGhvZC4gUG9zdENTUyB3aWxsIHVzZSB0aGF0IG1ldGhvZFxuICAgKiAgIGFzIGRlc2NyaWJlZCBpbiAjMi5cbiAgICogKiBBbm90aGVyIHtAbGluayBQcm9jZXNzb3J9IGluc3RhbmNlLiBQb3N0Q1NTIHdpbGwgY29weSBwbHVnaW5zXG4gICAqICAgZnJvbSB0aGF0IGluc3RhbmNlIGludG8gdGhpcyBvbmUuXG4gICAqXG4gICAqIFBsdWdpbnMgY2FuIGFsc28gYmUgYWRkZWQgYnkgcGFzc2luZyB0aGVtIGFzIGFyZ3VtZW50cyB3aGVuIGNyZWF0aW5nXG4gICAqIGEgYHBvc3Rjc3NgIGluc3RhbmNlIChzZWUgW2Bwb3N0Y3NzKHBsdWdpbnMpYF0pLlxuICAgKlxuICAgKiBBc3luY2hyb25vdXMgcGx1Z2lucyBzaG91bGQgcmV0dXJuIGEgYFByb21pc2VgIGluc3RhbmNlLlxuICAgKlxuICAgKiBAcGFyYW0ge1BsdWdpbnxwbHVnaW5GdW5jdGlvbnxQcm9jZXNzb3J9IHBsdWdpbiBQb3N0Q1NTIHBsdWdpblxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvciB7QGxpbmsgUHJvY2Vzc29yfVxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoIHBsdWdpbnMuXG4gICAqXG4gICAqIEBleGFtcGxlXG4gICAqIGNvbnN0IHByb2Nlc3NvciA9IHBvc3Rjc3MoKVxuICAgKiAgIC51c2UoYXV0b3ByZWZpeGVyKVxuICAgKiAgIC51c2UocHJlY3NzKVxuICAgKlxuICAgKiBAcmV0dXJuIHtQcm9jZXNzZXN9IEN1cnJlbnQgcHJvY2Vzc29yIHRvIG1ha2UgbWV0aG9kcyBjaGFpbi5cbiAgICovXG4gIHVzZSAocGx1Z2luKSB7XG4gICAgdGhpcy5wbHVnaW5zID0gdGhpcy5wbHVnaW5zLmNvbmNhdCh0aGlzLm5vcm1hbGl6ZShbcGx1Z2luXSkpXG4gICAgcmV0dXJuIHRoaXNcbiAgfVxuXG4gIC8qKlxuICAgKiBQYXJzZXMgc291cmNlIENTUyBhbmQgcmV0dXJucyBhIHtAbGluayBMYXp5UmVzdWx0fSBQcm9taXNlIHByb3h5LlxuICAgKiBCZWNhdXNlIHNvbWUgcGx1Z2lucyBjYW4gYmUgYXN5bmNocm9ub3VzIGl0IGRvZXNu4oCZdCBtYWtlXG4gICAqIGFueSB0cmFuc2Zvcm1hdGlvbnMuIFRyYW5zZm9ybWF0aW9ucyB3aWxsIGJlIGFwcGxpZWRcbiAgICogaW4gdGhlIHtAbGluayBMYXp5UmVzdWx0fSBtZXRob2RzLlxuICAgKlxuICAgKiBAcGFyYW0ge3N0cmluZ3x0b1N0cmluZ3xSZXN1bHR9IGNzcyBTdHJpbmcgd2l0aCBpbnB1dCBDU1Mgb3IgYW55IG9iamVjdFxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoIGEgYHRvU3RyaW5nKClgIG1ldGhvZCxcbiAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlrZSBhIEJ1ZmZlci4gT3B0aW9uYWxseSwgc2VuZFxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhIHtAbGluayBSZXN1bHR9IGluc3RhbmNlXG4gICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuZCB0aGUgcHJvY2Vzc29yIHdpbGwgdGFrZVxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGUge0BsaW5rIFJvb3R9IGZyb20gaXQuXG4gICAqIEBwYXJhbSB7cHJvY2Vzc09wdGlvbnN9IFtvcHRzXSAgICAgIE9wdGlvbnMuXG4gICAqXG4gICAqIEByZXR1cm4ge0xhenlSZXN1bHR9IFByb21pc2UgcHJveHkuXG4gICAqXG4gICAqIEBleGFtcGxlXG4gICAqIHByb2Nlc3Nvci5wcm9jZXNzKGNzcywgeyBmcm9tOiAnYS5jc3MnLCB0bzogJ2Eub3V0LmNzcycgfSlcbiAgICogICAudGhlbihyZXN1bHQgPT4ge1xuICAgKiAgICAgIGNvbnNvbGUubG9nKHJlc3VsdC5jc3MpXG4gICAqICAgfSlcbiAgICovXG4gIHByb2Nlc3MgKGNzcywgb3B0cyA9IHsgfSkge1xuICAgIGlmICh0aGlzLnBsdWdpbnMubGVuZ3RoID09PSAwICYmIG9wdHMucGFyc2VyID09PSBvcHRzLnN0cmluZ2lmaWVyKSB7XG4gICAgICBpZiAocHJvY2Vzcy5lbnYuTk9ERV9FTlYgIT09ICdwcm9kdWN0aW9uJykge1xuICAgICAgICBpZiAodHlwZW9mIGNvbnNvbGUgIT09ICd1bmRlZmluZWQnICYmIGNvbnNvbGUud2Fybikge1xuICAgICAgICAgIGNvbnNvbGUud2FybihcbiAgICAgICAgICAgICdZb3UgZGlkIG5vdCBzZXQgYW55IHBsdWdpbnMsIHBhcnNlciwgb3Igc3RyaW5naWZpZXIuICcgK1xuICAgICAgICAgICAgJ1JpZ2h0IG5vdywgUG9zdENTUyBkb2VzIG5vdGhpbmcuIFBpY2sgcGx1Z2lucyBmb3IgeW91ciBjYXNlICcgK1xuICAgICAgICAgICAgJ29uIGh0dHBzOi8vd3d3LnBvc3Rjc3MucGFydHMvIGFuZCB1c2UgdGhlbSBpbiBwb3N0Y3NzLmNvbmZpZy5qcy4nXG4gICAgICAgICAgKVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiBuZXcgTGF6eVJlc3VsdCh0aGlzLCBjc3MsIG9wdHMpXG4gIH1cblxuICBub3JtYWxpemUgKHBsdWdpbnMpIHtcbiAgICBsZXQgbm9ybWFsaXplZCA9IFtdXG4gICAgZm9yIChsZXQgaSBvZiBwbHVnaW5zKSB7XG4gICAgICBpZiAoaS5wb3N0Y3NzKSBpID0gaS5wb3N0Y3NzXG5cbiAgICAgIGlmICh0eXBlb2YgaSA9PT0gJ29iamVjdCcgJiYgQXJyYXkuaXNBcnJheShpLnBsdWdpbnMpKSB7XG4gICAgICAgIG5vcm1hbGl6ZWQgPSBub3JtYWxpemVkLmNvbmNhdChpLnBsdWdpbnMpXG4gICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIG5vcm1hbGl6ZWQucHVzaChpKVxuICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaSA9PT0gJ29iamVjdCcgJiYgKGkucGFyc2UgfHwgaS5zdHJpbmdpZnkpKSB7XG4gICAgICAgIGlmIChwcm9jZXNzLmVudi5OT0RFX0VOViAhPT0gJ3Byb2R1Y3Rpb24nKSB7XG4gICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxuICAgICAgICAgICAgJ1Bvc3RDU1Mgc3ludGF4ZXMgY2Fubm90IGJlIHVzZWQgYXMgcGx1Z2lucy4gSW5zdGVhZCwgcGxlYXNlIHVzZSAnICtcbiAgICAgICAgICAgICdvbmUgb2YgdGhlIHN5bnRheC9wYXJzZXIvc3RyaW5naWZpZXIgb3B0aW9ucyBhcyBvdXRsaW5lZCAnICtcbiAgICAgICAgICAgICdpbiB5b3VyIFBvc3RDU1MgcnVubmVyIGRvY3VtZW50YXRpb24uJ1xuICAgICAgICAgIClcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGkgKyAnIGlzIG5vdCBhIFBvc3RDU1MgcGx1Z2luJylcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIG5vcm1hbGl6ZWRcbiAgfVxufVxuXG5leHBvcnQgZGVmYXVsdCBQcm9jZXNzb3JcblxuLyoqXG4gKiBAY2FsbGJhY2sgYnVpbGRlclxuICogQHBhcmFtIHtzdHJpbmd9IHBhcnQgICAgICAgICAgUGFydCBvZiBnZW5lcmF0ZWQgQ1NTIGNvbm5lY3RlZCB0byB0aGlzIG5vZGUuXG4gKiBAcGFyYW0ge05vZGV9ICAgbm9kZSAgICAgICAgICBBU1Qgbm9kZS5cbiAqIEBwYXJhbSB7XCJzdGFydFwifFwiZW5kXCJ9IFt0eXBlXSBOb2Rl4oCZcyBwYXJ0IHR5cGUuXG4gKi9cblxuLyoqXG4gKiBAY2FsbGJhY2sgcGFyc2VyXG4gKlxuICogQHBhcmFtIHtzdHJpbmd8dG9TdHJpbmd9IGNzcyAgIFN0cmluZyB3aXRoIGlucHV0IENTUyBvciBhbnkgb2JqZWN0XG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2l0aCB0b1N0cmluZygpIG1ldGhvZCwgbGlrZSBhIEJ1ZmZlci5cbiAqIEBwYXJhbSB7cHJvY2Vzc09wdGlvbnN9IFtvcHRzXSBPcHRpb25zIHdpdGggb25seSBgZnJvbWAgYW5kIGBtYXBgIGtleXMuXG4gKlxuICogQHJldHVybiB7Um9vdH0gUG9zdENTUyBBU1RcbiAqL1xuXG4vKipcbiAqIEBjYWxsYmFjayBzdHJpbmdpZmllclxuICpcbiAqIEBwYXJhbSB7Tm9kZX0gbm9kZSAgICAgICBTdGFydCBub2RlIGZvciBzdHJpbmdpZmluZy4gVXN1YWxseSB7QGxpbmsgUm9vdH0uXG4gKiBAcGFyYW0ge2J1aWxkZXJ9IGJ1aWxkZXIgRnVuY3Rpb24gdG8gY29uY2F0ZW5hdGUgQ1NTIGZyb20gbm9kZeKAmXMgcGFydHNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICBvciBnZW5lcmF0ZSBzdHJpbmcgYW5kIHNvdXJjZSBtYXAuXG4gKlxuICogQHJldHVybiB7dm9pZH1cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHN5bnRheFxuICogQHByb3BlcnR5IHtwYXJzZXJ9IHBhcnNlICAgICAgICAgIEZ1bmN0aW9uIHRvIGdlbmVyYXRlIEFTVCBieSBzdHJpbmcuXG4gKiBAcHJvcGVydHkge3N0cmluZ2lmaWVyfSBzdHJpbmdpZnkgRnVuY3Rpb24gdG8gZ2VuZXJhdGUgc3RyaW5nIGJ5IEFTVC5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHRvU3RyaW5nXG4gKiBAcHJvcGVydHkge2Z1bmN0aW9ufSB0b1N0cmluZ1xuICovXG5cbi8qKlxuICogQGNhbGxiYWNrIHBsdWdpbkZ1bmN0aW9uXG4gKiBAcGFyYW0ge1Jvb3R9IHJvb3QgICAgIFBhcnNlZCBpbnB1dCBDU1MuXG4gKiBAcGFyYW0ge1Jlc3VsdH0gcmVzdWx0IFJlc3VsdCB0byBzZXQgd2FybmluZ3Mgb3IgY2hlY2sgb3RoZXIgcGx1Z2lucy5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IFBsdWdpblxuICogQHByb3BlcnR5IHtmdW5jdGlvbn0gcG9zdGNzcyBQb3N0Q1NTIHBsdWdpbiBmdW5jdGlvbi5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHByb2Nlc3NPcHRpb25zXG4gKiBAcHJvcGVydHkge3N0cmluZ30gZnJvbSAgICAgICAgICAgICBUaGUgcGF0aCBvZiB0aGUgQ1NTIHNvdXJjZSBmaWxlLlxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWW91IHNob3VsZCBhbHdheXMgc2V0IGBmcm9tYCxcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlY2F1c2UgaXQgaXMgdXNlZCBpbiBzb3VyY2UgbWFwXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZW5lcmF0aW9uIGFuZCBzeW50YXggZXJyb3IgbWVzc2FnZXMuXG4gKiBAcHJvcGVydHkge3N0cmluZ30gdG8gICAgICAgICAgICAgICBUaGUgcGF0aCB3aGVyZSB5b3XigJlsbCBwdXQgdGhlIG91dHB1dFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ1NTIGZpbGUuIFlvdSBzaG91bGQgYWx3YXlzIHNldCBgdG9gXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0byBnZW5lcmF0ZSBjb3JyZWN0IHNvdXJjZSBtYXBzLlxuICogQHByb3BlcnR5IHtwYXJzZXJ9IHBhcnNlciAgICAgICAgICAgRnVuY3Rpb24gdG8gZ2VuZXJhdGUgQVNUIGJ5IHN0cmluZy5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5naWZpZXJ9IHN0cmluZ2lmaWVyIENsYXNzIHRvIGdlbmVyYXRlIHN0cmluZyBieSBBU1QuXG4gKiBAcHJvcGVydHkge3N5bnRheH0gc3ludGF4ICAgICAgICAgICBPYmplY3Qgd2l0aCBgcGFyc2VgIGFuZCBgc3RyaW5naWZ5YC5cbiAqIEBwcm9wZXJ0eSB7b2JqZWN0fSBtYXAgICAgICAgICAgICAgIFNvdXJjZSBtYXAgb3B0aW9ucy5cbiAqIEBwcm9wZXJ0eSB7Ym9vbGVhbn0gbWFwLmlubGluZSAgICAgICAgICAgICAgICAgICAgRG9lcyBzb3VyY2UgbWFwIHNob3VsZFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZSBlbWJlZGRlZCBpbiB0aGUgb3V0cHV0XG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENTUyBhcyBhIGJhc2U2NC1lbmNvZGVkXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1lbnQuXG4gKiBAcHJvcGVydHkge3N0cmluZ3xvYmplY3R8ZmFsc2V8ZnVuY3Rpb259IG1hcC5wcmV2IFNvdXJjZSBtYXAgY29udGVudFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tIGEgcHJldmlvdXNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2luZyBzdGVwXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChmb3IgZXhhbXBsZSwgU2FzcykuXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBvc3RDU1Mgd2lsbCB0cnkgdG8gZmluZFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2aW91cyBtYXAgYXV0b21hdGljYWxseSxcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc28geW91IGNvdWxkIGRpc2FibGUgaXQgYnlcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYGZhbHNlYCB2YWx1ZS5cbiAqIEBwcm9wZXJ0eSB7Ym9vbGVhbn0gbWFwLnNvdXJjZXNDb250ZW50ICAgICAgICAgICAgRG9lcyBQb3N0Q1NTIHNob3VsZCBzZXRcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhlIG9yaWdpbiBjb250ZW50IHRvIG1hcC5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5nfGZhbHNlfSBtYXAuYW5ub3RhdGlvbiAgICAgICAgICAgRG9lcyBQb3N0Q1NTIHNob3VsZCBzZXRcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbiBjb21tZW50IHRvIG1hcC5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5nfSBtYXAuZnJvbSAgICAgICAgICAgICAgICAgICAgICAgT3ZlcnJpZGUgYGZyb21gIGluIG1hcOKAmXNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlc2AuXG4gKi9cbiJdLCJmaWxlIjoicHJvY2Vzc29yLmpzIn0=
/***/ }),
@@ -239751,8 +247003,31 @@ module.exports = Comma;
/***/ }),
-/* 790 */,
-/* 791 */,
+/* 790 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const compare = __webpack_require__(570)
+const gte = (a, b, loose) => compare(a, b, loose) >= 0
+module.exports = gte
+
+
+/***/ }),
+/* 791 */
+/***/ (function(module) {
+
+module.exports = function (x, opts) {
+ /**
+ * This file is purposefully a passthrough. It's expected that third-party
+ * environments will override it at runtime in order to inject special logic
+ * into `resolve` (by manipulating the options). One such example is the PnP
+ * code path in Yarn.
+ */
+
+ return opts || {};
+};
+
+
+/***/ }),
/* 792 */
/***/ (function(module, __unusedexports, __webpack_require__) {
@@ -239767,7 +247042,36 @@ module.exports = function getPolyfill() {
/***/ }),
-/* 793 */,
+/* 793 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+/*
+ * Copyright (c) 2012 Mathieu Turcotte
+ * Licensed under the MIT license.
+ */
+
+var util = __webpack_require__(669);
+
+function IllegalArgumentError(message) {
+ Error.call(this, message);
+ this.message = message;
+}
+util.inherits(IllegalArgumentError, Error);
+
+IllegalArgumentError.prototype.name = 'IllegalArgumentError';
+
+function IllegalStateError(message) {
+ Error.call(this, message);
+ this.message = message;
+}
+util.inherits(IllegalStateError, Error);
+
+IllegalStateError.prototype.name = 'IllegalStateError';
+
+module.exports.IllegalStateError = IllegalStateError;
+module.exports.IllegalArgumentError = IllegalArgumentError;
+
+/***/ }),
/* 794 */
/***/ (function(module, exports, __webpack_require__) {
@@ -240611,15 +247915,57 @@ if (util && util.inspect && util.inspect.custom) {
/* 801 */
/***/ (function(module, __unusedexports, __webpack_require__) {
+const { version: nodeVersion } = __webpack_require__(956)
+
+const findUp = __webpack_require__(957)
+const pathExists = __webpack_require__(757)
const resolve = __webpack_require__(371)
+const { lt: ltVersion } = __webpack_require__(94)
+
+// Find the path to a module's `package.json`
+// We need to use `resolve` instead of `require.resolve()` because:
+// - it is async
+// - it preserves symlinks:
+// - this is important because if a file does a `require('./symlink')`, we
+// need to bundle the symlink and its target, not only the target
+// - `path.resolve()` cannot be used for relative|absolute file paths
+// because it does not resolve ommitted file extension,
+// e.g. `require('./file')` instead of `require('./file.js')`
+// - the CLI flag `--preserve-symlinks` can be used with Node.js, but it
+// cannot be set runtime
+// However it does not give helpful error messages.
+// https://github.com/browserify/resolve/issues/223
+// So, on errors, we fallback to `require.resolve()`
+const resolvePackage = async function(moduleName, basedir) {
+ try {
+ return await resolvePathPreserveSymlinks(`${moduleName}/package.json`, basedir)
+ } catch (error) {
+ if (ltVersion(nodeVersion, REQUEST_RESOLVE_MIN_VERSION)) {
+ throw error
+ }
+
+ try {
+ return resolvePathFollowSymlinks(`${moduleName}/package.json`, basedir)
+ } catch (error) {
+ const packagePath = resolvePackageFallback(moduleName, basedir)
+ if (packagePath === undefined) {
+ throw error
+ }
+ return packagePath
+ }
+ }
+}
+
+// TODO: remove after dropping support for Node <8.9.0
+// `require.resolve()` option `paths` was introduced in Node 8.9.0
+const REQUEST_RESOLVE_MIN_VERSION = '8.9.0'
-// Like `require.resolve()` but works with a custom base directory.
// We need to use `new Promise()` due to a bug with `utils.promisify()` on
// `resolve`:
// https://github.com/browserify/resolve/issues/151#issuecomment-368210310
-const resolveLocation = function(location, basedir) {
+const resolvePathPreserveSymlinks = function(path, basedir) {
return new Promise((success, reject) => {
- resolve(location, { basedir, preserveSymlinks: true }, (error, resolvedLocation) => {
+ resolve(path, { basedir, preserveSymlinks: true }, (error, resolvedLocation) => {
if (error) {
return reject(error)
}
@@ -240629,7 +247975,36 @@ const resolveLocation = function(location, basedir) {
})
}
-module.exports = { resolveLocation }
+const resolvePathFollowSymlinks = function(path, basedir) {
+ return require.resolve(path, { paths: [basedir] })
+}
+
+// `require.resolve()` on a module's specific file (like `package.json`)
+// can be forbidden by the package author by using an `exports` field in
+// their `package.json`. We need this fallback.
+// It looks for the first directory up from a package's `main` file that:
+// - is named like the package
+// - has a `package.json`
+// Theoritically, this might not the root `package.json`, but this is very
+// unlikely, and we don't have any better alternative.
+const resolvePackageFallback = async function(moduleName, basedir) {
+ const mainFilePath = resolvePathFollowSymlinks(moduleName, basedir)
+ return findUp(isPackageDir.bind(null, moduleName), { cwd: mainFilePath, type: 'directory' })
+}
+
+const isPackageDir = async function(moduleName, dir) {
+ // Need to use `endsWith()` to take into account `@scope/package`.
+ // Backslashes need to be converted for Windows.
+ if (!dir.replace(BACKSLASH_REGEXP, '/').endsWith(moduleName) || !(await pathExists(`${dir}/package.json`))) {
+ return
+ }
+
+ return dir
+}
+
+const BACKSLASH_REGEXP = /\\/g
+
+module.exports = { resolvePackage, resolvePathPreserveSymlinks }
/***/ }),
@@ -240988,9 +248363,40 @@ module.exports = flatten;
/***/ }),
-/* 803 */,
-/* 804 */,
-/* 805 */,
+/* 803 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const parse = __webpack_require__(147)
+const valid = (version, options) => {
+ const v = parse(version, options)
+ return v ? v.version : null
+}
+module.exports = valid
+
+
+/***/ }),
+/* 804 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const compare = __webpack_require__(682)
+const eq = (a, b, loose) => compare(a, b, loose) === 0
+module.exports = eq
+
+
+/***/ }),
+/* 805 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const SemVer = __webpack_require__(369)
+const compareBuild = (a, b, loose) => {
+ const versionA = new SemVer(a, loose)
+ const versionB = new SemVer(b, loose)
+ return versionA.compare(versionB) || versionA.compareBuild(versionB)
+}
+module.exports = compareBuild
+
+
+/***/ }),
/* 806 */
/***/ (function(module) {
@@ -241250,7 +248656,12 @@ function whichSync (cmd, opt) {
/***/ }),
-/* 815 */,
+/* 815 */
+/***/ (function(module) {
+
+module.exports = {"assert":true,"async_hooks":">= 8","buffer_ieee754":"< 0.9.7","buffer":true,"child_process":true,"cluster":true,"console":true,"constants":true,"crypto":true,"_debug_agent":">= 1 && < 8","_debugger":"< 8","dgram":true,"dns":true,"domain":true,"events":true,"freelist":"< 6","fs":true,"fs/promises":">= 10 && < 10.1","_http_agent":">= 0.11.1","_http_client":">= 0.11.1","_http_common":">= 0.11.1","_http_incoming":">= 0.11.1","_http_outgoing":">= 0.11.1","_http_server":">= 0.11.1","http":true,"http2":">= 8.8","https":true,"inspector":">= 8.0.0","_linklist":"< 8","module":true,"net":true,"node-inspect/lib/_inspect":">= 7.6.0 && < 12","node-inspect/lib/internal/inspect_client":">= 7.6.0 && < 12","node-inspect/lib/internal/inspect_repl":">= 7.6.0 && < 12","os":true,"path":true,"perf_hooks":">= 8.5","process":">= 1","punycode":true,"querystring":true,"readline":true,"repl":true,"smalloc":">= 0.11.5 && < 3","_stream_duplex":">= 0.9.4","_stream_transform":">= 0.9.4","_stream_wrap":">= 1.4.1","_stream_passthrough":">= 0.9.4","_stream_readable":">= 0.9.4","_stream_writable":">= 0.9.4","stream":true,"string_decoder":true,"sys":true,"timers":true,"_tls_common":">= 0.11.13","_tls_legacy":">= 0.11.3 && < 10","_tls_wrap":">= 0.11.3","tls":true,"trace_events":">= 10","tty":true,"url":true,"util":true,"v8/tools/arguments":">= 10 && < 12","v8/tools/codemap":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/consarray":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/csvparser":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/logreader":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/profile_view":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/splaytree":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8":">= 1","vm":true,"wasi":">= 13.4 && < 13.5","worker_threads":">= 11.7","zlib":true};
+
+/***/ }),
/* 816 */
/***/ (function(module) {
@@ -243323,2113 +250734,755 @@ IndexedSourceMapConsumer.prototype.originalPositionFor =
});
var section = this._sections[sectionIndex];
- if (!section) {
- return {
- source: null,
- line: null,
- column: null,
- name: null
- };
- }
-
- return section.consumer.originalPositionFor({
- line: needle.generatedLine -
- (section.generatedOffset.generatedLine - 1),
- column: needle.generatedColumn -
- (section.generatedOffset.generatedLine === needle.generatedLine
- ? section.generatedOffset.generatedColumn - 1
- : 0),
- bias: aArgs.bias
- });
- };
-
-/**
- * Return true if we have the source content for every source in the source
- * map, false otherwise.
- */
-IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
- function IndexedSourceMapConsumer_hasContentsOfAllSources() {
- return this._sections.every(function (s) {
- return s.consumer.hasContentsOfAllSources();
- });
- };
-
-/**
- * Returns the original source content. The only argument is the url of the
- * original source file. Returns null if no original source content is
- * available.
- */
-IndexedSourceMapConsumer.prototype.sourceContentFor =
- function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
- for (var i = 0; i < this._sections.length; i++) {
- var section = this._sections[i];
-
- var content = section.consumer.sourceContentFor(aSource, true);
- if (content) {
- return content;
- }
- }
- if (nullOnMissing) {
- return null;
- }
- else {
- throw new Error('"' + aSource + '" is not in the SourceMap.');
- }
- };
-
-/**
- * Returns the generated line and column information for the original source,
- * line, and column positions provided. The only argument is an object with
- * the following properties:
- *
- * - source: The filename of the original source.
- * - line: The line number in the original source. The line number
- * is 1-based.
- * - column: The column number in the original source. The column
- * number is 0-based.
- *
- * and an object is returned with the following properties:
- *
- * - line: The line number in the generated source, or null. The
- * line number is 1-based.
- * - column: The column number in the generated source, or null.
- * The column number is 0-based.
- */
-IndexedSourceMapConsumer.prototype.generatedPositionFor =
- function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
- for (var i = 0; i < this._sections.length; i++) {
- var section = this._sections[i];
-
- // Only consider this section if the requested source is in the list of
- // sources of the consumer.
- if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
- continue;
- }
- var generatedPosition = section.consumer.generatedPositionFor(aArgs);
- if (generatedPosition) {
- var ret = {
- line: generatedPosition.line +
- (section.generatedOffset.generatedLine - 1),
- column: generatedPosition.column +
- (section.generatedOffset.generatedLine === generatedPosition.line
- ? section.generatedOffset.generatedColumn - 1
- : 0)
- };
- return ret;
- }
- }
-
- return {
- line: null,
- column: null
- };
- };
-
-/**
- * Parse the mappings in a string in to a data structure which we can easily
- * query (the ordered arrays in the `this.__generatedMappings` and
- * `this.__originalMappings` properties).
- */
-IndexedSourceMapConsumer.prototype._parseMappings =
- function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
- this.__generatedMappings = [];
- this.__originalMappings = [];
- for (var i = 0; i < this._sections.length; i++) {
- var section = this._sections[i];
- var sectionMappings = section.consumer._generatedMappings;
- for (var j = 0; j < sectionMappings.length; j++) {
- var mapping = sectionMappings[j];
-
- var source = section.consumer._sources.at(mapping.source);
- source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
- this._sources.add(source);
- source = this._sources.indexOf(source);
-
- var name = null;
- if (mapping.name) {
- name = section.consumer._names.at(mapping.name);
- this._names.add(name);
- name = this._names.indexOf(name);
- }
-
- // The mappings coming from the consumer for the section have
- // generated positions relative to the start of the section, so we
- // need to offset them to be relative to the start of the concatenated
- // generated file.
- var adjustedMapping = {
- source: source,
- generatedLine: mapping.generatedLine +
- (section.generatedOffset.generatedLine - 1),
- generatedColumn: mapping.generatedColumn +
- (section.generatedOffset.generatedLine === mapping.generatedLine
- ? section.generatedOffset.generatedColumn - 1
- : 0),
- originalLine: mapping.originalLine,
- originalColumn: mapping.originalColumn,
- name: name
- };
-
- this.__generatedMappings.push(adjustedMapping);
- if (typeof adjustedMapping.originalLine === 'number') {
- this.__originalMappings.push(adjustedMapping);
- }
- }
- }
-
- quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
- quickSort(this.__originalMappings, util.compareByOriginalPositions);
- };
-
-exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
-
-
-/***/ }),
-/* 820 */,
-/* 821 */
-/***/ (function(module, __unusedexports, __webpack_require__) {
-
-var toString = __webpack_require__(428),
- unescapeHtmlChar = __webpack_require__(673);
-
-/** Used to match HTML entities and HTML characters. */
-var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
- reHasEscapedHtml = RegExp(reEscapedHtml.source);
-
-/**
- * The inverse of `_.escape`; this method converts the HTML entities
- * `&`, `<`, `>`, `"`, and `'` in `string` to
- * their corresponding characters.
- *
- * **Note:** No other HTML entities are unescaped. To unescape additional
- * HTML entities use a third-party library like [_he_](https://mths.be/he).
- *
- * @static
- * @memberOf _
- * @since 0.6.0
- * @category String
- * @param {string} [string=''] The string to unescape.
- * @returns {string} Returns the unescaped string.
- * @example
- *
- * _.unescape('fred, barney, & pebbles');
- * // => 'fred, barney, & pebbles'
- */
-function unescape(string) {
- string = toString(string);
- return (string && reHasEscapedHtml.test(string))
- ? string.replace(reEscapedHtml, unescapeHtmlChar)
- : string;
-}
-
-module.exports = unescape;
-
-
-/***/ }),
-/* 822 */
-/***/ (function(module) {
-
-"use strict";
-
-
-if (typeof process === 'undefined' ||
- !process.version ||
- process.version.indexOf('v0.') === 0 ||
- process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
- module.exports = { nextTick: nextTick };
-} else {
- module.exports = process
-}
-
-function nextTick(fn, arg1, arg2, arg3) {
- if (typeof fn !== 'function') {
- throw new TypeError('"callback" argument must be a function');
- }
- var len = arguments.length;
- var args, i;
- switch (len) {
- case 0:
- case 1:
- return process.nextTick(fn);
- case 2:
- return process.nextTick(function afterTickOne() {
- fn.call(null, arg1);
- });
- case 3:
- return process.nextTick(function afterTickTwo() {
- fn.call(null, arg1, arg2);
- });
- case 4:
- return process.nextTick(function afterTickThree() {
- fn.call(null, arg1, arg2, arg3);
- });
- default:
- args = new Array(len - 1);
- i = 0;
- while (i < args.length) {
- args[i++] = arguments[i];
- }
- return process.nextTick(function afterTick() {
- fn.apply(null, args);
- });
- }
-}
-
-
-
-/***/ }),
-/* 823 */,
-/* 824 */
-/***/ (function(module, __unusedexports, __webpack_require__) {
-
-var freeGlobal = __webpack_require__(973);
-
-/** Detect free variable `self`. */
-var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
-
-/** Used as a reference to the global object. */
-var root = freeGlobal || freeSelf || Function('return this')();
-
-module.exports = root;
-
-
-/***/ }),
-/* 825 */,
-/* 826 */
-/***/ (function(module) {
-
-"use strict";
-
-
-/* eslint complexity: [2, 18], max-statements: [2, 33] */
-module.exports = function hasSymbols() {
- if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
- if (typeof Symbol.iterator === 'symbol') { return true; }
-
- var obj = {};
- var sym = Symbol('test');
- var symObj = Object(sym);
- if (typeof sym === 'string') { return false; }
-
- if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
- if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
-
- // temp disabled per https://github.com/ljharb/object.assign/issues/17
- // if (sym instanceof Symbol) { return false; }
- // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
- // if (!(symObj instanceof Symbol)) { return false; }
-
- // if (typeof Symbol.prototype.toString !== 'function') { return false; }
- // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
-
- var symVal = 42;
- obj[sym] = symVal;
- for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
- if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
-
- if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
-
- var syms = Object.getOwnPropertySymbols(obj);
- if (syms.length !== 1 || syms[0] !== sym) { return false; }
-
- if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
-
- if (typeof Object.getOwnPropertyDescriptor === 'function') {
- var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
- if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
- }
-
- return true;
-};
-
-
-/***/ }),
-/* 827 */,
-/* 828 */
-/***/ (function(module, __unusedexports, __webpack_require__) {
-
-"use strict";
-
-
-/**/
-
-var pna = __webpack_require__(822);
-/**/
-
-// undocumented cb() API, needed for core, not for public API
-function destroy(err, cb) {
- var _this = this;
-
- var readableDestroyed = this._readableState && this._readableState.destroyed;
- var writableDestroyed = this._writableState && this._writableState.destroyed;
-
- if (readableDestroyed || writableDestroyed) {
- if (cb) {
- cb(err);
- } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
- pna.nextTick(emitErrorNT, this, err);
- }
- return this;
- }
-
- // we set destroyed to true before firing error callbacks in order
- // to make it re-entrance safe in case destroy() is called within callbacks
-
- if (this._readableState) {
- this._readableState.destroyed = true;
- }
-
- // if this is a duplex stream mark the writable part as destroyed as well
- if (this._writableState) {
- this._writableState.destroyed = true;
- }
-
- this._destroy(err || null, function (err) {
- if (!cb && err) {
- pna.nextTick(emitErrorNT, _this, err);
- if (_this._writableState) {
- _this._writableState.errorEmitted = true;
- }
- } else if (cb) {
- cb(err);
- }
- });
-
- return this;
-}
-
-function undestroy() {
- if (this._readableState) {
- this._readableState.destroyed = false;
- this._readableState.reading = false;
- this._readableState.ended = false;
- this._readableState.endEmitted = false;
- }
-
- if (this._writableState) {
- this._writableState.destroyed = false;
- this._writableState.ended = false;
- this._writableState.ending = false;
- this._writableState.finished = false;
- this._writableState.errorEmitted = false;
- }
-}
-
-function emitErrorNT(self, err) {
- self.emit('error', err);
-}
-
-module.exports = {
- destroy: destroy,
- undestroy: undestroy
-};
-
-/***/ }),
-/* 829 */
-/***/ (function(__unusedmodule, exports) {
-
-/* -*- Mode: js; js-indent-level: 2; -*- */
-/*
- * Copyright 2011 Mozilla Foundation and contributors
- * Licensed under the New BSD license. See LICENSE or:
- * http://opensource.org/licenses/BSD-3-Clause
- */
-
-// It turns out that some (most?) JavaScript engines don't self-host
-// `Array.prototype.sort`. This makes sense because C++ will likely remain
-// faster than JS when doing raw CPU-intensive sorting. However, when using a
-// custom comparator function, calling back and forth between the VM's C++ and
-// JIT'd JS is rather slow *and* loses JIT type information, resulting in
-// worse generated code for the comparator function than would be optimal. In
-// fact, when sorting with a comparator, these costs outweigh the benefits of
-// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
-// a ~3500ms mean speed-up in `bench/bench.html`.
-
-/**
- * Swap the elements indexed by `x` and `y` in the array `ary`.
- *
- * @param {Array} ary
- * The array.
- * @param {Number} x
- * The index of the first item.
- * @param {Number} y
- * The index of the second item.
- */
-function swap(ary, x, y) {
- var temp = ary[x];
- ary[x] = ary[y];
- ary[y] = temp;
-}
-
-/**
- * Returns a random integer within the range `low .. high` inclusive.
- *
- * @param {Number} low
- * The lower bound on the range.
- * @param {Number} high
- * The upper bound on the range.
- */
-function randomIntInRange(low, high) {
- return Math.round(low + (Math.random() * (high - low)));
-}
-
-/**
- * The Quick Sort algorithm.
- *
- * @param {Array} ary
- * An array to sort.
- * @param {function} comparator
- * Function to use to compare two items.
- * @param {Number} p
- * Start index of the array
- * @param {Number} r
- * End index of the array
- */
-function doQuickSort(ary, comparator, p, r) {
- // If our lower bound is less than our upper bound, we (1) partition the
- // array into two pieces and (2) recurse on each half. If it is not, this is
- // the empty array and our base case.
-
- if (p < r) {
- // (1) Partitioning.
- //
- // The partitioning chooses a pivot between `p` and `r` and moves all
- // elements that are less than or equal to the pivot to the before it, and
- // all the elements that are greater than it after it. The effect is that
- // once partition is done, the pivot is in the exact place it will be when
- // the array is put in sorted order, and it will not need to be moved
- // again. This runs in O(n) time.
-
- // Always choose a random pivot so that an input array which is reverse
- // sorted does not cause O(n^2) running time.
- var pivotIndex = randomIntInRange(p, r);
- var i = p - 1;
-
- swap(ary, pivotIndex, r);
- var pivot = ary[r];
-
- // Immediately after `j` is incremented in this loop, the following hold
- // true:
- //
- // * Every element in `ary[p .. i]` is less than or equal to the pivot.
- //
- // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
- for (var j = p; j < r; j++) {
- if (comparator(ary[j], pivot) <= 0) {
- i += 1;
- swap(ary, i, j);
- }
- }
-
- swap(ary, i + 1, j);
- var q = i + 1;
-
- // (2) Recurse on each half.
-
- doQuickSort(ary, comparator, p, q - 1);
- doQuickSort(ary, comparator, q + 1, r);
- }
-}
-
-/**
- * Sort the given array in-place with the given comparator function.
- *
- * @param {Array} ary
- * An array to sort.
- * @param {function} comparator
- * Function to use to compare two items.
- */
-exports.quickSort = function (ary, comparator) {
- doQuickSort(ary, comparator, 0, ary.length - 1);
-};
-
-
-/***/ }),
-/* 830 */,
-/* 831 */
-/***/ (function(module, __unusedexports, __webpack_require__) {
-
-"use strict";
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-// a duplex stream is just a stream that is both readable and writable.
-// Since JS doesn't have multiple prototypal inheritance, this class
-// prototypally inherits from Readable, and then parasitically from
-// Writable.
-
-/**/
-
-var objectKeys = Object.keys || function (obj) {
- var keys = [];
-
- for (var key in obj) {
- keys.push(key);
- }
-
- return keys;
-};
-/**/
-
-
-module.exports = Duplex;
-
-var Readable = __webpack_require__(226);
-
-var Writable = __webpack_require__(241);
-
-__webpack_require__(689)(Duplex, Readable);
-
-{
- // Allow the keys array to be GC'ed.
- var keys = objectKeys(Writable.prototype);
-
- for (var v = 0; v < keys.length; v++) {
- var method = keys[v];
- if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
- }
-}
-
-function Duplex(options) {
- if (!(this instanceof Duplex)) return new Duplex(options);
- Readable.call(this, options);
- Writable.call(this, options);
- this.allowHalfOpen = true;
-
- if (options) {
- if (options.readable === false) this.readable = false;
- if (options.writable === false) this.writable = false;
-
- if (options.allowHalfOpen === false) {
- this.allowHalfOpen = false;
- this.once('end', onend);
- }
- }
-}
-
-Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
- // making it explicit this property is not enumerable
- // because otherwise some prototype manipulation in
- // userland will fail
- enumerable: false,
- get: function get() {
- return this._writableState.highWaterMark;
- }
-});
-Object.defineProperty(Duplex.prototype, 'writableBuffer', {
- // making it explicit this property is not enumerable
- // because otherwise some prototype manipulation in
- // userland will fail
- enumerable: false,
- get: function get() {
- return this._writableState && this._writableState.getBuffer();
- }
-});
-Object.defineProperty(Duplex.prototype, 'writableLength', {
- // making it explicit this property is not enumerable
- // because otherwise some prototype manipulation in
- // userland will fail
- enumerable: false,
- get: function get() {
- return this._writableState.length;
- }
-}); // the no-half-open enforcer
-
-function onend() {
- // If the writable side ended, then we're ok.
- if (this._writableState.ended) return; // no more data can be written.
- // But allow more writes to happen in this tick.
-
- process.nextTick(onEndNT, this);
-}
-
-function onEndNT(self) {
- self.end();
-}
-
-Object.defineProperty(Duplex.prototype, 'destroyed', {
- // making it explicit this property is not enumerable
- // because otherwise some prototype manipulation in
- // userland will fail
- enumerable: false,
- get: function get() {
- if (this._readableState === undefined || this._writableState === undefined) {
- return false;
- }
-
- return this._readableState.destroyed && this._writableState.destroyed;
- },
- set: function set(value) {
- // we ignore the value if the stream
- // has not been initialized yet
- if (this._readableState === undefined || this._writableState === undefined) {
- return;
- } // backward compatibility, the user is explicitly
- // managing destroyed
-
-
- this._readableState.destroyed = value;
- this._writableState.destroyed = value;
- }
-});
-
-/***/ }),
-/* 832 */
-/***/ (function(module, __unusedexports, __webpack_require__) {
-
-"use strict";
-
-
-module.exports = __webpack_require__(271).default;
-
-
-/***/ }),
-/* 833 */
-/***/ (function(__unusedmodule, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const ts = __webpack_require__(752);
-const node_1 = __webpack_require__(10);
-const _3_2_1 = __webpack_require__(584);
-const type_1 = __webpack_require__(90);
-function getChildOfKind(node, kind, sourceFile) {
- for (const child of node.getChildren(sourceFile))
- if (child.kind === kind)
- return child;
-}
-exports.getChildOfKind = getChildOfKind;
-function isTokenKind(kind) {
- return kind >= ts.SyntaxKind.FirstToken && kind <= ts.SyntaxKind.LastToken;
-}
-exports.isTokenKind = isTokenKind;
-function isNodeKind(kind) {
- return kind >= ts.SyntaxKind.FirstNode;
-}
-exports.isNodeKind = isNodeKind;
-function isAssignmentKind(kind) {
- return kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
-}
-exports.isAssignmentKind = isAssignmentKind;
-function isTypeNodeKind(kind) {
- return kind >= ts.SyntaxKind.FirstTypeNode && kind <= ts.SyntaxKind.LastTypeNode;
-}
-exports.isTypeNodeKind = isTypeNodeKind;
-function isJsDocKind(kind) {
- return kind >= ts.SyntaxKind.FirstJSDocNode && kind <= ts.SyntaxKind.LastJSDocNode;
-}
-exports.isJsDocKind = isJsDocKind;
-function isKeywordKind(kind) {
- return kind >= ts.SyntaxKind.FirstKeyword && kind <= ts.SyntaxKind.LastKeyword;
-}
-exports.isKeywordKind = isKeywordKind;
-function isThisParameter(parameter) {
- return parameter.name.kind === ts.SyntaxKind.Identifier && parameter.name.originalKeywordKind === ts.SyntaxKind.ThisKeyword;
-}
-exports.isThisParameter = isThisParameter;
-function getModifier(node, kind) {
- if (node.modifiers !== undefined)
- for (const modifier of node.modifiers)
- if (modifier.kind === kind)
- return modifier;
-}
-exports.getModifier = getModifier;
-function hasModifier(modifiers, ...kinds) {
- if (modifiers === undefined)
- return false;
- for (const modifier of modifiers)
- if (kinds.includes(modifier.kind))
- return true;
- return false;
-}
-exports.hasModifier = hasModifier;
-function isParameterProperty(node) {
- return hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ReadonlyKeyword);
-}
-exports.isParameterProperty = isParameterProperty;
-function hasAccessModifier(node) {
- return hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword);
-}
-exports.hasAccessModifier = hasAccessModifier;
-function isFlagSet(obj, flag) {
- return (obj.flags & flag) !== 0;
-}
-exports.isNodeFlagSet = isFlagSet;
-exports.isTypeFlagSet = isFlagSet;
-exports.isSymbolFlagSet = isFlagSet;
-function isObjectFlagSet(objectType, flag) {
- return (objectType.objectFlags & flag) !== 0;
-}
-exports.isObjectFlagSet = isObjectFlagSet;
-function isModifierFlagSet(node, flag) {
- return (ts.getCombinedModifierFlags(node) & flag) !== 0;
-}
-exports.isModifierFlagSet = isModifierFlagSet;
-function getPreviousStatement(statement) {
- const parent = statement.parent;
- if (node_1.isBlockLike(parent)) {
- const index = parent.statements.indexOf(statement);
- if (index > 0)
- return parent.statements[index - 1];
- }
-}
-exports.getPreviousStatement = getPreviousStatement;
-function getNextStatement(statement) {
- const parent = statement.parent;
- if (node_1.isBlockLike(parent)) {
- const index = parent.statements.indexOf(statement);
- if (index < parent.statements.length)
- return parent.statements[index + 1];
- }
-}
-exports.getNextStatement = getNextStatement;
-function getPreviousToken(node, sourceFile) {
- let parent = node.parent;
- while (parent !== undefined && parent.pos === node.pos)
- parent = parent.parent;
- if (parent === undefined)
- return;
- outer: while (true) {
- const children = parent.getChildren(sourceFile);
- for (let i = children.length - 1; i >= 0; --i) {
- const child = children[i];
- if (child.pos < node.pos && child.kind !== ts.SyntaxKind.JSDocComment) {
- if (isTokenKind(child.kind))
- return child;
- parent = child;
- continue outer;
- }
- }
- return;
- }
-}
-exports.getPreviousToken = getPreviousToken;
-function getNextToken(node, sourceFile = node.getSourceFile()) {
- if (node.kind === ts.SyntaxKind.SourceFile || node.kind === ts.SyntaxKind.EndOfFileToken)
- return;
- const end = node.end;
- node = node.parent;
- while (node.end === end) {
- if (node.parent === undefined)
- return node.endOfFileToken;
- node = node.parent;
- }
- return getTokenAtPositionWorker(node, end, sourceFile, false);
-}
-exports.getNextToken = getNextToken;
-function getTokenAtPosition(parent, pos, sourceFile, allowJsDoc) {
- if (pos < parent.pos || pos >= parent.end)
- return;
- if (isTokenKind(parent.kind))
- return parent;
- if (sourceFile === undefined)
- sourceFile = parent.getSourceFile();
- return getTokenAtPositionWorker(parent, pos, sourceFile, allowJsDoc === true);
-}
-exports.getTokenAtPosition = getTokenAtPosition;
-function getTokenAtPositionWorker(node, pos, sourceFile, allowJsDoc) {
- outer: while (true) {
- for (const child of node.getChildren(sourceFile)) {
- if (child.end > pos && (allowJsDoc || child.kind !== ts.SyntaxKind.JSDocComment)) {
- if (isTokenKind(child.kind))
- return child;
- node = child;
- continue outer;
- }
- }
- return;
- }
-}
-function getCommentAtPosition(sourceFile, pos, parent = sourceFile) {
- const token = getTokenAtPosition(parent, pos, sourceFile);
- if (token === undefined || token.kind === ts.SyntaxKind.JsxText || pos >= token.end - (ts.tokenToString(token.kind) || '').length)
- return;
- const startPos = token.pos === 0
- ? (ts.getShebang(sourceFile.text) || '').length
- : token.pos;
- return startPos !== 0 && ts.forEachTrailingCommentRange(sourceFile.text, startPos, commentAtPositionCallback, pos) ||
- ts.forEachLeadingCommentRange(sourceFile.text, startPos, commentAtPositionCallback, pos);
-}
-exports.getCommentAtPosition = getCommentAtPosition;
-function commentAtPositionCallback(pos, end, kind, _nl, at) {
- return at >= pos && at < end ? { pos, end, kind } : undefined;
-}
-function isPositionInComment(sourceFile, pos, parent) {
- return getCommentAtPosition(sourceFile, pos, parent) !== undefined;
-}
-exports.isPositionInComment = isPositionInComment;
-function commentText(sourceText, comment) {
- return sourceText.substring(comment.pos + 2, comment.kind === ts.SyntaxKind.SingleLineCommentTrivia ? comment.end : comment.end - 2);
-}
-exports.commentText = commentText;
-function getWrappedNodeAtPosition(wrap, pos) {
- if (wrap.node.pos > pos || wrap.node.end <= pos)
- return;
- outer: while (true) {
- for (const child of wrap.children) {
- if (child.node.pos > pos)
- return wrap;
- if (child.node.end > pos) {
- wrap = child;
- continue outer;
- }
- }
- return wrap;
- }
-}
-exports.getWrappedNodeAtPosition = getWrappedNodeAtPosition;
-function getPropertyName(propertyName) {
- if (propertyName.kind === ts.SyntaxKind.ComputedPropertyName) {
- if (!node_1.isLiteralExpression(propertyName.expression))
- return;
- if (_3_2_1.isBigIntLiteral(propertyName.expression))
- return propertyName.expression.text.slice(0, -1);
- return propertyName.expression.text;
- }
- return propertyName.text;
-}
-exports.getPropertyName = getPropertyName;
-function forEachDestructuringIdentifier(pattern, fn) {
- for (const element of pattern.elements) {
- if (element.kind !== ts.SyntaxKind.BindingElement)
- continue;
- let result;
- if (element.name.kind === ts.SyntaxKind.Identifier) {
- result = fn(element);
- }
- else {
- result = forEachDestructuringIdentifier(element.name, fn);
- }
- if (result)
- return result;
- }
-}
-exports.forEachDestructuringIdentifier = forEachDestructuringIdentifier;
-function forEachDeclaredVariable(declarationList, cb) {
- for (const declaration of declarationList.declarations) {
- let result;
- if (declaration.name.kind === ts.SyntaxKind.Identifier) {
- result = cb(declaration);
- }
- else {
- result = forEachDestructuringIdentifier(declaration.name, cb);
- }
- if (result)
- return result;
- }
-}
-exports.forEachDeclaredVariable = forEachDeclaredVariable;
-var VariableDeclarationKind;
-(function (VariableDeclarationKind) {
- VariableDeclarationKind[VariableDeclarationKind["Var"] = 0] = "Var";
- VariableDeclarationKind[VariableDeclarationKind["Let"] = 1] = "Let";
- VariableDeclarationKind[VariableDeclarationKind["Const"] = 2] = "Const";
-})(VariableDeclarationKind = exports.VariableDeclarationKind || (exports.VariableDeclarationKind = {}));
-function getVariableDeclarationKind(declarationList) {
- if (declarationList.flags & ts.NodeFlags.Let)
- return 1;
- if (declarationList.flags & ts.NodeFlags.Const)
- return 2;
- return 0;
-}
-exports.getVariableDeclarationKind = getVariableDeclarationKind;
-function isBlockScopedVariableDeclarationList(declarationList) {
- return (declarationList.flags & ts.NodeFlags.BlockScoped) !== 0;
-}
-exports.isBlockScopedVariableDeclarationList = isBlockScopedVariableDeclarationList;
-function isBlockScopedVariableDeclaration(declaration) {
- const parent = declaration.parent;
- return parent.kind === ts.SyntaxKind.CatchClause ||
- isBlockScopedVariableDeclarationList(parent);
-}
-exports.isBlockScopedVariableDeclaration = isBlockScopedVariableDeclaration;
-function isBlockScopedDeclarationStatement(statement) {
- switch (statement.kind) {
- case ts.SyntaxKind.VariableStatement:
- return isBlockScopedVariableDeclarationList(statement.declarationList);
- case ts.SyntaxKind.ClassDeclaration:
- case ts.SyntaxKind.EnumDeclaration:
- case ts.SyntaxKind.InterfaceDeclaration:
- case ts.SyntaxKind.TypeAliasDeclaration:
- return true;
- default:
- return false;
- }
-}
-exports.isBlockScopedDeclarationStatement = isBlockScopedDeclarationStatement;
-function isInSingleStatementContext(statement) {
- switch (statement.parent.kind) {
- case ts.SyntaxKind.ForStatement:
- case ts.SyntaxKind.ForInStatement:
- case ts.SyntaxKind.ForOfStatement:
- case ts.SyntaxKind.WhileStatement:
- case ts.SyntaxKind.DoStatement:
- case ts.SyntaxKind.IfStatement:
- case ts.SyntaxKind.WithStatement:
- case ts.SyntaxKind.LabeledStatement:
- return true;
- default:
- return false;
- }
-}
-exports.isInSingleStatementContext = isInSingleStatementContext;
-var ScopeBoundary;
-(function (ScopeBoundary) {
- ScopeBoundary[ScopeBoundary["None"] = 0] = "None";
- ScopeBoundary[ScopeBoundary["Function"] = 1] = "Function";
- ScopeBoundary[ScopeBoundary["Block"] = 2] = "Block";
- ScopeBoundary[ScopeBoundary["Type"] = 4] = "Type";
- ScopeBoundary[ScopeBoundary["ConditionalType"] = 8] = "ConditionalType";
-})(ScopeBoundary = exports.ScopeBoundary || (exports.ScopeBoundary = {}));
-var ScopeBoundarySelector;
-(function (ScopeBoundarySelector) {
- ScopeBoundarySelector[ScopeBoundarySelector["Function"] = 1] = "Function";
- ScopeBoundarySelector[ScopeBoundarySelector["Block"] = 3] = "Block";
- ScopeBoundarySelector[ScopeBoundarySelector["Type"] = 7] = "Type";
- ScopeBoundarySelector[ScopeBoundarySelector["InferType"] = 8] = "InferType";
-})(ScopeBoundarySelector = exports.ScopeBoundarySelector || (exports.ScopeBoundarySelector = {}));
-function isScopeBoundary(node) {
- return isFunctionScopeBoundary(node) || isBlockScopeBoundary(node) || isTypeScopeBoundary(node);
-}
-exports.isScopeBoundary = isScopeBoundary;
-function isTypeScopeBoundary(node) {
- switch (node.kind) {
- case ts.SyntaxKind.InterfaceDeclaration:
- case ts.SyntaxKind.TypeAliasDeclaration:
- case ts.SyntaxKind.MappedType:
- return 4;
- case ts.SyntaxKind.ConditionalType:
- return 8;
- default:
- return 0;
- }
-}
-exports.isTypeScopeBoundary = isTypeScopeBoundary;
-function isFunctionScopeBoundary(node) {
- switch (node.kind) {
- case ts.SyntaxKind.FunctionExpression:
- case ts.SyntaxKind.ArrowFunction:
- case ts.SyntaxKind.Constructor:
- case ts.SyntaxKind.ModuleDeclaration:
- case ts.SyntaxKind.ClassDeclaration:
- case ts.SyntaxKind.ClassExpression:
- case ts.SyntaxKind.EnumDeclaration:
- case ts.SyntaxKind.MethodDeclaration:
- case ts.SyntaxKind.FunctionDeclaration:
- case ts.SyntaxKind.GetAccessor:
- case ts.SyntaxKind.SetAccessor:
- case ts.SyntaxKind.MethodSignature:
- case ts.SyntaxKind.CallSignature:
- case ts.SyntaxKind.ConstructSignature:
- case ts.SyntaxKind.ConstructorType:
- case ts.SyntaxKind.FunctionType:
- return 1;
- case ts.SyntaxKind.SourceFile:
- return ts.isExternalModule(node) ? 1 : 0;
- default:
- return 0;
- }
-}
-exports.isFunctionScopeBoundary = isFunctionScopeBoundary;
-function isBlockScopeBoundary(node) {
- switch (node.kind) {
- case ts.SyntaxKind.Block:
- const parent = node.parent;
- return parent.kind !== ts.SyntaxKind.CatchClause &&
- (parent.kind === ts.SyntaxKind.SourceFile ||
- !isFunctionScopeBoundary(parent))
- ? 2
- : 0;
- case ts.SyntaxKind.ForStatement:
- case ts.SyntaxKind.ForInStatement:
- case ts.SyntaxKind.ForOfStatement:
- case ts.SyntaxKind.CaseBlock:
- case ts.SyntaxKind.CatchClause:
- case ts.SyntaxKind.WithStatement:
- return 2;
- default:
- return 0;
- }
-}
-exports.isBlockScopeBoundary = isBlockScopeBoundary;
-function hasOwnThisReference(node) {
- switch (node.kind) {
- case ts.SyntaxKind.ClassDeclaration:
- case ts.SyntaxKind.ClassExpression:
- case ts.SyntaxKind.FunctionExpression:
- return true;
- case ts.SyntaxKind.FunctionDeclaration:
- return node.body !== undefined;
- case ts.SyntaxKind.MethodDeclaration:
- case ts.SyntaxKind.GetAccessor:
- case ts.SyntaxKind.SetAccessor:
- return node.parent.kind === ts.SyntaxKind.ObjectLiteralExpression;
- default:
- return false;
- }
-}
-exports.hasOwnThisReference = hasOwnThisReference;
-function isFunctionWithBody(node) {
- switch (node.kind) {
- case ts.SyntaxKind.GetAccessor:
- case ts.SyntaxKind.SetAccessor:
- case ts.SyntaxKind.FunctionDeclaration:
- case ts.SyntaxKind.MethodDeclaration:
- case ts.SyntaxKind.Constructor:
- return node.body !== undefined;
- case ts.SyntaxKind.FunctionExpression:
- case ts.SyntaxKind.ArrowFunction:
- return true;
- default:
- return false;
- }
-}
-exports.isFunctionWithBody = isFunctionWithBody;
-function forEachToken(node, cb, sourceFile = node.getSourceFile()) {
- return (function iterate(child) {
- if (isTokenKind(child.kind))
- return cb(child);
- if (child.kind !== ts.SyntaxKind.JSDocComment)
- return child.getChildren(sourceFile).forEach(iterate);
- })(node);
-}
-exports.forEachToken = forEachToken;
-function forEachTokenWithTrivia(node, cb, sourceFile = node.getSourceFile()) {
- const fullText = sourceFile.text;
- const scanner = ts.createScanner(sourceFile.languageVersion, false, sourceFile.languageVariant, fullText);
- return forEachToken(node, (token) => {
- const tokenStart = token.kind === ts.SyntaxKind.JsxText || token.pos === token.end ? token.pos : token.getStart(sourceFile);
- if (tokenStart !== token.pos) {
- scanner.setTextPos(token.pos);
- let kind = scanner.scan();
- let pos = scanner.getTokenPos();
- while (pos < tokenStart) {
- const textPos = scanner.getTextPos();
- cb(fullText, kind, { pos, end: textPos }, token.parent);
- if (textPos === tokenStart)
- break;
- kind = scanner.scan();
- pos = scanner.getTokenPos();
- }
- }
- return cb(fullText, token.kind, { end: token.end, pos: tokenStart }, token.parent);
- }, sourceFile);
-}
-exports.forEachTokenWithTrivia = forEachTokenWithTrivia;
-function forEachComment(node, cb, sourceFile = node.getSourceFile()) {
- const fullText = sourceFile.text;
- const notJsx = sourceFile.languageVariant !== ts.LanguageVariant.JSX;
- return forEachToken(node, (token) => {
- if (token.pos === token.end)
- return;
- if (token.kind !== ts.SyntaxKind.JsxText)
- ts.forEachLeadingCommentRange(fullText, token.pos === 0 ? (ts.getShebang(fullText) || '').length : token.pos, commentCallback);
- if (notJsx || canHaveTrailingTrivia(token))
- return ts.forEachTrailingCommentRange(fullText, token.end, commentCallback);
- }, sourceFile);
- function commentCallback(pos, end, kind) {
- cb(fullText, { pos, end, kind });
- }
-}
-exports.forEachComment = forEachComment;
-function canHaveTrailingTrivia(token) {
- switch (token.kind) {
- case ts.SyntaxKind.CloseBraceToken:
- return token.parent.kind !== ts.SyntaxKind.JsxExpression || !isJsxElementOrFragment(token.parent.parent);
- case ts.SyntaxKind.GreaterThanToken:
- switch (token.parent.kind) {
- case ts.SyntaxKind.JsxOpeningElement:
- return token.end !== token.parent.end;
- case ts.SyntaxKind.JsxOpeningFragment:
- return false;
- case ts.SyntaxKind.JsxSelfClosingElement:
- return token.end !== token.parent.end ||
- !isJsxElementOrFragment(token.parent.parent);
- case ts.SyntaxKind.JsxClosingElement:
- case ts.SyntaxKind.JsxClosingFragment:
- return !isJsxElementOrFragment(token.parent.parent.parent);
- }
- }
- return true;
-}
-function isJsxElementOrFragment(node) {
- return node.kind === ts.SyntaxKind.JsxElement || node.kind === ts.SyntaxKind.JsxFragment;
-}
-function getLineRanges(sourceFile) {
- const lineStarts = sourceFile.getLineStarts();
- const result = [];
- const length = lineStarts.length;
- const sourceText = sourceFile.text;
- let pos = 0;
- for (let i = 1; i < length; ++i) {
- const end = lineStarts[i];
- let lineEnd = end;
- for (; lineEnd > pos; --lineEnd)
- if (!ts.isLineBreak(sourceText.charCodeAt(lineEnd - 1)))
- break;
- result.push({
- pos,
- end,
- contentLength: lineEnd - pos,
- });
- pos = end;
- }
- result.push({
- pos,
- end: sourceFile.end,
- contentLength: sourceFile.end - pos,
- });
- return result;
-}
-exports.getLineRanges = getLineRanges;
-function getLineBreakStyle(sourceFile) {
- const lineStarts = sourceFile.getLineStarts();
- return lineStarts.length === 1 || lineStarts[1] < 2 || sourceFile.text[lineStarts[1] - 2] !== '\r'
- ? '\n'
- : '\r\n';
-}
-exports.getLineBreakStyle = getLineBreakStyle;
-let cachedScanner;
-function scanToken(text, languageVersion) {
- if (cachedScanner === undefined) {
- cachedScanner = ts.createScanner(languageVersion, false, undefined, text);
- }
- else {
- cachedScanner.setScriptTarget(languageVersion);
- cachedScanner.setText(text);
- }
- cachedScanner.scan();
- return cachedScanner;
-}
-function isValidIdentifier(text, languageVersion = ts.ScriptTarget.Latest) {
- const scan = scanToken(text, languageVersion);
- return scan.isIdentifier() && scan.getTextPos() === text.length && scan.getTokenPos() === 0;
-}
-exports.isValidIdentifier = isValidIdentifier;
-function charSize(ch) {
- return ch >= 0x10000 ? 2 : 1;
-}
-function isValidPropertyAccess(text, languageVersion = ts.ScriptTarget.Latest) {
- if (text.length === 0)
- return false;
- let ch = text.codePointAt(0);
- if (!ts.isIdentifierStart(ch, languageVersion))
- return false;
- for (let i = charSize(ch); i < text.length; i += charSize(ch)) {
- ch = text.codePointAt(i);
- if (!ts.isIdentifierPart(ch, languageVersion))
- return false;
- }
- return true;
-}
-exports.isValidPropertyAccess = isValidPropertyAccess;
-function isValidPropertyName(text, languageVersion = ts.ScriptTarget.Latest) {
- if (isValidPropertyAccess(text, languageVersion))
- return true;
- const scan = scanToken(text, languageVersion);
- return scan.getTextPos() === text.length &&
- scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTokenValue() === text;
-}
-exports.isValidPropertyName = isValidPropertyName;
-function isValidNumericLiteral(text, languageVersion = ts.ScriptTarget.Latest) {
- const scan = scanToken(text, languageVersion);
- return scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTextPos() === text.length && scan.getTokenPos() === 0;
-}
-exports.isValidNumericLiteral = isValidNumericLiteral;
-function isValidJsxIdentifier(text, languageVersion = ts.ScriptTarget.Latest) {
- if (text.length === 0)
- return false;
- let ch = text.codePointAt(0);
- if (!ts.isIdentifierStart(ch, languageVersion))
- return false;
- for (let i = charSize(ch); i < text.length; i += charSize(ch)) {
- ch = text.codePointAt(i);
- if (!ts.isIdentifierPart(ch, languageVersion) && ch !== 45)
- return false;
- }
- return true;
-}
-exports.isValidJsxIdentifier = isValidJsxIdentifier;
-function isNumericPropertyName(name) {
- return String(+name) === name;
-}
-exports.isNumericPropertyName = isNumericPropertyName;
-function isSameLine(sourceFile, pos1, pos2) {
- return ts.getLineAndCharacterOfPosition(sourceFile, pos1).line === ts.getLineAndCharacterOfPosition(sourceFile, pos2).line;
-}
-exports.isSameLine = isSameLine;
-var SideEffectOptions;
-(function (SideEffectOptions) {
- SideEffectOptions[SideEffectOptions["None"] = 0] = "None";
- SideEffectOptions[SideEffectOptions["TaggedTemplate"] = 1] = "TaggedTemplate";
- SideEffectOptions[SideEffectOptions["Constructor"] = 2] = "Constructor";
- SideEffectOptions[SideEffectOptions["JsxElement"] = 4] = "JsxElement";
-})(SideEffectOptions = exports.SideEffectOptions || (exports.SideEffectOptions = {}));
-function hasSideEffects(node, options) {
- switch (node.kind) {
- case ts.SyntaxKind.CallExpression:
- case ts.SyntaxKind.PostfixUnaryExpression:
- case ts.SyntaxKind.AwaitExpression:
- case ts.SyntaxKind.YieldExpression:
- case ts.SyntaxKind.DeleteExpression:
- return true;
- case ts.SyntaxKind.TypeAssertionExpression:
- case ts.SyntaxKind.AsExpression:
- case ts.SyntaxKind.ParenthesizedExpression:
- case ts.SyntaxKind.NonNullExpression:
- case ts.SyntaxKind.VoidExpression:
- case ts.SyntaxKind.TypeOfExpression:
- case ts.SyntaxKind.PropertyAccessExpression:
- case ts.SyntaxKind.SpreadElement:
- case ts.SyntaxKind.PartiallyEmittedExpression:
- return hasSideEffects(node.expression, options);
- case ts.SyntaxKind.BinaryExpression:
- return isAssignmentKind(node.operatorToken.kind) ||
- hasSideEffects(node.left, options) ||
- hasSideEffects(node.right, options);
- case ts.SyntaxKind.PrefixUnaryExpression:
- switch (node.operator) {
- case ts.SyntaxKind.PlusPlusToken:
- case ts.SyntaxKind.MinusMinusToken:
- return true;
- default:
- return hasSideEffects(node.operand, options);
- }
- case ts.SyntaxKind.ElementAccessExpression:
- return hasSideEffects(node.expression, options) ||
- node.argumentExpression !== undefined &&
- hasSideEffects(node.argumentExpression, options);
- case ts.SyntaxKind.ConditionalExpression:
- return hasSideEffects(node.condition, options) ||
- hasSideEffects(node.whenTrue, options) ||
- hasSideEffects(node.whenFalse, options);
- case ts.SyntaxKind.NewExpression:
- if (options & 2 || hasSideEffects(node.expression, options))
- return true;
- if (node.arguments !== undefined)
- for (const child of node.arguments)
- if (hasSideEffects(child, options))
- return true;
- return false;
- case ts.SyntaxKind.TaggedTemplateExpression:
- if (options & 1 || hasSideEffects(node.tag, options))
- return true;
- if (node.template.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral)
- return false;
- node = node.template;
- case ts.SyntaxKind.TemplateExpression:
- for (const child of node.templateSpans)
- if (hasSideEffects(child.expression, options))
- return true;
- return false;
- case ts.SyntaxKind.ClassExpression:
- return classExpressionHasSideEffects(node, options);
- case ts.SyntaxKind.ArrayLiteralExpression:
- for (const child of node.elements)
- if (hasSideEffects(child, options))
- return true;
- return false;
- case ts.SyntaxKind.ObjectLiteralExpression:
- for (const child of node.properties) {
- if (child.name !== undefined && child.name.kind === ts.SyntaxKind.ComputedPropertyName &&
- hasSideEffects(child.name.expression, options))
- return true;
- switch (child.kind) {
- case ts.SyntaxKind.PropertyAssignment:
- if (hasSideEffects(child.initializer, options))
- return true;
- break;
- case ts.SyntaxKind.SpreadAssignment:
- if (hasSideEffects(child.expression, options))
- return true;
- }
- }
- return false;
- case ts.SyntaxKind.JsxExpression:
- return node.expression !== undefined && hasSideEffects(node.expression, options);
- case ts.SyntaxKind.JsxElement:
- case ts.SyntaxKind.JsxFragment:
- for (const child of node.children)
- if (child.kind !== ts.SyntaxKind.JsxText && hasSideEffects(child, options))
- return true;
- if (node.kind === ts.SyntaxKind.JsxFragment)
- return false;
- node = node.openingElement;
- case ts.SyntaxKind.JsxSelfClosingElement:
- case ts.SyntaxKind.JsxOpeningElement:
- if (options & 4)
- return true;
- for (const child of node.attributes.properties) {
- if (child.kind === ts.SyntaxKind.JsxSpreadAttribute) {
- if (hasSideEffects(child.expression, options))
- return true;
- }
- else if (child.initializer !== undefined && hasSideEffects(child.initializer, options)) {
- return true;
- }
- }
- return false;
- case ts.SyntaxKind.CommaListExpression:
- for (const child of node.elements)
- if (hasSideEffects(child, options))
- return true;
- return false;
- default:
- return false;
- }
-}
-exports.hasSideEffects = hasSideEffects;
-function classExpressionHasSideEffects(node, options) {
- if (node.heritageClauses !== undefined && node.heritageClauses[0].token === ts.SyntaxKind.ExtendsKeyword)
- for (const base of node.heritageClauses[0].types)
- if (hasSideEffects(base.expression, options))
- return true;
- for (const child of node.members)
- if (child.name !== undefined && child.name.kind === ts.SyntaxKind.ComputedPropertyName &&
- hasSideEffects(child.name.expression, options) ||
- node_1.isPropertyDeclaration(child) && child.initializer !== undefined &&
- hasSideEffects(child.initializer, options))
- return true;
- return false;
-}
-function getDeclarationOfBindingElement(node) {
- let parent = node.parent.parent;
- while (parent.kind === ts.SyntaxKind.BindingElement)
- parent = parent.parent.parent;
- return parent;
-}
-exports.getDeclarationOfBindingElement = getDeclarationOfBindingElement;
-function isExpressionValueUsed(node) {
- while (true) {
- const parent = node.parent;
- switch (parent.kind) {
- case ts.SyntaxKind.CallExpression:
- case ts.SyntaxKind.NewExpression:
- case ts.SyntaxKind.ElementAccessExpression:
- case ts.SyntaxKind.WhileStatement:
- case ts.SyntaxKind.DoStatement:
- case ts.SyntaxKind.WithStatement:
- case ts.SyntaxKind.ThrowStatement:
- case ts.SyntaxKind.ReturnStatement:
- case ts.SyntaxKind.JsxExpression:
- case ts.SyntaxKind.JsxSpreadAttribute:
- case ts.SyntaxKind.JsxElement:
- case ts.SyntaxKind.JsxFragment:
- case ts.SyntaxKind.JsxSelfClosingElement:
- case ts.SyntaxKind.ComputedPropertyName:
- case ts.SyntaxKind.ArrowFunction:
- case ts.SyntaxKind.ExportSpecifier:
- case ts.SyntaxKind.ExportAssignment:
- case ts.SyntaxKind.ImportDeclaration:
- case ts.SyntaxKind.ExternalModuleReference:
- case ts.SyntaxKind.Decorator:
- case ts.SyntaxKind.TaggedTemplateExpression:
- case ts.SyntaxKind.TemplateSpan:
- case ts.SyntaxKind.ExpressionWithTypeArguments:
- case ts.SyntaxKind.TypeOfExpression:
- case ts.SyntaxKind.AwaitExpression:
- case ts.SyntaxKind.YieldExpression:
- case ts.SyntaxKind.LiteralType:
- case ts.SyntaxKind.JsxAttributes:
- case ts.SyntaxKind.JsxOpeningElement:
- case ts.SyntaxKind.JsxClosingElement:
- case ts.SyntaxKind.IfStatement:
- case ts.SyntaxKind.CaseClause:
- case ts.SyntaxKind.SwitchStatement:
- return true;
- case ts.SyntaxKind.PropertyAccessExpression:
- return parent.expression === node;
- case ts.SyntaxKind.QualifiedName:
- return parent.left === node;
- case ts.SyntaxKind.ShorthandPropertyAssignment:
- return parent.objectAssignmentInitializer === node ||
- !isInDestructuringAssignment(parent);
- case ts.SyntaxKind.PropertyAssignment:
- return parent.initializer === node && !isInDestructuringAssignment(parent);
- case ts.SyntaxKind.SpreadAssignment:
- case ts.SyntaxKind.SpreadElement:
- case ts.SyntaxKind.ArrayLiteralExpression:
- return !isInDestructuringAssignment(parent);
- case ts.SyntaxKind.ParenthesizedExpression:
- case ts.SyntaxKind.AsExpression:
- case ts.SyntaxKind.TypeAssertionExpression:
- case ts.SyntaxKind.PostfixUnaryExpression:
- case ts.SyntaxKind.PrefixUnaryExpression:
- case ts.SyntaxKind.NonNullExpression:
- node = parent;
- break;
- case ts.SyntaxKind.ForStatement:
- return parent.condition === node;
- case ts.SyntaxKind.ForInStatement:
- case ts.SyntaxKind.ForOfStatement:
- return parent.expression === node;
- case ts.SyntaxKind.ConditionalExpression:
- if (parent.condition === node)
- return true;
- node = parent;
- break;
- case ts.SyntaxKind.PropertyDeclaration:
- case ts.SyntaxKind.BindingElement:
- case ts.SyntaxKind.VariableDeclaration:
- case ts.SyntaxKind.Parameter:
- case ts.SyntaxKind.EnumMember:
- return parent.initializer === node;
- case ts.SyntaxKind.ImportEqualsDeclaration:
- return parent.moduleReference === node;
- case ts.SyntaxKind.CommaListExpression:
- if (parent.elements[parent.elements.length - 1] !== node)
- return false;
- node = parent;
- break;
- case ts.SyntaxKind.BinaryExpression:
- if (parent.right === node) {
- if (parent.operatorToken.kind === ts.SyntaxKind.CommaToken) {
- node = parent;
- break;
- }
- return true;
- }
- switch (parent.operatorToken.kind) {
- case ts.SyntaxKind.CommaToken:
- case ts.SyntaxKind.EqualsToken:
- return false;
- case ts.SyntaxKind.EqualsEqualsEqualsToken:
- case ts.SyntaxKind.EqualsEqualsToken:
- case ts.SyntaxKind.ExclamationEqualsEqualsToken:
- case ts.SyntaxKind.ExclamationEqualsToken:
- case ts.SyntaxKind.InstanceOfKeyword:
- case ts.SyntaxKind.PlusToken:
- case ts.SyntaxKind.MinusToken:
- case ts.SyntaxKind.AsteriskToken:
- case ts.SyntaxKind.SlashToken:
- case ts.SyntaxKind.PercentToken:
- case ts.SyntaxKind.AsteriskAsteriskToken:
- case ts.SyntaxKind.GreaterThanToken:
- case ts.SyntaxKind.GreaterThanGreaterThanToken:
- case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
- case ts.SyntaxKind.GreaterThanEqualsToken:
- case ts.SyntaxKind.LessThanToken:
- case ts.SyntaxKind.LessThanLessThanToken:
- case ts.SyntaxKind.LessThanEqualsToken:
- case ts.SyntaxKind.AmpersandToken:
- case ts.SyntaxKind.BarToken:
- case ts.SyntaxKind.CaretToken:
- case ts.SyntaxKind.BarBarToken:
- case ts.SyntaxKind.AmpersandAmpersandToken:
- case ts.SyntaxKind.InKeyword:
- return true;
- default:
- node = parent;
- }
- break;
- default:
- return false;
- }
- }
-}
-exports.isExpressionValueUsed = isExpressionValueUsed;
-function isInDestructuringAssignment(node) {
- switch (node.kind) {
- case ts.SyntaxKind.ShorthandPropertyAssignment:
- if (node.objectAssignmentInitializer !== undefined)
- return true;
- case ts.SyntaxKind.PropertyAssignment:
- case ts.SyntaxKind.SpreadAssignment:
- node = node.parent;
- break;
- case ts.SyntaxKind.SpreadElement:
- if (node.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression)
- return false;
- node = node.parent;
- }
- while (true) {
- switch (node.parent.kind) {
- case ts.SyntaxKind.BinaryExpression:
- return node.parent.left === node &&
- node.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken;
- case ts.SyntaxKind.ForOfStatement:
- return node.parent.initializer === node;
- case ts.SyntaxKind.ArrayLiteralExpression:
- case ts.SyntaxKind.ObjectLiteralExpression:
- node = node.parent;
- break;
- case ts.SyntaxKind.SpreadAssignment:
- case ts.SyntaxKind.PropertyAssignment:
- node = node.parent.parent;
- break;
- case ts.SyntaxKind.SpreadElement:
- if (node.parent.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression)
- return false;
- node = node.parent.parent;
- break;
- default:
- return false;
- }
- }
-}
-var AccessKind;
-(function (AccessKind) {
- AccessKind[AccessKind["None"] = 0] = "None";
- AccessKind[AccessKind["Read"] = 1] = "Read";
- AccessKind[AccessKind["Write"] = 2] = "Write";
- AccessKind[AccessKind["Delete"] = 4] = "Delete";
- AccessKind[AccessKind["ReadWrite"] = 3] = "ReadWrite";
- AccessKind[AccessKind["Modification"] = 6] = "Modification";
-})(AccessKind = exports.AccessKind || (exports.AccessKind = {}));
-function getAccessKind(node) {
- const parent = node.parent;
- switch (parent.kind) {
- case ts.SyntaxKind.DeleteExpression:
- return 4;
- case ts.SyntaxKind.PostfixUnaryExpression:
- return 3;
- case ts.SyntaxKind.PrefixUnaryExpression:
- return parent.operator === ts.SyntaxKind.PlusPlusToken ||
- parent.operator === ts.SyntaxKind.MinusMinusToken
- ? 3
- : 1;
- case ts.SyntaxKind.BinaryExpression:
- return parent.right === node
- ? 1
- : !isAssignmentKind(parent.operatorToken.kind)
- ? 1
- : parent.operatorToken.kind === ts.SyntaxKind.EqualsToken
- ? 2
- : 3;
- case ts.SyntaxKind.ShorthandPropertyAssignment:
- return parent.objectAssignmentInitializer === node
- ? 1
- : isInDestructuringAssignment(parent)
- ? 2
- : 1;
- case ts.SyntaxKind.PropertyAssignment:
- return parent.name === node
- ? 0
- : isInDestructuringAssignment(parent)
- ? 2
- : 1;
- case ts.SyntaxKind.ArrayLiteralExpression:
- case ts.SyntaxKind.SpreadElement:
- case ts.SyntaxKind.SpreadAssignment:
- return isInDestructuringAssignment(parent)
- ? 2
- : 1;
- case ts.SyntaxKind.ParenthesizedExpression:
- case ts.SyntaxKind.NonNullExpression:
- case ts.SyntaxKind.TypeAssertionExpression:
- case ts.SyntaxKind.AsExpression:
- return getAccessKind(parent);
- case ts.SyntaxKind.ForOfStatement:
- case ts.SyntaxKind.ForInStatement:
- return parent.initializer === node
- ? 2
- : 1;
- case ts.SyntaxKind.ExpressionWithTypeArguments:
- return parent.parent.token === ts.SyntaxKind.ExtendsKeyword &&
- parent.parent.parent.kind !== ts.SyntaxKind.InterfaceDeclaration
- ? 1
- : 0;
- case ts.SyntaxKind.ComputedPropertyName:
- case ts.SyntaxKind.ExpressionStatement:
- case ts.SyntaxKind.TypeOfExpression:
- case ts.SyntaxKind.ElementAccessExpression:
- case ts.SyntaxKind.ForStatement:
- case ts.SyntaxKind.IfStatement:
- case ts.SyntaxKind.DoStatement:
- case ts.SyntaxKind.WhileStatement:
- case ts.SyntaxKind.SwitchStatement:
- case ts.SyntaxKind.WithStatement:
- case ts.SyntaxKind.ThrowStatement:
- case ts.SyntaxKind.CallExpression:
- case ts.SyntaxKind.NewExpression:
- case ts.SyntaxKind.TaggedTemplateExpression:
- case ts.SyntaxKind.JsxExpression:
- case ts.SyntaxKind.Decorator:
- case ts.SyntaxKind.TemplateSpan:
- case ts.SyntaxKind.JsxOpeningElement:
- case ts.SyntaxKind.JsxSelfClosingElement:
- case ts.SyntaxKind.JsxSpreadAttribute:
- case ts.SyntaxKind.VoidExpression:
- case ts.SyntaxKind.ReturnStatement:
- case ts.SyntaxKind.AwaitExpression:
- case ts.SyntaxKind.YieldExpression:
- case ts.SyntaxKind.ConditionalExpression:
- case ts.SyntaxKind.CaseClause:
- case ts.SyntaxKind.JsxElement:
- return 1;
- case ts.SyntaxKind.ArrowFunction:
- return parent.body === node
- ? 1
- : 2;
- case ts.SyntaxKind.PropertyDeclaration:
- case ts.SyntaxKind.VariableDeclaration:
- case ts.SyntaxKind.Parameter:
- case ts.SyntaxKind.EnumMember:
- case ts.SyntaxKind.BindingElement:
- case ts.SyntaxKind.JsxAttribute:
- return parent.initializer === node
- ? 1
- : 0;
- case ts.SyntaxKind.PropertyAccessExpression:
- return parent.expression === node
- ? 1
- : 0;
- case ts.SyntaxKind.ExportAssignment:
- return parent.isExportEquals
- ? 1
- : 0;
- }
- return 0;
-}
-exports.getAccessKind = getAccessKind;
-function isReassignmentTarget(node) {
- return (getAccessKind(node) & 2) !== 0;
-}
-exports.isReassignmentTarget = isReassignmentTarget;
-function canHaveJsDoc(node) {
- const kind = node.kind;
- switch (kind) {
- case ts.SyntaxKind.Parameter:
- case ts.SyntaxKind.CallSignature:
- case ts.SyntaxKind.ConstructSignature:
- case ts.SyntaxKind.MethodSignature:
- case ts.SyntaxKind.PropertySignature:
- case ts.SyntaxKind.ArrowFunction:
- case ts.SyntaxKind.ParenthesizedExpression:
- case ts.SyntaxKind.SpreadAssignment:
- case ts.SyntaxKind.ShorthandPropertyAssignment:
- case ts.SyntaxKind.PropertyAssignment:
- case ts.SyntaxKind.FunctionExpression:
- case ts.SyntaxKind.FunctionDeclaration:
- case ts.SyntaxKind.LabeledStatement:
- case ts.SyntaxKind.ExpressionStatement:
- case ts.SyntaxKind.VariableStatement:
- case ts.SyntaxKind.Constructor:
- case ts.SyntaxKind.MethodDeclaration:
- case ts.SyntaxKind.PropertyDeclaration:
- case ts.SyntaxKind.GetAccessor:
- case ts.SyntaxKind.SetAccessor:
- case ts.SyntaxKind.ClassDeclaration:
- case ts.SyntaxKind.ClassExpression:
- case ts.SyntaxKind.InterfaceDeclaration:
- case ts.SyntaxKind.TypeAliasDeclaration:
- case ts.SyntaxKind.EnumMember:
- case ts.SyntaxKind.EnumDeclaration:
- case ts.SyntaxKind.ModuleDeclaration:
- case ts.SyntaxKind.ImportEqualsDeclaration:
- case ts.SyntaxKind.IndexSignature:
- case ts.SyntaxKind.FunctionType:
- case ts.SyntaxKind.ConstructorType:
- case ts.SyntaxKind.JSDocFunctionType:
- case ts.SyntaxKind.EndOfFileToken:
- case ts.SyntaxKind.ExportDeclaration:
- return true;
- default:
- return false;
- }
-}
-exports.canHaveJsDoc = canHaveJsDoc;
-function getJsDoc(node, sourceFile) {
- if (node.kind === ts.SyntaxKind.EndOfFileToken)
- return parseJsDocWorker(node, sourceFile || node.parent);
- const result = [];
- for (const child of node.getChildren(sourceFile)) {
- if (!node_1.isJsDoc(child))
- break;
- result.push(child);
- }
- return result;
-}
-exports.getJsDoc = getJsDoc;
-function parseJsDocOfNode(node, considerTrailingComments, sourceFile = node.getSourceFile()) {
- if (canHaveJsDoc(node) && node.kind !== ts.SyntaxKind.EndOfFileToken) {
- const result = getJsDoc(node, sourceFile);
- if (result.length !== 0 || !considerTrailingComments)
- return result;
- }
- return parseJsDocWorker(node, sourceFile, considerTrailingComments);
-}
-exports.parseJsDocOfNode = parseJsDocOfNode;
-function parseJsDocWorker(node, sourceFile, considerTrailingComments) {
- const nodeStart = node.getStart(sourceFile);
- const start = ts[considerTrailingComments && isSameLine(sourceFile, node.pos, nodeStart)
- ? 'forEachTrailingCommentRange'
- : 'forEachLeadingCommentRange'](sourceFile.text, node.pos, (pos, _end, kind) => kind === ts.SyntaxKind.MultiLineCommentTrivia && sourceFile.text[pos + 2] === '*' ? { pos } : undefined);
- if (start === undefined)
- return [];
- const startPos = start.pos;
- const text = sourceFile.text.slice(startPos, nodeStart);
- const newSourceFile = ts.createSourceFile('jsdoc.ts', `${text}var a;`, sourceFile.languageVersion);
- const result = getJsDoc(newSourceFile.statements[0], newSourceFile);
- for (const doc of result)
- updateNode(doc, node);
- return result;
- function updateNode(n, parent) {
- n.pos += startPos;
- n.end += startPos;
- n.parent = parent;
- return ts.forEachChild(n, (child) => updateNode(child, n), (children) => {
- children.pos += startPos;
- children.end += startPos;
- for (const child of children)
- updateNode(child, n);
- });
- }
-}
-var ImportKind;
-(function (ImportKind) {
- ImportKind[ImportKind["ImportDeclaration"] = 1] = "ImportDeclaration";
- ImportKind[ImportKind["ImportEquals"] = 2] = "ImportEquals";
- ImportKind[ImportKind["ExportFrom"] = 4] = "ExportFrom";
- ImportKind[ImportKind["DynamicImport"] = 8] = "DynamicImport";
- ImportKind[ImportKind["Require"] = 16] = "Require";
- ImportKind[ImportKind["ImportType"] = 32] = "ImportType";
- ImportKind[ImportKind["All"] = 63] = "All";
- ImportKind[ImportKind["AllImports"] = 59] = "AllImports";
- ImportKind[ImportKind["AllStaticImports"] = 3] = "AllStaticImports";
- ImportKind[ImportKind["AllImportExpressions"] = 24] = "AllImportExpressions";
- ImportKind[ImportKind["AllRequireLike"] = 18] = "AllRequireLike";
- ImportKind[ImportKind["AllNestedImports"] = 56] = "AllNestedImports";
- ImportKind[ImportKind["AllTopLevelImports"] = 7] = "AllTopLevelImports";
-})(ImportKind = exports.ImportKind || (exports.ImportKind = {}));
-function findImports(sourceFile, kinds) {
- const result = [];
- for (const node of findImportLikeNodes(sourceFile, kinds)) {
- switch (node.kind) {
- case ts.SyntaxKind.ImportDeclaration:
- addIfTextualLiteral(node.moduleSpecifier);
- break;
- case ts.SyntaxKind.ImportEqualsDeclaration:
- addIfTextualLiteral(node.moduleReference.expression);
- break;
- case ts.SyntaxKind.ExportDeclaration:
- addIfTextualLiteral(node.moduleSpecifier);
- break;
- case ts.SyntaxKind.CallExpression:
- addIfTextualLiteral(node.arguments[0]);
- break;
- case ts.SyntaxKind.ImportType:
- if (node_1.isLiteralTypeNode(node.argument))
- addIfTextualLiteral(node.argument.literal);
- break;
- default:
- throw new Error('unexpected node');
- }
- }
- return result;
- function addIfTextualLiteral(node) {
- if (node_1.isTextualLiteral(node))
- result.push(node);
- }
-}
-exports.findImports = findImports;
-function findImportLikeNodes(sourceFile, kinds) {
- return new ImportFinder(sourceFile, kinds).find();
-}
-exports.findImportLikeNodes = findImportLikeNodes;
-class ImportFinder {
- constructor(_sourceFile, _options) {
- this._sourceFile = _sourceFile;
- this._options = _options;
- this._result = [];
+ if (!section) {
+ return {
+ source: null,
+ line: null,
+ column: null,
+ name: null
+ };
}
- find() {
- if (this._sourceFile.isDeclarationFile)
- this._options &= ~24;
- if (this._options & 7)
- this._findImports(this._sourceFile.statements);
- if (this._options & 56)
- this._findNestedImports();
- return this._result;
+
+ return section.consumer.originalPositionFor({
+ line: needle.generatedLine -
+ (section.generatedOffset.generatedLine - 1),
+ column: needle.generatedColumn -
+ (section.generatedOffset.generatedLine === needle.generatedLine
+ ? section.generatedOffset.generatedColumn - 1
+ : 0),
+ bias: aArgs.bias
+ });
+ };
+
+/**
+ * Return true if we have the source content for every source in the source
+ * map, false otherwise.
+ */
+IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
+ function IndexedSourceMapConsumer_hasContentsOfAllSources() {
+ return this._sections.every(function (s) {
+ return s.consumer.hasContentsOfAllSources();
+ });
+ };
+
+/**
+ * Returns the original source content. The only argument is the url of the
+ * original source file. Returns null if no original source content is
+ * available.
+ */
+IndexedSourceMapConsumer.prototype.sourceContentFor =
+ function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
+ for (var i = 0; i < this._sections.length; i++) {
+ var section = this._sections[i];
+
+ var content = section.consumer.sourceContentFor(aSource, true);
+ if (content) {
+ return content;
+ }
}
- _findImports(statements) {
- for (const statement of statements) {
- if (node_1.isImportDeclaration(statement)) {
- if (this._options & 1)
- this._result.push(statement);
- }
- else if (node_1.isImportEqualsDeclaration(statement)) {
- if (this._options & 2 &&
- statement.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference)
- this._result.push(statement);
- }
- else if (node_1.isExportDeclaration(statement)) {
- if (statement.moduleSpecifier !== undefined && this._options & 4)
- this._result.push(statement);
- }
- else if (node_1.isModuleDeclaration(statement)) {
- this._findImportsInModule(statement);
- }
- }
+ if (nullOnMissing) {
+ return null;
}
- _findImportsInModule(declaration) {
- if (declaration.body === undefined)
- return;
- if (declaration.body.kind === ts.SyntaxKind.ModuleDeclaration)
- return this._findImportsInModule(declaration.body);
- this._findImports(declaration.body.statements);
+ else {
+ throw new Error('"' + aSource + '" is not in the SourceMap.');
}
- _findNestedImports() {
- let re;
- if ((this._options & 56) === 16) {
- re = /\brequire\s*[(]/g;
- }
- else if (this._options & 16) {
- re = /\b(?:import|require)\s*[(]/g;
- }
- else {
- re = /\bimport\s*[(]/g;
+ };
+
+/**
+ * Returns the generated line and column information for the original source,
+ * line, and column positions provided. The only argument is an object with
+ * the following properties:
+ *
+ * - source: The filename of the original source.
+ * - line: The line number in the original source. The line number
+ * is 1-based.
+ * - column: The column number in the original source. The column
+ * number is 0-based.
+ *
+ * and an object is returned with the following properties:
+ *
+ * - line: The line number in the generated source, or null. The
+ * line number is 1-based.
+ * - column: The column number in the generated source, or null.
+ * The column number is 0-based.
+ */
+IndexedSourceMapConsumer.prototype.generatedPositionFor =
+ function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
+ for (var i = 0; i < this._sections.length; i++) {
+ var section = this._sections[i];
+
+ // Only consider this section if the requested source is in the list of
+ // sources of the consumer.
+ if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
+ continue;
+ }
+ var generatedPosition = section.consumer.generatedPositionFor(aArgs);
+ if (generatedPosition) {
+ var ret = {
+ line: generatedPosition.line +
+ (section.generatedOffset.generatedLine - 1),
+ column: generatedPosition.column +
+ (section.generatedOffset.generatedLine === generatedPosition.line
+ ? section.generatedOffset.generatedColumn - 1
+ : 0)
+ };
+ return ret;
+ }
+ }
+
+ return {
+ line: null,
+ column: null
+ };
+ };
+
+/**
+ * Parse the mappings in a string in to a data structure which we can easily
+ * query (the ordered arrays in the `this.__generatedMappings` and
+ * `this.__originalMappings` properties).
+ */
+IndexedSourceMapConsumer.prototype._parseMappings =
+ function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
+ this.__generatedMappings = [];
+ this.__originalMappings = [];
+ for (var i = 0; i < this._sections.length; i++) {
+ var section = this._sections[i];
+ var sectionMappings = section.consumer._generatedMappings;
+ for (var j = 0; j < sectionMappings.length; j++) {
+ var mapping = sectionMappings[j];
+
+ var source = section.consumer._sources.at(mapping.source);
+ source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
+ this._sources.add(source);
+ source = this._sources.indexOf(source);
+
+ var name = null;
+ if (mapping.name) {
+ name = section.consumer._names.at(mapping.name);
+ this._names.add(name);
+ name = this._names.indexOf(name);
}
- const isJavaScriptFile = (this._sourceFile.flags & ts.NodeFlags.JavaScriptFile) !== 0;
- for (let match = re.exec(this._sourceFile.text); match !== null; match = re.exec(this._sourceFile.text)) {
- const token = getTokenAtPositionWorker(this._sourceFile, match.index, this._sourceFile, match[0][0] === 'i' && isJavaScriptFile);
- if (token.kind === ts.SyntaxKind.ImportKeyword) {
- if (token.end - 'import'.length !== match.index)
- continue;
- switch (token.parent.kind) {
- case ts.SyntaxKind.ImportType:
- this._result.push(token.parent);
- break;
- case ts.SyntaxKind.CallExpression:
- if (token.parent.arguments.length === 1)
- this._result.push(token.parent);
- }
- }
- else if (token.kind === ts.SyntaxKind.Identifier &&
- token.end - 'require'.length === match.index &&
- token.parent.kind === ts.SyntaxKind.CallExpression &&
- token.parent.expression === token &&
- token.parent.arguments.length === 1) {
- this._result.push(token.parent);
- }
+
+ // The mappings coming from the consumer for the section have
+ // generated positions relative to the start of the section, so we
+ // need to offset them to be relative to the start of the concatenated
+ // generated file.
+ var adjustedMapping = {
+ source: source,
+ generatedLine: mapping.generatedLine +
+ (section.generatedOffset.generatedLine - 1),
+ generatedColumn: mapping.generatedColumn +
+ (section.generatedOffset.generatedLine === mapping.generatedLine
+ ? section.generatedOffset.generatedColumn - 1
+ : 0),
+ originalLine: mapping.originalLine,
+ originalColumn: mapping.originalColumn,
+ name: name
+ };
+
+ this.__generatedMappings.push(adjustedMapping);
+ if (typeof adjustedMapping.originalLine === 'number') {
+ this.__originalMappings.push(adjustedMapping);
}
+ }
}
+
+ quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
+ quickSort(this.__originalMappings, util.compareByOriginalPositions);
+ };
+
+exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
+
+
+/***/ }),
+/* 820 */,
+/* 821 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+var toString = __webpack_require__(428),
+ unescapeHtmlChar = __webpack_require__(673);
+
+/** Used to match HTML entities and HTML characters. */
+var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
+ reHasEscapedHtml = RegExp(reEscapedHtml.source);
+
+/**
+ * The inverse of `_.escape`; this method converts the HTML entities
+ * `&`, `<`, `>`, `"`, and `'` in `string` to
+ * their corresponding characters.
+ *
+ * **Note:** No other HTML entities are unescaped. To unescape additional
+ * HTML entities use a third-party library like [_he_](https://mths.be/he).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.6.0
+ * @category String
+ * @param {string} [string=''] The string to unescape.
+ * @returns {string} Returns the unescaped string.
+ * @example
+ *
+ * _.unescape('fred, barney, & pebbles');
+ * // => 'fred, barney, & pebbles'
+ */
+function unescape(string) {
+ string = toString(string);
+ return (string && reHasEscapedHtml.test(string))
+ ? string.replace(reEscapedHtml, unescapeHtmlChar)
+ : string;
}
-function isStatementInAmbientContext(node) {
- while (node.flags & ts.NodeFlags.NestedNamespace)
- node = node.parent;
- return hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword) || isAmbientModuleBlock(node.parent);
-}
-exports.isStatementInAmbientContext = isStatementInAmbientContext;
-function isAmbientModuleBlock(node) {
- while (node.kind === ts.SyntaxKind.ModuleBlock) {
- do
- node = node.parent;
- while (node.flags & ts.NodeFlags.NestedNamespace);
- if (hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword))
- return true;
- node = node.parent;
- }
- return false;
-}
-exports.isAmbientModuleBlock = isAmbientModuleBlock;
-function getIIFE(func) {
- let node = func.parent;
- while (node.kind === ts.SyntaxKind.ParenthesizedExpression)
- node = node.parent;
- return node_1.isCallExpression(node) && func.end <= node.expression.end ? node : undefined;
-}
-exports.getIIFE = getIIFE;
-function isStrictCompilerOptionEnabled(options, option) {
- return (options.strict ? options[option] !== false : options[option] === true) &&
- (option !== 'strictPropertyInitialization' || isStrictCompilerOptionEnabled(options, 'strictNullChecks'));
+
+module.exports = unescape;
+
+
+/***/ }),
+/* 822 */
+/***/ (function(module) {
+
+"use strict";
+
+
+if (typeof process === 'undefined' ||
+ !process.version ||
+ process.version.indexOf('v0.') === 0 ||
+ process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
+ module.exports = { nextTick: nextTick };
+} else {
+ module.exports = process
}
-exports.isStrictCompilerOptionEnabled = isStrictCompilerOptionEnabled;
-function isCompilerOptionEnabled(options, option) {
- switch (option) {
- case 'stripInternal':
- return options.stripInternal === true && isCompilerOptionEnabled(options, 'declaration');
- case 'declaration':
- return options.declaration || isCompilerOptionEnabled(options, 'composite');
- case 'incremental':
- return options.incremental === undefined ? isCompilerOptionEnabled(options, 'composite') : options.incremental;
- case 'skipDefaultLibCheck':
- return options.skipDefaultLibCheck || isCompilerOptionEnabled(options, 'skipLibCheck');
- case 'suppressImplicitAnyIndexErrors':
- return options.suppressImplicitAnyIndexErrors === true && isCompilerOptionEnabled(options, 'noImplicitAny');
- case 'allowSyntheticDefaultImports':
- return options.allowSyntheticDefaultImports !== undefined
- ? options.allowSyntheticDefaultImports
- : isCompilerOptionEnabled(options, 'esModuleInterop') || options.module === ts.ModuleKind.System;
- case 'noImplicitAny':
- case 'noImplicitThis':
- case 'strictNullChecks':
- case 'strictFunctionTypes':
- case 'strictPropertyInitialization':
- case 'alwaysStrict':
- case 'strictBindCallApply':
- return isStrictCompilerOptionEnabled(options, option);
+
+function nextTick(fn, arg1, arg2, arg3) {
+ if (typeof fn !== 'function') {
+ throw new TypeError('"callback" argument must be a function');
+ }
+ var len = arguments.length;
+ var args, i;
+ switch (len) {
+ case 0:
+ case 1:
+ return process.nextTick(fn);
+ case 2:
+ return process.nextTick(function afterTickOne() {
+ fn.call(null, arg1);
+ });
+ case 3:
+ return process.nextTick(function afterTickTwo() {
+ fn.call(null, arg1, arg2);
+ });
+ case 4:
+ return process.nextTick(function afterTickThree() {
+ fn.call(null, arg1, arg2, arg3);
+ });
+ default:
+ args = new Array(len - 1);
+ i = 0;
+ while (i < args.length) {
+ args[i++] = arguments[i];
}
- return options[option] === true;
-}
-exports.isCompilerOptionEnabled = isCompilerOptionEnabled;
-function isAmbientModule(node) {
- return node.name.kind === ts.SyntaxKind.StringLiteral || (node.flags & ts.NodeFlags.GlobalAugmentation) !== 0;
-}
-exports.isAmbientModule = isAmbientModule;
-function getCheckJsDirective(source) {
- let directive;
- ts.forEachLeadingCommentRange(source, (ts.getShebang(source) || '').length, (pos, end, kind) => {
- if (kind === ts.SyntaxKind.SingleLineCommentTrivia) {
- const text = source.slice(pos, end);
- const match = /^\/{2,3}\s*@ts-(no)?check(?:\s|$)/i.exec(text);
- if (match !== null)
- directive = { pos, end, enabled: match[1] === undefined };
- }
+ return process.nextTick(function afterTick() {
+ fn.apply(null, args);
});
- return directive;
-}
-exports.getCheckJsDirective = getCheckJsDirective;
-function isConstAssertion(node) {
- return node_1.isTypeReferenceNode(node.type) &&
- node.type.typeName.kind === ts.SyntaxKind.Identifier &&
- node.type.typeName.escapedText === 'const';
+ }
}
-exports.isConstAssertion = isConstAssertion;
-function isInConstContext(node) {
- let current = node;
- while (true) {
- const parent = current.parent;
- outer: switch (parent.kind) {
- case ts.SyntaxKind.TypeAssertionExpression:
- case ts.SyntaxKind.AsExpression:
- return isConstAssertion(parent);
- case ts.SyntaxKind.PrefixUnaryExpression:
- if (current.kind !== ts.SyntaxKind.NumericLiteral)
- return false;
- switch (parent.operator) {
- case ts.SyntaxKind.PlusToken:
- case ts.SyntaxKind.MinusToken:
- current = parent;
- break outer;
- default:
- return false;
- }
- case ts.SyntaxKind.PropertyAssignment:
- if (parent.initializer !== current)
- return false;
- current = parent.parent;
- break;
- case ts.SyntaxKind.ShorthandPropertyAssignment:
- current = parent.parent;
- break;
- case ts.SyntaxKind.ParenthesizedExpression:
- case ts.SyntaxKind.ArrayLiteralExpression:
- case ts.SyntaxKind.ObjectLiteralExpression:
- current = parent;
- break;
- default:
- return false;
- }
+
+
+
+/***/ }),
+/* 823 */,
+/* 824 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+var freeGlobal = __webpack_require__(973);
+
+/** Detect free variable `self`. */
+var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+/** Used as a reference to the global object. */
+var root = freeGlobal || freeSelf || Function('return this')();
+
+module.exports = root;
+
+
+/***/ }),
+/* 825 */,
+/* 826 */
+/***/ (function(module) {
+
+"use strict";
+
+
+/* eslint complexity: [2, 18], max-statements: [2, 33] */
+module.exports = function hasSymbols() {
+ if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
+ if (typeof Symbol.iterator === 'symbol') { return true; }
+
+ var obj = {};
+ var sym = Symbol('test');
+ var symObj = Object(sym);
+ if (typeof sym === 'string') { return false; }
+
+ if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
+ if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
+
+ // temp disabled per https://github.com/ljharb/object.assign/issues/17
+ // if (sym instanceof Symbol) { return false; }
+ // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
+ // if (!(symObj instanceof Symbol)) { return false; }
+
+ // if (typeof Symbol.prototype.toString !== 'function') { return false; }
+ // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
+
+ var symVal = 42;
+ obj[sym] = symVal;
+ for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
+ if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
+
+ if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
+
+ var syms = Object.getOwnPropertySymbols(obj);
+ if (syms.length !== 1 || syms[0] !== sym) { return false; }
+
+ if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
+
+ if (typeof Object.getOwnPropertyDescriptor === 'function') {
+ var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
+ if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
+ }
+
+ return true;
+};
+
+
+/***/ }),
+/* 827 */,
+/* 828 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+"use strict";
+
+
+/**/
+
+var pna = __webpack_require__(822);
+/**/
+
+// undocumented cb() API, needed for core, not for public API
+function destroy(err, cb) {
+ var _this = this;
+
+ var readableDestroyed = this._readableState && this._readableState.destroyed;
+ var writableDestroyed = this._writableState && this._writableState.destroyed;
+
+ if (readableDestroyed || writableDestroyed) {
+ if (cb) {
+ cb(err);
+ } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
+ pna.nextTick(emitErrorNT, this, err);
+ }
+ return this;
+ }
+
+ // we set destroyed to true before firing error callbacks in order
+ // to make it re-entrance safe in case destroy() is called within callbacks
+
+ if (this._readableState) {
+ this._readableState.destroyed = true;
+ }
+
+ // if this is a duplex stream mark the writable part as destroyed as well
+ if (this._writableState) {
+ this._writableState.destroyed = true;
+ }
+
+ this._destroy(err || null, function (err) {
+ if (!cb && err) {
+ pna.nextTick(emitErrorNT, _this, err);
+ if (_this._writableState) {
+ _this._writableState.errorEmitted = true;
+ }
+ } else if (cb) {
+ cb(err);
}
+ });
+
+ return this;
}
-exports.isInConstContext = isInConstContext;
-function isReadonlyAssignmentDeclaration(node, checker) {
- if (!isBindableObjectDefinePropertyCall(node))
- return false;
- const descriptorType = checker.getTypeAtLocation(node.arguments[2]);
- if (descriptorType.getProperty('value') === undefined)
- return descriptorType.getProperty('set') === undefined;
- const writableProp = descriptorType.getProperty('writable');
- if (writableProp === undefined)
- return false;
- const writableType = writableProp.valueDeclaration !== undefined && node_1.isPropertyAssignment(writableProp.valueDeclaration)
- ? checker.getTypeAtLocation(writableProp.valueDeclaration.initializer)
- : checker.getTypeOfSymbolAtLocation(writableProp, node.arguments[2]);
- return type_1.isBooleanLiteralType(writableType, false);
+
+function undestroy() {
+ if (this._readableState) {
+ this._readableState.destroyed = false;
+ this._readableState.reading = false;
+ this._readableState.ended = false;
+ this._readableState.endEmitted = false;
+ }
+
+ if (this._writableState) {
+ this._writableState.destroyed = false;
+ this._writableState.ended = false;
+ this._writableState.ending = false;
+ this._writableState.finished = false;
+ this._writableState.errorEmitted = false;
+ }
}
-exports.isReadonlyAssignmentDeclaration = isReadonlyAssignmentDeclaration;
-function isBindableObjectDefinePropertyCall(node) {
- return node.arguments.length === 3 &&
- node_1.isEntityNameExpression(node.arguments[0]) &&
- node_1.isNumericOrStringLikeLiteral(node.arguments[1]) &&
- node_1.isPropertyAccessExpression(node.expression) &&
- node.expression.name.escapedText === 'defineProperty' &&
- node_1.isIdentifier(node.expression.expression) &&
- node.expression.expression.escapedText === 'Object';
+
+function emitErrorNT(self, err) {
+ self.emit('error', err);
}
-exports.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall;
-function isWellKnownSymbolLiterally(node) {
- return ts.isPropertyAccessExpression(node) &&
- ts.isIdentifier(node.expression) &&
- node.expression.escapedText === 'Symbol';
+
+module.exports = {
+ destroy: destroy,
+ undestroy: undestroy
+};
+
+/***/ }),
+/* 829 */
+/***/ (function(__unusedmodule, exports) {
+
+/* -*- Mode: js; js-indent-level: 2; -*- */
+/*
+ * Copyright 2011 Mozilla Foundation and contributors
+ * Licensed under the New BSD license. See LICENSE or:
+ * http://opensource.org/licenses/BSD-3-Clause
+ */
+
+// It turns out that some (most?) JavaScript engines don't self-host
+// `Array.prototype.sort`. This makes sense because C++ will likely remain
+// faster than JS when doing raw CPU-intensive sorting. However, when using a
+// custom comparator function, calling back and forth between the VM's C++ and
+// JIT'd JS is rather slow *and* loses JIT type information, resulting in
+// worse generated code for the comparator function than would be optimal. In
+// fact, when sorting with a comparator, these costs outweigh the benefits of
+// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
+// a ~3500ms mean speed-up in `bench/bench.html`.
+
+/**
+ * Swap the elements indexed by `x` and `y` in the array `ary`.
+ *
+ * @param {Array} ary
+ * The array.
+ * @param {Number} x
+ * The index of the first item.
+ * @param {Number} y
+ * The index of the second item.
+ */
+function swap(ary, x, y) {
+ var temp = ary[x];
+ ary[x] = ary[y];
+ ary[y] = temp;
}
-exports.isWellKnownSymbolLiterally = isWellKnownSymbolLiterally;
-function getPropertyNameOfWellKnownSymbol(node) {
- return {
- displayName: `[Symbol.${node.name.text}]`,
- symbolName: ('__@' + node.name.text),
- };
+
+/**
+ * Returns a random integer within the range `low .. high` inclusive.
+ *
+ * @param {Number} low
+ * The lower bound on the range.
+ * @param {Number} high
+ * The upper bound on the range.
+ */
+function randomIntInRange(low, high) {
+ return Math.round(low + (Math.random() * (high - low)));
}
-exports.getPropertyNameOfWellKnownSymbol = getPropertyNameOfWellKnownSymbol;
-function getLateBoundPropertyNames(node, checker) {
- const result = {
- known: true,
- names: [],
- };
- node = unwrapParentheses(node);
- if (isWellKnownSymbolLiterally(node)) {
- result.names.push(getPropertyNameOfWellKnownSymbol(node));
+
+/**
+ * The Quick Sort algorithm.
+ *
+ * @param {Array} ary
+ * An array to sort.
+ * @param {function} comparator
+ * Function to use to compare two items.
+ * @param {Number} p
+ * Start index of the array
+ * @param {Number} r
+ * End index of the array
+ */
+function doQuickSort(ary, comparator, p, r) {
+ // If our lower bound is less than our upper bound, we (1) partition the
+ // array into two pieces and (2) recurse on each half. If it is not, this is
+ // the empty array and our base case.
+
+ if (p < r) {
+ // (1) Partitioning.
+ //
+ // The partitioning chooses a pivot between `p` and `r` and moves all
+ // elements that are less than or equal to the pivot to the before it, and
+ // all the elements that are greater than it after it. The effect is that
+ // once partition is done, the pivot is in the exact place it will be when
+ // the array is put in sorted order, and it will not need to be moved
+ // again. This runs in O(n) time.
+
+ // Always choose a random pivot so that an input array which is reverse
+ // sorted does not cause O(n^2) running time.
+ var pivotIndex = randomIntInRange(p, r);
+ var i = p - 1;
+
+ swap(ary, pivotIndex, r);
+ var pivot = ary[r];
+
+ // Immediately after `j` is incremented in this loop, the following hold
+ // true:
+ //
+ // * Every element in `ary[p .. i]` is less than or equal to the pivot.
+ //
+ // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
+ for (var j = p; j < r; j++) {
+ if (comparator(ary[j], pivot) <= 0) {
+ i += 1;
+ swap(ary, i, j);
+ }
}
- else {
- const type = checker.getTypeAtLocation(node);
- for (const key of type_1.unionTypeParts(checker.getBaseConstraintOfType(type) || type)) {
- const propertyName = type_1.getPropertyNameFromType(key);
- if (propertyName) {
- result.names.push(propertyName);
- }
- else {
- result.known = false;
- }
- }
+
+ swap(ary, i + 1, j);
+ var q = i + 1;
+
+ // (2) Recurse on each half.
+
+ doQuickSort(ary, comparator, p, q - 1);
+ doQuickSort(ary, comparator, q + 1, r);
+ }
+}
+
+/**
+ * Sort the given array in-place with the given comparator function.
+ *
+ * @param {Array} ary
+ * An array to sort.
+ * @param {function} comparator
+ * Function to use to compare two items.
+ */
+exports.quickSort = function (ary, comparator) {
+ doQuickSort(ary, comparator, 0, ary.length - 1);
+};
+
+
+/***/ }),
+/* 830 */,
+/* 831 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+"use strict";
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+// a duplex stream is just a stream that is both readable and writable.
+// Since JS doesn't have multiple prototypal inheritance, this class
+// prototypally inherits from Readable, and then parasitically from
+// Writable.
+
+/**/
+
+var objectKeys = Object.keys || function (obj) {
+ var keys = [];
+
+ for (var key in obj) {
+ keys.push(key);
+ }
+
+ return keys;
+};
+/**/
+
+
+module.exports = Duplex;
+
+var Readable = __webpack_require__(226);
+
+var Writable = __webpack_require__(241);
+
+__webpack_require__(689)(Duplex, Readable);
+
+{
+ // Allow the keys array to be GC'ed.
+ var keys = objectKeys(Writable.prototype);
+
+ for (var v = 0; v < keys.length; v++) {
+ var method = keys[v];
+ if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
+ }
+}
+
+function Duplex(options) {
+ if (!(this instanceof Duplex)) return new Duplex(options);
+ Readable.call(this, options);
+ Writable.call(this, options);
+ this.allowHalfOpen = true;
+
+ if (options) {
+ if (options.readable === false) this.readable = false;
+ if (options.writable === false) this.writable = false;
+
+ if (options.allowHalfOpen === false) {
+ this.allowHalfOpen = false;
+ this.once('end', onend);
}
- return result;
+ }
}
-exports.getLateBoundPropertyNames = getLateBoundPropertyNames;
-function getLateBoundPropertyNamesOfPropertyName(node, checker) {
- const staticName = getPropertyName(node);
- return staticName !== undefined
- ? { known: true, names: [{ displayName: staticName, symbolName: ts.escapeLeadingUnderscores(staticName) }] }
- : getLateBoundPropertyNames(node.expression, checker);
+
+Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._writableState.highWaterMark;
+ }
+});
+Object.defineProperty(Duplex.prototype, 'writableBuffer', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._writableState && this._writableState.getBuffer();
+ }
+});
+Object.defineProperty(Duplex.prototype, 'writableLength', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._writableState.length;
+ }
+}); // the no-half-open enforcer
+
+function onend() {
+ // If the writable side ended, then we're ok.
+ if (this._writableState.ended) return; // no more data can be written.
+ // But allow more writes to happen in this tick.
+
+ process.nextTick(onEndNT, this);
}
-exports.getLateBoundPropertyNamesOfPropertyName = getLateBoundPropertyNamesOfPropertyName;
-function getSingleLateBoundPropertyNameOfPropertyName(node, checker) {
- const staticName = getPropertyName(node);
- if (staticName !== undefined)
- return { displayName: staticName, symbolName: ts.escapeLeadingUnderscores(staticName) };
- const { expression } = node;
- return isWellKnownSymbolLiterally(expression)
- ? getPropertyNameOfWellKnownSymbol(expression)
- : type_1.getPropertyNameFromType(checker.getTypeAtLocation(expression));
+
+function onEndNT(self) {
+ self.end();
}
-exports.getSingleLateBoundPropertyNameOfPropertyName = getSingleLateBoundPropertyNameOfPropertyName;
-function unwrapParentheses(node) {
- while (node.kind === ts.SyntaxKind.ParenthesizedExpression)
- node = node.expression;
- return node;
+
+Object.defineProperty(Duplex.prototype, 'destroyed', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ if (this._readableState === undefined || this._writableState === undefined) {
+ return false;
+ }
+
+ return this._readableState.destroyed && this._writableState.destroyed;
+ },
+ set: function set(value) {
+ // we ignore the value if the stream
+ // has not been initialized yet
+ if (this._readableState === undefined || this._writableState === undefined) {
+ return;
+ } // backward compatibility, the user is explicitly
+ // managing destroyed
+
+
+ this._readableState.destroyed = value;
+ this._writableState.destroyed = value;
+ }
+});
+
+/***/ }),
+/* 832 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+"use strict";
+
+
+module.exports = __webpack_require__(271).default;
+
+
+/***/ }),
+/* 833 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const SemVer = __webpack_require__(369)
+const Range = __webpack_require__(986)
+const gt = __webpack_require__(136)
+
+const minVersion = (range, loose) => {
+ range = new Range(range, loose)
+
+ let minver = new SemVer('0.0.0')
+ if (range.test(minver)) {
+ return minver
+ }
+
+ minver = new SemVer('0.0.0-0')
+ if (range.test(minver)) {
+ return minver
+ }
+
+ minver = null
+ for (let i = 0; i < range.set.length; ++i) {
+ const comparators = range.set[i]
+
+ comparators.forEach((comparator) => {
+ // Clone to avoid manipulating the comparator's semver object.
+ const compver = new SemVer(comparator.semver.version)
+ switch (comparator.operator) {
+ case '>':
+ if (compver.prerelease.length === 0) {
+ compver.patch++
+ } else {
+ compver.prerelease.push(0)
+ }
+ compver.raw = compver.format()
+ /* fallthrough */
+ case '':
+ case '>=':
+ if (!minver || gt(minver, compver)) {
+ minver = compver
+ }
+ break
+ case '<':
+ case '<=':
+ /* Ignore maximum versions */
+ break
+ /* istanbul ignore next */
+ default:
+ throw new Error(`Unexpected operation: ${comparator.operator}`)
+ }
+ })
+ }
+
+ if (minver && range.test(minver)) {
+ return minver
+ }
+
+ return null
}
-exports.unwrapParentheses = unwrapParentheses;
+module.exports = minVersion
+
+
+/***/ }),
+/* 834 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const SemVer = __webpack_require__(369)
+const minor = (a, loose) => new SemVer(a, loose).minor
+module.exports = minor
/***/ }),
-/* 834 */,
/* 835 */
/***/ (function(module) {
@@ -245593,14 +251646,27 @@ exports.ArraySet = ArraySet;
"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- result["default"] = mod;
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
+exports.defaultInputs = void 0;
const core = __importStar(__webpack_require__(470));
exports.defaultInputs = {
publishDir() {
@@ -245626,6 +251692,9 @@ exports.defaultInputs = {
overwritesPullRequestComment() {
// Default: true
return ((core.getInput('overwrites-pull-request-comment') || 'true') === 'true');
+ },
+ netlifyConfigPath() {
+ return core.getInput('netlify-config-path') || undefined;
}
};
@@ -258836,7 +264905,19 @@ exports.restEndpointMethods = restEndpointMethods;
/***/ }),
/* 843 */,
-/* 844 */,
+/* 844 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const Range = __webpack_require__(986)
+const intersects = (r1, r2, options) => {
+ r1 = new Range(r1, options)
+ r2 = new Range(r2, options)
+ return r1.intersects(r2)
+}
+module.exports = intersects
+
+
+/***/ }),
/* 845 */
/***/ (function(__unusedmodule, exports, __webpack_require__) {
@@ -259436,7 +265517,35 @@ function paginationMethodsPlugin (octokit) {
/***/ }),
/* 851 */,
/* 852 */,
-/* 853 */,
+/* 853 */
+/***/ (function(module) {
+
+const numeric = /^[0-9]+$/
+const compareIdentifiers = (a, b) => {
+ const anum = numeric.test(a)
+ const bnum = numeric.test(b)
+
+ if (anum && bnum) {
+ a = +a
+ b = +b
+ }
+
+ return a === b ? 0
+ : (anum && !bnum) ? -1
+ : (bnum && !anum) ? 1
+ : a < b ? -1
+ : 1
+}
+
+const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
+
+module.exports = {
+ compareIdentifiers,
+ rcompareIdentifiers
+}
+
+
+/***/ }),
/* 854 */
/***/ (function(module) {
@@ -260416,7 +266525,7 @@ module.exports = __webpack_require__(160).default;
var replace = String.prototype.replace;
var percentTwenties = /%20/g;
-var util = __webpack_require__(658);
+var util = __webpack_require__(733);
var Format = {
RFC1738: 'RFC1738',
@@ -261327,7 +267436,35 @@ Duplex.prototype._destroy = function (err, cb) {
/***/ }),
/* 878 */,
-/* 879 */,
+/* 879 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const parse = __webpack_require__(658)
+const eq = __webpack_require__(804)
+
+const diff = (version1, version2) => {
+ if (eq(version1, version2)) {
+ return null
+ } else {
+ const v1 = parse(version1)
+ const v2 = parse(version2)
+ const hasPre = v1.prerelease.length || v2.prerelease.length
+ const prefix = hasPre ? 'pre' : ''
+ const defaultResult = hasPre ? 'prerelease' : ''
+ for (const key in v1) {
+ if (key === 'major' || key === 'minor' || key === 'patch') {
+ if (v1[key] !== v2[key]) {
+ return prefix + key
+ }
+ }
+ }
+ return defaultResult // may be undefined
+ }
+}
+module.exports = diff
+
+
+/***/ }),
/* 880 */
/***/ (function(module, exports, __webpack_require__) {
@@ -263614,7 +269751,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
var request = __webpack_require__(753);
var universalUserAgent = __webpack_require__(796);
-const VERSION = "4.4.0";
+const VERSION = "4.5.0";
class GraphqlError extends Error {
constructor(request, response) {
@@ -263695,8 +269832,69 @@ exports.withCustomRequest = withCustomRequest;
/***/ }),
-/* 899 */,
-/* 900 */,
+/* 899 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const compareBuild = __webpack_require__(50)
+const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
+module.exports = sort
+
+
+/***/ }),
+/* 900 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+// just pre-load all the stuff that index.js lazily exports
+const internalRe = __webpack_require__(590)
+module.exports = {
+ re: internalRe.re,
+ src: internalRe.src,
+ tokens: internalRe.t,
+ SEMVER_SPEC_VERSION: __webpack_require__(627).SEMVER_SPEC_VERSION,
+ SemVer: __webpack_require__(369),
+ compareIdentifiers: __webpack_require__(853).compareIdentifiers,
+ rcompareIdentifiers: __webpack_require__(853).rcompareIdentifiers,
+ parse: __webpack_require__(658),
+ valid: __webpack_require__(64),
+ clean: __webpack_require__(386),
+ inc: __webpack_require__(767),
+ diff: __webpack_require__(879),
+ major: __webpack_require__(476),
+ minor: __webpack_require__(834),
+ patch: __webpack_require__(32),
+ prerelease: __webpack_require__(609),
+ compare: __webpack_require__(682),
+ rcompare: __webpack_require__(972),
+ compareLoose: __webpack_require__(467),
+ compareBuild: __webpack_require__(805),
+ sort: __webpack_require__(638),
+ rsort: __webpack_require__(150),
+ gt: __webpack_require__(136),
+ lt: __webpack_require__(342),
+ eq: __webpack_require__(804),
+ neq: __webpack_require__(335),
+ gte: __webpack_require__(618),
+ lte: __webpack_require__(495),
+ cmp: __webpack_require__(134),
+ coerce: __webpack_require__(719),
+ Comparator: __webpack_require__(123),
+ Range: __webpack_require__(986),
+ satisfies: __webpack_require__(121),
+ toComparators: __webpack_require__(770),
+ maxSatisfying: __webpack_require__(994),
+ minSatisfying: __webpack_require__(217),
+ minVersion: __webpack_require__(833),
+ validRange: __webpack_require__(292),
+ outside: __webpack_require__(750),
+ gtr: __webpack_require__(530),
+ ltr: __webpack_require__(589),
+ intersects: __webpack_require__(844),
+ simplifyRange: __webpack_require__(930),
+ subset: __webpack_require__(321),
+}
+
+
+/***/ }),
/* 901 */
/***/ (function(__unusedmodule, exports) {
@@ -266172,860 +272370,330 @@ function isObjectLike(value) {
}
/**
- * This method returns `undefined`.
- *
- * @static
- * @memberOf _
- * @since 2.3.0
- * @category Util
- * @example
- *
- * _.times(2, _.noop);
- * // => [undefined, undefined]
- */
-function noop() {
- // No operation performed.
-}
-
-module.exports = union;
-
-
-/***/ }),
-/* 924 */,
-/* 925 */
-/***/ (function(module, __unusedexports, __webpack_require__) {
-
-"use strict";
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-// a transform stream is a readable/writable stream where you do
-// something with the data. Sometimes it's called a "filter",
-// but that's not a great name for it, since that implies a thing where
-// some bits pass through, and others are simply ignored. (That would
-// be a valid example of a transform, of course.)
-//
-// While the output is causally related to the input, it's not a
-// necessarily symmetric or synchronous transformation. For example,
-// a zlib stream might take multiple plain-text writes(), and then
-// emit a single compressed chunk some time in the future.
-//
-// Here's how this works:
-//
-// The Transform stream has all the aspects of the readable and writable
-// stream classes. When you write(chunk), that calls _write(chunk,cb)
-// internally, and returns false if there's a lot of pending writes
-// buffered up. When you call read(), that calls _read(n) until
-// there's enough pending readable data buffered up.
-//
-// In a transform stream, the written data is placed in a buffer. When
-// _read(n) is called, it transforms the queued up data, calling the
-// buffered _write cb's as it consumes chunks. If consuming a single
-// written chunk would result in multiple output chunks, then the first
-// outputted bit calls the readcb, and subsequent chunks just go into
-// the read buffer, and will cause it to emit 'readable' if necessary.
-//
-// This way, back-pressure is actually determined by the reading side,
-// since _read has to be called to start processing a new chunk. However,
-// a pathological inflate type of transform can cause excessive buffering
-// here. For example, imagine a stream where every byte of input is
-// interpreted as an integer from 0-255, and then results in that many
-// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
-// 1kb of data being output. In this case, you could write a very small
-// amount of input, and end up with a very large amount of output. In
-// such a pathological inflating mechanism, there'd be no way to tell
-// the system to stop doing the transform. A single 4MB write could
-// cause the system to run out of memory.
-//
-// However, even in such a pathological case, only a single written chunk
-// would be consumed, and then the rest would wait (un-transformed) until
-// the results of the previous transformed chunk were consumed.
-
-
-module.exports = Transform;
-
-var _require$codes = __webpack_require__(38).codes,
- ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
- ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
- ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
- ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
-
-var Duplex = __webpack_require__(831);
-
-__webpack_require__(689)(Transform, Duplex);
-
-function afterTransform(er, data) {
- var ts = this._transformState;
- ts.transforming = false;
- var cb = ts.writecb;
-
- if (cb === null) {
- return this.emit('error', new ERR_MULTIPLE_CALLBACK());
- }
-
- ts.writechunk = null;
- ts.writecb = null;
- if (data != null) // single equals check for both `null` and `undefined`
- this.push(data);
- cb(er);
- var rs = this._readableState;
- rs.reading = false;
-
- if (rs.needReadable || rs.length < rs.highWaterMark) {
- this._read(rs.highWaterMark);
- }
-}
-
-function Transform(options) {
- if (!(this instanceof Transform)) return new Transform(options);
- Duplex.call(this, options);
- this._transformState = {
- afterTransform: afterTransform.bind(this),
- needTransform: false,
- transforming: false,
- writecb: null,
- writechunk: null,
- writeencoding: null
- }; // start out asking for a readable event once data is transformed.
-
- this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
- // that Readable wants before the first _read call, so unset the
- // sync guard flag.
-
- this._readableState.sync = false;
-
- if (options) {
- if (typeof options.transform === 'function') this._transform = options.transform;
- if (typeof options.flush === 'function') this._flush = options.flush;
- } // When the writable side finishes, then flush out anything remaining.
-
-
- this.on('prefinish', prefinish);
-}
-
-function prefinish() {
- var _this = this;
-
- if (typeof this._flush === 'function' && !this._readableState.destroyed) {
- this._flush(function (er, data) {
- done(_this, er, data);
- });
- } else {
- done(this, null, null);
- }
-}
-
-Transform.prototype.push = function (chunk, encoding) {
- this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk, encoding);
-}; // This is the part where you do stuff!
-// override this function in implementation classes.
-// 'chunk' is an input chunk.
-//
-// Call `push(newChunk)` to pass along transformed output
-// to the readable side. You may call 'push' zero or more times.
-//
-// Call `cb(err)` when you are done with this chunk. If you pass
-// an error, then that'll put the hurt on the whole operation. If you
-// never call cb(), then you'll never get another chunk.
-
-
-Transform.prototype._transform = function (chunk, encoding, cb) {
- cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
-};
-
-Transform.prototype._write = function (chunk, encoding, cb) {
- var ts = this._transformState;
- ts.writecb = cb;
- ts.writechunk = chunk;
- ts.writeencoding = encoding;
-
- if (!ts.transforming) {
- var rs = this._readableState;
- if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
- }
-}; // Doesn't matter what the args are here.
-// _transform does all the work.
-// That we got here means that the readable side wants more data.
-
-
-Transform.prototype._read = function (n) {
- var ts = this._transformState;
-
- if (ts.writechunk !== null && !ts.transforming) {
- ts.transforming = true;
-
- this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
- } else {
- // mark that we need a transform, so that any data that comes in
- // will get processed, now that we've asked for it.
- ts.needTransform = true;
- }
-};
-
-Transform.prototype._destroy = function (err, cb) {
- Duplex.prototype._destroy.call(this, err, function (err2) {
- cb(err2);
- });
-};
-
-function done(stream, er, data) {
- if (er) return stream.emit('error', er);
- if (data != null) // single equals check for both `null` and `undefined`
- stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
- // if there's nothing in the write buffer, then that means
- // that nothing more will ever be provided
-
- if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
- if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
- return stream.push(null);
-}
-
-/***/ }),
-/* 926 */,
-/* 927 */,
-/* 928 */
-/***/ (function(module, __unusedexports, __webpack_require__) {
-
-module.exports = __webpack_require__(413);
-
-
-/***/ }),
-/* 929 */
-/***/ (function(module, __unusedexports, __webpack_require__) {
-
-module.exports = hasNextPage
-
-const deprecate = __webpack_require__(370)
-const getPageLinks = __webpack_require__(577)
-
-function hasNextPage (link) {
- deprecate(`octokit.hasNextPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
- return getPageLinks(link).next
-}
-
-
-/***/ }),
-/* 930 */,
-/* 931 */
-/***/ (function(module) {
-
-/**
- * lodash (Custom Build)
- * Build: `lodash modularize exports="npm" -o ./`
- * Copyright jQuery Foundation and other contributors
- * Released under MIT license
- * Based on Underscore.js 1.8.3
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- */
-
-/** Used as references for various `Number` constants. */
-var INFINITY = 1 / 0;
-
-/** `Object#toString` result references. */
-var symbolTag = '[object Symbol]';
-
-/** Used to match words composed of alphanumeric characters. */
-var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
-
-/** Used to match Latin Unicode letters (excluding mathematical operators). */
-var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
-
-/** Used to compose unicode character classes. */
-var rsAstralRange = '\\ud800-\\udfff',
- rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
- rsComboSymbolsRange = '\\u20d0-\\u20f0',
- rsDingbatRange = '\\u2700-\\u27bf',
- rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
- rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
- rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
- rsPunctuationRange = '\\u2000-\\u206f',
- rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
- rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
- rsVarRange = '\\ufe0e\\ufe0f',
- rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
-
-/** Used to compose unicode capture groups. */
-var rsApos = "['\u2019]",
- rsAstral = '[' + rsAstralRange + ']',
- rsBreak = '[' + rsBreakRange + ']',
- rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
- rsDigits = '\\d+',
- rsDingbat = '[' + rsDingbatRange + ']',
- rsLower = '[' + rsLowerRange + ']',
- rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
- rsFitz = '\\ud83c[\\udffb-\\udfff]',
- rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
- rsNonAstral = '[^' + rsAstralRange + ']',
- rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
- rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
- rsUpper = '[' + rsUpperRange + ']',
- rsZWJ = '\\u200d';
-
-/** Used to compose unicode regexes. */
-var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
- rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
- rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
- rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
- reOptMod = rsModifier + '?',
- rsOptVar = '[' + rsVarRange + ']?',
- rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
- rsSeq = rsOptVar + reOptMod + rsOptJoin,
- rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
- rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
-
-/** Used to match apostrophes. */
-var reApos = RegExp(rsApos, 'g');
-
-/**
- * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
- * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
- */
-var reComboMark = RegExp(rsCombo, 'g');
-
-/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
-var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
-
-/** Used to match complex or compound words. */
-var reUnicodeWord = RegExp([
- rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
- rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
- rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
- rsUpper + '+' + rsOptUpperContr,
- rsDigits,
- rsEmoji
-].join('|'), 'g');
-
-/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
-var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
-
-/** Used to detect strings that need a more robust regexp to match words. */
-var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
-
-/** Used to map Latin Unicode letters to basic Latin letters. */
-var deburredLetters = {
- // Latin-1 Supplement block.
- '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
- '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
- '\xc7': 'C', '\xe7': 'c',
- '\xd0': 'D', '\xf0': 'd',
- '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
- '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
- '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
- '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
- '\xd1': 'N', '\xf1': 'n',
- '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
- '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
- '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
- '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
- '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
- '\xc6': 'Ae', '\xe6': 'ae',
- '\xde': 'Th', '\xfe': 'th',
- '\xdf': 'ss',
- // Latin Extended-A block.
- '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
- '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
- '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
- '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
- '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
- '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
- '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
- '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
- '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
- '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
- '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
- '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
- '\u0134': 'J', '\u0135': 'j',
- '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
- '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
- '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
- '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
- '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
- '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
- '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
- '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
- '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
- '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
- '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
- '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
- '\u0163': 't', '\u0165': 't', '\u0167': 't',
- '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
- '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
- '\u0174': 'W', '\u0175': 'w',
- '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
- '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
- '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
- '\u0132': 'IJ', '\u0133': 'ij',
- '\u0152': 'Oe', '\u0153': 'oe',
- '\u0149': "'n", '\u017f': 'ss'
-};
-
-/** Detect free variable `global` from Node.js. */
-var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
-
-/** Detect free variable `self`. */
-var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
-
-/** Used as a reference to the global object. */
-var root = freeGlobal || freeSelf || Function('return this')();
-
-/**
- * A specialized version of `_.reduce` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {*} [accumulator] The initial value.
- * @param {boolean} [initAccum] Specify using the first element of `array` as
- * the initial value.
- * @returns {*} Returns the accumulated value.
- */
-function arrayReduce(array, iteratee, accumulator, initAccum) {
- var index = -1,
- length = array ? array.length : 0;
-
- if (initAccum && length) {
- accumulator = array[++index];
- }
- while (++index < length) {
- accumulator = iteratee(accumulator, array[index], index, array);
- }
- return accumulator;
-}
-
-/**
- * Converts an ASCII `string` to an array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the converted array.
- */
-function asciiToArray(string) {
- return string.split('');
-}
-
-/**
- * Splits an ASCII `string` into an array of its words.
- *
- * @private
- * @param {string} The string to inspect.
- * @returns {Array} Returns the words of `string`.
- */
-function asciiWords(string) {
- return string.match(reAsciiWord) || [];
-}
-
-/**
- * The base implementation of `_.propertyOf` without support for deep paths.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Function} Returns the new accessor function.
- */
-function basePropertyOf(object) {
- return function(key) {
- return object == null ? undefined : object[key];
- };
-}
-
-/**
- * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
- * letters to basic Latin letters.
- *
- * @private
- * @param {string} letter The matched letter to deburr.
- * @returns {string} Returns the deburred letter.
- */
-var deburrLetter = basePropertyOf(deburredLetters);
-
-/**
- * Checks if `string` contains Unicode symbols.
- *
- * @private
- * @param {string} string The string to inspect.
- * @returns {boolean} Returns `true` if a symbol is found, else `false`.
- */
-function hasUnicode(string) {
- return reHasUnicode.test(string);
-}
-
-/**
- * Checks if `string` contains a word composed of Unicode symbols.
- *
- * @private
- * @param {string} string The string to inspect.
- * @returns {boolean} Returns `true` if a word is found, else `false`.
- */
-function hasUnicodeWord(string) {
- return reHasUnicodeWord.test(string);
-}
-
-/**
- * Converts `string` to an array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the converted array.
- */
-function stringToArray(string) {
- return hasUnicode(string)
- ? unicodeToArray(string)
- : asciiToArray(string);
-}
-
-/**
- * Converts a Unicode `string` to an array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the converted array.
- */
-function unicodeToArray(string) {
- return string.match(reUnicode) || [];
-}
-
-/**
- * Splits a Unicode `string` into an array of its words.
- *
- * @private
- * @param {string} The string to inspect.
- * @returns {Array} Returns the words of `string`.
- */
-function unicodeWords(string) {
- return string.match(reUnicodeWord) || [];
-}
-
-/** Used for built-in method references. */
-var objectProto = Object.prototype;
-
-/**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
- * of values.
- */
-var objectToString = objectProto.toString;
-
-/** Built-in value references. */
-var Symbol = root.Symbol;
-
-/** Used to convert symbols to primitives and strings. */
-var symbolProto = Symbol ? Symbol.prototype : undefined,
- symbolToString = symbolProto ? symbolProto.toString : undefined;
-
-/**
- * The base implementation of `_.slice` without an iteratee call guard.
- *
- * @private
- * @param {Array} array The array to slice.
- * @param {number} [start=0] The start position.
- * @param {number} [end=array.length] The end position.
- * @returns {Array} Returns the slice of `array`.
- */
-function baseSlice(array, start, end) {
- var index = -1,
- length = array.length;
-
- if (start < 0) {
- start = -start > length ? 0 : (length + start);
- }
- end = end > length ? length : end;
- if (end < 0) {
- end += length;
- }
- length = start > end ? 0 : ((end - start) >>> 0);
- start >>>= 0;
-
- var result = Array(length);
- while (++index < length) {
- result[index] = array[index + start];
- }
- return result;
-}
-
-/**
- * The base implementation of `_.toString` which doesn't convert nullish
- * values to empty strings.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- */
-function baseToString(value) {
- // Exit early for strings to avoid a performance hit in some environments.
- if (typeof value == 'string') {
- return value;
- }
- if (isSymbol(value)) {
- return symbolToString ? symbolToString.call(value) : '';
- }
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
-}
-
-/**
- * Casts `array` to a slice if it's needed.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {number} start The start position.
- * @param {number} [end=array.length] The end position.
- * @returns {Array} Returns the cast slice.
- */
-function castSlice(array, start, end) {
- var length = array.length;
- end = end === undefined ? length : end;
- return (!start && end >= length) ? array : baseSlice(array, start, end);
-}
-
-/**
- * Creates a function like `_.lowerFirst`.
- *
- * @private
- * @param {string} methodName The name of the `String` case method to use.
- * @returns {Function} Returns the new case function.
- */
-function createCaseFirst(methodName) {
- return function(string) {
- string = toString(string);
-
- var strSymbols = hasUnicode(string)
- ? stringToArray(string)
- : undefined;
-
- var chr = strSymbols
- ? strSymbols[0]
- : string.charAt(0);
-
- var trailing = strSymbols
- ? castSlice(strSymbols, 1).join('')
- : string.slice(1);
-
- return chr[methodName]() + trailing;
- };
-}
-
-/**
- * Creates a function like `_.camelCase`.
- *
- * @private
- * @param {Function} callback The function to combine each word.
- * @returns {Function} Returns the new compounder function.
- */
-function createCompounder(callback) {
- return function(string) {
- return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
- };
-}
-
-/**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
-function isObjectLike(value) {
- return !!value && typeof value == 'object';
-}
-
-/**
- * Checks if `value` is classified as a `Symbol` primitive or object.
+ * This method returns `undefined`.
*
* @static
* @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
+ * @since 2.3.0
+ * @category Util
* @example
*
- * _.isSymbol(Symbol.iterator);
- * // => true
- *
- * _.isSymbol('abc');
- * // => false
+ * _.times(2, _.noop);
+ * // => [undefined, undefined]
*/
-function isSymbol(value) {
- return typeof value == 'symbol' ||
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
+function noop() {
+ // No operation performed.
}
-/**
- * Converts `value` to a string. An empty string is returned for `null`
- * and `undefined` values. The sign of `-0` is preserved.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- * @example
- *
- * _.toString(null);
- * // => ''
- *
- * _.toString(-0);
- * // => '-0'
- *
- * _.toString([1, 2, 3]);
- * // => '1,2,3'
- */
-function toString(value) {
- return value == null ? '' : baseToString(value);
+module.exports = union;
+
+
+/***/ }),
+/* 924 */,
+/* 925 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+"use strict";
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+// a transform stream is a readable/writable stream where you do
+// something with the data. Sometimes it's called a "filter",
+// but that's not a great name for it, since that implies a thing where
+// some bits pass through, and others are simply ignored. (That would
+// be a valid example of a transform, of course.)
+//
+// While the output is causally related to the input, it's not a
+// necessarily symmetric or synchronous transformation. For example,
+// a zlib stream might take multiple plain-text writes(), and then
+// emit a single compressed chunk some time in the future.
+//
+// Here's how this works:
+//
+// The Transform stream has all the aspects of the readable and writable
+// stream classes. When you write(chunk), that calls _write(chunk,cb)
+// internally, and returns false if there's a lot of pending writes
+// buffered up. When you call read(), that calls _read(n) until
+// there's enough pending readable data buffered up.
+//
+// In a transform stream, the written data is placed in a buffer. When
+// _read(n) is called, it transforms the queued up data, calling the
+// buffered _write cb's as it consumes chunks. If consuming a single
+// written chunk would result in multiple output chunks, then the first
+// outputted bit calls the readcb, and subsequent chunks just go into
+// the read buffer, and will cause it to emit 'readable' if necessary.
+//
+// This way, back-pressure is actually determined by the reading side,
+// since _read has to be called to start processing a new chunk. However,
+// a pathological inflate type of transform can cause excessive buffering
+// here. For example, imagine a stream where every byte of input is
+// interpreted as an integer from 0-255, and then results in that many
+// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
+// 1kb of data being output. In this case, you could write a very small
+// amount of input, and end up with a very large amount of output. In
+// such a pathological inflating mechanism, there'd be no way to tell
+// the system to stop doing the transform. A single 4MB write could
+// cause the system to run out of memory.
+//
+// However, even in such a pathological case, only a single written chunk
+// would be consumed, and then the rest would wait (un-transformed) until
+// the results of the previous transformed chunk were consumed.
+
+
+module.exports = Transform;
+
+var _require$codes = __webpack_require__(38).codes,
+ ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
+ ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
+ ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
+ ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
+
+var Duplex = __webpack_require__(831);
+
+__webpack_require__(689)(Transform, Duplex);
+
+function afterTransform(er, data) {
+ var ts = this._transformState;
+ ts.transforming = false;
+ var cb = ts.writecb;
+
+ if (cb === null) {
+ return this.emit('error', new ERR_MULTIPLE_CALLBACK());
+ }
+
+ ts.writechunk = null;
+ ts.writecb = null;
+ if (data != null) // single equals check for both `null` and `undefined`
+ this.push(data);
+ cb(er);
+ var rs = this._readableState;
+ rs.reading = false;
+
+ if (rs.needReadable || rs.length < rs.highWaterMark) {
+ this._read(rs.highWaterMark);
+ }
}
-/**
- * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to convert.
- * @returns {string} Returns the camel cased string.
- * @example
- *
- * _.camelCase('Foo Bar');
- * // => 'fooBar'
- *
- * _.camelCase('--foo-bar--');
- * // => 'fooBar'
- *
- * _.camelCase('__FOO_BAR__');
- * // => 'fooBar'
- */
-var camelCase = createCompounder(function(result, word, index) {
- word = word.toLowerCase();
- return result + (index ? capitalize(word) : word);
-});
+function Transform(options) {
+ if (!(this instanceof Transform)) return new Transform(options);
+ Duplex.call(this, options);
+ this._transformState = {
+ afterTransform: afterTransform.bind(this),
+ needTransform: false,
+ transforming: false,
+ writecb: null,
+ writechunk: null,
+ writeencoding: null
+ }; // start out asking for a readable event once data is transformed.
-/**
- * Converts the first character of `string` to upper case and the remaining
- * to lower case.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to capitalize.
- * @returns {string} Returns the capitalized string.
- * @example
- *
- * _.capitalize('FRED');
- * // => 'Fred'
- */
-function capitalize(string) {
- return upperFirst(toString(string).toLowerCase());
+ this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
+ // that Readable wants before the first _read call, so unset the
+ // sync guard flag.
+
+ this._readableState.sync = false;
+
+ if (options) {
+ if (typeof options.transform === 'function') this._transform = options.transform;
+ if (typeof options.flush === 'function') this._flush = options.flush;
+ } // When the writable side finishes, then flush out anything remaining.
+
+
+ this.on('prefinish', prefinish);
}
-/**
- * Deburrs `string` by converting
- * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
- * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
- * letters to basic Latin letters and removing
- * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to deburr.
- * @returns {string} Returns the deburred string.
- * @example
- *
- * _.deburr('déjà vu');
- * // => 'deja vu'
- */
-function deburr(string) {
- string = toString(string);
- return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
+function prefinish() {
+ var _this = this;
+
+ if (typeof this._flush === 'function' && !this._readableState.destroyed) {
+ this._flush(function (er, data) {
+ done(_this, er, data);
+ });
+ } else {
+ done(this, null, null);
+ }
}
-/**
- * Converts the first character of `string` to upper case.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category String
- * @param {string} [string=''] The string to convert.
- * @returns {string} Returns the converted string.
- * @example
- *
- * _.upperFirst('fred');
- * // => 'Fred'
- *
- * _.upperFirst('FRED');
- * // => 'FRED'
- */
-var upperFirst = createCaseFirst('toUpperCase');
+Transform.prototype.push = function (chunk, encoding) {
+ this._transformState.needTransform = false;
+ return Duplex.prototype.push.call(this, chunk, encoding);
+}; // This is the part where you do stuff!
+// override this function in implementation classes.
+// 'chunk' is an input chunk.
+//
+// Call `push(newChunk)` to pass along transformed output
+// to the readable side. You may call 'push' zero or more times.
+//
+// Call `cb(err)` when you are done with this chunk. If you pass
+// an error, then that'll put the hurt on the whole operation. If you
+// never call cb(), then you'll never get another chunk.
-/**
- * Splits `string` into an array of its words.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to inspect.
- * @param {RegExp|string} [pattern] The pattern to match words.
- * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
- * @returns {Array} Returns the words of `string`.
- * @example
- *
- * _.words('fred, barney, & pebbles');
- * // => ['fred', 'barney', 'pebbles']
- *
- * _.words('fred, barney, & pebbles', /[^, ]+/g);
- * // => ['fred', 'barney', '&', 'pebbles']
- */
-function words(string, pattern, guard) {
- string = toString(string);
- pattern = guard ? undefined : pattern;
- if (pattern === undefined) {
- return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
+Transform.prototype._transform = function (chunk, encoding, cb) {
+ cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
+};
+
+Transform.prototype._write = function (chunk, encoding, cb) {
+ var ts = this._transformState;
+ ts.writecb = cb;
+ ts.writechunk = chunk;
+ ts.writeencoding = encoding;
+
+ if (!ts.transforming) {
+ var rs = this._readableState;
+ if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
}
- return string.match(pattern) || [];
+}; // Doesn't matter what the args are here.
+// _transform does all the work.
+// That we got here means that the readable side wants more data.
+
+
+Transform.prototype._read = function (n) {
+ var ts = this._transformState;
+
+ if (ts.writechunk !== null && !ts.transforming) {
+ ts.transforming = true;
+
+ this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
+ } else {
+ // mark that we need a transform, so that any data that comes in
+ // will get processed, now that we've asked for it.
+ ts.needTransform = true;
+ }
+};
+
+Transform.prototype._destroy = function (err, cb) {
+ Duplex.prototype._destroy.call(this, err, function (err2) {
+ cb(err2);
+ });
+};
+
+function done(stream, er, data) {
+ if (er) return stream.emit('error', er);
+ if (data != null) // single equals check for both `null` and `undefined`
+ stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
+ // if there's nothing in the write buffer, then that means
+ // that nothing more will ever be provided
+
+ if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
+ if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
+ return stream.push(null);
}
-module.exports = camelCase;
+/***/ }),
+/* 926 */,
+/* 927 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const Range = __webpack_require__(635)
+const intersects = (r1, r2, options) => {
+ r1 = new Range(r1, options)
+ r2 = new Range(r2, options)
+ return r1.intersects(r2)
+}
+module.exports = intersects
+
+
+/***/ }),
+/* 928 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+module.exports = __webpack_require__(413);
+
+
+/***/ }),
+/* 929 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+module.exports = hasNextPage
+
+const deprecate = __webpack_require__(370)
+const getPageLinks = __webpack_require__(577)
+
+function hasNextPage (link) {
+ deprecate(`octokit.hasNextPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
+ return getPageLinks(link).next
+}
+
+
+/***/ }),
+/* 930 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+// given a set of versions and a range, create a "simplified" range
+// that includes the same versions that the original range does
+// If the original range is shorter than the simplified one, return that.
+const satisfies = __webpack_require__(121)
+const compare = __webpack_require__(682)
+module.exports = (versions, range, options) => {
+ const set = []
+ let min = null
+ let prev = null
+ const v = versions.sort((a, b) => compare(a, b, options))
+ for (const version of v) {
+ const included = satisfies(version, range, options)
+ if (included) {
+ prev = version
+ if (!min)
+ min = version
+ } else {
+ if (prev) {
+ set.push([min, prev])
+ }
+ prev = null
+ min = null
+ }
+ }
+ if (min)
+ set.push([min, null])
+
+ const ranges = []
+ for (const [min, max] of set) {
+ if (min === max)
+ ranges.push(min)
+ else if (!max && min === v[0])
+ ranges.push('*')
+ else if (!max)
+ ranges.push(`>=${min}`)
+ else if (min === v[0])
+ ranges.push(`<=${max}`)
+ else
+ ranges.push(`${min} - ${max}`)
+ }
+ const simplified = ranges.join(' || ')
+ const original = typeof range.raw === 'string' ? range.raw : String(range)
+ return simplified.length < original.length ? simplified : range
+}
+
+
+/***/ }),
+/* 931 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const Range = __webpack_require__(635)
+
+// Mostly just for testing and legacy API reasons
+const toComparators = (range, options) =>
+ new Range(range, options).set
+ .map(comp => comp.map(c => c.value).join(' ').trim().split(' '))
+
+module.exports = toComparators
/***/ }),
@@ -268705,7 +274373,7 @@ var fs = __webpack_require__(747);
var path = __webpack_require__(622);
var caller = __webpack_require__(433);
var nodeModulesPaths = __webpack_require__(194);
-var normalizeOptions = __webpack_require__(590);
+var normalizeOptions = __webpack_require__(791);
var isCore = __webpack_require__(127);
var defaultIsFile = function isFile(file, cb) {
@@ -269642,7 +275310,12 @@ module.exports.shellSync = (cmd, opts) => handleShell(module.exports.sync, cmd,
/***/ }),
-/* 956 */,
+/* 956 */
+/***/ (function(module) {
+
+module.exports = require("process");
+
+/***/ }),
/* 957 */
/***/ (function(module, __unusedexports, __webpack_require__) {
@@ -270893,9 +276566,25 @@ function onceStrict (fn) {
/***/ }),
-/* 970 */,
+/* 970 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const compare = __webpack_require__(570)
+const compareLoose = (a, b) => compare(a, b, true)
+module.exports = compareLoose
+
+
+/***/ }),
/* 971 */,
-/* 972 */,
+/* 972 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const compare = __webpack_require__(682)
+const rcompare = (a, b, loose) => compare(b, a, loose)
+module.exports = rcompare
+
+
+/***/ }),
/* 973 */
/***/ (function(module) {
@@ -270918,7 +276607,7 @@ const precinct = __webpack_require__(92)
const requirePackageName = __webpack_require__(332)
const promisify = __webpack_require__(799)
-const { resolveLocation } = __webpack_require__(801)
+const { resolvePathPreserveSymlinks, resolvePackage } = __webpack_require__(801)
const pGlob = promisify(glob)
@@ -270977,7 +276666,7 @@ const LOCAL_IMPORT_REGEXP = /^(\.|\/)/
// When a file requires another one, we apply the top-level logic recursively
const getLocalImportDependencies = async function(dependency, basedir, packageJson, state) {
- const dependencyPath = await resolveLocation(dependency, basedir)
+ const dependencyPath = await resolvePathPreserveSymlinks(dependency, basedir)
const depsPath = await getFileDependencies(dependencyPath, packageJson, state)
return [dependencyPath, ...depsPath]
}
@@ -271002,7 +276691,7 @@ const getModuleNameDependencies = async function(moduleName, basedir, state) {
}
// Find the Node.js module directory path
- const packagePath = await resolveLocation(`${moduleName}/package.json`, basedir)
+ const packagePath = await resolvePackage(moduleName, basedir)
const modulePath = dirname(packagePath)
if (state.modulePaths.includes(modulePath)) {
@@ -285116,7 +290805,475 @@ exports.tokTypes = types;
/***/ }),
-/* 986 */,
+/* 986 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+// hoisted class for cyclic dependency
+class Range {
+ constructor (range, options) {
+ if (!options || typeof options !== 'object') {
+ options = {
+ loose: !!options,
+ includePrerelease: false
+ }
+ }
+
+ if (range instanceof Range) {
+ if (
+ range.loose === !!options.loose &&
+ range.includePrerelease === !!options.includePrerelease
+ ) {
+ return range
+ } else {
+ return new Range(range.raw, options)
+ }
+ }
+
+ if (range instanceof Comparator) {
+ // just put it in the set and return
+ this.raw = range.value
+ this.set = [[range]]
+ this.format()
+ return this
+ }
+
+ this.options = options
+ this.loose = !!options.loose
+ this.includePrerelease = !!options.includePrerelease
+
+ // First, split based on boolean or ||
+ this.raw = range
+ this.set = range
+ .split(/\s*\|\|\s*/)
+ // map the range to a 2d array of comparators
+ .map(range => this.parseRange(range.trim()))
+ // throw out any comparator lists that are empty
+ // this generally means that it was not a valid range, which is allowed
+ // in loose mode, but will still throw if the WHOLE range is invalid.
+ .filter(c => c.length)
+
+ if (!this.set.length) {
+ throw new TypeError(`Invalid SemVer Range: ${range}`)
+ }
+
+ this.format()
+ }
+
+ format () {
+ this.range = this.set
+ .map((comps) => {
+ return comps.join(' ').trim()
+ })
+ .join('||')
+ .trim()
+ return this.range
+ }
+
+ toString () {
+ return this.range
+ }
+
+ parseRange (range) {
+ const loose = this.options.loose
+ range = range.trim()
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
+ debug('hyphen replace', range)
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
+ debug('comparator trim', range, re[t.COMPARATORTRIM])
+
+ // `~ 1.2.3` => `~1.2.3`
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
+
+ // `^ 1.2.3` => `^1.2.3`
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace)
+
+ // normalize spaces
+ range = range.split(/\s+/).join(' ')
+
+ // At this point, the range is completely trimmed and
+ // ready to be split into comparators.
+
+ const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
+ return range
+ .split(' ')
+ .map(comp => parseComparator(comp, this.options))
+ .join(' ')
+ .split(/\s+/)
+ .map(comp => replaceGTE0(comp, this.options))
+ // in loose mode, throw out any that are not valid comparators
+ .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true)
+ .map(comp => new Comparator(comp, this.options))
+ }
+
+ intersects (range, options) {
+ if (!(range instanceof Range)) {
+ throw new TypeError('a Range is required')
+ }
+
+ return this.set.some((thisComparators) => {
+ return (
+ isSatisfiable(thisComparators, options) &&
+ range.set.some((rangeComparators) => {
+ return (
+ isSatisfiable(rangeComparators, options) &&
+ thisComparators.every((thisComparator) => {
+ return rangeComparators.every((rangeComparator) => {
+ return thisComparator.intersects(rangeComparator, options)
+ })
+ })
+ )
+ })
+ )
+ })
+ }
+
+ // if ANY of the sets match ALL of its comparators, then pass
+ test (version) {
+ if (!version) {
+ return false
+ }
+
+ if (typeof version === 'string') {
+ try {
+ version = new SemVer(version, this.options)
+ } catch (er) {
+ return false
+ }
+ }
+
+ for (let i = 0; i < this.set.length; i++) {
+ if (testSet(this.set[i], version, this.options)) {
+ return true
+ }
+ }
+ return false
+ }
+}
+module.exports = Range
+
+const Comparator = __webpack_require__(123)
+const debug = __webpack_require__(487)
+const SemVer = __webpack_require__(369)
+const {
+ re,
+ t,
+ comparatorTrimReplace,
+ tildeTrimReplace,
+ caretTrimReplace
+} = __webpack_require__(590)
+
+// take a set of comparators and determine whether there
+// exists a version which can satisfy it
+const isSatisfiable = (comparators, options) => {
+ let result = true
+ const remainingComparators = comparators.slice()
+ let testComparator = remainingComparators.pop()
+
+ while (result && remainingComparators.length) {
+ result = remainingComparators.every((otherComparator) => {
+ return testComparator.intersects(otherComparator, options)
+ })
+
+ testComparator = remainingComparators.pop()
+ }
+
+ return result
+}
+
+// comprised of xranges, tildes, stars, and gtlt's at this point.
+// already replaced the hyphen ranges
+// turn into a set of JUST comparators.
+const parseComparator = (comp, options) => {
+ debug('comp', comp, options)
+ comp = replaceCarets(comp, options)
+ debug('caret', comp)
+ comp = replaceTildes(comp, options)
+ debug('tildes', comp)
+ comp = replaceXRanges(comp, options)
+ debug('xrange', comp)
+ comp = replaceStars(comp, options)
+ debug('stars', comp)
+ return comp
+}
+
+const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
+
+// ~, ~> --> * (any, kinda silly)
+// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
+// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
+// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
+// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
+// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
+const replaceTildes = (comp, options) =>
+ comp.trim().split(/\s+/).map((comp) => {
+ return replaceTilde(comp, options)
+ }).join(' ')
+
+const replaceTilde = (comp, options) => {
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
+ return comp.replace(r, (_, M, m, p, pr) => {
+ debug('tilde', comp, _, M, m, p, pr)
+ let ret
+
+ if (isX(M)) {
+ ret = ''
+ } else if (isX(m)) {
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`
+ } else if (isX(p)) {
+ // ~1.2 == >=1.2.0 <1.3.0-0
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`
+ } else if (pr) {
+ debug('replaceTilde pr', pr)
+ ret = `>=${M}.${m}.${p}-${pr
+ } <${M}.${+m + 1}.0-0`
+ } else {
+ // ~1.2.3 == >=1.2.3 <1.3.0-0
+ ret = `>=${M}.${m}.${p
+ } <${M}.${+m + 1}.0-0`
+ }
+
+ debug('tilde return', ret)
+ return ret
+ })
+}
+
+// ^ --> * (any, kinda silly)
+// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
+// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
+// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
+// ^1.2.3 --> >=1.2.3 <2.0.0-0
+// ^1.2.0 --> >=1.2.0 <2.0.0-0
+const replaceCarets = (comp, options) =>
+ comp.trim().split(/\s+/).map((comp) => {
+ return replaceCaret(comp, options)
+ }).join(' ')
+
+const replaceCaret = (comp, options) => {
+ debug('caret', comp, options)
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
+ const z = options.includePrerelease ? '-0' : ''
+ return comp.replace(r, (_, M, m, p, pr) => {
+ debug('caret', comp, _, M, m, p, pr)
+ let ret
+
+ if (isX(M)) {
+ ret = ''
+ } else if (isX(m)) {
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`
+ } else if (isX(p)) {
+ if (M === '0') {
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
+ } else {
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`
+ }
+ } else if (pr) {
+ debug('replaceCaret pr', pr)
+ if (M === '0') {
+ if (m === '0') {
+ ret = `>=${M}.${m}.${p}-${pr
+ } <${M}.${m}.${+p + 1}-0`
+ } else {
+ ret = `>=${M}.${m}.${p}-${pr
+ } <${M}.${+m + 1}.0-0`
+ }
+ } else {
+ ret = `>=${M}.${m}.${p}-${pr
+ } <${+M + 1}.0.0-0`
+ }
+ } else {
+ debug('no pr')
+ if (M === '0') {
+ if (m === '0') {
+ ret = `>=${M}.${m}.${p
+ }${z} <${M}.${m}.${+p + 1}-0`
+ } else {
+ ret = `>=${M}.${m}.${p
+ }${z} <${M}.${+m + 1}.0-0`
+ }
+ } else {
+ ret = `>=${M}.${m}.${p
+ } <${+M + 1}.0.0-0`
+ }
+ }
+
+ debug('caret return', ret)
+ return ret
+ })
+}
+
+const replaceXRanges = (comp, options) => {
+ debug('replaceXRanges', comp, options)
+ return comp.split(/\s+/).map((comp) => {
+ return replaceXRange(comp, options)
+ }).join(' ')
+}
+
+const replaceXRange = (comp, options) => {
+ comp = comp.trim()
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
+ debug('xRange', comp, ret, gtlt, M, m, p, pr)
+ const xM = isX(M)
+ const xm = xM || isX(m)
+ const xp = xm || isX(p)
+ const anyX = xp
+
+ if (gtlt === '=' && anyX) {
+ gtlt = ''
+ }
+
+ // if we're including prereleases in the match, then we need
+ // to fix this to -0, the lowest possible prerelease value
+ pr = options.includePrerelease ? '-0' : ''
+
+ if (xM) {
+ if (gtlt === '>' || gtlt === '<') {
+ // nothing is allowed
+ ret = '<0.0.0-0'
+ } else {
+ // nothing is forbidden
+ ret = '*'
+ }
+ } else if (gtlt && anyX) {
+ // we know patch is an x, because we have any x at all.
+ // replace X with 0
+ if (xm) {
+ m = 0
+ }
+ p = 0
+
+ if (gtlt === '>') {
+ // >1 => >=2.0.0
+ // >1.2 => >=1.3.0
+ gtlt = '>='
+ if (xm) {
+ M = +M + 1
+ m = 0
+ p = 0
+ } else {
+ m = +m + 1
+ p = 0
+ }
+ } else if (gtlt === '<=') {
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
+ gtlt = '<'
+ if (xm) {
+ M = +M + 1
+ } else {
+ m = +m + 1
+ }
+ }
+
+ if (gtlt === '<')
+ pr = '-0'
+
+ ret = `${gtlt + M}.${m}.${p}${pr}`
+ } else if (xm) {
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`
+ } else if (xp) {
+ ret = `>=${M}.${m}.0${pr
+ } <${M}.${+m + 1}.0-0`
+ }
+
+ debug('xRange return', ret)
+
+ return ret
+ })
+}
+
+// Because * is AND-ed with everything else in the comparator,
+// and '' means "any version", just remove the *s entirely.
+const replaceStars = (comp, options) => {
+ debug('replaceStars', comp, options)
+ // Looseness is ignored here. star is always as loose as it gets!
+ return comp.trim().replace(re[t.STAR], '')
+}
+
+const replaceGTE0 = (comp, options) => {
+ debug('replaceGTE0', comp, options)
+ return comp.trim()
+ .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
+}
+
+// This function is passed to string.replace(re[t.HYPHENRANGE])
+// M, m, patch, prerelease, build
+// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
+// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
+// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
+const hyphenReplace = incPr => ($0,
+ from, fM, fm, fp, fpr, fb,
+ to, tM, tm, tp, tpr, tb) => {
+ if (isX(fM)) {
+ from = ''
+ } else if (isX(fm)) {
+ from = `>=${fM}.0.0${incPr ? '-0' : ''}`
+ } else if (isX(fp)) {
+ from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`
+ } else if (fpr) {
+ from = `>=${from}`
+ } else {
+ from = `>=${from}${incPr ? '-0' : ''}`
+ }
+
+ if (isX(tM)) {
+ to = ''
+ } else if (isX(tm)) {
+ to = `<${+tM + 1}.0.0-0`
+ } else if (isX(tp)) {
+ to = `<${tM}.${+tm + 1}.0-0`
+ } else if (tpr) {
+ to = `<=${tM}.${tm}.${tp}-${tpr}`
+ } else if (incPr) {
+ to = `<${tM}.${tm}.${+tp + 1}-0`
+ } else {
+ to = `<=${to}`
+ }
+
+ return (`${from} ${to}`).trim()
+}
+
+const testSet = (set, version, options) => {
+ for (let i = 0; i < set.length; i++) {
+ if (!set[i].test(version)) {
+ return false
+ }
+ }
+
+ if (version.prerelease.length && !options.includePrerelease) {
+ // Find the set of versions that are allowed to have prereleases
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
+ // That should allow `1.2.3-pr.2` to pass.
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
+ // even though it's within the range set by the comparators.
+ for (let i = 0; i < set.length; i++) {
+ debug(set[i].semver)
+ if (set[i].semver === Comparator.ANY) {
+ continue
+ }
+
+ if (set[i].semver.prerelease.length > 0) {
+ const allowed = set[i].semver
+ if (allowed.major === version.major &&
+ allowed.minor === version.minor &&
+ allowed.patch === version.patch) {
+ return true
+ }
+ }
+ }
+
+ // Version has a -pre, but it's not one of the ones we like.
+ return false
+ }
+
+ return true
+}
+
+
+/***/ }),
/* 987 */
/***/ (function(module, __unusedexports, __webpack_require__) {
@@ -285125,7 +291282,7 @@ var fs = __webpack_require__(747);
var path = __webpack_require__(622);
var caller = __webpack_require__(433);
var nodeModulesPaths = __webpack_require__(194);
-var normalizeOptions = __webpack_require__(590);
+var normalizeOptions = __webpack_require__(791);
var defaultIsFile = function isFile(file) {
try {
@@ -285362,7 +291519,27 @@ module.exports = getRawTag;
/***/ }),
-/* 989 */,
+/* 989 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const SemVer = __webpack_require__(243)
+
+const inc = (version, release, options, identifier) => {
+ if (typeof (options) === 'string') {
+ identifier = options
+ options = undefined
+ }
+
+ try {
+ return new SemVer(version, options).inc(release, identifier).version
+ } catch (er) {
+ return null
+ }
+}
+module.exports = inc
+
+
+/***/ }),
/* 990 */
/***/ (function(module, exports, __webpack_require__) {
@@ -286735,7 +292912,37 @@ exports.computeSourceURL = computeSourceURL;
/***/ }),
/* 993 */,
-/* 994 */,
+/* 994 */
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+const SemVer = __webpack_require__(369)
+const Range = __webpack_require__(986)
+
+const maxSatisfying = (versions, range, options) => {
+ let max = null
+ let maxSV = null
+ let rangeObj = null
+ try {
+ rangeObj = new Range(range, options)
+ } catch (er) {
+ return null
+ }
+ versions.forEach((v) => {
+ if (rangeObj.test(v)) {
+ // satisfies(v, range, options)
+ if (!max || maxSV.compare(v) === -1) {
+ // compare(max, v, true)
+ max = v
+ maxSV = new SemVer(max, options)
+ }
+ }
+ })
+ return max
+}
+module.exports = maxSatisfying
+
+
+/***/ }),
/* 995 */
/***/ (function(module) {
@@ -287417,7 +293624,7 @@ module.exports = defaults;
"use strict";
-var utils = __webpack_require__(658);
+var utils = __webpack_require__(733);
var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
diff --git a/doc_assets/github-deployment.png b/doc_assets/github-deployment.png
new file mode 100644
index 00000000..01a70657
Binary files /dev/null and b/doc_assets/github-deployment.png differ
diff --git a/package-lock.json b/package-lock.json
index a38dd045..6c2004de 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "actions-netlify",
- "version": "1.1.0",
+ "version": "1.1.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -37,19 +37,19 @@
}
},
"@babel/core": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.9.6.tgz",
- "integrity": "sha512-nD3deLvbsApbHAHttzIssYqgb883yU/d9roe4RZymBCDaZryMJDbptVpEpeQuRh4BJ+SYI8le9YGxKvFEvl1Wg==",
- "dev": true,
- "requires": {
- "@babel/code-frame": "^7.8.3",
- "@babel/generator": "^7.9.6",
- "@babel/helper-module-transforms": "^7.9.0",
- "@babel/helpers": "^7.9.6",
- "@babel/parser": "^7.9.6",
- "@babel/template": "^7.8.6",
- "@babel/traverse": "^7.9.6",
- "@babel/types": "^7.9.6",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.1.tgz",
+ "integrity": "sha512-u8XiZ6sMXW/gPmoP5ijonSUln4unazG291X0XAQ5h0s8qnAFr6BRRZGUEK+jtRWdmB0NTJQt7Uga25q8GetIIg==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.10.1",
+ "@babel/generator": "^7.10.1",
+ "@babel/helper-module-transforms": "^7.10.1",
+ "@babel/helpers": "^7.10.1",
+ "@babel/parser": "^7.10.1",
+ "@babel/template": "^7.10.1",
+ "@babel/traverse": "^7.10.1",
+ "@babel/types": "^7.10.1",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.1",
@@ -60,68 +60,167 @@
"source-map": "^0.5.0"
},
"dependencies": {
+ "@babel/code-frame": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz",
+ "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==",
+ "dev": true,
+ "requires": {
+ "@babel/highlight": "^7.10.1"
+ }
+ },
"@babel/generator": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.6.tgz",
- "integrity": "sha512-+htwWKJbH2bL72HRluF8zumBxzuX0ZZUFl3JLNyoUjM/Ho8wnVpPXM6aUz8cfKDqQ/h7zHqKt4xzJteUosckqQ==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.1.tgz",
+ "integrity": "sha512-AT0YPLQw9DI21tliuJIdplVfLHya6mcGa8ctkv7n4Qv+hYacJrKmNWIteAK1P9iyLikFIAkwqJ7HAOqIDLFfgA==",
"dev": true,
"requires": {
- "@babel/types": "^7.9.6",
+ "@babel/types": "^7.10.1",
"jsesc": "^2.5.1",
"lodash": "^4.17.13",
"source-map": "^0.5.0"
}
},
"@babel/helper-function-name": {
- "version": "7.9.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz",
- "integrity": "sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.1.tgz",
+ "integrity": "sha512-fcpumwhs3YyZ/ttd5Rz0xn0TpIwVkN7X0V38B9TWNfVF42KEkhkAAuPCQ3oXmtTRtiPJrmZ0TrfS0GKF0eMaRQ==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-get-function-arity": "^7.10.1",
+ "@babel/template": "^7.10.1",
+ "@babel/types": "^7.10.1"
+ }
+ },
+ "@babel/helper-get-function-arity": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.1.tgz",
+ "integrity": "sha512-F5qdXkYGOQUb0hpRaPoetF9AnsXknKjWMZ+wmsIRsp5ge5sFh4c3h1eH2pRTTuy9KKAA2+TTYomGXAtEL2fQEw==",
+ "dev": true,
+ "requires": {
+ "@babel/types": "^7.10.1"
+ }
+ },
+ "@babel/helper-split-export-declaration": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz",
+ "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==",
"dev": true,
"requires": {
- "@babel/helper-get-function-arity": "^7.8.3",
- "@babel/template": "^7.8.3",
- "@babel/types": "^7.9.5"
+ "@babel/types": "^7.10.1"
}
},
"@babel/helper-validator-identifier": {
- "version": "7.9.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz",
- "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz",
+ "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==",
"dev": true
},
+ "@babel/highlight": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz",
+ "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "chalk": "^2.0.0",
+ "js-tokens": "^4.0.0"
+ }
+ },
"@babel/parser": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.6.tgz",
- "integrity": "sha512-AoeIEJn8vt+d/6+PXDRPaksYhnlbMIiejioBZvvMQsOjW/JYK6k/0dKnvvP3EhK5GfMBWDPtrxRtegWdAcdq9Q==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz",
+ "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==",
"dev": true
},
+ "@babel/template": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz",
+ "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.10.1",
+ "@babel/parser": "^7.10.1",
+ "@babel/types": "^7.10.1"
+ }
+ },
"@babel/traverse": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.6.tgz",
- "integrity": "sha512-b3rAHSjbxy6VEAvlxM8OV/0X4XrG72zoxme6q1MOoe2vd0bEc+TwayhuC1+Dfgqh1QEG+pj7atQqvUprHIccsg==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.1.tgz",
+ "integrity": "sha512-C/cTuXeKt85K+p08jN6vMDz8vSV0vZcI0wmQ36o6mjbuo++kPMdpOYw23W2XH04dbRt9/nMEfA4W3eR21CD+TQ==",
"dev": true,
"requires": {
- "@babel/code-frame": "^7.8.3",
- "@babel/generator": "^7.9.6",
- "@babel/helper-function-name": "^7.9.5",
- "@babel/helper-split-export-declaration": "^7.8.3",
- "@babel/parser": "^7.9.6",
- "@babel/types": "^7.9.6",
+ "@babel/code-frame": "^7.10.1",
+ "@babel/generator": "^7.10.1",
+ "@babel/helper-function-name": "^7.10.1",
+ "@babel/helper-split-export-declaration": "^7.10.1",
+ "@babel/parser": "^7.10.1",
+ "@babel/types": "^7.10.1",
"debug": "^4.1.0",
"globals": "^11.1.0",
"lodash": "^4.17.13"
}
},
"@babel/types": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.6.tgz",
- "integrity": "sha512-qxXzvBO//jO9ZnoasKF1uJzHd2+M6Q2ZPIVfnFps8JJvXy0ZBbwbNOmE6SGIY5XOY6d1Bo5lb9d9RJ8nv3WSeA==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz",
+ "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==",
"dev": true,
"requires": {
- "@babel/helper-validator-identifier": "^7.9.5",
+ "@babel/helper-validator-identifier": "^7.10.1",
"lodash": "^4.17.13",
"to-fast-properties": "^2.0.0"
}
+ },
+ "ansi-styles": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
+ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
+ "dev": true,
+ "requires": {
+ "color-convert": "^1.9.0"
+ }
+ },
+ "chalk": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
+ "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^3.2.1",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^5.3.0"
+ }
+ },
+ "color-convert": {
+ "version": "1.9.3",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "dev": true,
+ "requires": {
+ "color-name": "1.1.3"
+ }
+ },
+ "color-name": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
+ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
+ "dev": true
+ },
+ "has-flag": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^3.0.0"
+ }
}
}
},
@@ -158,138 +257,515 @@
}
},
"@babel/helper-member-expression-to-functions": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.8.3.tgz",
- "integrity": "sha512-fO4Egq88utkQFjbPrSHGmGLFqmrshs11d46WI+WZDESt7Wu7wN2G2Iu+NMMZJFDOVRHAMIkB5SNh30NtwCA7RA==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.1.tgz",
+ "integrity": "sha512-u7XLXeM2n50gb6PWJ9hoO5oO7JFPaZtrh35t8RqKLT1jFKj9IWeD1zrcrYp1q1qiZTdEarfDWfTIP8nGsu0h5g==",
"dev": true,
"requires": {
- "@babel/types": "^7.8.3"
+ "@babel/types": "^7.10.1"
+ },
+ "dependencies": {
+ "@babel/helper-validator-identifier": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz",
+ "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==",
+ "dev": true
+ },
+ "@babel/types": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz",
+ "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "lodash": "^4.17.13",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
}
},
"@babel/helper-module-imports": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.8.3.tgz",
- "integrity": "sha512-R0Bx3jippsbAEtzkpZ/6FIiuzOURPcMjHp+Z6xPe6DtApDJx+w7UYyOLanZqO8+wKR9G10s/FmHXvxaMd9s6Kg==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.1.tgz",
+ "integrity": "sha512-SFxgwYmZ3HZPyZwJRiVNLRHWuW2OgE5k2nrVs6D9Iv4PPnXVffuEHy83Sfx/l4SqF+5kyJXjAyUmrG7tNm+qVg==",
"dev": true,
"requires": {
- "@babel/types": "^7.8.3"
+ "@babel/types": "^7.10.1"
+ },
+ "dependencies": {
+ "@babel/helper-validator-identifier": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz",
+ "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==",
+ "dev": true
+ },
+ "@babel/types": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz",
+ "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "lodash": "^4.17.13",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
}
},
"@babel/helper-module-transforms": {
- "version": "7.9.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.9.0.tgz",
- "integrity": "sha512-0FvKyu0gpPfIQ8EkxlrAydOWROdHpBmiCiRwLkUiBGhCUPRRbVD2/tm3sFr/c/GWFrQ/ffutGUAnx7V0FzT2wA==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.1.tgz",
+ "integrity": "sha512-RLHRCAzyJe7Q7sF4oy2cB+kRnU4wDZY/H2xJFGof+M+SJEGhZsb+GFj5j1AD8NiSaVBJ+Pf0/WObiXu/zxWpFg==",
"dev": true,
"requires": {
- "@babel/helper-module-imports": "^7.8.3",
- "@babel/helper-replace-supers": "^7.8.6",
- "@babel/helper-simple-access": "^7.8.3",
- "@babel/helper-split-export-declaration": "^7.8.3",
- "@babel/template": "^7.8.6",
- "@babel/types": "^7.9.0",
+ "@babel/helper-module-imports": "^7.10.1",
+ "@babel/helper-replace-supers": "^7.10.1",
+ "@babel/helper-simple-access": "^7.10.1",
+ "@babel/helper-split-export-declaration": "^7.10.1",
+ "@babel/template": "^7.10.1",
+ "@babel/types": "^7.10.1",
"lodash": "^4.17.13"
+ },
+ "dependencies": {
+ "@babel/code-frame": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz",
+ "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==",
+ "dev": true,
+ "requires": {
+ "@babel/highlight": "^7.10.1"
+ }
+ },
+ "@babel/helper-split-export-declaration": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz",
+ "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==",
+ "dev": true,
+ "requires": {
+ "@babel/types": "^7.10.1"
+ }
+ },
+ "@babel/helper-validator-identifier": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz",
+ "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==",
+ "dev": true
+ },
+ "@babel/highlight": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz",
+ "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "chalk": "^2.0.0",
+ "js-tokens": "^4.0.0"
+ }
+ },
+ "@babel/parser": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz",
+ "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==",
+ "dev": true
+ },
+ "@babel/template": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz",
+ "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.10.1",
+ "@babel/parser": "^7.10.1",
+ "@babel/types": "^7.10.1"
+ }
+ },
+ "@babel/types": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz",
+ "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "lodash": "^4.17.13",
+ "to-fast-properties": "^2.0.0"
+ }
+ },
+ "ansi-styles": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
+ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
+ "dev": true,
+ "requires": {
+ "color-convert": "^1.9.0"
+ }
+ },
+ "chalk": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
+ "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^3.2.1",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^5.3.0"
+ }
+ },
+ "color-convert": {
+ "version": "1.9.3",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "dev": true,
+ "requires": {
+ "color-name": "1.1.3"
+ }
+ },
+ "color-name": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
+ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
+ "dev": true
+ },
+ "has-flag": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^3.0.0"
+ }
+ }
}
},
"@babel/helper-optimise-call-expression": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.8.3.tgz",
- "integrity": "sha512-Kag20n86cbO2AvHca6EJsvqAd82gc6VMGule4HwebwMlwkpXuVqrNRj6CkCV2sKxgi9MyAUnZVnZ6lJ1/vKhHQ==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.1.tgz",
+ "integrity": "sha512-a0DjNS1prnBsoKx83dP2falChcs7p3i8VMzdrSbfLhuQra/2ENC4sbri34dz/rWmDADsmF1q5GbfaXydh0Jbjg==",
"dev": true,
"requires": {
- "@babel/types": "^7.8.3"
+ "@babel/types": "^7.10.1"
+ },
+ "dependencies": {
+ "@babel/helper-validator-identifier": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz",
+ "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==",
+ "dev": true
+ },
+ "@babel/types": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz",
+ "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "lodash": "^4.17.13",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
}
},
"@babel/helper-plugin-utils": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.8.3.tgz",
- "integrity": "sha512-j+fq49Xds2smCUNYmEHF9kGNkhbet6yVIBp4e6oeQpH1RUs/Ir06xUKzDjDkGcaaokPiTNs2JBWHjaE4csUkZQ==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.1.tgz",
+ "integrity": "sha512-fvoGeXt0bJc7VMWZGCAEBEMo/HAjW2mP8apF5eXK0wSqwLAVHAISCWRoLMBMUs2kqeaG77jltVqu4Hn8Egl3nA==",
"dev": true
},
"@babel/helper-replace-supers": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.9.6.tgz",
- "integrity": "sha512-qX+chbxkbArLyCImk3bWV+jB5gTNU/rsze+JlcF6Nf8tVTigPJSI1o1oBow/9Resa1yehUO9lIipsmu9oG4RzA==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.1.tgz",
+ "integrity": "sha512-SOwJzEfpuQwInzzQJGjGaiG578UYmyi2Xw668klPWV5n07B73S0a9btjLk/52Mlcxa+5AdIYqws1KyXRfMoB7A==",
"dev": true,
"requires": {
- "@babel/helper-member-expression-to-functions": "^7.8.3",
- "@babel/helper-optimise-call-expression": "^7.8.3",
- "@babel/traverse": "^7.9.6",
- "@babel/types": "^7.9.6"
+ "@babel/helper-member-expression-to-functions": "^7.10.1",
+ "@babel/helper-optimise-call-expression": "^7.10.1",
+ "@babel/traverse": "^7.10.1",
+ "@babel/types": "^7.10.1"
},
"dependencies": {
+ "@babel/code-frame": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz",
+ "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==",
+ "dev": true,
+ "requires": {
+ "@babel/highlight": "^7.10.1"
+ }
+ },
"@babel/generator": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.6.tgz",
- "integrity": "sha512-+htwWKJbH2bL72HRluF8zumBxzuX0ZZUFl3JLNyoUjM/Ho8wnVpPXM6aUz8cfKDqQ/h7zHqKt4xzJteUosckqQ==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.1.tgz",
+ "integrity": "sha512-AT0YPLQw9DI21tliuJIdplVfLHya6mcGa8ctkv7n4Qv+hYacJrKmNWIteAK1P9iyLikFIAkwqJ7HAOqIDLFfgA==",
"dev": true,
"requires": {
- "@babel/types": "^7.9.6",
+ "@babel/types": "^7.10.1",
"jsesc": "^2.5.1",
"lodash": "^4.17.13",
"source-map": "^0.5.0"
}
},
"@babel/helper-function-name": {
- "version": "7.9.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz",
- "integrity": "sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.1.tgz",
+ "integrity": "sha512-fcpumwhs3YyZ/ttd5Rz0xn0TpIwVkN7X0V38B9TWNfVF42KEkhkAAuPCQ3oXmtTRtiPJrmZ0TrfS0GKF0eMaRQ==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-get-function-arity": "^7.10.1",
+ "@babel/template": "^7.10.1",
+ "@babel/types": "^7.10.1"
+ }
+ },
+ "@babel/helper-get-function-arity": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.1.tgz",
+ "integrity": "sha512-F5qdXkYGOQUb0hpRaPoetF9AnsXknKjWMZ+wmsIRsp5ge5sFh4c3h1eH2pRTTuy9KKAA2+TTYomGXAtEL2fQEw==",
"dev": true,
"requires": {
- "@babel/helper-get-function-arity": "^7.8.3",
- "@babel/template": "^7.8.3",
- "@babel/types": "^7.9.5"
+ "@babel/types": "^7.10.1"
+ }
+ },
+ "@babel/helper-split-export-declaration": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz",
+ "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==",
+ "dev": true,
+ "requires": {
+ "@babel/types": "^7.10.1"
}
},
"@babel/helper-validator-identifier": {
- "version": "7.9.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz",
- "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz",
+ "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==",
"dev": true
},
+ "@babel/highlight": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz",
+ "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "chalk": "^2.0.0",
+ "js-tokens": "^4.0.0"
+ }
+ },
"@babel/parser": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.6.tgz",
- "integrity": "sha512-AoeIEJn8vt+d/6+PXDRPaksYhnlbMIiejioBZvvMQsOjW/JYK6k/0dKnvvP3EhK5GfMBWDPtrxRtegWdAcdq9Q==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz",
+ "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==",
"dev": true
},
+ "@babel/template": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz",
+ "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.10.1",
+ "@babel/parser": "^7.10.1",
+ "@babel/types": "^7.10.1"
+ }
+ },
"@babel/traverse": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.6.tgz",
- "integrity": "sha512-b3rAHSjbxy6VEAvlxM8OV/0X4XrG72zoxme6q1MOoe2vd0bEc+TwayhuC1+Dfgqh1QEG+pj7atQqvUprHIccsg==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.1.tgz",
+ "integrity": "sha512-C/cTuXeKt85K+p08jN6vMDz8vSV0vZcI0wmQ36o6mjbuo++kPMdpOYw23W2XH04dbRt9/nMEfA4W3eR21CD+TQ==",
"dev": true,
"requires": {
- "@babel/code-frame": "^7.8.3",
- "@babel/generator": "^7.9.6",
- "@babel/helper-function-name": "^7.9.5",
- "@babel/helper-split-export-declaration": "^7.8.3",
- "@babel/parser": "^7.9.6",
- "@babel/types": "^7.9.6",
+ "@babel/code-frame": "^7.10.1",
+ "@babel/generator": "^7.10.1",
+ "@babel/helper-function-name": "^7.10.1",
+ "@babel/helper-split-export-declaration": "^7.10.1",
+ "@babel/parser": "^7.10.1",
+ "@babel/types": "^7.10.1",
"debug": "^4.1.0",
"globals": "^11.1.0",
"lodash": "^4.17.13"
}
},
"@babel/types": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.6.tgz",
- "integrity": "sha512-qxXzvBO//jO9ZnoasKF1uJzHd2+M6Q2ZPIVfnFps8JJvXy0ZBbwbNOmE6SGIY5XOY6d1Bo5lb9d9RJ8nv3WSeA==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz",
+ "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==",
"dev": true,
"requires": {
- "@babel/helper-validator-identifier": "^7.9.5",
+ "@babel/helper-validator-identifier": "^7.10.1",
"lodash": "^4.17.13",
"to-fast-properties": "^2.0.0"
}
+ },
+ "ansi-styles": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
+ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
+ "dev": true,
+ "requires": {
+ "color-convert": "^1.9.0"
+ }
+ },
+ "chalk": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
+ "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^3.2.1",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^5.3.0"
+ }
+ },
+ "color-convert": {
+ "version": "1.9.3",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "dev": true,
+ "requires": {
+ "color-name": "1.1.3"
+ }
+ },
+ "color-name": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
+ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
+ "dev": true
+ },
+ "has-flag": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^3.0.0"
+ }
}
}
},
"@babel/helper-simple-access": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.8.3.tgz",
- "integrity": "sha512-VNGUDjx5cCWg4vvCTR8qQ7YJYZ+HBjxOgXEl7ounz+4Sn7+LMD3CFrCTEU6/qXKbA2nKg21CwhhBzO0RpRbdCw==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.1.tgz",
+ "integrity": "sha512-VSWpWzRzn9VtgMJBIWTZ+GP107kZdQ4YplJlCmIrjoLVSi/0upixezHCDG8kpPVTBJpKfxTH01wDhh+jS2zKbw==",
"dev": true,
"requires": {
- "@babel/template": "^7.8.3",
- "@babel/types": "^7.8.3"
+ "@babel/template": "^7.10.1",
+ "@babel/types": "^7.10.1"
+ },
+ "dependencies": {
+ "@babel/code-frame": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz",
+ "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==",
+ "dev": true,
+ "requires": {
+ "@babel/highlight": "^7.10.1"
+ }
+ },
+ "@babel/helper-validator-identifier": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz",
+ "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==",
+ "dev": true
+ },
+ "@babel/highlight": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz",
+ "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "chalk": "^2.0.0",
+ "js-tokens": "^4.0.0"
+ }
+ },
+ "@babel/parser": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz",
+ "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==",
+ "dev": true
+ },
+ "@babel/template": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz",
+ "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.10.1",
+ "@babel/parser": "^7.10.1",
+ "@babel/types": "^7.10.1"
+ }
+ },
+ "@babel/types": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz",
+ "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "lodash": "^4.17.13",
+ "to-fast-properties": "^2.0.0"
+ }
+ },
+ "ansi-styles": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
+ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
+ "dev": true,
+ "requires": {
+ "color-convert": "^1.9.0"
+ }
+ },
+ "chalk": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
+ "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^3.2.1",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^5.3.0"
+ }
+ },
+ "color-convert": {
+ "version": "1.9.3",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "dev": true,
+ "requires": {
+ "color-name": "1.1.3"
+ }
+ },
+ "color-name": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
+ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
+ "dev": true
+ },
+ "has-flag": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^3.0.0"
+ }
+ }
}
},
"@babel/helper-split-export-declaration": {
@@ -308,78 +784,177 @@
"dev": true
},
"@babel/helpers": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.9.6.tgz",
- "integrity": "sha512-tI4bUbldloLcHWoRUMAj4g1bF313M/o6fBKhIsb3QnGVPwRm9JsNf/gqMkQ7zjqReABiffPV6RWj7hEglID5Iw==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.1.tgz",
+ "integrity": "sha512-muQNHF+IdU6wGgkaJyhhEmI54MOZBKsFfsXFhboz1ybwJ1Kl7IHlbm2a++4jwrmY5UYsgitt5lfqo1wMFcHmyw==",
"dev": true,
"requires": {
- "@babel/template": "^7.8.3",
- "@babel/traverse": "^7.9.6",
- "@babel/types": "^7.9.6"
+ "@babel/template": "^7.10.1",
+ "@babel/traverse": "^7.10.1",
+ "@babel/types": "^7.10.1"
},
"dependencies": {
+ "@babel/code-frame": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz",
+ "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==",
+ "dev": true,
+ "requires": {
+ "@babel/highlight": "^7.10.1"
+ }
+ },
"@babel/generator": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.6.tgz",
- "integrity": "sha512-+htwWKJbH2bL72HRluF8zumBxzuX0ZZUFl3JLNyoUjM/Ho8wnVpPXM6aUz8cfKDqQ/h7zHqKt4xzJteUosckqQ==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.1.tgz",
+ "integrity": "sha512-AT0YPLQw9DI21tliuJIdplVfLHya6mcGa8ctkv7n4Qv+hYacJrKmNWIteAK1P9iyLikFIAkwqJ7HAOqIDLFfgA==",
"dev": true,
"requires": {
- "@babel/types": "^7.9.6",
+ "@babel/types": "^7.10.1",
"jsesc": "^2.5.1",
"lodash": "^4.17.13",
"source-map": "^0.5.0"
}
},
"@babel/helper-function-name": {
- "version": "7.9.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz",
- "integrity": "sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.1.tgz",
+ "integrity": "sha512-fcpumwhs3YyZ/ttd5Rz0xn0TpIwVkN7X0V38B9TWNfVF42KEkhkAAuPCQ3oXmtTRtiPJrmZ0TrfS0GKF0eMaRQ==",
"dev": true,
"requires": {
- "@babel/helper-get-function-arity": "^7.8.3",
- "@babel/template": "^7.8.3",
- "@babel/types": "^7.9.5"
+ "@babel/helper-get-function-arity": "^7.10.1",
+ "@babel/template": "^7.10.1",
+ "@babel/types": "^7.10.1"
+ }
+ },
+ "@babel/helper-get-function-arity": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.1.tgz",
+ "integrity": "sha512-F5qdXkYGOQUb0hpRaPoetF9AnsXknKjWMZ+wmsIRsp5ge5sFh4c3h1eH2pRTTuy9KKAA2+TTYomGXAtEL2fQEw==",
+ "dev": true,
+ "requires": {
+ "@babel/types": "^7.10.1"
+ }
+ },
+ "@babel/helper-split-export-declaration": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz",
+ "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==",
+ "dev": true,
+ "requires": {
+ "@babel/types": "^7.10.1"
}
},
"@babel/helper-validator-identifier": {
- "version": "7.9.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz",
- "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz",
+ "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==",
"dev": true
},
+ "@babel/highlight": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz",
+ "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.1",
+ "chalk": "^2.0.0",
+ "js-tokens": "^4.0.0"
+ }
+ },
"@babel/parser": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.6.tgz",
- "integrity": "sha512-AoeIEJn8vt+d/6+PXDRPaksYhnlbMIiejioBZvvMQsOjW/JYK6k/0dKnvvP3EhK5GfMBWDPtrxRtegWdAcdq9Q==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz",
+ "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==",
"dev": true
},
+ "@babel/template": {
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz",
+ "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.10.1",
+ "@babel/parser": "^7.10.1",
+ "@babel/types": "^7.10.1"
+ }
+ },
"@babel/traverse": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.6.tgz",
- "integrity": "sha512-b3rAHSjbxy6VEAvlxM8OV/0X4XrG72zoxme6q1MOoe2vd0bEc+TwayhuC1+Dfgqh1QEG+pj7atQqvUprHIccsg==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.1.tgz",
+ "integrity": "sha512-C/cTuXeKt85K+p08jN6vMDz8vSV0vZcI0wmQ36o6mjbuo++kPMdpOYw23W2XH04dbRt9/nMEfA4W3eR21CD+TQ==",
"dev": true,
"requires": {
- "@babel/code-frame": "^7.8.3",
- "@babel/generator": "^7.9.6",
- "@babel/helper-function-name": "^7.9.5",
- "@babel/helper-split-export-declaration": "^7.8.3",
- "@babel/parser": "^7.9.6",
- "@babel/types": "^7.9.6",
+ "@babel/code-frame": "^7.10.1",
+ "@babel/generator": "^7.10.1",
+ "@babel/helper-function-name": "^7.10.1",
+ "@babel/helper-split-export-declaration": "^7.10.1",
+ "@babel/parser": "^7.10.1",
+ "@babel/types": "^7.10.1",
"debug": "^4.1.0",
"globals": "^11.1.0",
"lodash": "^4.17.13"
}
},
"@babel/types": {
- "version": "7.9.6",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.6.tgz",
- "integrity": "sha512-qxXzvBO//jO9ZnoasKF1uJzHd2+M6Q2ZPIVfnFps8JJvXy0ZBbwbNOmE6SGIY5XOY6d1Bo5lb9d9RJ8nv3WSeA==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz",
+ "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==",
"dev": true,
"requires": {
- "@babel/helper-validator-identifier": "^7.9.5",
+ "@babel/helper-validator-identifier": "^7.10.1",
"lodash": "^4.17.13",
"to-fast-properties": "^2.0.0"
}
+ },
+ "ansi-styles": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
+ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
+ "dev": true,
+ "requires": {
+ "color-convert": "^1.9.0"
+ }
+ },
+ "chalk": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
+ "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^3.2.1",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^5.3.0"
+ }
+ },
+ "color-convert": {
+ "version": "1.9.3",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "dev": true,
+ "requires": {
+ "color-name": "1.1.3"
+ }
+ },
+ "color-name": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
+ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
+ "dev": true
+ },
+ "has-flag": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^3.0.0"
+ }
}
}
},
@@ -470,12 +1045,12 @@
}
},
"@babel/plugin-syntax-class-properties": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.8.3.tgz",
- "integrity": "sha512-UcAyQWg2bAN647Q+O811tG9MrJ38Z10jjhQdKNAL8fsyPzE3cCN/uT+f55cFVY4aGO4jqJAvmqsuY3GQDwAoXg==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.10.1.tgz",
+ "integrity": "sha512-Gf2Yx/iRs1JREDtVZ56OrjjgFHCaldpTnuy9BHla10qyVT3YkIIGEtoDWhyop0ksu1GvNjHIoYRBqm3zoR1jyQ==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.8.3"
+ "@babel/helper-plugin-utils": "^7.10.1"
}
},
"@babel/plugin-syntax-json-strings": {
@@ -488,12 +1063,12 @@
}
},
"@babel/plugin-syntax-logical-assignment-operators": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.8.3.tgz",
- "integrity": "sha512-Zpg2Sgc++37kuFl6ppq2Q7Awc6E6AIW671x5PY8E/f7MCIyPPGK/EoeZXvvY3P42exZ3Q4/t3YOzP/HiN79jDg==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.1.tgz",
+ "integrity": "sha512-XyHIFa9kdrgJS91CUH+ccPVTnJShr8nLGc5bG2IhGXv5p1Rd+8BleGE5yzIg2Nc1QZAdHDa0Qp4m6066OL96Iw==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.8.3"
+ "@babel/helper-plugin-utils": "^7.10.1"
}
},
"@babel/plugin-syntax-nullish-coalescing-operator": {
@@ -506,12 +1081,12 @@
}
},
"@babel/plugin-syntax-numeric-separator": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.8.3.tgz",
- "integrity": "sha512-H7dCMAdN83PcCmqmkHB5dtp+Xa9a6LKSvA2hiFBC/5alSHxM5VgWZXFqDi0YFe8XNGT6iCa+z4V4zSt/PdZ7Dw==",
+ "version": "7.10.1",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.1.tgz",
+ "integrity": "sha512-uTd0OsHrpe3tH5gRPTxG8Voh99/WCU78vIm5NMRYPAqC8lR4vajt6KkCAknCHrx24vkPdd/05yfdGSB4EIY2mg==",
"dev": true,
"requires": {
- "@babel/helper-plugin-utils": "^7.8.3"
+ "@babel/helper-plugin-utils": "^7.10.1"
}
},
"@babel/plugin-syntax-object-rest-spread": {
@@ -616,13 +1191,14 @@
}
},
"@istanbuljs/load-nyc-config": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.0.0.tgz",
- "integrity": "sha512-ZR0rq/f/E4f4XcgnDvtMWXCUJpi8eO0rssVhmztsZqLIEFA9UUP9zmpE0VxlM+kv/E1ul2I876Fwil2ayptDVg==",
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
+ "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==",
"dev": true,
"requires": {
"camelcase": "^5.3.1",
"find-up": "^4.1.0",
+ "get-package-type": "^0.1.0",
"js-yaml": "^3.13.1",
"resolve-from": "^5.0.0"
},
@@ -971,20 +1547,21 @@
}
},
"@netlify/open-api": {
- "version": "0.14.0",
- "resolved": "https://registry.npmjs.org/@netlify/open-api/-/open-api-0.14.0.tgz",
- "integrity": "sha512-epAbGVkUtFutiVDBqqepW/6Le619rGk79bnhEO7pMRMoVlPt3ga/hiFrqxozXI+QUvcHw6lvDSli6MLAonBIig=="
+ "version": "0.15.0",
+ "resolved": "https://registry.npmjs.org/@netlify/open-api/-/open-api-0.15.0.tgz",
+ "integrity": "sha512-Nk1NswVrUtI7SDbyn/uvITYeIG5iukKlhsu/6fg4k1G5RMHqMDtVHy+2qcOhKmkf7Qc3ZkIKKd2mQfM6zg2cxw=="
},
"@netlify/zip-it-and-ship-it": {
- "version": "0.4.0-18",
- "resolved": "https://registry.npmjs.org/@netlify/zip-it-and-ship-it/-/zip-it-and-ship-it-0.4.0-18.tgz",
- "integrity": "sha512-UzmG6WWi8tspqQX3nwIw9qtN2i5HJin51KC25Y2DnRjUXj1QEX0OCa/NJEfjHD4tPd0tEjmhZ1k2vuZ5ndjZ7w==",
+ "version": "0.4.0-19",
+ "resolved": "https://registry.npmjs.org/@netlify/zip-it-and-ship-it/-/zip-it-and-ship-it-0.4.0-19.tgz",
+ "integrity": "sha512-QjGw5d8iTa9JLqFzMJw2DPYAmG0q7mfZsahf5rPPCmdNty/HkmNTkSswgxuTX+BCXsfjCnfCGbVZbM+8crIT0w==",
"requires": {
"archiver": "^3.0.0",
"common-path-prefix": "^2.0.0",
"cp-file": "^7.0.0",
"elf-tools": "^1.1.1",
"end-of-stream": "^1.4.4",
+ "find-up": "^4.1.0",
"glob": "^7.1.6",
"make-dir": "^3.0.2",
"p-map": "^3.0.0",
@@ -993,6 +1570,7 @@
"precinct": "^6.2.0",
"require-package-name": "^2.0.1",
"resolve": "^2.0.0-next.1",
+ "semver": "^7.3.2",
"unixify": "^1.0.0",
"util.promisify": "^1.0.1",
"yargs": "^15.3.1"
@@ -1056,34 +1634,39 @@
"requires": {
"path-parse": "^1.0.6"
}
+ },
+ "semver": {
+ "version": "7.3.2",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
+ "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ=="
}
}
},
"@octokit/auth-token": {
- "version": "2.4.0",
- "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.0.tgz",
- "integrity": "sha512-eoOVMjILna7FVQf96iWc3+ZtE/ZT6y8ob8ZzcqKY1ibSQCnu4O/B7pJvzMx5cyZ/RjAff6DAdEb0O0Cjcxidkg==",
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.1.tgz",
+ "integrity": "sha512-NB81O5h39KfHYGtgfWr2booRxp2bWOJoqbWwbyUg2hw6h35ArWYlAST5B3XwAkbdcx13yt84hFXyFP5X0QToWA==",
"requires": {
- "@octokit/types": "^2.0.0"
+ "@octokit/types": "^4.0.1"
}
},
"@octokit/endpoint": {
- "version": "6.0.1",
- "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.1.tgz",
- "integrity": "sha512-pOPHaSz57SFT/m3R5P8MUu4wLPszokn5pXcB/pzavLTQf2jbU+6iayTvzaY6/BiotuRS0qyEUkx3QglT4U958A==",
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.2.tgz",
+ "integrity": "sha512-xs1mmCEZ2y4shXCpFjNq3UbmNR+bLzxtZim2L0zfEtj9R6O6kc4qLDvYw66hvO6lUsYzPTM5hMkltbuNAbRAcQ==",
"requires": {
- "@octokit/types": "^2.11.1",
+ "@octokit/types": "^4.0.1",
"is-plain-object": "^3.0.0",
"universal-user-agent": "^5.0.0"
}
},
"@octokit/graphql": {
- "version": "4.4.0",
- "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.4.0.tgz",
- "integrity": "sha512-Du3hAaSROQ8EatmYoSAJjzAz3t79t9Opj/WY1zUgxVUGfIKn0AEjg+hlOLscF6fv6i/4y/CeUvsWgIfwMkTccw==",
+ "version": "4.5.0",
+ "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.5.0.tgz",
+ "integrity": "sha512-StJWfn0M1QfhL3NKBz31e1TdDNZrHLLS57J2hin92SIfzlOVBuUaRkp31AGkGOAFOAVtyEX6ZiZcsjcJDjeb5g==",
"requires": {
"@octokit/request": "^5.3.0",
- "@octokit/types": "^2.0.0",
+ "@octokit/types": "^4.0.1",
"universal-user-agent": "^5.0.0"
}
},
@@ -1093,6 +1676,16 @@
"integrity": "sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q==",
"requires": {
"@octokit/types": "^2.0.1"
+ },
+ "dependencies": {
+ "@octokit/types": {
+ "version": "2.16.2",
+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.16.2.tgz",
+ "integrity": "sha512-O75k56TYvJ8WpAakWwYRN8Bgu60KrmX0z1KqFp1kNiFNkgW+JW+9EBKZ+S33PU6SLvbihqd+3drvPxKK68Ee8Q==",
+ "requires": {
+ "@types/node": ">= 8"
+ }
+ }
}
},
"@octokit/plugin-request-log": {
@@ -1107,16 +1700,26 @@
"requires": {
"@octokit/types": "^2.0.1",
"deprecation": "^2.3.1"
+ },
+ "dependencies": {
+ "@octokit/types": {
+ "version": "2.16.2",
+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.16.2.tgz",
+ "integrity": "sha512-O75k56TYvJ8WpAakWwYRN8Bgu60KrmX0z1KqFp1kNiFNkgW+JW+9EBKZ+S33PU6SLvbihqd+3drvPxKK68Ee8Q==",
+ "requires": {
+ "@types/node": ">= 8"
+ }
+ }
}
},
"@octokit/request": {
- "version": "5.4.2",
- "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.2.tgz",
- "integrity": "sha512-zKdnGuQ2TQ2vFk9VU8awFT4+EYf92Z/v3OlzRaSh4RIP0H6cvW1BFPXq4XYvNez+TPQjqN+0uSkCYnMFFhcFrw==",
+ "version": "5.4.4",
+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.4.tgz",
+ "integrity": "sha512-vqv1lz41c6VTxUvF9nM+a6U+vvP3vGk7drDpr0DVQg4zyqlOiKVrY17DLD6de5okj+YLHKcoqaUZTBtlNZ1BtQ==",
"requires": {
"@octokit/endpoint": "^6.0.1",
"@octokit/request-error": "^2.0.0",
- "@octokit/types": "^2.11.1",
+ "@octokit/types": "^4.0.1",
"deprecation": "^2.0.0",
"is-plain-object": "^3.0.0",
"node-fetch": "^2.3.0",
@@ -1125,11 +1728,11 @@
}
},
"@octokit/request-error": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.0.tgz",
- "integrity": "sha512-rtYicB4Absc60rUv74Rjpzek84UbVHGHJRu4fNVlZ1mCcyUPPuzFfG9Rn6sjHrd95DEsmjSt1Axlc699ZlbDkw==",
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.1.tgz",
+ "integrity": "sha512-5lqBDJ9/TOehK82VvomQ6zFiZjPeSom8fLkFVLuYL3sKiIb5RB8iN/lenLkY7oBmyQcGP7FBMGiIZTO8jufaRQ==",
"requires": {
- "@octokit/types": "^2.0.0",
+ "@octokit/types": "^4.0.1",
"deprecation": "^2.0.0",
"once": "^1.4.0"
}
@@ -1167,6 +1770,14 @@
"once": "^1.4.0"
}
},
+ "@octokit/types": {
+ "version": "2.16.2",
+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.16.2.tgz",
+ "integrity": "sha512-O75k56TYvJ8WpAakWwYRN8Bgu60KrmX0z1KqFp1kNiFNkgW+JW+9EBKZ+S33PU6SLvbihqd+3drvPxKK68Ee8Q==",
+ "requires": {
+ "@types/node": ">= 8"
+ }
+ },
"universal-user-agent": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.1.tgz",
@@ -1178,17 +1789,17 @@
}
},
"@octokit/types": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.15.0.tgz",
- "integrity": "sha512-0mnpenB8rLhBVu8VUklp38gWi+EatjvcEcLWcdProMKauSaQWWepOAybZ714sOGsEyhXPlIcHICggn8HUsCXVw==",
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-4.0.2.tgz",
+ "integrity": "sha512-+4X6qfhT/fk/5FD66395NrFLxCzD6FsGlpPwfwvnukdyfYbhiZB/FJltiT1XM5Q63rGGBSf9FPaNV3WpNHm54A==",
"requires": {
"@types/node": ">= 8"
}
},
"@sinonjs/commons": {
- "version": "1.7.2",
- "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.2.tgz",
- "integrity": "sha512-+DUO6pnp3udV/v2VfUWgaY5BIE1IfT7lLfeDzPVeMT1XKkaAp9LgSI9x5RtrFQoZ9Oi0PgXQQHPaoKu7dCjVxw==",
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.0.tgz",
+ "integrity": "sha512-wEj54PfsZ5jGSwMX68G8ZXFawcSglQSXqCftWX3ec8MDUzQdHgcKvw97awHbY0efQEL5iKUOAmmVtoYgmrSG4Q==",
"dev": true,
"requires": {
"type-detect": "4.0.8"
@@ -1265,9 +1876,9 @@
}
},
"@types/istanbul-lib-coverage": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz",
- "integrity": "sha512-hRJD2ahnnpLgsj6KWMYSrmXkM3rm2Dl1qkx6IOFD5FnuNPXJIG5L0dhgKXCYTRMGzU4n0wImQ/xfmRc4POUFlg==",
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.2.tgz",
+ "integrity": "sha512-rsZg7eL+Xcxsxk2XlBt9KcG8nOp9iYdKCOikY9x2RFJCyOdNj4MKPQty0e8oZr29vVAzKXr1BmR+kZauti3o1w==",
"dev": true
},
"@types/istanbul-lib-report": {
@@ -1280,9 +1891,9 @@
}
},
"@types/istanbul-reports": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-1.1.1.tgz",
- "integrity": "sha512-UpYjBi8xefVChsCoBpKShdxTllC9pwISirfoZsUa2AAdQg/Jd2KQGtSbw+ya7GPo7x/wAPlH6JBhKhAsXUEZNA==",
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-1.1.2.tgz",
+ "integrity": "sha512-P/W9yOX/3oPZSpaYOCQzGqgCQRXn0FFO/V8bWrCQs+wLmvVVxk6CRBXALEvNs9OHIatlnlFokfhuDo2ug01ciw==",
"dev": true,
"requires": {
"@types/istanbul-lib-coverage": "*",
@@ -1290,9 +1901,9 @@
}
},
"@types/jest": {
- "version": "25.2.1",
- "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.2.1.tgz",
- "integrity": "sha512-msra1bCaAeEdkSyA0CZ6gW1ukMIvZ5YoJkdXw/qhQdsuuDlFTcEUrUw8CLCPt2rVRUfXlClVvK2gvPs9IokZaA==",
+ "version": "25.2.3",
+ "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.2.3.tgz",
+ "integrity": "sha512-JXc1nK/tXHiDhV55dvfzqtmP4S3sy3T3ouV2tkViZgxY/zeUkcpQcQPGRlgF4KmWzWW5oiWYSZwtCB+2RsE4Fw==",
"dev": true,
"requires": {
"jest-diff": "^25.2.1",
@@ -1306,9 +1917,9 @@
"dev": true
},
"@types/node": {
- "version": "12.12.38",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.38.tgz",
- "integrity": "sha512-75eLjX0pFuTcUXnnWmALMzzkYorjND0ezNEycaKesbUBg9eGZp4GHPuDmkRc4mQQvIpe29zrzATNRA6hkYqwmA=="
+ "version": "12.12.42",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.42.tgz",
+ "integrity": "sha512-R/9QdYFLL9dE9l5cWWzWIZByVGFd7lk7JVOJ7KD+E1SJ4gni7XJRLz9QTjyYQiHIqEAgku9VgxdLjMlhhUaAFg=="
},
"@types/normalize-package-data": {
"version": "2.4.0",
@@ -1329,9 +1940,9 @@
"dev": true
},
"@types/yargs": {
- "version": "15.0.4",
- "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.4.tgz",
- "integrity": "sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==",
+ "version": "15.0.5",
+ "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz",
+ "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==",
"dev": true,
"requires": {
"@types/yargs-parser": "*"
@@ -1405,54 +2016,89 @@
}
},
"@typescript-eslint/experimental-utils": {
- "version": "2.31.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.31.0.tgz",
- "integrity": "sha512-MI6IWkutLYQYTQgZ48IVnRXmLR/0Q6oAyJgiOror74arUMh7EWjJkADfirZhRsUMHeLJ85U2iySDwHTSnNi9vA==",
+ "version": "2.34.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz",
+ "integrity": "sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
- "@typescript-eslint/typescript-estree": "2.31.0",
+ "@typescript-eslint/typescript-estree": "2.34.0",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
}
},
"@typescript-eslint/parser": {
- "version": "2.31.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.31.0.tgz",
- "integrity": "sha512-uph+w6xUOlyV2DLSC6o+fBDzZ5i7+3/TxAsH4h3eC64tlga57oMb96vVlXoMwjR/nN+xyWlsnxtbDkB46M2EPQ==",
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.0.2.tgz",
+ "integrity": "sha512-80Z7s83e8QXHNUspqVlWwb4t5gdz/1bBBmafElbK1wwAwiD/yvJsFyHRxlEpNrt4rdK6eB3p+2WEFkEDHAKk9w==",
"dev": true,
"requires": {
"@types/eslint-visitor-keys": "^1.0.0",
- "@typescript-eslint/experimental-utils": "2.31.0",
- "@typescript-eslint/typescript-estree": "2.31.0",
+ "@typescript-eslint/experimental-utils": "3.0.2",
+ "@typescript-eslint/typescript-estree": "3.0.2",
"eslint-visitor-keys": "^1.1.0"
+ },
+ "dependencies": {
+ "@typescript-eslint/experimental-utils": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.0.2.tgz",
+ "integrity": "sha512-4Wc4EczvoY183SSEnKgqAfkj1eLtRgBQ04AAeG+m4RhTVyaazxc1uI8IHf0qLmu7xXe9j1nn+UoDJjbmGmuqXQ==",
+ "dev": true,
+ "requires": {
+ "@types/json-schema": "^7.0.3",
+ "@typescript-eslint/typescript-estree": "3.0.2",
+ "eslint-scope": "^5.0.0",
+ "eslint-utils": "^2.0.0"
+ }
+ },
+ "@typescript-eslint/typescript-estree": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.2.tgz",
+ "integrity": "sha512-cs84mxgC9zQ6viV8MEcigfIKQmKtBkZNDYf8Gru2M+MhnA6z9q0NFMZm2IEzKqAwN8lY5mFVd1Z8DiHj6zQ3Tw==",
+ "dev": true,
+ "requires": {
+ "debug": "^4.1.1",
+ "eslint-visitor-keys": "^1.1.0",
+ "glob": "^7.1.6",
+ "is-glob": "^4.0.1",
+ "lodash": "^4.17.15",
+ "semver": "^7.3.2",
+ "tsutils": "^3.17.1"
+ }
+ },
+ "semver": {
+ "version": "7.3.2",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
+ "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
+ "dev": true
+ }
}
},
"@typescript-eslint/typescript-estree": {
- "version": "2.31.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.31.0.tgz",
- "integrity": "sha512-vxW149bXFXXuBrAak0eKHOzbcu9cvi6iNcJDzEtOkRwGHxJG15chiAQAwhLOsk+86p9GTr/TziYvw+H9kMaIgA==",
+ "version": "2.34.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz",
+ "integrity": "sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg==",
"requires": {
"debug": "^4.1.1",
"eslint-visitor-keys": "^1.1.0",
"glob": "^7.1.6",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
- "semver": "^6.3.0",
+ "semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"semver": {
- "version": "6.3.0",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
- "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
+ "version": "7.3.2",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
+ "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ=="
}
}
},
"@zeit/ncc": {
- "version": "0.22.1",
- "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.1.tgz",
- "integrity": "sha512-Qq3bMuonkcnV/96jhy9SQYdh39NXHxNMJ1O31ZFzWG9n52fR2DLtgrNzhj/ahlEjnBziMLGVWDbaS9sf03/fEw==",
+ "version": "0.22.3",
+ "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.3.tgz",
+ "integrity": "sha512-jnCLpLXWuw/PAiJiVbLjA8WBC0IJQbFeUwF4I9M+23MvIxTxk5pD4Q8byQBSPmHQjz5aBoA7AKAElQxMpjrCLQ==",
"dev": true
},
"abab": {
@@ -1727,9 +2373,9 @@
"dev": true
},
"aws4": {
- "version": "1.9.1",
- "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz",
- "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==",
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.0.tgz",
+ "integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==",
"dev": true
},
"axobject-query": {
@@ -3092,9 +3738,9 @@
}
},
"eslint-plugin-jest": {
- "version": "23.10.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.10.0.tgz",
- "integrity": "sha512-cHC//nesojSO1MLxVmFJR/bUaQQG7xvMHQD8YLbsQzevR41WKm8paKDUv2wMHlUy5XLZUmNcWuflOi4apS8D+Q==",
+ "version": "23.13.2",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.13.2.tgz",
+ "integrity": "sha512-qZit+moTXTyZFNDqSIR88/L3rdBlTU7CuW6XmyErD2FfHEkdoLgThkRbiQjzgYnX6rfgLx3Ci4eJmF4Ui5v1Cw==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "^2.5.0"
@@ -3693,6 +4339,12 @@
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="
},
+ "get-package-type": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",
+ "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==",
+ "dev": true
+ },
"get-stdin": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz",
@@ -4411,15 +5063,12 @@
"dev": true
},
"istanbul-lib-instrument": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.1.tgz",
- "integrity": "sha512-imIchxnodll7pvQBYOqUu88EufLCU56LMeFPZZM/fJZ1irYcYdqroaV+ACK1Ila8ls09iEYArp+nqyC6lW1Vfg==",
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz",
+ "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==",
"dev": true,
"requires": {
"@babel/core": "^7.7.5",
- "@babel/parser": "^7.7.5",
- "@babel/template": "^7.7.4",
- "@babel/traverse": "^7.7.4",
"@istanbuljs/schema": "^0.1.2",
"istanbul-lib-coverage": "^3.0.0",
"semver": "^6.3.0"
@@ -4526,9 +5175,9 @@
},
"dependencies": {
"cross-spawn": {
- "version": "7.0.2",
- "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.2.tgz",
- "integrity": "sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw==",
+ "version": "7.0.3",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
+ "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dev": true,
"requires": {
"path-key": "^3.1.0",
@@ -4777,15 +5426,15 @@
}
},
"@types/prettier": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.0.0.tgz",
- "integrity": "sha512-/rM+sWiuOZ5dvuVzV37sUuklsbg+JPOP8d+nNFlo2ZtfpzPiPvh1/gc8liWOLBqe+sR+ZM7guPaIcTt6UZTo7Q==",
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.0.1.tgz",
+ "integrity": "sha512-boy4xPNEtiw6N3abRhBi/e7hNvy3Tt8E9ZRAQrwAGzoCGZS/1wjo9KY7JHhnfnEsG5wSjDbymCozUM9a3ea7OQ==",
"dev": true
},
"acorn": {
- "version": "7.1.1",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz",
- "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==",
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz",
+ "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==",
"dev": true
},
"acorn-globals": {
@@ -6105,9 +6754,9 @@
"dev": true
},
"js-yaml": {
- "version": "3.13.1",
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
- "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
+ "version": "3.14.0",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz",
+ "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
@@ -6155,9 +6804,9 @@
},
"dependencies": {
"acorn": {
- "version": "7.1.1",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz",
- "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==",
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz",
+ "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==",
"dev": true
}
}
@@ -6605,12 +7254,12 @@
"integrity": "sha512-AO81vsIO1k1sM4Zrd6Hu7regmJN1NSiAja10gc4bX3F0wd+9rQmcuHQaHVQCYIEC8iFXnE+mavh23GOt7wBgug=="
},
"netlify": {
- "version": "4.1.5",
- "resolved": "https://registry.npmjs.org/netlify/-/netlify-4.1.5.tgz",
- "integrity": "sha512-73OLoP60bc09fKXyOzTel+QALKJQS5Y9WYZphzTmkNTqXeq3vDVfaF7e50Cl7vppTxwpZ0r4YQVQt24TPu3UDw==",
+ "version": "4.1.7",
+ "resolved": "https://registry.npmjs.org/netlify/-/netlify-4.1.7.tgz",
+ "integrity": "sha512-MMI84bLb1QrkAadnNRvglcUbje+hJNQo3ZEUAYJSUiQ4QPpIp9cuayFtfJ/N/dYRPehNiH7B6ZbSZ9FfmpUyVA==",
"requires": {
- "@netlify/open-api": "^0.14.0",
- "@netlify/zip-it-and-ship-it": "^0.4.0-18",
+ "@netlify/open-api": "^0.15.0",
+ "@netlify/zip-it-and-ship-it": "^0.4.0-19",
"backoff": "^2.5.0",
"clean-deep": "^3.3.0",
"filter-obj": "^2.0.1",
@@ -7145,9 +7794,9 @@
"dev": true
},
"postcss": {
- "version": "7.0.29",
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.29.tgz",
- "integrity": "sha512-ba0ApvR3LxGvRMMiUa9n0WR4HjzcYm7tS+ht4/2Nd0NLtHpPIH77fuB9Xh1/yJVz9O/E/95Y/dn8ygWsyffXtw==",
+ "version": "7.0.31",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.31.tgz",
+ "integrity": "sha512-a937VDHE1ftkjk+8/7nj/mrjtmkn69xxzJgRETXdAUU+IgOYPQNJF17haGWbeDxSyk++HA14UA98FurvPyBJOA==",
"requires": {
"chalk": "^2.4.2",
"source-map": "^0.6.1",
@@ -8788,9 +9437,9 @@
}
},
"typescript": {
- "version": "3.8.3",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
- "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w=="
+ "version": "3.9.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz",
+ "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ=="
},
"union-value": {
"version": "1.0.1",
@@ -9132,9 +9781,9 @@
}
},
"ws": {
- "version": "7.2.5",
- "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.5.tgz",
- "integrity": "sha512-C34cIU4+DB2vMyAbmEKossWq2ZQDr6QEyuuCzWrM9zfw1sGc0mYiJ0UnG9zzNykt49C2Fi34hvr2vssFQRS6EA==",
+ "version": "7.3.0",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz",
+ "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==",
"dev": true
},
"xml-name-validator": {
diff --git a/package.json b/package.json
index 76bb330b..add61868 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "actions-netlify",
- "version": "1.1.0",
+ "version": "1.1.1",
"private": true,
"description": "GitHub Actions for Netlify",
"main": "lib/main.js",
@@ -26,21 +26,21 @@
"dependencies": {
"@actions/core": "^1.2.4",
"@actions/github": "^2.2.0",
- "netlify": "^4.1.5"
+ "netlify": "^4.1.7"
},
"devDependencies": {
- "@types/jest": "^25.2.1",
- "@types/node": "^12.12.38",
- "@typescript-eslint/parser": "^2.31.0",
- "@zeit/ncc": "^0.22.1",
+ "@types/jest": "^25.2.3",
+ "@types/node": "^12.12.42",
+ "@typescript-eslint/parser": "^3.0.2",
+ "@zeit/ncc": "^0.22.3",
"eslint": "^5.16.0",
"eslint-plugin-github": "^2.0.0",
- "eslint-plugin-jest": "^23.10.0",
+ "eslint-plugin-jest": "^23.13.2",
"jest": "^25.5.4",
"jest-circus": "^26.0.1",
- "js-yaml": "^3.13.1",
+ "js-yaml": "^3.14.0",
"prettier": "^2.0.5",
"ts-jest": "^25.5.1",
- "typescript": "^3.8.3"
+ "typescript": "^3.9.3"
}
}
diff --git a/src/inputs.ts b/src/inputs.ts
index 964f76d1..b1d97587 100644
--- a/src/inputs.ts
+++ b/src/inputs.ts
@@ -9,6 +9,7 @@ export interface Inputs {
enableCommitComment(): boolean
githubToken(): string
overwritesPullRequestComment(): boolean
+ netlifyConfigPath(): string | undefined
}
export const defaultInputs: Inputs = {
@@ -37,5 +38,8 @@ export const defaultInputs: Inputs = {
return (
(core.getInput('overwrites-pull-request-comment') || 'true') === 'true'
)
+ },
+ netlifyConfigPath() {
+ return core.getInput('netlify-config-path') || undefined
}
}
diff --git a/src/main.ts b/src/main.ts
index 427fc7aa..3b11127d 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -27,6 +27,33 @@ async function findIssueComment(
return undefined
}
+async function createGitHubDeployment(
+ githubClient: GitHub,
+ environmentUrl: string,
+ environment: string
+): Promise {
+ const {ref} = context
+ const deployment = await githubClient.repos.createDeployment({
+ // eslint-disable-next-line @typescript-eslint/camelcase
+ auto_merge: false,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ ref,
+ environment,
+ // eslint-disable-next-line @typescript-eslint/camelcase
+ required_contexts: []
+ })
+ await githubClient.repos.createDeploymentStatus({
+ state: 'success',
+ // eslint-disable-next-line @typescript-eslint/camelcase
+ environment_url: environmentUrl,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ // eslint-disable-next-line @typescript-eslint/camelcase
+ deployment_id: deployment.data.id
+ })
+}
+
async function run(inputs: Inputs): Promise {
try {
const netlifyAuthToken = process.env.NETLIFY_AUTH_TOKEN
@@ -42,6 +69,7 @@ async function run(inputs: Inputs): Promise {
const enablePullRequestComment: boolean = inputs.enablePullRequestComment()
const enableCommitComment: boolean = inputs.enableCommitComment()
const overwritesPullRequestComment: boolean = inputs.overwritesPullRequestComment()
+ const netlifyConfigPath: string | undefined = inputs.netlifyConfigPath()
const isDraft: boolean =
productionBranch === undefined ||
context.ref !== `refs/heads/${productionBranch}`
@@ -53,7 +81,8 @@ async function run(inputs: Inputs): Promise {
// Deploy to Netlify
const deploy = await netlifyClient.deploy(siteId, deployFolder, {
draft: isDraft,
- message: deployMessage
+ message: deployMessage,
+ configPath: netlifyConfigPath
})
// Create a message
const message = isDraft
@@ -95,35 +124,67 @@ async function run(inputs: Inputs): Promise {
}
}
- // If it is a pull request and enable comment on pull request
- if (context.issue.number !== undefined && enablePullRequestComment) {
- let commentId: number | undefined = undefined
- if (overwritesPullRequestComment) {
- // Find issue comment
- commentId = await findIssueComment(githubClient)
+ if (context.issue.number === undefined) {
+ try {
+ const environmentUrl = isDraft
+ ? deploy.deploy.deploy_ssl_url
+ : deploy.deploy.ssl_url
+ const environment = isDraft ? 'commit' : 'production'
+ // Create GitHub Deployment
+ await createGitHubDeployment(
+ githubClient,
+ environmentUrl,
+ environment
+ )
+ } catch (err) {
+ // eslint-disable-next-line no-console
+ console.error(err)
}
+ }
+
+ // If it is a pull request and enable comment on pull request
+ if (context.issue.number !== undefined) {
+ if (enablePullRequestComment) {
+ let commentId: number | undefined = undefined
+ if (overwritesPullRequestComment) {
+ // Find issue comment
+ commentId = await findIssueComment(githubClient)
+ }
- // NOTE: if not overwrite, commentId is always undefined
- if (commentId !== undefined) {
- // Update comment of the deploy URL
- await githubClient.issues.updateComment({
- owner: context.issue.owner,
- repo: context.issue.repo,
- // eslint-disable-next-line @typescript-eslint/camelcase
- comment_id: commentId,
- body: markdownComment
- })
- return
+ // NOTE: if not overwrite, commentId is always undefined
+ if (commentId !== undefined) {
+ // Update comment of the deploy URL
+ await githubClient.issues.updateComment({
+ owner: context.issue.owner,
+ repo: context.issue.repo,
+ // eslint-disable-next-line @typescript-eslint/camelcase
+ comment_id: commentId,
+ body: markdownComment
+ })
+ } else {
+ // Comment the deploy URL
+ await githubClient.issues.createComment({
+ // eslint-disable-next-line @typescript-eslint/camelcase
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ body: markdownComment
+ })
+ }
}
- // Comment the deploy URL
- await githubClient.issues.createComment({
- // eslint-disable-next-line @typescript-eslint/camelcase
- issue_number: context.issue.number,
- owner: context.repo.owner,
- repo: context.repo.repo,
- body: markdownComment
- })
+ try {
+ const environmentUrl = deploy.deploy.deploy_ssl_url
+ // Create GitHub Deployment
+ await createGitHubDeployment(
+ githubClient,
+ environmentUrl,
+ 'pull request'
+ )
+ } catch (err) {
+ // eslint-disable-next-line no-console
+ console.error(err)
+ }
}
}
} catch (error) {