diff --git a/lib/de/diagnosticMessages.generated.json b/lib/de/diagnosticMessages.generated.json
index 9a63b99d233..61c5a4bc241 100644
--- a/lib/de/diagnosticMessages.generated.json
+++ b/lib/de/diagnosticMessages.generated.json
@@ -332,7 +332,7 @@
"Duplicate_number_index_signature_2375": "Doppelte Zahlenindexsignatur.",
"Duplicate_string_index_signature_2374": "Doppelte Zeichenfolgen-Indexsignatur.",
"Dynamic_import_cannot_have_type_arguments_1326": "Der dynamische Import kann nicht über Typargumente verfügen.",
- "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323": "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.",
+ "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323": "Der dynamische Import wird nur unterstützt, wenn das Flag \"--module\" auf \"commonjs\" oder \"esNext\" festgelegt ist.",
"Dynamic_import_must_have_one_specifier_as_an_argument_1324": "Der dynamische Import benötigt einen Spezifizierer als Argument.",
"Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "Der Spezifizierer des dynamischen Imports muss den Typ \"string\" aufweisen, hier ist er jedoch vom Typ \"{0}\".",
"Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015": "Das Element weist implizit einen Typ \"any\" auf, weil der Indexausdruck nicht vom Typ \"number\" ist.",
@@ -567,7 +567,7 @@
"Module_name_0_was_successfully_resolved_to_1_6089": "======== Der Modulname \"{0}\" wurde erfolgreich in \"{1}\" aufgelöst. ========",
"Module_resolution_kind_is_not_specified_using_0_6088": "Die Art der Modulauflösung wird nicht angegeben. \"{0}\" wird verwendet.",
"Module_resolution_using_rootDirs_has_failed_6111": "Fehler bei der Modulauflösung mithilfe von \"rootDirs\".",
- "Move_to_a_new_file_95049": "Move to a new file",
+ "Move_to_a_new_file_95049": "In neue Datei verschieben",
"Multiple_consecutive_numeric_separators_are_not_permitted_6189": "Mehrere aufeinander folgende numerische Trennzeichen sind nicht zulässig.",
"Multiple_constructor_implementations_are_not_allowed_2392": "Mehrere Konstruktorimplementierungen sind unzulässig.",
"NEWLINE_6061": "NEUE ZEILE",
@@ -707,11 +707,11 @@
"Raise_error_on_this_expressions_with_an_implied_any_type_6115": "Fehler für \"this\"-Ausdrücke mit einem impliziten any-Typ auslösen.",
"Redirect_output_structure_to_the_directory_6006": "Die Ausgabestruktur in das Verzeichnis umleiten.",
"Referenced_project_0_must_have_setting_composite_Colon_true_6306": "Das referenzierte Projekt \"{0}\" muss für die Einstellung \"composite\" den Wert TRUE aufweisen.",
- "Remove_all_unreachable_code_95051": "Remove all unreachable code",
+ "Remove_all_unreachable_code_95051": "Gesamten nicht erreichbaren Code entfernen",
"Remove_declaration_for_Colon_0_90004": "Deklaration entfernen für: {0}",
"Remove_destructuring_90009": "Destrukturierung entfernen",
"Remove_import_from_0_90005": "Import aus \"{0}\" entfernen",
- "Remove_unreachable_code_95050": "Remove unreachable code",
+ "Remove_unreachable_code_95050": "Nicht erreichbaren Code entfernen",
"Replace_import_with_0_95015": "Ersetzen Sie den Import durch \"{0}\".",
"Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Fehler melden, wenn nicht alle Codepfade in der Funktion einen Wert zurückgeben.",
"Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Für FallTrough-Fälle in switch-Anweisung Fehler melden.",
diff --git a/lib/enu/diagnosticMessages.generated.json.lcg b/lib/enu/diagnosticMessages.generated.json.lcg
index e017d024e7c..86d8f14cddd 100644
--- a/lib/enu/diagnosticMessages.generated.json.lcg
+++ b/lib/enu/diagnosticMessages.generated.json.lcg
@@ -651,6 +651,12 @@
+ -
+
+
+
+
+
-
diff --git a/lib/es/diagnosticMessages.generated.json b/lib/es/diagnosticMessages.generated.json
index cf58a0e20fd..06492d95a8c 100644
--- a/lib/es/diagnosticMessages.generated.json
+++ b/lib/es/diagnosticMessages.generated.json
@@ -332,7 +332,7 @@
"Duplicate_number_index_signature_2375": "Signatura de índice de número duplicada.",
"Duplicate_string_index_signature_2374": "Signatura de índice de cadena duplicada.",
"Dynamic_import_cannot_have_type_arguments_1326": "La importación dinámica no puede tener argumentos de tipo",
- "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323": "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.",
+ "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323": "La importación dinámica solo se admite cuando la marca \"--module\" es \"commonjs\" o \"esNext\".",
"Dynamic_import_must_have_one_specifier_as_an_argument_1324": "La importación dinámica debe tener un especificador como argumento.",
"Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "El especificador de la importación dinámica debe ser de tipo \"string\", pero aquí tiene el tipo \"{0}\".",
"Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015": "El elemento tiene un tipo 'any' implícito porque la expresión de índice no es de tipo 'number'.",
@@ -567,6 +567,7 @@
"Module_name_0_was_successfully_resolved_to_1_6089": "======== El nombre del módulo '{0}' se resolvió correctamente como '{1}'. ========",
"Module_resolution_kind_is_not_specified_using_0_6088": "No se ha especificado el tipo de resolución del módulo, se usará '{0}'.",
"Module_resolution_using_rootDirs_has_failed_6111": "No se pudo resolver el módulo con \"rootDirs\".",
+ "Move_to_a_new_file_95049": "Mover a un nuevo archivo",
"Multiple_consecutive_numeric_separators_are_not_permitted_6189": "No se permiten varios separadores numéricos consecutivos.",
"Multiple_constructor_implementations_are_not_allowed_2392": "No se permiten varias implementaciones del constructor.",
"NEWLINE_6061": "NUEVA LÍNEA",
@@ -706,9 +707,11 @@
"Raise_error_on_this_expressions_with_an_implied_any_type_6115": "Generar un error en expresiones 'this' con un tipo 'any' implícito.",
"Redirect_output_structure_to_the_directory_6006": "Redirija la estructura de salida al directorio.",
"Referenced_project_0_must_have_setting_composite_Colon_true_6306": "El proyecto \"{0}\" al que se hace referencia debe tener el valor \"composite\": true.",
+ "Remove_all_unreachable_code_95051": "Quitar todo el código inaccesible",
"Remove_declaration_for_Colon_0_90004": "Quitar declaración de: \"{0}\"",
"Remove_destructuring_90009": "Quitar la desestructuración",
"Remove_import_from_0_90005": "Quitar importación de \"{0}\"",
+ "Remove_unreachable_code_95050": "Quitar el código inaccesible",
"Replace_import_with_0_95015": "Reemplazar importación por \"{0}\".",
"Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Notificar un error cuando no todas las rutas de acceso de código en funcionamiento devuelven un valor.",
"Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Notificar errores de los casos de fallthrough en la instrucción switch.",
diff --git a/lib/lib.es2018.regexp.d.ts b/lib/lib.es2018.regexp.d.ts
index a0017f21438..0c3358ef6af 100644
--- a/lib/lib.es2018.regexp.d.ts
+++ b/lib/lib.es2018.regexp.d.ts
@@ -28,9 +28,4 @@ interface RegExpExecArray {
groups?: {
[key: string]: string
}
-}
-
-interface RegExp {
- /** Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression. Default is false. Read-only. */
- readonly dotAll: boolean;
-}
+}
\ No newline at end of file
diff --git a/lib/tr/diagnosticMessages.generated.json b/lib/tr/diagnosticMessages.generated.json
index 3fe8769022a..d037f7d0d20 100644
--- a/lib/tr/diagnosticMessages.generated.json
+++ b/lib/tr/diagnosticMessages.generated.json
@@ -332,7 +332,7 @@
"Duplicate_number_index_signature_2375": "Dizin imzasında yinelenen numara.",
"Duplicate_string_index_signature_2374": "Dizin imzasında yinelenen dize.",
"Dynamic_import_cannot_have_type_arguments_1326": "Dinamik içeri aktarma, tür bağımsız değişkenleri içeremez",
- "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323": "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.",
+ "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323": "Dinamik içeri aktarma yalnızca '--module' bayrağı 'commonjs' veya 'esNext' olduğunda desteklenir.",
"Dynamic_import_must_have_one_specifier_as_an_argument_1324": "Dinamik içeri aktarma, bağımsız değişken olarak bir tanımlayıcı içermelidir.",
"Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036": "Dinamik içeri aktarmanın tanımlayıcısı 'string' türünde olmalıdır, ancak buradaki tür: '{0}'.",
"Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015": "Dizin ifadesi 'number' türünde olmadığından, öğe örtük olarak 'any' türü içeriyor.",
@@ -567,6 +567,7 @@
"Module_name_0_was_successfully_resolved_to_1_6089": "======== '{0}' modül adı '{1}' öğesine başarıyla çözümlendi. ========",
"Module_resolution_kind_is_not_specified_using_0_6088": "Modül çözümleme türü belirtilmedi, '{0}' kullanılıyor.",
"Module_resolution_using_rootDirs_has_failed_6111": "'rootDirs' kullanarak modül çözümleme başarısız oldu.",
+ "Move_to_a_new_file_95049": "Yeni bir dosyaya taşı",
"Multiple_consecutive_numeric_separators_are_not_permitted_6189": "Birbirini izleyen birden çok sayısal ayırıcıya izin verilmez.",
"Multiple_constructor_implementations_are_not_allowed_2392": "Birden çok oluşturucu uygulamasına izin verilmez.",
"NEWLINE_6061": "YENİ SATIR",
@@ -706,9 +707,11 @@
"Raise_error_on_this_expressions_with_an_implied_any_type_6115": "Örtük olarak 'any' türü içeren 'this' ifadelerinde hata tetikle.",
"Redirect_output_structure_to_the_directory_6006": "Çıktı yapısını dizine yeniden yönlendir.",
"Referenced_project_0_must_have_setting_composite_Colon_true_6306": "Başvurulan proje '{0}' \"composite\": true ayarına sahip olmalıdır.",
+ "Remove_all_unreachable_code_95051": "Tüm erişilemeyen kodları kaldır",
"Remove_declaration_for_Colon_0_90004": "'{0}' bildirimini kaldır",
"Remove_destructuring_90009": "Yıkmayı kaldır",
"Remove_import_from_0_90005": "'{0}' öğesinden içeri aktarmayı kaldır",
+ "Remove_unreachable_code_95050": "Erişilemeyen kodları kaldır",
"Replace_import_with_0_95015": "İçeri aktarma işlemini '{0}' ile değiştirin.",
"Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "İşlevdeki tüm kod yolları bir değer döndürmediğinde hata bildir.",
"Report_errors_for_fallthrough_cases_in_switch_statement_6076": "switch deyiminde sonraki ifadelere geçiş ile ilgili hataları bildir.",
diff --git a/lib/tsc.js b/lib/tsc.js
index 15e9273877a..3042b2797e7 100644
--- a/lib/tsc.js
+++ b/lib/tsc.js
@@ -428,6 +428,15 @@ var ts;
return -1;
}
ts.findIndex = findIndex;
+ function findLastIndex(array, predicate, startIndex) {
+ for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
+ if (predicate(array[i], i)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+ ts.findLastIndex = findLastIndex;
function findMap(array, callback) {
for (var i = 0; i < array.length; i++) {
var result = callback(array[i], i);
@@ -758,6 +767,23 @@ var ts;
return false;
}
ts.some = some;
+ function getRangesWhere(arr, pred, cb) {
+ var start;
+ for (var i = 0; i < arr.length; i++) {
+ if (pred(arr[i])) {
+ start = start === undefined ? i : start;
+ }
+ else {
+ if (start !== undefined) {
+ cb(start, i);
+ start = undefined;
+ }
+ }
+ }
+ if (start !== undefined)
+ cb(start, arr.length);
+ }
+ ts.getRangesWhere = getRangesWhere;
function concatenate(array1, array2) {
if (!some(array2))
return array1;
@@ -4674,6 +4700,7 @@ var ts;
Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
+ Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing typeof"),
};
})(ts || (ts = {}));
var ts;
@@ -6240,11 +6267,10 @@ var ts;
}
}
function scanJSDocToken() {
+ startPos = tokenPos = pos;
if (pos >= end) {
return token = 1;
}
- startPos = pos;
- tokenPos = pos;
var ch = text.charCodeAt(pos);
pos++;
switch (ch) {
@@ -6601,7 +6627,7 @@ var ts;
if (includeJsDoc && ts.hasJSDocNodes(node)) {
return getTokenPosOfNode(node.jsDoc[0]);
}
- if (node.kind === 296 && node._children.length > 0) {
+ if (node.kind === 298 && node._children.length > 0) {
return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
}
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
@@ -6781,7 +6807,7 @@ var ts;
case 204:
case 235:
case 236:
- case 293:
+ case 295:
case 233:
case 153:
case 154:
@@ -6789,6 +6815,9 @@ var ts;
case 156:
case 191:
case 192:
+ case 291:
+ case 296:
+ case 287:
return true;
default:
ts.assertTypeIsNever(node);
@@ -6828,13 +6857,7 @@ var ts;
}
ts.isAnyImportOrReExport = isAnyImportOrReExport;
function getEnclosingBlockScopeContainer(node) {
- var current = node.parent;
- while (current) {
- if (isBlockScope(current, current.parent)) {
- return current;
- }
- current = current.parent;
- }
+ return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
}
ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
function declarationNameToString(name) {
@@ -7897,6 +7920,14 @@ var ts;
node.parameters[0].name.escapedText === "new";
}
ts.isJSDocConstructSignature = isJSDocConstructSignature;
+ function isJSDocTypeAlias(node) {
+ return node.kind === 296 || node.kind === 291;
+ }
+ ts.isJSDocTypeAlias = isJSDocTypeAlias;
+ function isTypeAlias(node) {
+ return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
+ }
+ ts.isTypeAlias = isTypeAlias;
function getSourceOfAssignment(node) {
return ts.isExpressionStatement(node) &&
node.expression && ts.isBinaryExpression(node.expression) &&
@@ -7918,6 +7949,8 @@ var ts;
return v && v.initializer;
case 151:
return node.initializer;
+ case 269:
+ return node.initializer;
}
}
function getSingleVariableOfVariableStatement(node) {
@@ -7942,8 +7975,7 @@ var ts;
if (parent.kind === 269 || parent.kind === 151 || getNestedModuleDeclaration(parent)) {
getJSDocCommentsAndTagsWorker(parent);
}
- if (parent.parent &&
- (getSingleVariableOfVariableStatement(parent.parent) === node)) {
+ if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) {
getJSDocCommentsAndTagsWorker(parent.parent);
}
if (parent.parent && parent.parent.parent &&
@@ -7986,7 +8018,10 @@ var ts;
}
ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
function getHostSignatureFromJSDoc(node) {
- var host = getJSDocHost(node);
+ return getHostSignatureFromJSDocHost(getJSDocHost(node));
+ }
+ ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ function getHostSignatureFromJSDocHost(host) {
var decl = getSourceOfDefaultedAssignment(host) ||
getSourceOfAssignment(host) ||
getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
@@ -7995,18 +8030,12 @@ var ts;
host;
return decl && ts.isFunctionLike(decl) ? decl : undefined;
}
- ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ ts.getHostSignatureFromJSDocHost = getHostSignatureFromJSDocHost;
function getJSDocHost(node) {
- while (node.parent.kind === 286) {
- if (node.parent.parent.kind === 294) {
- node = node.parent.parent;
- }
- else {
- node = node.parent.parent.parent;
- }
+ var comment = ts.findAncestor(node.parent, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152) ? "quit" : node.kind === 285; });
+ if (comment) {
+ return comment.parent;
}
- ts.Debug.assert(node.parent.kind === 285);
- return node.parent.parent;
}
ts.getJSDocHost = getJSDocHost;
function getTypeParameterFromJsDoc(node) {
@@ -8021,7 +8050,8 @@ var ts;
}
ts.hasRestParameter = hasRestParameter;
function isRestParameter(node) {
- return node.dotDotDotToken !== undefined || node.type && node.type.kind === 284;
+ var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
+ return node.dotDotDotToken !== undefined || type && type.kind === 284;
}
ts.isRestParameter = isRestParameter;
function getAssignmentTargetKind(node) {
@@ -8490,7 +8520,7 @@ var ts;
ts.getOperator = getOperator;
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
switch (nodeKind) {
- case 299:
+ case 301:
return 0;
case 203:
return 1;
@@ -8801,8 +8831,8 @@ var ts;
};
}
ts.createTextWriter = createTextWriter;
- function getResolvedExternalModuleName(host, file) {
- return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
+ function getResolvedExternalModuleName(host, file, referenceFile) {
+ return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
}
ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
@@ -8813,12 +8843,13 @@ var ts;
return getResolvedExternalModuleName(host, file);
}
ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
- function getExternalModuleNameFromPath(host, fileName) {
+ function getExternalModuleNameFromPath(host, fileName, referencePath) {
var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
- var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
+ var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false);
- return ts.removeFileExtension(relativePath);
+ var extensionless = ts.removeFileExtension(relativePath);
+ return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
}
ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
function getOwnEmitOutputFilePath(sourceFile, host, extension) {
@@ -8900,7 +8931,7 @@ var ts;
}
ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
function getThisParameter(signature) {
- if (signature.parameters.length) {
+ if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
var thisParameter = signature.parameters[0];
if (parameterIsThisKeyword(thisParameter)) {
return thisParameter;
@@ -8977,18 +9008,32 @@ var ts;
}
ts.getTypeAnnotationNode = getTypeAnnotationNode;
function getEffectiveReturnTypeNode(node) {
+ if (ts.isJSDocSignature(node)) {
+ return node.type && node.type.typeExpression && node.type.typeExpression.type;
+ }
return node.type || (isInJavaScriptFile(node) ? ts.getJSDocReturnType(node) : undefined);
}
ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
function getEffectiveTypeParameterDeclarations(node) {
- return ts.isJSDocTypedefTag(node)
- ? getJSDocTypeParameterDeclarations(node)
- : node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined);
+ if (ts.isJSDocSignature(node)) {
+ return ts.emptyArray;
+ }
+ if (isJSDocTypeAlias(node)) {
+ ts.Debug.assert(node.parent.kind === 285);
+ var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; });
+ var templateTagNodes = templateTags;
+ templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos;
+ templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end;
+ templateTagNodes.hasTrailingComma = false;
+ return templateTagNodes;
+ }
+ return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray);
}
ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
function getJSDocTypeParameterDeclarations(node) {
- var templateTag = ts.getJSDocTemplateTag(node);
- return templateTag && templateTag.typeParameters;
+ var tags = ts.filter(ts.getJSDocTags(node), ts.isJSDocTemplateTag);
+ var tag = ts.find(tags, function (tag) { return !(tag.parent.kind === 285 && ts.find(tag.parent.tags, isJSDocTypeAlias)); });
+ return (tag && tag.typeParameters) || ts.emptyArray;
}
ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
function getEffectiveSetAccessorTypeAnnotationNode(node) {
@@ -10107,8 +10152,8 @@ var ts;
break;
case 71:
return declaration;
- case 295:
- case 290: {
+ case 297:
+ case 292: {
var name = declaration.name;
if (name.kind === 145) {
return name.right;
@@ -10127,7 +10172,9 @@ var ts;
return undefined;
}
}
- case 294:
+ case 291:
+ return declaration.name;
+ case 296:
return getNameOfJSDocTypedef(declaration);
case 248: {
var expression = declaration.expression;
@@ -10456,7 +10503,7 @@ var ts;
}
ts.isParenthesizedExpression = isParenthesizedExpression;
function skipPartiallyEmittedExpressions(node) {
- while (node.kind === 298) {
+ while (node.kind === 300) {
node = node.expression;
}
return node;
@@ -10839,49 +10886,57 @@ var ts;
}
ts.isJSDoc = isJSDoc;
function isJSDocAugmentsTag(node) {
- return node.kind === 288;
+ return node.kind === 289;
}
ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
function isJSDocClassTag(node) {
- return node.kind === 289;
+ return node.kind === 290;
}
ts.isJSDocClassTag = isJSDocClassTag;
function isJSDocParameterTag(node) {
- return node.kind === 290;
+ return node.kind === 292;
}
ts.isJSDocParameterTag = isJSDocParameterTag;
function isJSDocReturnTag(node) {
- return node.kind === 291;
+ return node.kind === 293;
}
ts.isJSDocReturnTag = isJSDocReturnTag;
function isJSDocTypeTag(node) {
- return node.kind === 292;
+ return node.kind === 294;
}
ts.isJSDocTypeTag = isJSDocTypeTag;
function isJSDocTemplateTag(node) {
- return node.kind === 293;
+ return node.kind === 295;
}
ts.isJSDocTemplateTag = isJSDocTemplateTag;
function isJSDocTypedefTag(node) {
- return node.kind === 294;
+ return node.kind === 296;
}
ts.isJSDocTypedefTag = isJSDocTypedefTag;
function isJSDocPropertyTag(node) {
- return node.kind === 295;
+ return node.kind === 297;
}
ts.isJSDocPropertyTag = isJSDocPropertyTag;
function isJSDocPropertyLikeTag(node) {
- return node.kind === 295 || node.kind === 290;
+ return node.kind === 297 || node.kind === 292;
}
ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
function isJSDocTypeLiteral(node) {
return node.kind === 286;
}
ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
+ function isJSDocCallbackTag(node) {
+ return node.kind === 291;
+ }
+ ts.isJSDocCallbackTag = isJSDocCallbackTag;
+ function isJSDocSignature(node) {
+ return node.kind === 287;
+ }
+ ts.isJSDocSignature = isJSDocSignature;
})(ts || (ts = {}));
(function (ts) {
function isSyntaxList(n) {
- return n.kind === 296;
+ return n.kind === 298;
}
ts.isSyntaxList = isSyntaxList;
function isNode(node) {
@@ -11003,6 +11058,7 @@ var ts;
switch (kind) {
case 152:
case 157:
+ case 287:
case 158:
case 159:
case 162:
@@ -11278,8 +11334,8 @@ var ts;
case 203:
case 207:
case 205:
- case 299:
- case 298:
+ case 301:
+ case 300:
return true;
default:
return isUnaryExpressionKind(kind);
@@ -11292,11 +11348,11 @@ var ts;
}
ts.isAssertionExpression = isAssertionExpression;
function isPartiallyEmittedExpression(node) {
- return node.kind === 298;
+ return node.kind === 300;
}
ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
function isNotEmittedStatement(node) {
- return node.kind === 297;
+ return node.kind === 299;
}
ts.isNotEmittedStatement = isNotEmittedStatement;
function isNotEmittedOrPartiallyEmittedNode(node) {
@@ -11396,8 +11452,9 @@ var ts;
|| kind === 236
|| kind === 147
|| kind === 231
- || kind === 294
- || kind === 295;
+ || kind === 296
+ || kind === 291
+ || kind === 297;
}
function isDeclarationStatementKind(kind) {
return kind === 233
@@ -11432,13 +11489,13 @@ var ts;
|| kind === 213
|| kind === 218
|| kind === 225
- || kind === 297
- || kind === 301
- || kind === 300;
+ || kind === 299
+ || kind === 303
+ || kind === 302;
}
function isDeclaration(node) {
if (node.kind === 147) {
- return node.parent.kind !== 293 || ts.isInJavaScriptFile(node);
+ return node.parent.kind !== 295 || ts.isInJavaScriptFile(node);
}
return isDeclarationKind(node.kind);
}
@@ -11516,15 +11573,15 @@ var ts;
}
ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
function isJSDocNode(node) {
- return node.kind >= 277 && node.kind <= 295;
+ return node.kind >= 277 && node.kind <= 297;
}
ts.isJSDocNode = isJSDocNode;
function isJSDocCommentContainingNode(node) {
- return node.kind === 285 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node);
+ return node.kind === 285 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node);
}
ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
function isJSDocTag(node) {
- return node.kind >= 287 && node.kind <= 295;
+ return node.kind >= 288 && node.kind <= 297;
}
ts.isJSDocTag = isJSDocTag;
function isSetAccessor(node) {
@@ -12031,7 +12088,7 @@ var ts;
return visitNode(cbNode, node.expression);
case 252:
return visitNodes(cbNode, cbNodes, node.decorators);
- case 299:
+ case 301:
return visitNodes(cbNode, cbNodes, node.elements);
case 254:
return visitNode(cbNode, node.openingElement) ||
@@ -12073,8 +12130,8 @@ var ts;
return visitNode(cbNode, node.type);
case 285:
return visitNodes(cbNode, cbNodes, node.tags);
- case 290:
- case 295:
+ case 292:
+ case 297:
if (node.isNameFirst) {
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.typeExpression);
@@ -12083,15 +12140,15 @@ var ts;
return visitNode(cbNode, node.typeExpression) ||
visitNode(cbNode, node.name);
}
- case 291:
- return visitNode(cbNode, node.typeExpression);
- case 292:
- return visitNode(cbNode, node.typeExpression);
- case 288:
- return visitNode(cbNode, node.class);
case 293:
- return visitNodes(cbNode, cbNodes, node.typeParameters);
+ return visitNode(cbNode, node.typeExpression);
case 294:
+ return visitNode(cbNode, node.typeExpression);
+ case 289:
+ return visitNode(cbNode, node.class);
+ case 295:
+ return visitNodes(cbNode, cbNodes, node.typeParameters);
+ case 296:
if (node.typeExpression &&
node.typeExpression.kind === 277) {
return visitNode(cbNode, node.typeExpression) ||
@@ -12101,6 +12158,15 @@ var ts;
return visitNode(cbNode, node.fullName) ||
visitNode(cbNode, node.typeExpression);
}
+ case 291:
+ return visitNode(cbNode, node.fullName) ||
+ visitNode(cbNode, node.typeExpression);
+ case 287:
+ return visitNodes(cbNode, cbNodes, node.decorators) ||
+ visitNodes(cbNode, cbNodes, node.modifiers) ||
+ visitNodes(cbNode, cbNodes, node.typeParameters) ||
+ visitNodes(cbNode, cbNodes, node.parameters) ||
+ visitNode(cbNode, node.type);
case 286:
if (node.jsDocPropertyTags) {
for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
@@ -12109,7 +12175,7 @@ var ts;
}
}
return;
- case 298:
+ case 300:
return visitNode(cbNode, node.expression);
}
}
@@ -16221,7 +16287,7 @@ var ts;
case 57:
if (state === 0 || state === 1) {
removeTrailingNewlines(comments);
- parseTag(indent);
+ addTag(parseTag(indent));
state = 0;
margin = undefined;
indent++;
@@ -16290,7 +16356,23 @@ var ts;
result.comment = comments.length ? comments.join("") : undefined;
return finishNode(result, end);
}
+ function isNextNonwhitespaceTokenEndOfFile() {
+ while (true) {
+ nextJSDocToken();
+ if (token() === 1) {
+ return true;
+ }
+ if (!(token() === 5 || token() === 4)) {
+ return false;
+ }
+ }
+ }
function skipWhitespace() {
+ if (token() === 5 || token() === 4) {
+ if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
+ return;
+ }
+ }
while (token() === 5 || token() === 4) {
nextJSDocToken();
}
@@ -16319,8 +16401,7 @@ var ts;
case "arg":
case "argument":
case "param":
- addTag(parseParameterOrPropertyTag(atToken, tagName, 1, indent));
- return;
+ return parseParameterOrPropertyTag(atToken, tagName, 2, indent);
case "return":
case "returns":
tag = parseReturnTag(atToken, tagName);
@@ -16332,7 +16413,10 @@ var ts;
tag = parseTypeTag(atToken, tagName);
break;
case "typedef":
- tag = parseTypedefTag(atToken, tagName);
+ tag = parseTypedefTag(atToken, tagName, indent);
+ break;
+ case "callback":
+ tag = parseCallbackTag(atToken, tagName, indent);
break;
default:
tag = parseUnknownTag(atToken, tagName);
@@ -16345,8 +16429,10 @@ var ts;
if (!tag) {
return;
}
- tag.comment = parseTagComments(indent + tag.end - tag.pos);
- addTag(tag);
+ if (!tag.comment) {
+ tag.comment = parseTagComments(indent + tag.end - tag.pos);
+ }
+ return tag;
}
function parseTagComments(indent) {
var comments = [];
@@ -16403,12 +16489,15 @@ var ts;
return comments.length === 0 ? undefined : comments.join("");
}
function parseUnknownTag(atToken, tagName) {
- var result = createNode(287, atToken.pos);
+ var result = createNode(288, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
return finishNode(result);
}
function addTag(tag) {
+ if (!tag) {
+ return;
+ }
if (!tags) {
tags = [tag];
tagsPos = tag.pos;
@@ -16457,8 +16546,8 @@ var ts;
typeExpression = tryParseTypeExpression();
}
var result = target === 1 ?
- createNode(290, atToken.pos) :
- createNode(295, atToken.pos);
+ createNode(297, atToken.pos) :
+ createNode(292, atToken.pos);
var comment;
if (indent !== undefined)
comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
@@ -16484,7 +16573,7 @@ var ts;
var start_2 = scanner.getStartPos();
var children = void 0;
while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) {
- if (child.kind === 290 || child.kind === 295) {
+ if (child.kind === 292 || child.kind === 297) {
children = ts.append(children, child);
}
}
@@ -16500,27 +16589,27 @@ var ts;
}
}
function parseReturnTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 291; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 293; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(291, atToken.pos);
+ var result = createNode(293, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result);
}
function parseTypeTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 292; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 294; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(292, atToken.pos);
+ var result = createNode(294, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = parseJSDocTypeExpression(true);
return finishNode(result);
}
function parseAugmentsTag(atToken, tagName) {
- var result = createNode(288, atToken.pos);
+ var result = createNode(289, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.class = parseExpressionWithTypeArgumentsForAugments();
@@ -16548,30 +16637,23 @@ var ts;
return node;
}
function parseClassTag(atToken, tagName) {
- var tag = createNode(289, atToken.pos);
+ var tag = createNode(290, atToken.pos);
tag.atToken = atToken;
tag.tagName = tagName;
return finishNode(tag);
}
- function parseTypedefTag(atToken, tagName) {
+ function parseTypedefTag(atToken, tagName, indent) {
var typeExpression = tryParseTypeExpression();
skipWhitespace();
- var typedefTag = createNode(294, atToken.pos);
+ var typedefTag = createNode(296, atToken.pos);
typedefTag.atToken = atToken;
typedefTag.tagName = tagName;
- typedefTag.fullName = parseJSDocTypeNameWithNamespace(0);
- if (typedefTag.fullName) {
- var rightNode = typedefTag.fullName;
- while (true) {
- if (rightNode.kind === 71 || !rightNode.body) {
- typedefTag.name = rightNode.kind === 71 ? rightNode : rightNode.name;
- break;
- }
- rightNode = rightNode.body;
- }
- }
+ typedefTag.fullName = parseJSDocTypeNameWithNamespace();
+ typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
skipWhitespace();
+ typedefTag.comment = parseTagComments(indent);
typedefTag.typeExpression = typeExpression;
+ var end;
if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
var child = void 0;
var jsdocTypeLiteral = void 0;
@@ -16581,7 +16663,7 @@ var ts;
if (!jsdocTypeLiteral) {
jsdocTypeLiteral = createNode(286, start_3);
}
- if (child.kind === 292) {
+ if (child.kind === 294) {
if (childTypeTag) {
break;
}
@@ -16600,23 +16682,67 @@ var ts;
typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
childTypeTag.typeExpression :
finishNode(jsdocTypeLiteral);
+ end = typedefTag.typeExpression.end;
}
}
- return finishNode(typedefTag);
- function parseJSDocTypeNameWithNamespace(flags) {
- var pos = scanner.getTokenPos();
- var typeNameOrNamespaceName = parseJSDocIdentifierName();
- if (typeNameOrNamespaceName && parseOptional(23)) {
- var jsDocNamespaceNode = createNode(238, pos);
- jsDocNamespaceNode.flags |= flags;
- jsDocNamespaceNode.name = typeNameOrNamespaceName;
- jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4);
- return finishNode(jsDocNamespaceNode);
+ return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
+ }
+ function parseJSDocTypeNameWithNamespace(nested) {
+ var pos = scanner.getTokenPos();
+ var typeNameOrNamespaceName = parseJSDocIdentifierName();
+ if (typeNameOrNamespaceName && parseOptional(23)) {
+ var jsDocNamespaceNode = createNode(238, pos);
+ if (nested) {
+ jsDocNamespaceNode.flags |= 4;
}
- if (typeNameOrNamespaceName && flags & 4) {
- typeNameOrNamespaceName.isInJSDocNamespace = true;
+ jsDocNamespaceNode.name = typeNameOrNamespaceName;
+ jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(true);
+ return finishNode(jsDocNamespaceNode);
+ }
+ if (typeNameOrNamespaceName && nested) {
+ typeNameOrNamespaceName.isInJSDocNamespace = true;
+ }
+ return typeNameOrNamespaceName;
+ }
+ function parseCallbackTag(atToken, tagName, indent) {
+ var callbackTag = createNode(291, atToken.pos);
+ callbackTag.atToken = atToken;
+ callbackTag.tagName = tagName;
+ callbackTag.fullName = parseJSDocTypeNameWithNamespace();
+ callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
+ skipWhitespace();
+ callbackTag.comment = parseTagComments(indent);
+ var child;
+ var start = scanner.getStartPos();
+ var jsdocSignature = createNode(287, start);
+ jsdocSignature.parameters = [];
+ while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4); })) {
+ jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
+ }
+ var returnTag = tryParse(function () {
+ if (token() === 57) {
+ nextJSDocToken();
+ var tag = parseTag(indent);
+ if (tag && tag.kind === 293) {
+ return tag;
+ }
+ }
+ });
+ if (returnTag) {
+ jsdocSignature.type = returnTag;
+ }
+ callbackTag.typeExpression = finishNode(jsdocSignature);
+ return finishNode(callbackTag);
+ }
+ function getJSDocTypeAliasName(fullName) {
+ if (fullName) {
+ var rightNode = fullName;
+ while (true) {
+ if (ts.isIdentifier(rightNode) || !rightNode.body) {
+ return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
+ }
+ rightNode = rightNode.body;
}
- return typeNameOrNamespaceName;
}
}
function escapedTextsEqual(a, b) {
@@ -16632,7 +16758,7 @@ var ts;
return a.escapedText === b.escapedText;
}
function parseChildPropertyTag() {
- return parseChildParameterOrPropertyTag(0);
+ return parseChildParameterOrPropertyTag(1);
}
function parseChildParameterOrPropertyTag(target, name) {
var canParseTag = true;
@@ -16642,7 +16768,8 @@ var ts;
case 57:
if (canParseTag) {
var child = tryParseChildTag(target);
- if (child && child.kind === 290 &&
+ if (child && child.kind === 292 &&
+ target !== 4 &&
(ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
return false;
}
@@ -16681,20 +16808,20 @@ var ts;
var t;
switch (tagName.escapedText) {
case "type":
- return target === 0 && parseTypeTag(atToken, tagName);
+ return target === 1 && parseTypeTag(atToken, tagName);
case "prop":
case "property":
- t = 0;
+ t = 1;
break;
case "arg":
case "argument":
case "param":
- t = 1;
+ t = 2 | 4;
break;
default:
return false;
}
- if (target !== t) {
+ if (!(target & t)) {
return false;
}
var tag = parseParameterOrPropertyTag(atToken, tagName, target, undefined);
@@ -16726,7 +16853,7 @@ var ts;
break;
}
}
- var result = createNode(293, atToken.pos);
+ var result = createNode(295, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
@@ -16772,7 +16899,7 @@ var ts;
var pos = scanner.getTokenPos();
var end = scanner.getTextPos();
var result = createNode(71, pos);
- result.escapedText = ts.escapeLeadingUnderscores(content.substring(pos, end));
+ result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText());
finishNode(result, end);
nextJSDocToken();
return result;
@@ -17336,7 +17463,7 @@ var ts;
var thisParentContainer;
var blockScopeContainer;
var lastContainer;
- var delayedTypedefs;
+ var delayedTypeAliases;
var seenThisKeyword;
var currentFlow;
var currentBreakTarget;
@@ -17382,7 +17509,7 @@ var ts;
thisParentContainer = undefined;
blockScopeContainer = undefined;
lastContainer = undefined;
- delayedTypedefs = undefined;
+ delayedTypeAliases = undefined;
seenThisKeyword = false;
currentFlow = undefined;
currentBreakTarget = undefined;
@@ -17451,6 +17578,7 @@ var ts;
return "__constructor";
case 162:
case 157:
+ case 287:
return "__call";
case 163:
case 158:
@@ -17474,9 +17602,6 @@ var ts;
var functionType = node.parent;
var index = functionType.parameters.indexOf(node);
return "arg" + index;
- case 294:
- var name_2 = ts.getNameOfJSDocTypedef(node);
- return typeof name_2 !== "undefined" ? name_2.escapedText : undefined;
}
}
function getDisplayName(node) {
@@ -17556,9 +17681,9 @@ var ts;
}
}
else {
- if (node.kind === 294)
+ if (ts.isJSDocTypeAlias(node))
ts.Debug.assert(ts.isInJavaScriptFile(node));
- if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || ts.isJSDocTypedefTag(node)) {
+ if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || ts.isJSDocTypeAlias(node)) {
if (ts.hasModifier(node, 512) && !getDeclarationName(node)) {
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
}
@@ -17695,20 +17820,6 @@ var ts;
ts.forEachChild(node, bind, bindEach);
}
function bindChildrenWorker(node) {
- if (ts.hasJSDocNodes(node)) {
- if (ts.isInJavaScriptFile(node)) {
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var j = _a[_i];
- bind(j);
- }
- }
- else {
- for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
- var j = _c[_b];
- setParentPointers(node, j);
- }
- }
- }
if (checkUnreachable(node)) {
bindEachChild(node);
return;
@@ -17774,11 +17885,9 @@ var ts;
case 186:
bindCallExpressionFlow(node);
break;
- case 285:
- bindJSDocComment(node);
- break;
- case 294:
- bindJSDocTypedefTag(node);
+ case 296:
+ case 291:
+ bindJSDocTypeAlias(node);
break;
case 273:
bindEachFunctionsFirst(node.statements);
@@ -17792,6 +17901,7 @@ var ts;
bindEachChild(node);
break;
}
+ bindJSDoc(node);
}
function isNarrowingExpression(expr) {
switch (expr.kind) {
@@ -18354,20 +18464,10 @@ var ts;
bindInitializedVariableFlow(node);
}
}
- function bindJSDocComment(node) {
- ts.forEachChild(node, function (n) {
- if (n.kind !== 294) {
- bind(n);
- }
- });
- }
- function bindJSDocTypedefTag(node) {
- ts.forEachChild(node, function (n) {
- if (node.fullName && n === node.name && node.fullName.kind !== 71) {
- return;
- }
- bind(n);
- });
+ function bindJSDocTypeAlias(node) {
+ if (node.fullName) {
+ setParentPointers(node, node.fullName);
+ }
}
function bindCallExpressionFlow(node) {
var expr = node.expression;
@@ -18417,6 +18517,7 @@ var ts;
case 155:
case 156:
case 157:
+ case 287:
case 283:
case 162:
case 158:
@@ -18468,6 +18569,7 @@ var ts;
case 163:
case 157:
case 158:
+ case 287:
case 159:
case 153:
case 152:
@@ -18478,6 +18580,8 @@ var ts;
case 191:
case 192:
case 283:
+ case 296:
+ case 291:
case 236:
case 176:
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
@@ -18621,22 +18725,35 @@ var ts;
bindBlockScopedDeclaration(node, 2, 67216319);
}
function delayedBindJSDocTypedefTag() {
- if (!delayedTypedefs) {
+ if (!delayedTypeAliases) {
return;
}
var saveContainer = container;
var saveLastContainer = lastContainer;
var saveBlockScopeContainer = blockScopeContainer;
var saveParent = parent;
- for (var _i = 0, delayedTypedefs_1 = delayedTypedefs; _i < delayedTypedefs_1.length; _i++) {
- var delay = delayedTypedefs_1[_i];
- (container = delay.container, lastContainer = delay.lastContainer, blockScopeContainer = delay.blockScopeContainer, parent = delay.parent);
- bindBlockScopedDeclaration(delay.typedef, 524288, 67901928);
+ var saveCurrentFlow = currentFlow;
+ for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
+ var typeAlias = delayedTypeAliases_1[_i];
+ var host = ts.getJSDocHost(typeAlias);
+ container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); }) || file;
+ blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
+ currentFlow = { flags: 2 };
+ parent = typeAlias;
+ bind(typeAlias.typeExpression);
+ if (!typeAlias.fullName || typeAlias.fullName.kind === 71) {
+ parent = typeAlias.parent;
+ bindBlockScopedDeclaration(typeAlias, 524288, 67901928);
+ }
+ else {
+ bind(typeAlias.fullName);
+ }
}
container = saveContainer;
lastContainer = saveLastContainer;
blockScopeContainer = saveBlockScopeContainer;
parent = saveParent;
+ currentFlow = saveCurrentFlow;
}
function checkStrictModeIdentifier(node) {
if (inStrictMode &&
@@ -18751,8 +18868,6 @@ var ts;
}
node.parent = parent;
var saveInStrictMode = inStrictMode;
- if (ts.isInJavaScriptFile(node))
- bindJSDocTypedefTagIfAny(node);
bindWorker(node);
if (node.kind > 144) {
var saveParent = parent;
@@ -18768,25 +18883,22 @@ var ts;
}
else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912) === 0) {
subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
+ bindJSDoc(node);
}
inStrictMode = saveInStrictMode;
}
- function bindJSDocTypedefTagIfAny(node) {
- if (!ts.hasJSDocNodes(node)) {
- return;
- }
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var jsDoc = _a[_i];
- if (!jsDoc.tags) {
- continue;
+ function bindJSDoc(node) {
+ if (ts.hasJSDocNodes(node)) {
+ if (ts.isInJavaScriptFile(node)) {
+ for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
+ var j = _a[_i];
+ bind(j);
+ }
}
- for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) {
- var tag = _c[_b];
- if (tag.kind === 294) {
- var savedParent = parent;
- parent = jsDoc;
- bind(tag);
- parent = savedParent;
+ else {
+ for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
+ var j = _c[_b];
+ setParentPointers(node, j);
}
}
}
@@ -18814,7 +18926,7 @@ var ts;
case 71:
if (node.isInJSDocNamespace) {
var parentNode = node.parent;
- while (parentNode && parentNode.kind !== 294) {
+ while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
parentNode = parentNode.parent;
}
bindBlockScopedDeclaration(parentNode, 524288, 67901928);
@@ -18911,6 +19023,7 @@ var ts;
return bindPropertyOrMethodOrAccessor(node, 65536, 67183551);
case 162:
case 283:
+ case 287:
case 163:
return bindFunctionOrConstructorType(node);
case 165:
@@ -18965,23 +19078,22 @@ var ts;
}
case 239:
return updateStrictModeStatementList(node.statements);
- case 290:
+ case 292:
+ if (node.parent.kind === 287) {
+ return bindParameter(node);
+ }
if (node.parent.kind !== 286) {
break;
}
- case 295:
+ case 297:
var propTag = node;
var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 ?
4 | 16777216 :
4;
return declareSymbolAndAddToSymbolTable(propTag, flags, 0);
- case 294: {
- var fullName = node.fullName;
- if (!fullName || fullName.kind === 71) {
- (delayedTypedefs || (delayedTypedefs = [])).push({ typedef: node, container: container, lastContainer: lastContainer, blockScopeContainer: blockScopeContainer, parent: parent });
- }
- break;
- }
+ case 296:
+ case 291:
+ return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
}
}
function bindPropertyWorker(node) {
@@ -19277,6 +19389,9 @@ var ts;
}
}
function bindParameter(node) {
+ if (node.kind === 292 && container.kind !== 287) {
+ return;
+ }
if (inStrictMode && !(node.flags & 4194304)) {
checkStrictModeEvalOrArguments(node, node.name);
}
@@ -19331,24 +19446,30 @@ var ts;
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
function getInferTypeContainer(node) {
- while (node) {
- var parent_2 = node.parent;
- if (parent_2 && parent_2.kind === 170 && parent_2.extendsType === node) {
- return parent_2;
- }
- node = parent_2;
- }
- return undefined;
+ var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
+ return extendsType && extendsType.parent;
}
function bindTypeParameter(node) {
- if (node.parent.kind === 171) {
- var container_1 = getInferTypeContainer(node.parent);
+ if (ts.isJSDocTemplateTag(node.parent)) {
+ var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
if (container_1) {
if (!container_1.locals) {
container_1.locals = ts.createSymbolTable();
}
declareSymbol(container_1.locals, undefined, node, 262144, 67639784);
}
+ else {
+ declareSymbolAndAddToSymbolTable(node, 262144, 67639784);
+ }
+ }
+ else if (node.parent.kind === 171) {
+ var container_2 = getInferTypeContainer(node.parent);
+ if (container_2) {
+ if (!container_2.locals) {
+ container_2.locals = ts.createSymbolTable();
+ }
+ declareSymbol(container_2.locals, undefined, node, 262144, 67639784);
+ }
else {
bindAnonymousDeclaration(node, 262144, getDeclarationName(node));
}
@@ -19851,7 +19972,7 @@ var ts;
break;
case 189:
case 207:
- case 298:
+ case 300:
transformFlags |= 3;
excludeFlags = 536872257;
break;
@@ -20084,7 +20205,7 @@ var ts;
return 940049729;
case 189:
case 207:
- case 298:
+ case 300:
case 190:
case 97:
return 536872257;
@@ -20098,7 +20219,7 @@ var ts;
ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
function setParentPointers(parent, child) {
child.parent = parent;
- ts.forEachChild(child, function (childsChild) { return setParentPointers(child, childsChild); });
+ ts.forEachChild(child, function (grandchild) { return setParentPointers(child, grandchild); });
}
})(ts || (ts = {}));
var ts;
@@ -22305,6 +22426,11 @@ var ts;
location = location.parent;
}
break;
+ case 296:
+ case 291:
+ lastLocation = location;
+ location = ts.getJSDocHost(location).parent;
+ continue;
}
if (isSelfReferenceLocation(location)) {
lastSelfReferenceLocation = location;
@@ -22402,9 +22528,11 @@ var ts;
function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
- if (decl.kind === 147 && parent === container) {
- return true;
+ if (decl.kind === 147) {
+ var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
+ if (parent === container) {
+ return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
+ }
}
}
return false;
@@ -22799,7 +22927,7 @@ var ts;
var symbol;
if (name.kind === 71) {
var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0;
- var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSPrototype(name, meaning) : undefined;
+ var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSSpecialAssignment(name, meaning) : undefined;
symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true);
if (!symbol) {
return symbolFromJSPrototype;
@@ -22851,20 +22979,33 @@ var ts;
ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
}
- function resolveEntityNameFromJSPrototype(name, meaning) {
- if (isJSDocTypeReference(name.parent) && ts.isJSDocTag(name.parent.parent.parent)) {
- var host_1 = ts.getJSDocHost(name.parent.parent.parent);
- if (ts.isExpressionStatement(host_1) &&
- ts.isBinaryExpression(host_1.expression) &&
- ts.getSpecialPropertyAssignmentKind(host_1.expression) === 3) {
- var symbol = getSymbolOfNode(host_1.expression.left);
- if (symbol) {
- var secondaryLocation = symbol.parent.valueDeclaration;
- return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
- }
+ function resolveEntityNameFromJSSpecialAssignment(name, meaning) {
+ if (isJSDocTypeReference(name.parent)) {
+ var secondaryLocation = getJSSpecialAssignmentLocation(name.parent);
+ if (secondaryLocation) {
+ return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
}
}
}
+ function getJSSpecialAssignmentLocation(node) {
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152) ? "quit" : ts.isJSDocTypeAlias(node); });
+ if (typeAlias) {
+ return;
+ }
+ var host = ts.getJSDocHost(node);
+ if (host &&
+ ts.isExpressionStatement(host) &&
+ ts.isBinaryExpression(host.expression) &&
+ ts.getSpecialPropertyAssignmentKind(host.expression) === 3) {
+ var symbol = getSymbolOfNode(host.expression.left);
+ return symbol && symbol.parent.valueDeclaration;
+ }
+ var sig = ts.getHostSignatureFromJSDocHost(host);
+ if (sig) {
+ var symbol = getSymbolOfNode(sig);
+ return symbol && symbol.valueDeclaration;
+ }
+ }
function resolveExternalModuleName(location, moduleReferenceExpression) {
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0);
}
@@ -23348,6 +23489,13 @@ var ts;
}
return hasAccessibleDeclarations;
}
+ else {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol)) {
+ return {
+ accessibility: 0
+ };
+ }
+ }
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = getParentOfSymbol(symbol);
}
@@ -23557,7 +23705,7 @@ var ts;
flags: flags,
tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop },
encounteredError: false,
- symbolStack: undefined,
+ visitedSymbols: undefined,
inferTypeParameters: undefined
};
}
@@ -23663,9 +23811,10 @@ var ts;
return ts.createTypeReferenceNode(name, undefined);
}
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
- var name = symbolToTypeReferenceName(type.aliasSymbol);
var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
- return ts.createTypeReferenceNode(name, typeArgumentNodes);
+ if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32))
+ return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes);
+ return symbolToTypeNode(type.aliasSymbol, context, 67901928, typeArgumentNodes);
}
if (type.flags & (131072 | 262144)) {
var types = type.flags & 131072 ? formatUnionTypes(type.types) : type.types;
@@ -23727,7 +23876,10 @@ var ts;
}
function createAnonymousTypeNode(type) {
var symbol = type.symbol;
+ var id;
if (symbol) {
+ var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
+ id = (isConstructorObject ? "+" : "") + getSymbolId(symbol);
if (isJavaScriptConstructor(symbol.valueDeclaration)) {
var isInstanceType = type === getInferredClassType(symbol) ? 67901928 : 67216319;
return symbolToTypeNode(symbol, context, isInstanceType);
@@ -23737,7 +23889,7 @@ var ts;
shouldWriteTypeOfFunctionSymbol()) {
return symbolToTypeNode(symbol, context, 67216319);
}
- else if (ts.contains(context.symbolStack, symbol)) {
+ else if (context.visitedSymbols && context.visitedSymbols.has(id)) {
var typeAlias = getTypeAliasForTypeLiteral(type);
if (typeAlias) {
return symbolToTypeNode(typeAlias, context, 67901928);
@@ -23747,19 +23899,13 @@ var ts;
}
}
else {
- if (!context.symbolStack) {
- context.symbolStack = [];
- }
- var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
- if (isConstructorObject) {
- return createTypeNodeFromObjectType(type);
- }
- else {
- context.symbolStack.push(symbol);
- var result = createTypeNodeFromObjectType(type);
- context.symbolStack.pop();
- return result;
+ if (!context.visitedSymbols) {
+ context.visitedSymbols = ts.createMap();
}
+ context.visitedSymbols.set(id, true);
+ var result = createTypeNodeFromObjectType(type);
+ context.visitedSymbols.delete(id);
+ return result;
}
}
else {
@@ -23774,7 +23920,7 @@ var ts;
return declaration.parent.kind === 273 || declaration.parent.kind === 239;
}));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
- return (!!(context.flags & 4096) || ts.contains(context.symbolStack, symbol)) &&
+ return (!!(context.flags & 4096) || (context.visitedSymbols && context.visitedSymbols.has(id))) &&
(!(context.flags & 8) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
}
}
@@ -23806,10 +23952,6 @@ var ts;
var typeLiteralNode = ts.createTypeLiteralNode(members);
return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1);
}
- function symbolToTypeReferenceName(symbol) {
- var entityName = symbol.flags & 32 || !isReservedMemberName(symbol.escapedName) ? symbolToName(symbol, context, 67901928, false) : ts.createIdentifier("");
- return entityName;
- }
function typeReferenceToTypeNode(type) {
var typeArguments = type.typeArguments || ts.emptyArray;
if (type.target === globalArrayType) {
@@ -23842,7 +23984,7 @@ var ts;
else {
var outerTypeParameters = type.target.outerTypeParameters;
var i = 0;
- var qualifiedName = void 0;
+ var resultType = void 0;
if (outerTypeParameters) {
var length_1 = outerTypeParameters.length;
while (i < length_1) {
@@ -23853,55 +23995,61 @@ var ts;
} while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent);
if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
- var typeArgumentNodes_1 = typeArgumentSlice && ts.createNodeArray(typeArgumentSlice);
- var namePart = symbolToTypeReferenceName(parent);
- (namePart.kind === 71 ? namePart : namePart.right).typeArguments = typeArgumentNodes_1;
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, namePart);
- qualifiedName = ts.createQualifiedName(qualifiedName, undefined);
- }
- else {
- qualifiedName = ts.createQualifiedName(namePart, undefined);
- }
+ var flags_2 = context.flags;
+ context.flags |= 16;
+ var ref = symbolToTypeNode(parent, context, 67901928, typeArgumentSlice);
+ context.flags = flags_2;
+ resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
}
}
}
- var entityName = void 0;
- var nameIdentifier = symbolToTypeReferenceName(type.symbol);
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, nameIdentifier);
- entityName = qualifiedName;
- }
- else {
- entityName = nameIdentifier;
- }
var typeArgumentNodes = void 0;
if (typeArguments.length > 0) {
var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
}
- if (typeArgumentNodes) {
- var lastIdentifier = entityName.kind === 71 ? entityName : entityName.right;
- lastIdentifier.typeArguments = undefined;
- }
- return ts.createTypeReferenceNode(entityName, typeArgumentNodes);
+ var flags = context.flags;
+ context.flags |= 16;
+ var finalRef = symbolToTypeNode(type.symbol, context, 67901928, typeArgumentNodes);
+ context.flags = flags;
+ return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
}
}
- function addToQualifiedNameMissingRightIdentifier(left, right) {
- ts.Debug.assert(left.right === undefined);
- if (right.kind === 71) {
- left.right = right;
- return left;
+ function appendReferenceToType(root, ref) {
+ if (ts.isImportTypeNode(root)) {
+ var innerParams = root.typeArguments;
+ if (root.qualifier) {
+ (ts.isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams;
+ }
+ root.typeArguments = ref.typeArguments;
+ var ids = getAccessStack(ref);
+ for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
+ var id = ids_1[_i];
+ root.qualifier = root.qualifier ? ts.createQualifiedName(root.qualifier, id) : id;
+ }
+ return root;
}
- var rightPart = right;
- while (rightPart.left.kind !== 71) {
- rightPart = rightPart.left;
+ else {
+ var innerParams = root.typeArguments;
+ (ts.isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams;
+ root.typeArguments = ref.typeArguments;
+ var ids = getAccessStack(ref);
+ for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
+ var id = ids_2[_a];
+ root.typeName = ts.createQualifiedName(root.typeName, id);
+ }
+ return root;
}
- left.right = rightPart.left;
- rightPart.left = left;
- return right;
+ }
+ function getAccessStack(ref) {
+ var state = ref.typeName;
+ var ids = [];
+ while (!ts.isIdentifier(state)) {
+ ids.unshift(state.right);
+ state = state.left;
+ }
+ ids.unshift(state);
+ return ids;
}
function createTypeNodesFromResolvedType(resolvedType) {
var typeElements = [];
@@ -24064,7 +24212,9 @@ var ts;
}
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) {
var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148);
- ts.Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol));
+ if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) {
+ parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292);
+ }
var parameterType = getTypeOfSymbol(parameterSymbol);
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
parameterType = getOptionalType(parameterType);
@@ -24075,9 +24225,9 @@ var ts;
var dotDotDotToken = isRest ? ts.createToken(24) : undefined;
var name = parameterDeclaration
? parameterDeclaration.name ?
- parameterDeclaration.name.kind === 71 ?
- ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) :
- cloneBindingName(parameterDeclaration.name) :
+ parameterDeclaration.name.kind === 71 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) :
+ parameterDeclaration.name.kind === 145 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) :
+ cloneBindingName(parameterDeclaration.name) :
ts.symbolName(parameterSymbol)
: ts.symbolName(parameterSymbol);
var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55) : undefined;
@@ -24095,7 +24245,7 @@ var ts;
}
}
}
- function lookupSymbolChain(symbol, context, meaning) {
+ function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
var chain;
var isTypeParameter = symbol.flags & 262144;
@@ -24125,7 +24275,7 @@ var ts;
return accessibleSymbolChain;
}
if (endOfChain ||
- !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) &&
+ (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) &&
!(symbol.flags & (2048 | 4096))) {
return [symbol];
}
@@ -24162,17 +24312,21 @@ var ts;
}
return top;
}
- function symbolToTypeNode(symbol, context, meaning) {
- var chain = lookupSymbolChain(symbol, context, meaning);
+ function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
+ var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384));
context.flags |= 16777216;
var rootName = getNameOfSymbolAsWritten(chain[0], context);
context.flags ^= 16777216;
var isTypeOf = meaning === 67216319;
if (ambientModuleSymbolRegex.test(rootName)) {
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
- var typeParameterNodes = lookupTypeParameterNodes(chain, 0, context);
+ var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1)));
if (!nonRootParts || ts.isEntityName(nonRootParts)) {
+ if (nonRootParts) {
+ var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
+ lastId.typeArguments = undefined;
+ }
return ts.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
}
else {
@@ -24185,9 +24339,17 @@ var ts;
if (ts.isIndexedAccessTypeNode(entityName)) {
return entityName;
}
- return isTypeOf ? ts.createTypeQueryNode(entityName) : ts.createTypeReferenceNode(entityName, undefined);
+ if (isTypeOf) {
+ return ts.createTypeQueryNode(entityName);
+ }
+ else {
+ var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
+ var lastTypeArgs = lastId.typeArguments;
+ lastId.typeArguments = undefined;
+ return ts.createTypeReferenceNode(entityName, lastTypeArgs);
+ }
function createAccessFromSymbolChain(chain, index, stopper) {
- var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
+ var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
var symbol = chain[index];
if (index === 0) {
context.flags |= 16777216;
@@ -24197,7 +24359,7 @@ var ts;
context.flags ^= 16777216;
}
var parent = chain[index - 1];
- if (parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
+ if (!(context.flags & 16) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
if (ts.isIndexedAccessTypeNode(LHS)) {
return ts.createIndexedAccessTypeNode(LHS, ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
@@ -24354,6 +24516,23 @@ var ts;
return "default";
}
if (symbol.declarations && symbol.declarations.length) {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) {
+ var file_3 = ts.getDeclarationOfKind(symbol, 273);
+ if (!file_3 || !context.tracker.moduleResolverHost) {
+ if (context.tracker.trackReferencedAmbientModule) {
+ var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
+ if (ts.length(ambientDecls)) {
+ for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
+ var decl = ambientDecls_1[_i];
+ context.tracker.trackReferencedAmbientModule(decl);
+ }
+ }
+ }
+ }
+ else {
+ return "\"" + ts.getResolvedExternalModuleName(context.tracker.moduleResolverHost, file_3, ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration))) + "\"";
+ }
+ }
var declaration = symbol.declarations[0];
var name = ts.getNameOfDeclaration(declaration);
if (name) {
@@ -24395,7 +24574,8 @@ var ts;
return false;
function determineIfDeclarationIsVisible() {
switch (node.kind) {
- case 294:
+ case 291:
+ case 296:
return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
case 181:
return isDeclarationVisible(node.parent.parent);
@@ -25028,7 +25208,7 @@ var ts;
declaration.kind === 184 && declaration.parent.kind === 199) {
type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol);
}
- else if (ts.isJSDocPropertyTag(declaration)
+ else if (ts.isJSDocPropertyLikeTag(declaration)
|| ts.isPropertyAccessExpression(declaration)
|| ts.isIdentifier(declaration)
|| (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
@@ -25289,7 +25469,9 @@ var ts;
case 191:
case 192:
case 236:
- case 293:
+ case 295:
+ case 296:
+ case 291:
case 176:
case 170:
var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
@@ -25299,7 +25481,7 @@ var ts;
else if (node.kind === 170) {
return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
}
- var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray);
+ var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
var thisType = includeThisTypes &&
(node.kind === 234 || node.kind === 204 || node.kind === 235) &&
getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
@@ -25315,13 +25497,12 @@ var ts;
var result;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var node = _a[_i];
- if (node.kind === 235 || node.kind === 234 ||
- node.kind === 204 || node.kind === 236 || node.kind === 294) {
+ if (node.kind === 235 ||
+ node.kind === 234 ||
+ node.kind === 204 ||
+ ts.isTypeAlias(node)) {
var declaration = node;
- var typeParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- if (typeParameters) {
- result = appendTypeParameters(result, typeParameters);
- }
+ result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
}
}
return result;
@@ -25555,9 +25736,9 @@ var ts;
return unknownType;
}
var declaration = ts.find(symbol.declarations, function (d) {
- return d.kind === 294 || d.kind === 236;
+ return ts.isJSDocTypeAlias(d) || d.kind === 236;
});
- var typeNode = declaration.kind === 294 ? declaration.typeExpression : declaration.type;
+ var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType;
if (popTypeResolution()) {
var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
@@ -25744,7 +25925,7 @@ var ts;
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
return (node.kind === 154 || (returnType && isThislessType(returnType))) &&
node.parameters.every(isThislessVariableLikeDeclaration) &&
- (!typeParameters || typeParameters.every(isThislessTypeParameter));
+ typeParameters.every(isThislessTypeParameter);
}
function isThisless(symbol) {
if (symbol.declarations && symbol.declarations.length === 1) {
@@ -25851,9 +26032,9 @@ var ts;
var earlySymbol = earlySymbols && earlySymbols.get(memberName);
if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
- var name_3 = ts.declarationNameToString(decl.name);
- ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_3); });
- error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_3);
+ var name_2 = ts.declarationNameToString(decl.name);
+ ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_2); });
+ error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_2);
lateSymbol = createSymbol(0, memberName, 1024);
}
lateSymbol.nameType = type;
@@ -26782,9 +26963,10 @@ var ts;
}
function getTypeParametersFromDeclaration(declaration) {
var result;
- ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) {
+ for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
+ var node = _a[_i];
result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
- });
+ }
return result;
}
function symbolsToArray(symbols) {
@@ -26811,7 +26993,7 @@ var ts;
return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
}
function isOptionalParameter(node) {
- if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) {
+ if (ts.hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) {
return true;
}
if (node.initializer) {
@@ -26828,6 +27010,13 @@ var ts;
}
return false;
}
+ function isOptionalJSDocParameterTag(node) {
+ if (!ts.isJSDocParameterTag(node)) {
+ return false;
+ }
+ var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
+ return isBracketed || !!typeExpression && typeExpression.type.kind === 282;
+ }
function createTypePredicateFromTypePredicateNode(node) {
var parameterName = node.parameterName;
var type = getTypeFromTypeNode(node.type);
@@ -26897,6 +27086,7 @@ var ts;
for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
var param = declaration.parameters[i];
var paramSymbol = param.symbol;
+ var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) {
var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67216319, undefined, undefined, false);
paramSymbol = resolvedSymbol;
@@ -26908,11 +27098,12 @@ var ts;
else {
parameters.push(paramSymbol);
}
- if (param.type && param.type.kind === 177) {
+ if (type && type.kind === 177) {
hasLiteralTypes = true;
}
- var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken ||
- iife && parameters.length > iife.arguments.length && !param.type ||
+ var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) ||
+ param.initializer || param.questionToken || param.dotDotDotToken ||
+ iife && parameters.length > iife.arguments.length && !type ||
isUntypedSignatureInJSFile ||
isJSDocOptionalParameter(param);
if (!isOptionalParameter_1) {
@@ -26939,7 +27130,7 @@ var ts;
return links.resolvedSignature;
}
function maybeAddJsSyntheticRestParameter(declaration, parameters) {
- if (!containsArgumentsReference(declaration)) {
+ if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
return false;
}
var lastParam = ts.lastOrUndefined(declaration.parameters);
@@ -27298,7 +27489,7 @@ var ts;
var isJs = ts.isInJavaScriptFile(node);
var isJsImplicitAny = !noImplicitAny && isJs;
if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
- var missingAugmentsTag = isJs && node.parent.kind !== 288;
+ var missingAugmentsTag = isJs && node.parent.kind !== 289;
var diag = minTypeArgumentCount === typeParameters.length
? missingAugmentsTag
? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag
@@ -27430,7 +27621,7 @@ var ts;
}
function getConstrainedTypeVariable(typeVariable, node) {
var constraints;
- while (node && !ts.isStatement(node)) {
+ while (node && !ts.isStatement(node) && node.kind !== 285) {
var parent = node.parent;
if (parent.kind === 170 && node === parent.trueType) {
var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType);
@@ -27842,7 +28033,7 @@ var ts;
includes & 4096 ? includes & 16777216 ? undefinedType : undefinedWideningType :
neverType;
}
- return getUnionTypeFromSortedList(typeSet, aliasSymbol, aliasTypeArguments);
+ return getUnionTypeFromSortedList(typeSet, includes & 8374815 ? 0 : 268435456, aliasSymbol, aliasTypeArguments);
}
function getUnionTypePredicate(signatures) {
var first;
@@ -27876,7 +28067,7 @@ var ts;
? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex
: !ts.isIdentifierTypePredicate(b);
}
- function getUnionTypeFromSortedList(types, aliasSymbol, aliasTypeArguments) {
+ function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) {
if (types.length === 0) {
return neverType;
}
@@ -27887,7 +28078,7 @@ var ts;
var type = unionTypes.get(id);
if (!type) {
var propagatedFlags = getPropagatingFlagsOfTypes(types, 12288);
- type = createType(131072 | propagatedFlags);
+ type = createType(131072 | propagatedFlags | unionOfUnitTypes);
unionTypes.set(id, type);
type.types = types;
type.aliasSymbol = aliasSymbol;
@@ -27898,7 +28089,8 @@ var ts;
function getTypeFromUnionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -27945,6 +28137,28 @@ var ts;
}
}
}
+ function intersectUnionsOfUnitTypes(types) {
+ var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456) !== 0; });
+ var unionType = types[unionIndex];
+ var intersection = unionType.types;
+ var i = types.length - 1;
+ var _loop_5 = function () {
+ var t = types[i];
+ if (t.flags & 268435456) {
+ intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); });
+ ts.orderedRemoveItemAt(types, i);
+ }
+ i--;
+ };
+ while (i > unionIndex) {
+ _loop_5();
+ }
+ if (intersection === unionType.types) {
+ return false;
+ }
+ types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456);
+ return true;
+ }
function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
if (types.length === 0) {
return emptyObjectType;
@@ -27969,6 +28183,9 @@ var ts;
return typeSet[0];
}
if (includes & 131072) {
+ if (includes & 268435456 && intersectUnionsOfUnitTypes(typeSet)) {
+ return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072) !== 0; });
var unionType = typeSet[unionIndex_1];
return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments);
@@ -27988,7 +28205,8 @@ var ts;
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -28254,7 +28472,7 @@ var ts;
var type = createObjectType(32, node.symbol);
type.declaration = node;
type.aliasSymbol = getAliasSymbolForTypeNode(node);
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
links.resolvedType = type;
getConstraintTypeFromMappedType(type);
}
@@ -28336,7 +28554,8 @@ var ts;
var links = getNodeLinks(node);
if (!links.resolvedType) {
var checkType = getTypeFromTypeNode(node.checkType);
- var aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
var allOuterTypeParameters = getOuterTypeParameters(node, true);
var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isPossiblyReferencedInConditionalType(tp, node); });
var root = {
@@ -28349,7 +28568,7 @@ var ts;
inferTypeParameters: getInferTypeParameters(node),
outerTypeParameters: outerTypeParameters,
instantiations: undefined,
- aliasSymbol: getAliasSymbolForTypeNode(node),
+ aliasSymbol: aliasSymbol,
aliasTypeArguments: aliasTypeArguments
};
links.resolvedType = getConditionalType(root, undefined);
@@ -28446,7 +28665,7 @@ var ts;
else {
var type = createObjectType(16, node.symbol);
type.aliasSymbol = aliasSymbol;
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
type = createArrayType(type);
}
@@ -28456,10 +28675,9 @@ var ts;
return links.resolvedType;
}
function getAliasSymbolForTypeNode(node) {
- return (node.parent.kind === 236 || node.parent.kind === 294) ? getSymbolOfNode(node.parent) : undefined;
+ return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined;
}
- function getAliasTypeArgumentsForTypeNode(node) {
- var symbol = getAliasSymbolForTypeNode(node);
+ function getTypeArgumentsForAliasSymbol(symbol) {
return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
}
function getSpreadType(left, right, symbol, typeFlags, objectFlags) {
@@ -28684,6 +28902,7 @@ var ts;
case 165:
case 286:
case 283:
+ case 287:
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
case 174:
return getTypeFromTypeOperatorNode(node);
@@ -28848,6 +29067,15 @@ var ts;
var typeParameters = links.outerTypeParameters;
if (!typeParameters) {
var declaration_1 = symbol.declarations[0];
+ if (ts.isInJavaScriptFile(declaration_1)) {
+ var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag);
+ if (paramTag) {
+ var paramSymbol = ts.getParameterSymbolFromJSDoc(paramTag);
+ if (paramSymbol) {
+ declaration_1 = paramSymbol.valueDeclaration;
+ }
+ }
+ }
var outerTypeParameters = getOuterTypeParameters(declaration_1, true);
if (isJavaScriptConstructor(declaration_1)) {
var templateTagParameters = getTypeParametersFromDeclaration(declaration_1);
@@ -28883,8 +29111,8 @@ var ts;
}
function isTypeParameterPossiblyReferenced(tp, node) {
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
- var container_2 = tp.symbol.declarations[0].parent;
- if (ts.findAncestor(node, function (n) { return n.kind === 212 ? "quit" : n === container_2; })) {
+ var container_3 = tp.symbol.declarations[0].parent;
+ if (ts.findAncestor(node, function (n) { return n.kind === 212 ? "quit" : n === container_3; })) {
return ts.forEachChild(node, containsReference);
}
}
@@ -29612,7 +29840,7 @@ var ts;
if (discriminant) {
return hasExcessProperties(source, discriminant, undefined, reportErrors);
}
- var _loop_5 = function (prop) {
+ var _loop_6 = function (prop) {
if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
if (reportErrors) {
ts.Debug.assert(!!errorNode);
@@ -29643,7 +29871,7 @@ var ts;
};
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
- var state_3 = _loop_5(prop);
+ var state_3 = _loop_6(prop);
if (typeof state_3 === "object")
return state_3.value;
}
@@ -31886,7 +32114,7 @@ var ts;
if (type.flags & 131072) {
var types = type.types;
var filtered = ts.filter(types, f);
- return filtered === types ? type : getUnionTypeFromSortedList(filtered);
+ return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456);
}
return f(type) ? type : neverType;
}
@@ -33488,10 +33716,11 @@ var ts;
links.resolvedSignatures = ts.createMap();
}
var cacheKey = "" + getTypeId(valueType);
- if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) !== resolvingSignaturesArray) {
- signatures = links.resolvedSignatures.get(cacheKey);
+ var cachedResolved = links.resolvedSignatures.get(cacheKey);
+ if (cachedResolved && cachedResolved !== resolvingSignaturesArray) {
+ signatures = cachedResolved;
}
- else if (!links.resolvedSignatures.get(cacheKey)) {
+ else if (!cachedResolved) {
links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray);
links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures));
}
@@ -34443,7 +34672,7 @@ var ts;
else if (!isSourceAttributeTypeAssignableToTarget) {
if (ts.length(openingLikeElement.attributes.properties)) {
var reportedError = false;
- var _loop_6 = function (prop) {
+ var _loop_7 = function (prop) {
if (ts.isJsxSpreadAttribute(prop))
return "continue";
var name = ts.idText(prop.name);
@@ -34456,7 +34685,7 @@ var ts;
};
for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) {
var prop = _c[_b];
- _loop_6(prop);
+ _loop_7(prop);
}
if (reportedError) {
return;
@@ -36006,8 +36235,8 @@ var ts;
if (allowSyntheticDefaultImports && type && type !== unknownType) {
var synthType = type;
if (!synthType.syntheticType) {
- var file_3 = ts.find(originalSymbol.declarations, ts.isSourceFile);
- var hasSyntheticDefault = canHaveSyntheticDefault(file_3, originalSymbol, false);
+ var file_4 = ts.find(originalSymbol.declarations, ts.isSourceFile);
+ var hasSyntheticDefault = canHaveSyntheticDefault(file_4, originalSymbol, false);
if (hasSyntheticDefault) {
var memberTable = ts.createSymbolTable();
var newSymbol = createSymbol(2097152, "default");
@@ -38220,7 +38449,8 @@ var ts;
switch (d.kind) {
case 235:
case 236:
- case 294:
+ case 296:
+ case 291:
return 2;
case 238:
return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0
@@ -38549,7 +38779,7 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function checkJSDocTypedefTag(node) {
+ function checkJSDocTypeAliasTag(node) {
if (!node.typeExpression) {
error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
}
@@ -38751,7 +38981,7 @@ var ts;
}
function checkUnusedTypeParameters(node, addDiagnostic) {
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (!(node.flags & 4194304) && typeParameters && ts.last(getSymbolOfNode(node).declarations) === node) {
+ if (!(node.flags & 4194304) && ts.last(getSymbolOfNode(node).declarations) === node) {
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
var typeParameter = typeParameters_2[_i];
if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) {
@@ -39760,7 +39990,7 @@ var ts;
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
var declaration = declarations_6[_i];
var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- var numTypeParameters = ts.length(sourceParameters);
+ var numTypeParameters = sourceParameters.length;
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
return false;
}
@@ -39895,7 +40125,7 @@ var ts;
}
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
var issuedMemberError = false;
- var _loop_7 = function (member) {
+ var _loop_8 = function (member) {
if (ts.hasStaticModifier(member)) {
return "continue";
}
@@ -39913,7 +40143,7 @@ var ts;
};
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- _loop_7(member);
+ _loop_8(member);
}
if (!issuedMemberError) {
checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
@@ -40767,11 +40997,12 @@ var ts;
return checkInferType(node);
case 178:
return checkImportType(node);
- case 288:
+ case 289:
return checkJSDocAugmentsTag(node);
- case 294:
- return checkJSDocTypedefTag(node);
- case 290:
+ case 296:
+ case 291:
+ return checkJSDocTypeAliasTag(node);
+ case 292:
return checkJSDocParameterTag(node);
case 283:
checkSignatureDeclaration(node);
@@ -40895,9 +41126,9 @@ var ts;
var parent = node.parent;
var paramTag = parent.parent;
if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) {
- var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
- if (host_2) {
- var lastParamDeclaration = ts.lastOrUndefined(host_2.parameters);
+ var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
+ if (host_1) {
+ var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
if (!lastParamDeclaration ||
symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
@@ -41237,10 +41468,10 @@ var ts;
return entityNameSymbol;
}
}
- if (entityName.parent.kind === 290) {
+ if (entityName.parent.kind === 292) {
return ts.getParameterSymbolFromJSDoc(entityName.parent);
}
- if (entityName.parent.kind === 147 && entityName.parent.parent.kind === 293) {
+ if (entityName.parent.kind === 147 && entityName.parent.parent.kind === 295) {
ts.Debug.assert(!ts.isInJavaScriptFile(entityName));
var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent);
return typeParameter && typeParameter.symbol;
@@ -41678,6 +41909,7 @@ var ts;
function isRequiredInitializedParameter(parameter) {
return strictNullChecks &&
!isOptionalParameter(parameter) &&
+ !ts.isJSDocParameterTag(parameter) &&
parameter.initializer &&
!ts.hasModifier(parameter, 92);
}
@@ -41957,8 +42189,8 @@ var ts;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
if (decl.symbol && decl.symbol.flags & meaning) {
- var file_4 = ts.getSourceFileOfNode(decl);
- var typeReferenceDirective = fileToDirective.get(file_4.path);
+ var file_5 = ts.getSourceFileOfNode(decl);
+ var typeReferenceDirective = fileToDirective.get(file_5.path);
if (typeReferenceDirective) {
(typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
}
@@ -41988,8 +42220,8 @@ var ts;
}
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var file_5 = ts.getSourceFileOfNode(decl);
- if (fileToDirective.has(file_5.path)) {
+ var file_6 = ts.getSourceFileOfNode(decl);
+ if (fileToDirective.has(file_6.path)) {
return true;
}
}
@@ -42006,23 +42238,23 @@ var ts;
}
function initializeTypeChecker() {
for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
- var file_6 = _a[_i];
- ts.bindSourceFile(file_6, compilerOptions);
+ var file_7 = _a[_i];
+ ts.bindSourceFile(file_7, compilerOptions);
}
var augmentations;
for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
- var file_7 = _c[_b];
- if (!ts.isExternalOrCommonJsModule(file_7)) {
- mergeSymbolTable(globals, file_7.locals);
+ var file_8 = _c[_b];
+ if (!ts.isExternalOrCommonJsModule(file_8)) {
+ mergeSymbolTable(globals, file_8.locals);
}
- if (file_7.patternAmbientModules && file_7.patternAmbientModules.length) {
- patternAmbientModules = ts.concatenate(patternAmbientModules, file_7.patternAmbientModules);
+ if (file_8.patternAmbientModules && file_8.patternAmbientModules.length) {
+ patternAmbientModules = ts.concatenate(patternAmbientModules, file_8.patternAmbientModules);
}
- if (file_7.moduleAugmentations.length) {
- (augmentations || (augmentations = [])).push(file_7.moduleAugmentations);
+ if (file_8.moduleAugmentations.length) {
+ (augmentations || (augmentations = [])).push(file_8.moduleAugmentations);
}
- if (file_7.symbol && file_7.symbol.globalExports) {
- var source = file_7.symbol.globalExports;
+ if (file_8.symbol && file_8.symbol.globalExports) {
+ var source = file_8.symbol.globalExports;
source.forEach(function (sourceSymbol, id) {
if (!globals.has(id)) {
globals.set(id, sourceSymbol);
@@ -42454,7 +42686,7 @@ var ts;
}
function checkGrammarClassLikeDeclaration(node) {
var file = ts.getSourceFileOfNode(node);
- return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(ts.getEffectiveTypeParameterDeclarations(node), file);
+ return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
}
function checkGrammarArrowFunction(node, file) {
if (!ts.isArrowFunction(node)) {
@@ -43084,8 +43316,8 @@ var ts;
}
function checkGrammarConstructorTypeParameters(node) {
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (typeParameters) {
- var _a = ts.isNodeArray(typeParameters) ? typeParameters : ts.first(typeParameters), pos = _a.pos, end = _a.end;
+ if (ts.isNodeArray(typeParameters)) {
+ var pos = typeParameters.pos, end = typeParameters.end;
return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
}
}
@@ -43499,7 +43731,7 @@ var ts;
ts.updateQualifiedName = updateQualifiedName;
function parenthesizeForComputedName(expression) {
return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26) ||
- expression.kind === 299 ?
+ expression.kind === 301 ?
createParen(expression) :
expression;
}
@@ -45451,28 +45683,28 @@ var ts;
}
ts.getMutableClone = getMutableClone;
function createNotEmittedStatement(original) {
- var node = createSynthesizedNode(297);
+ var node = createSynthesizedNode(299);
node.original = original;
setTextRange(node, original);
return node;
}
ts.createNotEmittedStatement = createNotEmittedStatement;
function createEndOfDeclarationMarker(original) {
- var node = createSynthesizedNode(301);
+ var node = createSynthesizedNode(303);
node.emitNode = {};
node.original = original;
return node;
}
ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker;
function createMergeDeclarationMarker(original) {
- var node = createSynthesizedNode(300);
+ var node = createSynthesizedNode(302);
node.emitNode = {};
node.original = original;
return node;
}
ts.createMergeDeclarationMarker = createMergeDeclarationMarker;
function createPartiallyEmittedExpression(expression, original) {
- var node = createSynthesizedNode(298);
+ var node = createSynthesizedNode(300);
node.expression = expression;
node.original = original;
setTextRange(node, original);
@@ -45488,7 +45720,7 @@ var ts;
ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression;
function flattenCommaElements(node) {
if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
- if (node.kind === 299) {
+ if (node.kind === 301) {
return node.elements;
}
if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) {
@@ -45498,7 +45730,7 @@ var ts;
return node;
}
function createCommaList(elements) {
- var node = createSynthesizedNode(299);
+ var node = createSynthesizedNode(301);
node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
return node;
}
@@ -46465,7 +46697,7 @@ var ts;
function parenthesizeSubexpressionOfConditionalExpression(e) {
var emittedExpression = ts.skipPartiallyEmittedExpressions(e);
return emittedExpression.kind === 199 && emittedExpression.operatorToken.kind === 26 ||
- emittedExpression.kind === 299
+ emittedExpression.kind === 301
? ts.createParen(e)
: e;
}
@@ -46474,7 +46706,7 @@ var ts;
var check = ts.skipPartiallyEmittedExpressions(e);
return (check.kind === 204 ||
check.kind === 191 ||
- check.kind === 299 ||
+ check.kind === 301 ||
ts.isBinaryExpression(check) && check.operatorToken.kind === 26)
? ts.createParen(e)
: e;
@@ -46620,7 +46852,7 @@ var ts;
case 184:
node = node.expression;
continue;
- case 298:
+ case 300:
node = node.expression;
continue;
}
@@ -46643,7 +46875,7 @@ var ts;
case 207:
case 208:
return (kinds & 2) !== 0;
- case 298:
+ case 300:
return (kinds & 4) !== 0;
}
return false;
@@ -46680,7 +46912,7 @@ var ts;
case 189: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression);
case 207: return ts.updateAsExpression(outerExpression, expression, outerExpression.type);
case 208: return ts.updateNonNullExpression(outerExpression, expression);
- case 298: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
+ case 300: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
}
}
function isIgnorableParen(node) {
@@ -47305,9 +47537,9 @@ var ts;
return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
case 273:
return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context));
- case 298:
+ case 300:
return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression));
- case 299:
+ case 301:
return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression));
default:
return node;
@@ -47345,7 +47577,7 @@ var ts;
case 214:
case 205:
case 230:
- case 297:
+ case 299:
break;
case 145:
result = reduceNode(node.left, cbNode, result);
@@ -47708,10 +47940,10 @@ var ts;
case 273:
result = reduceNodes(node.statements, cbNodes, result);
break;
- case 298:
+ case 300:
result = reduceNode(node.expression, cbNode, result);
break;
- case 299:
+ case 301:
result = reduceNodes(node.elements, cbNodes, result);
break;
default:
@@ -55405,9 +55637,9 @@ var ts;
return visitFunctionDeclaration(node);
case 234:
return visitClassDeclaration(node);
- case 300:
+ case 302:
return visitMergeDeclarationMarker(node);
- case 301:
+ case 303:
return visitEndOfDeclarationMarker(node);
default:
return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
@@ -56611,9 +56843,9 @@ var ts;
return visitCatchClause(node);
case 212:
return visitBlock(node);
- case 300:
+ case 302:
return visitMergeDeclarationMarker(node);
- case 301:
+ case 303:
return visitEndOfDeclarationMarker(node);
default:
return destructuringAndImportCallVisitor(node);
@@ -57419,19 +57651,22 @@ var ts;
var lateMarkedStatements;
var lateStatementReplacementMap;
var suppressNewDiagnosticContexts;
+ var host = context.getEmitHost();
var symbolTracker = {
trackSymbol: trackSymbol,
reportInaccessibleThisError: reportInaccessibleThisError,
reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
- reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression
+ reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
+ moduleResolverHost: host,
+ trackReferencedAmbientModule: trackReferencedAmbientModule,
};
var errorNameNode;
var currentSourceFile;
+ var refs;
var resolver = context.getEmitResolver();
var options = context.getCompilerOptions();
var newLine = ts.getNewLineCharacter(options);
var noResolve = options.noResolve, stripInternal = options.stripInternal;
- var host = context.getEmitHost();
return transformRoot;
function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
if (!typeReferenceDirectives) {
@@ -57443,6 +57678,10 @@ var ts;
necessaryTypeRefernces.set(ref, true);
}
}
+ function trackReferencedAmbientModule(node) {
+ var container = ts.getSourceFileOfNode(node);
+ refs.set("" + ts.getOriginalNodeId(container), container);
+ }
function handleSymbolAccessibilityError(symbolAccessibilityResult) {
if (symbolAccessibilityResult.accessibility === 0) {
if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -57546,13 +57785,13 @@ var ts;
lateMarkedStatements = undefined;
lateStatementReplacementMap = ts.createMap();
necessaryTypeRefernces = undefined;
- var refs = collectReferences(currentSourceFile, ts.createMap());
+ refs = collectReferences(currentSourceFile, ts.createMap());
var references = [];
var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
- refs.forEach(referenceVisitor);
var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
+ refs.forEach(referenceVisitor);
var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([]), undefined)])), combinedStatements);
@@ -57563,17 +57802,19 @@ var ts;
return necessaryTypeRefernces ? ts.mapDefined(ts.arrayFrom(necessaryTypeRefernces.keys()), getFileReferenceForTypeName) : [];
}
function getFileReferenceForTypeName(typeName) {
- for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
- var importStatement = emittedImports_1[_i];
- if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
- var expr = importStatement.moduleReference.expression;
- if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ if (emittedImports) {
+ for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
+ var importStatement = emittedImports_1[_i];
+ if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
+ var expr = importStatement.moduleReference.expression;
+ if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ return undefined;
+ }
+ }
+ else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
return undefined;
}
}
- else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
- return undefined;
- }
}
return { fileName: typeName, pos: -1, end: -1 };
}
@@ -58260,7 +58501,7 @@ var ts;
var prop = ts.createProperty(undefined, maskModifiers(node, undefined, (!accessors.setAccessor) ? 64 : 0), node.name, node.questionToken, ensureType(node, accessorType), undefined);
var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile);
if (leadingsSyntheticCommentRanges) {
- var _loop_8 = function (range) {
+ var _loop_9 = function (range) {
if (range.kind === 3) {
var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2);
var lines = text.split(/\r\n?|\n/g);
@@ -58274,7 +58515,7 @@ var ts;
};
for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) {
var range = leadingsSyntheticCommentRanges_1[_i];
- _loop_8(range);
+ _loop_9(range);
}
}
return prop;
@@ -58410,7 +58651,7 @@ var ts;
}
ts.getTransformers = getTransformers;
function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) {
- var enabledSyntaxKindFeatures = new Array(302);
+ var enabledSyntaxKindFeatures = new Array(304);
var lexicalEnvironmentVariableDeclarations;
var lexicalEnvironmentFunctionDeclarations;
var lexicalEnvironmentVariableDeclarationsStack = [];
@@ -58787,7 +59028,7 @@ var ts;
source = undefined;
if (source)
setSourceFile(source);
- if (node.kind !== 297
+ if (node.kind !== 299
&& (emitFlags & 16) === 0
&& pos >= 0) {
emitPos(skipSourceTrivia(pos));
@@ -58804,7 +59045,7 @@ var ts;
}
if (source)
setSourceFile(source);
- if (node.kind !== 297
+ if (node.kind !== 299
&& (emitFlags & 32) === 0
&& end >= 0) {
emitPos(end);
@@ -58946,7 +59187,7 @@ var ts;
if (extendedDiagnostics) {
ts.performance.mark("preEmitNodeWithComment");
}
- var isEmittedNode = node.kind !== 297;
+ var isEmittedNode = node.kind !== 299;
var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 10;
var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 10;
if (!skipLeadingComments) {
@@ -59991,9 +60232,9 @@ var ts;
return emitJsxSelfClosingElement(node);
case 258:
return emitJsxFragment(node);
- case 298:
+ case 300:
return emitPartiallyEmittedExpression(node);
- case 299:
+ case 301:
return emitCommaList(node);
}
}
@@ -62707,11 +62948,11 @@ var ts;
var diagnostic = diagnostics_2[_i];
var context_2 = "";
if (diagnostic.file) {
- var start = diagnostic.start, length_4 = diagnostic.length, file_8 = diagnostic.file;
- var _a = ts.getLineAndCharacterOfPosition(file_8, start), firstLine = _a.line, firstLineChar = _a.character;
- var _b = ts.getLineAndCharacterOfPosition(file_8, start + length_4), lastLine = _b.line, lastLineChar = _b.character;
- var lastLineInFile = ts.getLineAndCharacterOfPosition(file_8, file_8.text.length).line;
- var relativeFileName = host ? ts.convertToRelativePath(file_8.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_8.fileName;
+ var start = diagnostic.start, length_4 = diagnostic.length, file_9 = diagnostic.file;
+ var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character;
+ var _b = ts.getLineAndCharacterOfPosition(file_9, start + length_4), lastLine = _b.line, lastLineChar = _b.character;
+ var lastLineInFile = ts.getLineAndCharacterOfPosition(file_9, file_9.text.length).line;
+ var relativeFileName = host ? ts.convertToRelativePath(file_9.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_9.fileName;
var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
var gutterWidth = (lastLine + 1 + "").length;
if (hasMoreThanFiveLines) {
@@ -62723,9 +62964,9 @@ var ts;
context_2 += formatColorAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
i = lastLine - 1;
}
- var lineStart = ts.getPositionOfLineAndCharacter(file_8, i, 0);
- var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file_8, i + 1, 0) : file_8.text.length;
- var lineContent = file_8.text.slice(lineStart, lineEnd);
+ var lineStart = ts.getPositionOfLineAndCharacter(file_9, i, 0);
+ var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file_9, i + 1, 0) : file_9.text.length;
+ var lineContent = file_9.text.slice(lineStart, lineEnd);
lineContent = lineContent.replace(/\s+$/g, "");
lineContent = lineContent.replace("\t", " ");
context_2 += formatColorAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
@@ -63883,26 +64124,26 @@ var ts;
}
function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd, packageId) {
if (filesByName.has(path)) {
- var file_9 = filesByName.get(path);
- if (file_9 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_9.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
- reportFileNamesDifferOnlyInCasingError(fileName, file_9.fileName, refFile, refPos, refEnd);
+ var file_10 = filesByName.get(path);
+ if (file_10 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_10.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
+ reportFileNamesDifferOnlyInCasingError(fileName, file_10.fileName, refFile, refPos, refEnd);
}
- if (file_9 && sourceFilesFoundSearchingNodeModules.get(file_9.path) && currentNodeModulesDepth === 0) {
- sourceFilesFoundSearchingNodeModules.set(file_9.path, false);
+ if (file_10 && sourceFilesFoundSearchingNodeModules.get(file_10.path) && currentNodeModulesDepth === 0) {
+ sourceFilesFoundSearchingNodeModules.set(file_10.path, false);
if (!options.noResolve) {
- processReferencedFiles(file_9, isDefaultLib);
- processTypeReferenceDirectives(file_9);
+ processReferencedFiles(file_10, isDefaultLib);
+ processTypeReferenceDirectives(file_10);
}
- modulesWithElidedImports.set(file_9.path, false);
- processImportedModules(file_9);
+ modulesWithElidedImports.set(file_10.path, false);
+ processImportedModules(file_10);
}
- else if (file_9 && modulesWithElidedImports.get(file_9.path)) {
+ else if (file_10 && modulesWithElidedImports.get(file_10.path)) {
if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
- modulesWithElidedImports.set(file_9.path, false);
- processImportedModules(file_9);
+ modulesWithElidedImports.set(file_10.path, false);
+ processImportedModules(file_10);
}
}
- return file_9;
+ return file_10;
}
var redirectedPath;
if (refFile) {
@@ -64098,9 +64339,9 @@ var ts;
function computeCommonSourceDirectory(sourceFiles) {
var fileNames = [];
for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
- var file_10 = sourceFiles_2[_i];
- if (!file_10.isDeclarationFile) {
- fileNames.push(file_10.fileName);
+ var file_11 = sourceFiles_2[_i];
+ if (!file_11.isDeclarationFile) {
+ fileNames.push(file_11.fileName);
}
}
return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
@@ -64201,14 +64442,14 @@ var ts;
if (options.composite && rootNames.length < files.length) {
var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); });
var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); });
- var _loop_9 = function (file_11) {
- if (normalizedRootNames.every(function (r) { return r !== file_11; })) {
- programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file_11));
+ var _loop_10 = function (file_12) {
+ if (normalizedRootNames.every(function (r) { return r !== file_12; })) {
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file_12));
}
};
for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
- var file_11 = sourceFiles_4[_i];
- _loop_9(file_11);
+ var file_12 = sourceFiles_4[_i];
+ _loop_10(file_12);
}
}
if (options.paths) {
@@ -67375,7 +67616,7 @@ var ts;
function serializeCompilerOptions(options) {
var result = ts.createMap();
var optionsNameMap = getOptionNameMap().optionNameMap;
- var _loop_10 = function (name) {
+ var _loop_11 = function (name) {
if (ts.hasProperty(options, name)) {
if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
return "continue";
@@ -67399,7 +67640,7 @@ var ts;
}
};
for (var name in options) {
- _loop_10(name);
+ _loop_11(name);
}
return result;
}
@@ -67913,20 +68154,20 @@ var ts;
if (filesSpecs) {
for (var _i = 0, filesSpecs_1 = filesSpecs; _i < filesSpecs_1.length; _i++) {
var fileName = filesSpecs_1[_i];
- var file_12 = ts.getNormalizedAbsolutePath(fileName, basePath);
- literalFileMap.set(keyMapper(file_12), file_12);
+ var file_13 = ts.getNormalizedAbsolutePath(fileName, basePath);
+ literalFileMap.set(keyMapper(file_13), file_13);
}
}
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, validatedExcludeSpecs, validatedIncludeSpecs, undefined); _a < _b.length; _a++) {
- var file_13 = _b[_a];
- if (hasFileWithHigherPriorityExtension(file_13, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
+ var file_14 = _b[_a];
+ if (hasFileWithHigherPriorityExtension(file_14, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
continue;
}
- removeWildcardFilesWithLowerPriorityExtension(file_13, wildcardFileMap, supportedExtensions, keyMapper);
- var key = keyMapper(file_13);
+ removeWildcardFilesWithLowerPriorityExtension(file_14, wildcardFileMap, supportedExtensions, keyMapper);
+ var key = keyMapper(file_14);
if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
- wildcardFileMap.set(key, file_13);
+ wildcardFileMap.set(key, file_14);
}
}
}
@@ -67973,8 +68214,8 @@ var ts;
if (include !== undefined) {
var recursiveKeys = [];
for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
- var file_14 = include_1[_i];
- var spec = ts.normalizePath(ts.combinePaths(path, file_14));
+ var file_15 = include_1[_i];
+ var spec = ts.normalizePath(ts.combinePaths(path, file_15));
if (excludeRegex && excludeRegex.test(spec)) {
continue;
}
diff --git a/lib/tsserver.js b/lib/tsserver.js
index 427b048aa5a..47aa7289a50 100644
--- a/lib/tsserver.js
+++ b/lib/tsserver.js
@@ -333,22 +333,24 @@ var ts;
SyntaxKind[SyntaxKind["JSDocVariadicType"] = 284] = "JSDocVariadicType";
SyntaxKind[SyntaxKind["JSDocComment"] = 285] = "JSDocComment";
SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral";
- SyntaxKind[SyntaxKind["JSDocTag"] = 287] = "JSDocTag";
- SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 288] = "JSDocAugmentsTag";
- SyntaxKind[SyntaxKind["JSDocClassTag"] = 289] = "JSDocClassTag";
- SyntaxKind[SyntaxKind["JSDocParameterTag"] = 290] = "JSDocParameterTag";
- SyntaxKind[SyntaxKind["JSDocReturnTag"] = 291] = "JSDocReturnTag";
- SyntaxKind[SyntaxKind["JSDocTypeTag"] = 292] = "JSDocTypeTag";
- SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 293] = "JSDocTemplateTag";
- SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 294] = "JSDocTypedefTag";
- SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 295] = "JSDocPropertyTag";
- SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList";
- SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement";
- SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression";
- SyntaxKind[SyntaxKind["CommaListExpression"] = 299] = "CommaListExpression";
- SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 300] = "MergeDeclarationMarker";
- SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 301] = "EndOfDeclarationMarker";
- SyntaxKind[SyntaxKind["Count"] = 302] = "Count";
+ SyntaxKind[SyntaxKind["JSDocSignature"] = 287] = "JSDocSignature";
+ SyntaxKind[SyntaxKind["JSDocTag"] = 288] = "JSDocTag";
+ SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 289] = "JSDocAugmentsTag";
+ SyntaxKind[SyntaxKind["JSDocClassTag"] = 290] = "JSDocClassTag";
+ SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 291] = "JSDocCallbackTag";
+ SyntaxKind[SyntaxKind["JSDocParameterTag"] = 292] = "JSDocParameterTag";
+ SyntaxKind[SyntaxKind["JSDocReturnTag"] = 293] = "JSDocReturnTag";
+ SyntaxKind[SyntaxKind["JSDocTypeTag"] = 294] = "JSDocTypeTag";
+ SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 295] = "JSDocTemplateTag";
+ SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 296] = "JSDocTypedefTag";
+ SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 297] = "JSDocPropertyTag";
+ SyntaxKind[SyntaxKind["SyntaxList"] = 298] = "SyntaxList";
+ SyntaxKind[SyntaxKind["NotEmittedStatement"] = 299] = "NotEmittedStatement";
+ SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 300] = "PartiallyEmittedExpression";
+ SyntaxKind[SyntaxKind["CommaListExpression"] = 301] = "CommaListExpression";
+ SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 302] = "MergeDeclarationMarker";
+ SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 303] = "EndOfDeclarationMarker";
+ SyntaxKind[SyntaxKind["Count"] = 304] = "Count";
SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment";
SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment";
SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment";
@@ -375,9 +377,9 @@ var ts;
SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator";
SyntaxKind[SyntaxKind["FirstNode"] = 145] = "FirstNode";
SyntaxKind[SyntaxKind["FirstJSDocNode"] = 277] = "FirstJSDocNode";
- SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode";
- SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 287] = "FirstJSDocTagNode";
- SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode";
+ SyntaxKind[SyntaxKind["LastJSDocNode"] = 297] = "LastJSDocNode";
+ SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 288] = "FirstJSDocTagNode";
+ SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 297] = "LastJSDocTagNode";
SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword";
SyntaxKind[SyntaxKind["LastContextualKeyword"] = 144] = "LastContextualKeyword";
})(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
@@ -528,6 +530,7 @@ var ts;
NodeBuilderFlags[NodeBuilderFlags["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType";
NodeBuilderFlags[NodeBuilderFlags["GenerateNamesForShadowedTypeParams"] = 4] = "GenerateNamesForShadowedTypeParams";
NodeBuilderFlags[NodeBuilderFlags["UseStructuralFallback"] = 8] = "UseStructuralFallback";
+ NodeBuilderFlags[NodeBuilderFlags["ForbidIndexedAccessSymbolReferences"] = 16] = "ForbidIndexedAccessSymbolReferences";
NodeBuilderFlags[NodeBuilderFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature";
NodeBuilderFlags[NodeBuilderFlags["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType";
NodeBuilderFlags[NodeBuilderFlags["UseOnlyExternalAliasing"] = 128] = "UseOnlyExternalAliasing";
@@ -773,6 +776,7 @@ var ts;
TypeFlags[TypeFlags["ContainsObjectLiteral"] = 33554432] = "ContainsObjectLiteral";
TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 67108864] = "ContainsAnyFunctionType";
TypeFlags[TypeFlags["NonPrimitive"] = 134217728] = "NonPrimitive";
+ TypeFlags[TypeFlags["UnionOfUnitTypes"] = 268435456] = "UnionOfUnitTypes";
TypeFlags[TypeFlags["GenericMappedType"] = 536870912] = "GenericMappedType";
TypeFlags[TypeFlags["Nullable"] = 12288] = "Nullable";
TypeFlags[TypeFlags["Literal"] = 224] = "Literal";
@@ -799,6 +803,7 @@ var ts;
TypeFlags[TypeFlags["StructuredOrInstantiable"] = 8355840] = "StructuredOrInstantiable";
TypeFlags[TypeFlags["Narrowable"] = 142575359] = "Narrowable";
TypeFlags[TypeFlags["NotUnionOrUnit"] = 134283777] = "NotUnionOrUnit";
+ TypeFlags[TypeFlags["NotUnit"] = 8374815] = "NotUnit";
TypeFlags[TypeFlags["RequiresWidening"] = 50331648] = "RequiresWidening";
TypeFlags[TypeFlags["PropagatingFlags"] = 117440512] = "PropagatingFlags";
TypeFlags[TypeFlags["NonWideningType"] = 16777216] = "NonWideningType";
@@ -1636,6 +1641,15 @@ var ts;
return -1;
}
ts.findIndex = findIndex;
+ function findLastIndex(array, predicate, startIndex) {
+ for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
+ if (predicate(array[i], i)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+ ts.findLastIndex = findLastIndex;
function findMap(array, callback) {
for (var i = 0; i < array.length; i++) {
var result = callback(array[i], i);
@@ -1966,6 +1980,23 @@ var ts;
return false;
}
ts.some = some;
+ function getRangesWhere(arr, pred, cb) {
+ var start;
+ for (var i = 0; i < arr.length; i++) {
+ if (pred(arr[i])) {
+ start = start === undefined ? i : start;
+ }
+ else {
+ if (start !== undefined) {
+ cb(start, i);
+ start = undefined;
+ }
+ }
+ }
+ if (start !== undefined)
+ cb(start, arr.length);
+ }
+ ts.getRangesWhere = getRangesWhere;
function concatenate(array1, array2) {
if (!some(array2))
return array1;
@@ -5901,6 +5932,7 @@ var ts;
Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
+ Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing typeof"),
};
})(ts || (ts = {}));
var ts;
@@ -7467,11 +7499,10 @@ var ts;
}
}
function scanJSDocToken() {
+ startPos = tokenPos = pos;
if (pos >= end) {
return token = 1;
}
- startPos = pos;
- tokenPos = pos;
var ch = text.charCodeAt(pos);
pos++;
switch (ch) {
@@ -7828,7 +7859,7 @@ var ts;
if (includeJsDoc && ts.hasJSDocNodes(node)) {
return getTokenPosOfNode(node.jsDoc[0]);
}
- if (node.kind === 296 && node._children.length > 0) {
+ if (node.kind === 298 && node._children.length > 0) {
return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
}
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
@@ -8008,7 +8039,7 @@ var ts;
case 204:
case 235:
case 236:
- case 293:
+ case 295:
case 233:
case 153:
case 154:
@@ -8016,6 +8047,9 @@ var ts;
case 156:
case 191:
case 192:
+ case 291:
+ case 296:
+ case 287:
return true;
default:
ts.assertTypeIsNever(node);
@@ -8055,13 +8089,7 @@ var ts;
}
ts.isAnyImportOrReExport = isAnyImportOrReExport;
function getEnclosingBlockScopeContainer(node) {
- var current = node.parent;
- while (current) {
- if (isBlockScope(current, current.parent)) {
- return current;
- }
- current = current.parent;
- }
+ return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
}
ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
function declarationNameToString(name) {
@@ -9124,6 +9152,14 @@ var ts;
node.parameters[0].name.escapedText === "new";
}
ts.isJSDocConstructSignature = isJSDocConstructSignature;
+ function isJSDocTypeAlias(node) {
+ return node.kind === 296 || node.kind === 291;
+ }
+ ts.isJSDocTypeAlias = isJSDocTypeAlias;
+ function isTypeAlias(node) {
+ return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
+ }
+ ts.isTypeAlias = isTypeAlias;
function getSourceOfAssignment(node) {
return ts.isExpressionStatement(node) &&
node.expression && ts.isBinaryExpression(node.expression) &&
@@ -9145,6 +9181,8 @@ var ts;
return v && v.initializer;
case 151:
return node.initializer;
+ case 269:
+ return node.initializer;
}
}
function getSingleVariableOfVariableStatement(node) {
@@ -9169,8 +9207,7 @@ var ts;
if (parent.kind === 269 || parent.kind === 151 || getNestedModuleDeclaration(parent)) {
getJSDocCommentsAndTagsWorker(parent);
}
- if (parent.parent &&
- (getSingleVariableOfVariableStatement(parent.parent) === node)) {
+ if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) {
getJSDocCommentsAndTagsWorker(parent.parent);
}
if (parent.parent && parent.parent.parent &&
@@ -9213,7 +9250,10 @@ var ts;
}
ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
function getHostSignatureFromJSDoc(node) {
- var host = getJSDocHost(node);
+ return getHostSignatureFromJSDocHost(getJSDocHost(node));
+ }
+ ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ function getHostSignatureFromJSDocHost(host) {
var decl = getSourceOfDefaultedAssignment(host) ||
getSourceOfAssignment(host) ||
getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
@@ -9222,18 +9262,12 @@ var ts;
host;
return decl && ts.isFunctionLike(decl) ? decl : undefined;
}
- ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ ts.getHostSignatureFromJSDocHost = getHostSignatureFromJSDocHost;
function getJSDocHost(node) {
- while (node.parent.kind === 286) {
- if (node.parent.parent.kind === 294) {
- node = node.parent.parent;
- }
- else {
- node = node.parent.parent.parent;
- }
+ var comment = ts.findAncestor(node.parent, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152) ? "quit" : node.kind === 285; });
+ if (comment) {
+ return comment.parent;
}
- ts.Debug.assert(node.parent.kind === 285);
- return node.parent.parent;
}
ts.getJSDocHost = getJSDocHost;
function getTypeParameterFromJsDoc(node) {
@@ -9248,7 +9282,8 @@ var ts;
}
ts.hasRestParameter = hasRestParameter;
function isRestParameter(node) {
- return node.dotDotDotToken !== undefined || node.type && node.type.kind === 284;
+ var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
+ return node.dotDotDotToken !== undefined || type && type.kind === 284;
}
ts.isRestParameter = isRestParameter;
var AssignmentKind;
@@ -9736,7 +9771,7 @@ var ts;
ts.getOperator = getOperator;
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
switch (nodeKind) {
- case 299:
+ case 301:
return 0;
case 203:
return 1;
@@ -10047,8 +10082,8 @@ var ts;
};
}
ts.createTextWriter = createTextWriter;
- function getResolvedExternalModuleName(host, file) {
- return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
+ function getResolvedExternalModuleName(host, file, referenceFile) {
+ return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
}
ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
@@ -10059,12 +10094,13 @@ var ts;
return getResolvedExternalModuleName(host, file);
}
ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
- function getExternalModuleNameFromPath(host, fileName) {
+ function getExternalModuleNameFromPath(host, fileName, referencePath) {
var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
- var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
+ var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false);
- return ts.removeFileExtension(relativePath);
+ var extensionless = ts.removeFileExtension(relativePath);
+ return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
}
ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
function getOwnEmitOutputFilePath(sourceFile, host, extension) {
@@ -10146,7 +10182,7 @@ var ts;
}
ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
function getThisParameter(signature) {
- if (signature.parameters.length) {
+ if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
var thisParameter = signature.parameters[0];
if (parameterIsThisKeyword(thisParameter)) {
return thisParameter;
@@ -10223,18 +10259,32 @@ var ts;
}
ts.getTypeAnnotationNode = getTypeAnnotationNode;
function getEffectiveReturnTypeNode(node) {
+ if (ts.isJSDocSignature(node)) {
+ return node.type && node.type.typeExpression && node.type.typeExpression.type;
+ }
return node.type || (isInJavaScriptFile(node) ? ts.getJSDocReturnType(node) : undefined);
}
ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
function getEffectiveTypeParameterDeclarations(node) {
- return ts.isJSDocTypedefTag(node)
- ? getJSDocTypeParameterDeclarations(node)
- : node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined);
+ if (ts.isJSDocSignature(node)) {
+ return ts.emptyArray;
+ }
+ if (isJSDocTypeAlias(node)) {
+ ts.Debug.assert(node.parent.kind === 285);
+ var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; });
+ var templateTagNodes = templateTags;
+ templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos;
+ templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end;
+ templateTagNodes.hasTrailingComma = false;
+ return templateTagNodes;
+ }
+ return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray);
}
ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
function getJSDocTypeParameterDeclarations(node) {
- var templateTag = ts.getJSDocTemplateTag(node);
- return templateTag && templateTag.typeParameters;
+ var tags = ts.filter(ts.getJSDocTags(node), ts.isJSDocTemplateTag);
+ var tag = ts.find(tags, function (tag) { return !(tag.parent.kind === 285 && ts.find(tag.parent.tags, isJSDocTypeAlias)); });
+ return (tag && tag.typeParameters) || ts.emptyArray;
}
ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
function getEffectiveSetAccessorTypeAnnotationNode(node) {
@@ -11359,8 +11409,8 @@ var ts;
break;
case 71:
return declaration;
- case 295:
- case 290: {
+ case 297:
+ case 292: {
var name = declaration.name;
if (name.kind === 145) {
return name.right;
@@ -11379,7 +11429,9 @@ var ts;
return undefined;
}
}
- case 294:
+ case 291:
+ return declaration.name;
+ case 296:
return getNameOfJSDocTypedef(declaration);
case 248: {
var expression = declaration.expression;
@@ -11708,7 +11760,7 @@ var ts;
}
ts.isParenthesizedExpression = isParenthesizedExpression;
function skipPartiallyEmittedExpressions(node) {
- while (node.kind === 298) {
+ while (node.kind === 300) {
node = node.expression;
}
return node;
@@ -12091,49 +12143,57 @@ var ts;
}
ts.isJSDoc = isJSDoc;
function isJSDocAugmentsTag(node) {
- return node.kind === 288;
+ return node.kind === 289;
}
ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
function isJSDocClassTag(node) {
- return node.kind === 289;
+ return node.kind === 290;
}
ts.isJSDocClassTag = isJSDocClassTag;
function isJSDocParameterTag(node) {
- return node.kind === 290;
+ return node.kind === 292;
}
ts.isJSDocParameterTag = isJSDocParameterTag;
function isJSDocReturnTag(node) {
- return node.kind === 291;
+ return node.kind === 293;
}
ts.isJSDocReturnTag = isJSDocReturnTag;
function isJSDocTypeTag(node) {
- return node.kind === 292;
+ return node.kind === 294;
}
ts.isJSDocTypeTag = isJSDocTypeTag;
function isJSDocTemplateTag(node) {
- return node.kind === 293;
+ return node.kind === 295;
}
ts.isJSDocTemplateTag = isJSDocTemplateTag;
function isJSDocTypedefTag(node) {
- return node.kind === 294;
+ return node.kind === 296;
}
ts.isJSDocTypedefTag = isJSDocTypedefTag;
function isJSDocPropertyTag(node) {
- return node.kind === 295;
+ return node.kind === 297;
}
ts.isJSDocPropertyTag = isJSDocPropertyTag;
function isJSDocPropertyLikeTag(node) {
- return node.kind === 295 || node.kind === 290;
+ return node.kind === 297 || node.kind === 292;
}
ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
function isJSDocTypeLiteral(node) {
return node.kind === 286;
}
ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
+ function isJSDocCallbackTag(node) {
+ return node.kind === 291;
+ }
+ ts.isJSDocCallbackTag = isJSDocCallbackTag;
+ function isJSDocSignature(node) {
+ return node.kind === 287;
+ }
+ ts.isJSDocSignature = isJSDocSignature;
})(ts || (ts = {}));
(function (ts) {
function isSyntaxList(n) {
- return n.kind === 296;
+ return n.kind === 298;
}
ts.isSyntaxList = isSyntaxList;
function isNode(node) {
@@ -12255,6 +12315,7 @@ var ts;
switch (kind) {
case 152:
case 157:
+ case 287:
case 158:
case 159:
case 162:
@@ -12530,8 +12591,8 @@ var ts;
case 203:
case 207:
case 205:
- case 299:
- case 298:
+ case 301:
+ case 300:
return true;
default:
return isUnaryExpressionKind(kind);
@@ -12544,11 +12605,11 @@ var ts;
}
ts.isAssertionExpression = isAssertionExpression;
function isPartiallyEmittedExpression(node) {
- return node.kind === 298;
+ return node.kind === 300;
}
ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
function isNotEmittedStatement(node) {
- return node.kind === 297;
+ return node.kind === 299;
}
ts.isNotEmittedStatement = isNotEmittedStatement;
function isNotEmittedOrPartiallyEmittedNode(node) {
@@ -12648,8 +12709,9 @@ var ts;
|| kind === 236
|| kind === 147
|| kind === 231
- || kind === 294
- || kind === 295;
+ || kind === 296
+ || kind === 291
+ || kind === 297;
}
function isDeclarationStatementKind(kind) {
return kind === 233
@@ -12684,13 +12746,13 @@ var ts;
|| kind === 213
|| kind === 218
|| kind === 225
- || kind === 297
- || kind === 301
- || kind === 300;
+ || kind === 299
+ || kind === 303
+ || kind === 302;
}
function isDeclaration(node) {
if (node.kind === 147) {
- return node.parent.kind !== 293 || ts.isInJavaScriptFile(node);
+ return node.parent.kind !== 295 || ts.isInJavaScriptFile(node);
}
return isDeclarationKind(node.kind);
}
@@ -12768,15 +12830,15 @@ var ts;
}
ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
function isJSDocNode(node) {
- return node.kind >= 277 && node.kind <= 295;
+ return node.kind >= 277 && node.kind <= 297;
}
ts.isJSDocNode = isJSDocNode;
function isJSDocCommentContainingNode(node) {
- return node.kind === 285 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node);
+ return node.kind === 285 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node);
}
ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
function isJSDocTag(node) {
- return node.kind >= 287 && node.kind <= 295;
+ return node.kind >= 288 && node.kind <= 297;
}
ts.isJSDocTag = isJSDocTag;
function isSetAccessor(node) {
@@ -13293,7 +13355,7 @@ var ts;
return visitNode(cbNode, node.expression);
case 252:
return visitNodes(cbNode, cbNodes, node.decorators);
- case 299:
+ case 301:
return visitNodes(cbNode, cbNodes, node.elements);
case 254:
return visitNode(cbNode, node.openingElement) ||
@@ -13335,8 +13397,8 @@ var ts;
return visitNode(cbNode, node.type);
case 285:
return visitNodes(cbNode, cbNodes, node.tags);
- case 290:
- case 295:
+ case 292:
+ case 297:
if (node.isNameFirst) {
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.typeExpression);
@@ -13345,15 +13407,15 @@ var ts;
return visitNode(cbNode, node.typeExpression) ||
visitNode(cbNode, node.name);
}
- case 291:
- return visitNode(cbNode, node.typeExpression);
- case 292:
- return visitNode(cbNode, node.typeExpression);
- case 288:
- return visitNode(cbNode, node.class);
case 293:
- return visitNodes(cbNode, cbNodes, node.typeParameters);
+ return visitNode(cbNode, node.typeExpression);
case 294:
+ return visitNode(cbNode, node.typeExpression);
+ case 289:
+ return visitNode(cbNode, node.class);
+ case 295:
+ return visitNodes(cbNode, cbNodes, node.typeParameters);
+ case 296:
if (node.typeExpression &&
node.typeExpression.kind === 277) {
return visitNode(cbNode, node.typeExpression) ||
@@ -13363,6 +13425,15 @@ var ts;
return visitNode(cbNode, node.fullName) ||
visitNode(cbNode, node.typeExpression);
}
+ case 291:
+ return visitNode(cbNode, node.fullName) ||
+ visitNode(cbNode, node.typeExpression);
+ case 287:
+ return visitNodes(cbNode, cbNodes, node.decorators) ||
+ visitNodes(cbNode, cbNodes, node.modifiers) ||
+ visitNodes(cbNode, cbNodes, node.typeParameters) ||
+ visitNodes(cbNode, cbNodes, node.parameters) ||
+ visitNode(cbNode, node.type);
case 286:
if (node.jsDocPropertyTags) {
for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
@@ -13371,7 +13442,7 @@ var ts;
}
}
return;
- case 298:
+ case 300:
return visitNode(cbNode, node.expression);
}
}
@@ -17483,8 +17554,9 @@ var ts;
})(JSDocState || (JSDocState = {}));
var PropertyLikeParse;
(function (PropertyLikeParse) {
- PropertyLikeParse[PropertyLikeParse["Property"] = 0] = "Property";
- PropertyLikeParse[PropertyLikeParse["Parameter"] = 1] = "Parameter";
+ PropertyLikeParse[PropertyLikeParse["Property"] = 1] = "Property";
+ PropertyLikeParse[PropertyLikeParse["Parameter"] = 2] = "Parameter";
+ PropertyLikeParse[PropertyLikeParse["CallbackParameter"] = 4] = "CallbackParameter";
})(PropertyLikeParse || (PropertyLikeParse = {}));
function parseJSDocCommentWorker(start, length) {
var content = sourceText;
@@ -17527,7 +17599,7 @@ var ts;
case 57:
if (state === 0 || state === 1) {
removeTrailingNewlines(comments);
- parseTag(indent);
+ addTag(parseTag(indent));
state = 0;
margin = undefined;
indent++;
@@ -17596,7 +17668,23 @@ var ts;
result.comment = comments.length ? comments.join("") : undefined;
return finishNode(result, end);
}
+ function isNextNonwhitespaceTokenEndOfFile() {
+ while (true) {
+ nextJSDocToken();
+ if (token() === 1) {
+ return true;
+ }
+ if (!(token() === 5 || token() === 4)) {
+ return false;
+ }
+ }
+ }
function skipWhitespace() {
+ if (token() === 5 || token() === 4) {
+ if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
+ return;
+ }
+ }
while (token() === 5 || token() === 4) {
nextJSDocToken();
}
@@ -17625,8 +17713,7 @@ var ts;
case "arg":
case "argument":
case "param":
- addTag(parseParameterOrPropertyTag(atToken, tagName, 1, indent));
- return;
+ return parseParameterOrPropertyTag(atToken, tagName, 2, indent);
case "return":
case "returns":
tag = parseReturnTag(atToken, tagName);
@@ -17638,7 +17725,10 @@ var ts;
tag = parseTypeTag(atToken, tagName);
break;
case "typedef":
- tag = parseTypedefTag(atToken, tagName);
+ tag = parseTypedefTag(atToken, tagName, indent);
+ break;
+ case "callback":
+ tag = parseCallbackTag(atToken, tagName, indent);
break;
default:
tag = parseUnknownTag(atToken, tagName);
@@ -17651,8 +17741,10 @@ var ts;
if (!tag) {
return;
}
- tag.comment = parseTagComments(indent + tag.end - tag.pos);
- addTag(tag);
+ if (!tag.comment) {
+ tag.comment = parseTagComments(indent + tag.end - tag.pos);
+ }
+ return tag;
}
function parseTagComments(indent) {
var comments = [];
@@ -17709,12 +17801,15 @@ var ts;
return comments.length === 0 ? undefined : comments.join("");
}
function parseUnknownTag(atToken, tagName) {
- var result = createNode(287, atToken.pos);
+ var result = createNode(288, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
return finishNode(result);
}
function addTag(tag) {
+ if (!tag) {
+ return;
+ }
if (!tags) {
tags = [tag];
tagsPos = tag.pos;
@@ -17763,8 +17858,8 @@ var ts;
typeExpression = tryParseTypeExpression();
}
var result = target === 1 ?
- createNode(290, atToken.pos) :
- createNode(295, atToken.pos);
+ createNode(297, atToken.pos) :
+ createNode(292, atToken.pos);
var comment;
if (indent !== undefined)
comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
@@ -17790,7 +17885,7 @@ var ts;
var start_2 = scanner.getStartPos();
var children = void 0;
while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) {
- if (child.kind === 290 || child.kind === 295) {
+ if (child.kind === 292 || child.kind === 297) {
children = ts.append(children, child);
}
}
@@ -17806,27 +17901,27 @@ var ts;
}
}
function parseReturnTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 291; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 293; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(291, atToken.pos);
+ var result = createNode(293, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result);
}
function parseTypeTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 292; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 294; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(292, atToken.pos);
+ var result = createNode(294, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = parseJSDocTypeExpression(true);
return finishNode(result);
}
function parseAugmentsTag(atToken, tagName) {
- var result = createNode(288, atToken.pos);
+ var result = createNode(289, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.class = parseExpressionWithTypeArgumentsForAugments();
@@ -17854,30 +17949,23 @@ var ts;
return node;
}
function parseClassTag(atToken, tagName) {
- var tag = createNode(289, atToken.pos);
+ var tag = createNode(290, atToken.pos);
tag.atToken = atToken;
tag.tagName = tagName;
return finishNode(tag);
}
- function parseTypedefTag(atToken, tagName) {
+ function parseTypedefTag(atToken, tagName, indent) {
var typeExpression = tryParseTypeExpression();
skipWhitespace();
- var typedefTag = createNode(294, atToken.pos);
+ var typedefTag = createNode(296, atToken.pos);
typedefTag.atToken = atToken;
typedefTag.tagName = tagName;
- typedefTag.fullName = parseJSDocTypeNameWithNamespace(0);
- if (typedefTag.fullName) {
- var rightNode = typedefTag.fullName;
- while (true) {
- if (rightNode.kind === 71 || !rightNode.body) {
- typedefTag.name = rightNode.kind === 71 ? rightNode : rightNode.name;
- break;
- }
- rightNode = rightNode.body;
- }
- }
+ typedefTag.fullName = parseJSDocTypeNameWithNamespace();
+ typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
skipWhitespace();
+ typedefTag.comment = parseTagComments(indent);
typedefTag.typeExpression = typeExpression;
+ var end;
if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
var child = void 0;
var jsdocTypeLiteral = void 0;
@@ -17887,7 +17975,7 @@ var ts;
if (!jsdocTypeLiteral) {
jsdocTypeLiteral = createNode(286, start_3);
}
- if (child.kind === 292) {
+ if (child.kind === 294) {
if (childTypeTag) {
break;
}
@@ -17906,23 +17994,67 @@ var ts;
typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
childTypeTag.typeExpression :
finishNode(jsdocTypeLiteral);
+ end = typedefTag.typeExpression.end;
}
}
- return finishNode(typedefTag);
- function parseJSDocTypeNameWithNamespace(flags) {
- var pos = scanner.getTokenPos();
- var typeNameOrNamespaceName = parseJSDocIdentifierName();
- if (typeNameOrNamespaceName && parseOptional(23)) {
- var jsDocNamespaceNode = createNode(238, pos);
- jsDocNamespaceNode.flags |= flags;
- jsDocNamespaceNode.name = typeNameOrNamespaceName;
- jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4);
- return finishNode(jsDocNamespaceNode);
+ return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
+ }
+ function parseJSDocTypeNameWithNamespace(nested) {
+ var pos = scanner.getTokenPos();
+ var typeNameOrNamespaceName = parseJSDocIdentifierName();
+ if (typeNameOrNamespaceName && parseOptional(23)) {
+ var jsDocNamespaceNode = createNode(238, pos);
+ if (nested) {
+ jsDocNamespaceNode.flags |= 4;
}
- if (typeNameOrNamespaceName && flags & 4) {
- typeNameOrNamespaceName.isInJSDocNamespace = true;
+ jsDocNamespaceNode.name = typeNameOrNamespaceName;
+ jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(true);
+ return finishNode(jsDocNamespaceNode);
+ }
+ if (typeNameOrNamespaceName && nested) {
+ typeNameOrNamespaceName.isInJSDocNamespace = true;
+ }
+ return typeNameOrNamespaceName;
+ }
+ function parseCallbackTag(atToken, tagName, indent) {
+ var callbackTag = createNode(291, atToken.pos);
+ callbackTag.atToken = atToken;
+ callbackTag.tagName = tagName;
+ callbackTag.fullName = parseJSDocTypeNameWithNamespace();
+ callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
+ skipWhitespace();
+ callbackTag.comment = parseTagComments(indent);
+ var child;
+ var start = scanner.getStartPos();
+ var jsdocSignature = createNode(287, start);
+ jsdocSignature.parameters = [];
+ while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4); })) {
+ jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
+ }
+ var returnTag = tryParse(function () {
+ if (token() === 57) {
+ nextJSDocToken();
+ var tag = parseTag(indent);
+ if (tag && tag.kind === 293) {
+ return tag;
+ }
+ }
+ });
+ if (returnTag) {
+ jsdocSignature.type = returnTag;
+ }
+ callbackTag.typeExpression = finishNode(jsdocSignature);
+ return finishNode(callbackTag);
+ }
+ function getJSDocTypeAliasName(fullName) {
+ if (fullName) {
+ var rightNode = fullName;
+ while (true) {
+ if (ts.isIdentifier(rightNode) || !rightNode.body) {
+ return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
+ }
+ rightNode = rightNode.body;
}
- return typeNameOrNamespaceName;
}
}
function escapedTextsEqual(a, b) {
@@ -17938,7 +18070,7 @@ var ts;
return a.escapedText === b.escapedText;
}
function parseChildPropertyTag() {
- return parseChildParameterOrPropertyTag(0);
+ return parseChildParameterOrPropertyTag(1);
}
function parseChildParameterOrPropertyTag(target, name) {
var canParseTag = true;
@@ -17948,7 +18080,8 @@ var ts;
case 57:
if (canParseTag) {
var child = tryParseChildTag(target);
- if (child && child.kind === 290 &&
+ if (child && child.kind === 292 &&
+ target !== 4 &&
(ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
return false;
}
@@ -17987,20 +18120,20 @@ var ts;
var t;
switch (tagName.escapedText) {
case "type":
- return target === 0 && parseTypeTag(atToken, tagName);
+ return target === 1 && parseTypeTag(atToken, tagName);
case "prop":
case "property":
- t = 0;
+ t = 1;
break;
case "arg":
case "argument":
case "param":
- t = 1;
+ t = 2 | 4;
break;
default:
return false;
}
- if (target !== t) {
+ if (!(target & t)) {
return false;
}
var tag = parseParameterOrPropertyTag(atToken, tagName, target, undefined);
@@ -18032,7 +18165,7 @@ var ts;
break;
}
}
- var result = createNode(293, atToken.pos);
+ var result = createNode(295, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
@@ -18078,7 +18211,7 @@ var ts;
var pos = scanner.getTokenPos();
var end = scanner.getTextPos();
var result = createNode(71, pos);
- result.escapedText = ts.escapeLeadingUnderscores(content.substring(pos, end));
+ result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText());
finishNode(result, end);
nextJSDocToken();
return result;
@@ -18664,7 +18797,7 @@ var ts;
var thisParentContainer;
var blockScopeContainer;
var lastContainer;
- var delayedTypedefs;
+ var delayedTypeAliases;
var seenThisKeyword;
var currentFlow;
var currentBreakTarget;
@@ -18710,7 +18843,7 @@ var ts;
thisParentContainer = undefined;
blockScopeContainer = undefined;
lastContainer = undefined;
- delayedTypedefs = undefined;
+ delayedTypeAliases = undefined;
seenThisKeyword = false;
currentFlow = undefined;
currentBreakTarget = undefined;
@@ -18779,6 +18912,7 @@ var ts;
return "__constructor";
case 162:
case 157:
+ case 287:
return "__call";
case 163:
case 158:
@@ -18802,9 +18936,6 @@ var ts;
var functionType = node.parent;
var index = functionType.parameters.indexOf(node);
return "arg" + index;
- case 294:
- var name_2 = ts.getNameOfJSDocTypedef(node);
- return typeof name_2 !== "undefined" ? name_2.escapedText : undefined;
}
}
function getDisplayName(node) {
@@ -18884,9 +19015,9 @@ var ts;
}
}
else {
- if (node.kind === 294)
+ if (ts.isJSDocTypeAlias(node))
ts.Debug.assert(ts.isInJavaScriptFile(node));
- if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || ts.isJSDocTypedefTag(node)) {
+ if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || ts.isJSDocTypeAlias(node)) {
if (ts.hasModifier(node, 512) && !getDeclarationName(node)) {
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
}
@@ -19023,20 +19154,6 @@ var ts;
ts.forEachChild(node, bind, bindEach);
}
function bindChildrenWorker(node) {
- if (ts.hasJSDocNodes(node)) {
- if (ts.isInJavaScriptFile(node)) {
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var j = _a[_i];
- bind(j);
- }
- }
- else {
- for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
- var j = _c[_b];
- setParentPointers(node, j);
- }
- }
- }
if (checkUnreachable(node)) {
bindEachChild(node);
return;
@@ -19102,11 +19219,9 @@ var ts;
case 186:
bindCallExpressionFlow(node);
break;
- case 285:
- bindJSDocComment(node);
- break;
- case 294:
- bindJSDocTypedefTag(node);
+ case 296:
+ case 291:
+ bindJSDocTypeAlias(node);
break;
case 273:
bindEachFunctionsFirst(node.statements);
@@ -19120,6 +19235,7 @@ var ts;
bindEachChild(node);
break;
}
+ bindJSDoc(node);
}
function isNarrowingExpression(expr) {
switch (expr.kind) {
@@ -19682,20 +19798,10 @@ var ts;
bindInitializedVariableFlow(node);
}
}
- function bindJSDocComment(node) {
- ts.forEachChild(node, function (n) {
- if (n.kind !== 294) {
- bind(n);
- }
- });
- }
- function bindJSDocTypedefTag(node) {
- ts.forEachChild(node, function (n) {
- if (node.fullName && n === node.name && node.fullName.kind !== 71) {
- return;
- }
- bind(n);
- });
+ function bindJSDocTypeAlias(node) {
+ if (node.fullName) {
+ setParentPointers(node, node.fullName);
+ }
}
function bindCallExpressionFlow(node) {
var expr = node.expression;
@@ -19745,6 +19851,7 @@ var ts;
case 155:
case 156:
case 157:
+ case 287:
case 283:
case 162:
case 158:
@@ -19796,6 +19903,7 @@ var ts;
case 163:
case 157:
case 158:
+ case 287:
case 159:
case 153:
case 152:
@@ -19806,6 +19914,8 @@ var ts;
case 191:
case 192:
case 283:
+ case 296:
+ case 291:
case 236:
case 176:
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
@@ -19954,22 +20064,35 @@ var ts;
bindBlockScopedDeclaration(node, 2, 67216319);
}
function delayedBindJSDocTypedefTag() {
- if (!delayedTypedefs) {
+ if (!delayedTypeAliases) {
return;
}
var saveContainer = container;
var saveLastContainer = lastContainer;
var saveBlockScopeContainer = blockScopeContainer;
var saveParent = parent;
- for (var _i = 0, delayedTypedefs_1 = delayedTypedefs; _i < delayedTypedefs_1.length; _i++) {
- var delay = delayedTypedefs_1[_i];
- (container = delay.container, lastContainer = delay.lastContainer, blockScopeContainer = delay.blockScopeContainer, parent = delay.parent);
- bindBlockScopedDeclaration(delay.typedef, 524288, 67901928);
+ var saveCurrentFlow = currentFlow;
+ for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
+ var typeAlias = delayedTypeAliases_1[_i];
+ var host = ts.getJSDocHost(typeAlias);
+ container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); }) || file;
+ blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
+ currentFlow = { flags: 2 };
+ parent = typeAlias;
+ bind(typeAlias.typeExpression);
+ if (!typeAlias.fullName || typeAlias.fullName.kind === 71) {
+ parent = typeAlias.parent;
+ bindBlockScopedDeclaration(typeAlias, 524288, 67901928);
+ }
+ else {
+ bind(typeAlias.fullName);
+ }
}
container = saveContainer;
lastContainer = saveLastContainer;
blockScopeContainer = saveBlockScopeContainer;
parent = saveParent;
+ currentFlow = saveCurrentFlow;
}
function checkStrictModeIdentifier(node) {
if (inStrictMode &&
@@ -20084,8 +20207,6 @@ var ts;
}
node.parent = parent;
var saveInStrictMode = inStrictMode;
- if (ts.isInJavaScriptFile(node))
- bindJSDocTypedefTagIfAny(node);
bindWorker(node);
if (node.kind > 144) {
var saveParent = parent;
@@ -20101,25 +20222,22 @@ var ts;
}
else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912) === 0) {
subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
+ bindJSDoc(node);
}
inStrictMode = saveInStrictMode;
}
- function bindJSDocTypedefTagIfAny(node) {
- if (!ts.hasJSDocNodes(node)) {
- return;
- }
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var jsDoc = _a[_i];
- if (!jsDoc.tags) {
- continue;
+ function bindJSDoc(node) {
+ if (ts.hasJSDocNodes(node)) {
+ if (ts.isInJavaScriptFile(node)) {
+ for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
+ var j = _a[_i];
+ bind(j);
+ }
}
- for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) {
- var tag = _c[_b];
- if (tag.kind === 294) {
- var savedParent = parent;
- parent = jsDoc;
- bind(tag);
- parent = savedParent;
+ else {
+ for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
+ var j = _c[_b];
+ setParentPointers(node, j);
}
}
}
@@ -20147,7 +20265,7 @@ var ts;
case 71:
if (node.isInJSDocNamespace) {
var parentNode = node.parent;
- while (parentNode && parentNode.kind !== 294) {
+ while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
parentNode = parentNode.parent;
}
bindBlockScopedDeclaration(parentNode, 524288, 67901928);
@@ -20244,6 +20362,7 @@ var ts;
return bindPropertyOrMethodOrAccessor(node, 65536, 67183551);
case 162:
case 283:
+ case 287:
case 163:
return bindFunctionOrConstructorType(node);
case 165:
@@ -20298,23 +20417,22 @@ var ts;
}
case 239:
return updateStrictModeStatementList(node.statements);
- case 290:
+ case 292:
+ if (node.parent.kind === 287) {
+ return bindParameter(node);
+ }
if (node.parent.kind !== 286) {
break;
}
- case 295:
+ case 297:
var propTag = node;
var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 ?
4 | 16777216 :
4;
return declareSymbolAndAddToSymbolTable(propTag, flags, 0);
- case 294: {
- var fullName = node.fullName;
- if (!fullName || fullName.kind === 71) {
- (delayedTypedefs || (delayedTypedefs = [])).push({ typedef: node, container: container, lastContainer: lastContainer, blockScopeContainer: blockScopeContainer, parent: parent });
- }
- break;
- }
+ case 296:
+ case 291:
+ return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
}
}
function bindPropertyWorker(node) {
@@ -20610,6 +20728,9 @@ var ts;
}
}
function bindParameter(node) {
+ if (node.kind === 292 && container.kind !== 287) {
+ return;
+ }
if (inStrictMode && !(node.flags & 4194304)) {
checkStrictModeEvalOrArguments(node, node.name);
}
@@ -20664,24 +20785,30 @@ var ts;
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
function getInferTypeContainer(node) {
- while (node) {
- var parent_2 = node.parent;
- if (parent_2 && parent_2.kind === 170 && parent_2.extendsType === node) {
- return parent_2;
- }
- node = parent_2;
- }
- return undefined;
+ var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
+ return extendsType && extendsType.parent;
}
function bindTypeParameter(node) {
- if (node.parent.kind === 171) {
- var container_1 = getInferTypeContainer(node.parent);
+ if (ts.isJSDocTemplateTag(node.parent)) {
+ var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
if (container_1) {
if (!container_1.locals) {
container_1.locals = ts.createSymbolTable();
}
declareSymbol(container_1.locals, undefined, node, 262144, 67639784);
}
+ else {
+ declareSymbolAndAddToSymbolTable(node, 262144, 67639784);
+ }
+ }
+ else if (node.parent.kind === 171) {
+ var container_2 = getInferTypeContainer(node.parent);
+ if (container_2) {
+ if (!container_2.locals) {
+ container_2.locals = ts.createSymbolTable();
+ }
+ declareSymbol(container_2.locals, undefined, node, 262144, 67639784);
+ }
else {
bindAnonymousDeclaration(node, 262144, getDeclarationName(node));
}
@@ -21184,7 +21311,7 @@ var ts;
break;
case 189:
case 207:
- case 298:
+ case 300:
transformFlags |= 3;
excludeFlags = 536872257;
break;
@@ -21417,7 +21544,7 @@ var ts;
return 940049729;
case 189:
case 207:
- case 298:
+ case 300:
case 190:
case 97:
return 536872257;
@@ -21431,7 +21558,7 @@ var ts;
ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
function setParentPointers(parent, child) {
child.parent = parent;
- ts.forEachChild(child, function (childsChild) { return setParentPointers(child, childsChild); });
+ ts.forEachChild(child, function (grandchild) { return setParentPointers(child, grandchild); });
}
})(ts || (ts = {}));
var ts;
@@ -23742,6 +23869,11 @@ var ts;
location = location.parent;
}
break;
+ case 296:
+ case 291:
+ lastLocation = location;
+ location = ts.getJSDocHost(location).parent;
+ continue;
}
if (isSelfReferenceLocation(location)) {
lastSelfReferenceLocation = location;
@@ -23839,9 +23971,11 @@ var ts;
function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
- if (decl.kind === 147 && parent === container) {
- return true;
+ if (decl.kind === 147) {
+ var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
+ if (parent === container) {
+ return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
+ }
}
}
return false;
@@ -24236,7 +24370,7 @@ var ts;
var symbol;
if (name.kind === 71) {
var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0;
- var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSPrototype(name, meaning) : undefined;
+ var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSSpecialAssignment(name, meaning) : undefined;
symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true);
if (!symbol) {
return symbolFromJSPrototype;
@@ -24288,20 +24422,33 @@ var ts;
ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
}
- function resolveEntityNameFromJSPrototype(name, meaning) {
- if (isJSDocTypeReference(name.parent) && ts.isJSDocTag(name.parent.parent.parent)) {
- var host_1 = ts.getJSDocHost(name.parent.parent.parent);
- if (ts.isExpressionStatement(host_1) &&
- ts.isBinaryExpression(host_1.expression) &&
- ts.getSpecialPropertyAssignmentKind(host_1.expression) === 3) {
- var symbol = getSymbolOfNode(host_1.expression.left);
- if (symbol) {
- var secondaryLocation = symbol.parent.valueDeclaration;
- return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
- }
+ function resolveEntityNameFromJSSpecialAssignment(name, meaning) {
+ if (isJSDocTypeReference(name.parent)) {
+ var secondaryLocation = getJSSpecialAssignmentLocation(name.parent);
+ if (secondaryLocation) {
+ return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
}
}
}
+ function getJSSpecialAssignmentLocation(node) {
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152) ? "quit" : ts.isJSDocTypeAlias(node); });
+ if (typeAlias) {
+ return;
+ }
+ var host = ts.getJSDocHost(node);
+ if (host &&
+ ts.isExpressionStatement(host) &&
+ ts.isBinaryExpression(host.expression) &&
+ ts.getSpecialPropertyAssignmentKind(host.expression) === 3) {
+ var symbol = getSymbolOfNode(host.expression.left);
+ return symbol && symbol.parent.valueDeclaration;
+ }
+ var sig = ts.getHostSignatureFromJSDocHost(host);
+ if (sig) {
+ var symbol = getSymbolOfNode(sig);
+ return symbol && symbol.valueDeclaration;
+ }
+ }
function resolveExternalModuleName(location, moduleReferenceExpression) {
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0);
}
@@ -24785,6 +24932,13 @@ var ts;
}
return hasAccessibleDeclarations;
}
+ else {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol)) {
+ return {
+ accessibility: 0
+ };
+ }
+ }
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = getParentOfSymbol(symbol);
}
@@ -24994,7 +25148,7 @@ var ts;
flags: flags,
tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop },
encounteredError: false,
- symbolStack: undefined,
+ visitedSymbols: undefined,
inferTypeParameters: undefined
};
}
@@ -25100,9 +25254,10 @@ var ts;
return ts.createTypeReferenceNode(name, undefined);
}
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
- var name = symbolToTypeReferenceName(type.aliasSymbol);
var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
- return ts.createTypeReferenceNode(name, typeArgumentNodes);
+ if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32))
+ return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes);
+ return symbolToTypeNode(type.aliasSymbol, context, 67901928, typeArgumentNodes);
}
if (type.flags & (131072 | 262144)) {
var types = type.flags & 131072 ? formatUnionTypes(type.types) : type.types;
@@ -25164,7 +25319,10 @@ var ts;
}
function createAnonymousTypeNode(type) {
var symbol = type.symbol;
+ var id;
if (symbol) {
+ var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
+ id = (isConstructorObject ? "+" : "") + getSymbolId(symbol);
if (isJavaScriptConstructor(symbol.valueDeclaration)) {
var isInstanceType = type === getInferredClassType(symbol) ? 67901928 : 67216319;
return symbolToTypeNode(symbol, context, isInstanceType);
@@ -25174,7 +25332,7 @@ var ts;
shouldWriteTypeOfFunctionSymbol()) {
return symbolToTypeNode(symbol, context, 67216319);
}
- else if (ts.contains(context.symbolStack, symbol)) {
+ else if (context.visitedSymbols && context.visitedSymbols.has(id)) {
var typeAlias = getTypeAliasForTypeLiteral(type);
if (typeAlias) {
return symbolToTypeNode(typeAlias, context, 67901928);
@@ -25184,19 +25342,13 @@ var ts;
}
}
else {
- if (!context.symbolStack) {
- context.symbolStack = [];
- }
- var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
- if (isConstructorObject) {
- return createTypeNodeFromObjectType(type);
- }
- else {
- context.symbolStack.push(symbol);
- var result = createTypeNodeFromObjectType(type);
- context.symbolStack.pop();
- return result;
+ if (!context.visitedSymbols) {
+ context.visitedSymbols = ts.createMap();
}
+ context.visitedSymbols.set(id, true);
+ var result = createTypeNodeFromObjectType(type);
+ context.visitedSymbols.delete(id);
+ return result;
}
}
else {
@@ -25211,7 +25363,7 @@ var ts;
return declaration.parent.kind === 273 || declaration.parent.kind === 239;
}));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
- return (!!(context.flags & 4096) || ts.contains(context.symbolStack, symbol)) &&
+ return (!!(context.flags & 4096) || (context.visitedSymbols && context.visitedSymbols.has(id))) &&
(!(context.flags & 8) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
}
}
@@ -25243,10 +25395,6 @@ var ts;
var typeLiteralNode = ts.createTypeLiteralNode(members);
return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1);
}
- function symbolToTypeReferenceName(symbol) {
- var entityName = symbol.flags & 32 || !isReservedMemberName(symbol.escapedName) ? symbolToName(symbol, context, 67901928, false) : ts.createIdentifier("");
- return entityName;
- }
function typeReferenceToTypeNode(type) {
var typeArguments = type.typeArguments || ts.emptyArray;
if (type.target === globalArrayType) {
@@ -25279,7 +25427,7 @@ var ts;
else {
var outerTypeParameters = type.target.outerTypeParameters;
var i = 0;
- var qualifiedName = void 0;
+ var resultType = void 0;
if (outerTypeParameters) {
var length_1 = outerTypeParameters.length;
while (i < length_1) {
@@ -25290,55 +25438,61 @@ var ts;
} while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent);
if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
- var typeArgumentNodes_1 = typeArgumentSlice && ts.createNodeArray(typeArgumentSlice);
- var namePart = symbolToTypeReferenceName(parent);
- (namePart.kind === 71 ? namePart : namePart.right).typeArguments = typeArgumentNodes_1;
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, namePart);
- qualifiedName = ts.createQualifiedName(qualifiedName, undefined);
- }
- else {
- qualifiedName = ts.createQualifiedName(namePart, undefined);
- }
+ var flags_2 = context.flags;
+ context.flags |= 16;
+ var ref = symbolToTypeNode(parent, context, 67901928, typeArgumentSlice);
+ context.flags = flags_2;
+ resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
}
}
}
- var entityName = void 0;
- var nameIdentifier = symbolToTypeReferenceName(type.symbol);
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, nameIdentifier);
- entityName = qualifiedName;
- }
- else {
- entityName = nameIdentifier;
- }
var typeArgumentNodes = void 0;
if (typeArguments.length > 0) {
var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
}
- if (typeArgumentNodes) {
- var lastIdentifier = entityName.kind === 71 ? entityName : entityName.right;
- lastIdentifier.typeArguments = undefined;
- }
- return ts.createTypeReferenceNode(entityName, typeArgumentNodes);
+ var flags = context.flags;
+ context.flags |= 16;
+ var finalRef = symbolToTypeNode(type.symbol, context, 67901928, typeArgumentNodes);
+ context.flags = flags;
+ return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
}
}
- function addToQualifiedNameMissingRightIdentifier(left, right) {
- ts.Debug.assert(left.right === undefined);
- if (right.kind === 71) {
- left.right = right;
- return left;
+ function appendReferenceToType(root, ref) {
+ if (ts.isImportTypeNode(root)) {
+ var innerParams = root.typeArguments;
+ if (root.qualifier) {
+ (ts.isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams;
+ }
+ root.typeArguments = ref.typeArguments;
+ var ids = getAccessStack(ref);
+ for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
+ var id = ids_1[_i];
+ root.qualifier = root.qualifier ? ts.createQualifiedName(root.qualifier, id) : id;
+ }
+ return root;
}
- var rightPart = right;
- while (rightPart.left.kind !== 71) {
- rightPart = rightPart.left;
+ else {
+ var innerParams = root.typeArguments;
+ (ts.isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams;
+ root.typeArguments = ref.typeArguments;
+ var ids = getAccessStack(ref);
+ for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
+ var id = ids_2[_a];
+ root.typeName = ts.createQualifiedName(root.typeName, id);
+ }
+ return root;
}
- left.right = rightPart.left;
- rightPart.left = left;
- return right;
+ }
+ function getAccessStack(ref) {
+ var state = ref.typeName;
+ var ids = [];
+ while (!ts.isIdentifier(state)) {
+ ids.unshift(state.right);
+ state = state.left;
+ }
+ ids.unshift(state);
+ return ids;
}
function createTypeNodesFromResolvedType(resolvedType) {
var typeElements = [];
@@ -25501,7 +25655,9 @@ var ts;
}
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) {
var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148);
- ts.Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol));
+ if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) {
+ parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292);
+ }
var parameterType = getTypeOfSymbol(parameterSymbol);
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
parameterType = getOptionalType(parameterType);
@@ -25512,9 +25668,9 @@ var ts;
var dotDotDotToken = isRest ? ts.createToken(24) : undefined;
var name = parameterDeclaration
? parameterDeclaration.name ?
- parameterDeclaration.name.kind === 71 ?
- ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) :
- cloneBindingName(parameterDeclaration.name) :
+ parameterDeclaration.name.kind === 71 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) :
+ parameterDeclaration.name.kind === 145 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) :
+ cloneBindingName(parameterDeclaration.name) :
ts.symbolName(parameterSymbol)
: ts.symbolName(parameterSymbol);
var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55) : undefined;
@@ -25532,7 +25688,7 @@ var ts;
}
}
}
- function lookupSymbolChain(symbol, context, meaning) {
+ function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
var chain;
var isTypeParameter = symbol.flags & 262144;
@@ -25562,7 +25718,7 @@ var ts;
return accessibleSymbolChain;
}
if (endOfChain ||
- !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) &&
+ (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) &&
!(symbol.flags & (2048 | 4096))) {
return [symbol];
}
@@ -25599,17 +25755,21 @@ var ts;
}
return top;
}
- function symbolToTypeNode(symbol, context, meaning) {
- var chain = lookupSymbolChain(symbol, context, meaning);
+ function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
+ var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384));
context.flags |= 16777216;
var rootName = getNameOfSymbolAsWritten(chain[0], context);
context.flags ^= 16777216;
var isTypeOf = meaning === 67216319;
if (ambientModuleSymbolRegex.test(rootName)) {
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
- var typeParameterNodes = lookupTypeParameterNodes(chain, 0, context);
+ var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1)));
if (!nonRootParts || ts.isEntityName(nonRootParts)) {
+ if (nonRootParts) {
+ var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
+ lastId.typeArguments = undefined;
+ }
return ts.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
}
else {
@@ -25622,9 +25782,17 @@ var ts;
if (ts.isIndexedAccessTypeNode(entityName)) {
return entityName;
}
- return isTypeOf ? ts.createTypeQueryNode(entityName) : ts.createTypeReferenceNode(entityName, undefined);
+ if (isTypeOf) {
+ return ts.createTypeQueryNode(entityName);
+ }
+ else {
+ var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
+ var lastTypeArgs = lastId.typeArguments;
+ lastId.typeArguments = undefined;
+ return ts.createTypeReferenceNode(entityName, lastTypeArgs);
+ }
function createAccessFromSymbolChain(chain, index, stopper) {
- var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
+ var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
var symbol = chain[index];
if (index === 0) {
context.flags |= 16777216;
@@ -25634,7 +25802,7 @@ var ts;
context.flags ^= 16777216;
}
var parent = chain[index - 1];
- if (parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
+ if (!(context.flags & 16) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
if (ts.isIndexedAccessTypeNode(LHS)) {
return ts.createIndexedAccessTypeNode(LHS, ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
@@ -25791,6 +25959,23 @@ var ts;
return "default";
}
if (symbol.declarations && symbol.declarations.length) {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) {
+ var file = ts.getDeclarationOfKind(symbol, 273);
+ if (!file || !context.tracker.moduleResolverHost) {
+ if (context.tracker.trackReferencedAmbientModule) {
+ var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
+ if (ts.length(ambientDecls)) {
+ for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
+ var decl = ambientDecls_1[_i];
+ context.tracker.trackReferencedAmbientModule(decl);
+ }
+ }
+ }
+ }
+ else {
+ return "\"" + ts.getResolvedExternalModuleName(context.tracker.moduleResolverHost, file, ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration))) + "\"";
+ }
+ }
var declaration = symbol.declarations[0];
var name = ts.getNameOfDeclaration(declaration);
if (name) {
@@ -25832,7 +26017,8 @@ var ts;
return false;
function determineIfDeclarationIsVisible() {
switch (node.kind) {
- case 294:
+ case 291:
+ case 296:
return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
case 181:
return isDeclarationVisible(node.parent.parent);
@@ -26465,7 +26651,7 @@ var ts;
declaration.kind === 184 && declaration.parent.kind === 199) {
type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol);
}
- else if (ts.isJSDocPropertyTag(declaration)
+ else if (ts.isJSDocPropertyLikeTag(declaration)
|| ts.isPropertyAccessExpression(declaration)
|| ts.isIdentifier(declaration)
|| (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
@@ -26726,7 +26912,9 @@ var ts;
case 191:
case 192:
case 236:
- case 293:
+ case 295:
+ case 296:
+ case 291:
case 176:
case 170:
var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
@@ -26736,7 +26924,7 @@ var ts;
else if (node.kind === 170) {
return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
}
- var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray);
+ var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
var thisType = includeThisTypes &&
(node.kind === 234 || node.kind === 204 || node.kind === 235) &&
getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
@@ -26752,13 +26940,12 @@ var ts;
var result;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var node = _a[_i];
- if (node.kind === 235 || node.kind === 234 ||
- node.kind === 204 || node.kind === 236 || node.kind === 294) {
+ if (node.kind === 235 ||
+ node.kind === 234 ||
+ node.kind === 204 ||
+ ts.isTypeAlias(node)) {
var declaration = node;
- var typeParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- if (typeParameters) {
- result = appendTypeParameters(result, typeParameters);
- }
+ result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
}
}
return result;
@@ -26992,9 +27179,9 @@ var ts;
return unknownType;
}
var declaration = ts.find(symbol.declarations, function (d) {
- return d.kind === 294 || d.kind === 236;
+ return ts.isJSDocTypeAlias(d) || d.kind === 236;
});
- var typeNode = declaration.kind === 294 ? declaration.typeExpression : declaration.type;
+ var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType;
if (popTypeResolution()) {
var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
@@ -27181,7 +27368,7 @@ var ts;
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
return (node.kind === 154 || (returnType && isThislessType(returnType))) &&
node.parameters.every(isThislessVariableLikeDeclaration) &&
- (!typeParameters || typeParameters.every(isThislessTypeParameter));
+ typeParameters.every(isThislessTypeParameter);
}
function isThisless(symbol) {
if (symbol.declarations && symbol.declarations.length === 1) {
@@ -27288,9 +27475,9 @@ var ts;
var earlySymbol = earlySymbols && earlySymbols.get(memberName);
if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
- var name_3 = ts.declarationNameToString(decl.name);
- ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_3); });
- error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_3);
+ var name_2 = ts.declarationNameToString(decl.name);
+ ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_2); });
+ error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_2);
lateSymbol = createSymbol(0, memberName, 1024);
}
lateSymbol.nameType = type;
@@ -28219,9 +28406,10 @@ var ts;
}
function getTypeParametersFromDeclaration(declaration) {
var result;
- ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) {
+ for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
+ var node = _a[_i];
result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
- });
+ }
return result;
}
function symbolsToArray(symbols) {
@@ -28248,7 +28436,7 @@ var ts;
return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
}
function isOptionalParameter(node) {
- if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) {
+ if (ts.hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) {
return true;
}
if (node.initializer) {
@@ -28265,6 +28453,13 @@ var ts;
}
return false;
}
+ function isOptionalJSDocParameterTag(node) {
+ if (!ts.isJSDocParameterTag(node)) {
+ return false;
+ }
+ var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
+ return isBracketed || !!typeExpression && typeExpression.type.kind === 282;
+ }
function createTypePredicateFromTypePredicateNode(node) {
var parameterName = node.parameterName;
var type = getTypeFromTypeNode(node.type);
@@ -28334,6 +28529,7 @@ var ts;
for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
var param = declaration.parameters[i];
var paramSymbol = param.symbol;
+ var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) {
var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67216319, undefined, undefined, false);
paramSymbol = resolvedSymbol;
@@ -28345,11 +28541,12 @@ var ts;
else {
parameters.push(paramSymbol);
}
- if (param.type && param.type.kind === 177) {
+ if (type && type.kind === 177) {
hasLiteralTypes = true;
}
- var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken ||
- iife && parameters.length > iife.arguments.length && !param.type ||
+ var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) ||
+ param.initializer || param.questionToken || param.dotDotDotToken ||
+ iife && parameters.length > iife.arguments.length && !type ||
isUntypedSignatureInJSFile ||
isJSDocOptionalParameter(param);
if (!isOptionalParameter_1) {
@@ -28376,7 +28573,7 @@ var ts;
return links.resolvedSignature;
}
function maybeAddJsSyntheticRestParameter(declaration, parameters) {
- if (!containsArgumentsReference(declaration)) {
+ if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
return false;
}
var lastParam = ts.lastOrUndefined(declaration.parameters);
@@ -28735,7 +28932,7 @@ var ts;
var isJs = ts.isInJavaScriptFile(node);
var isJsImplicitAny = !noImplicitAny && isJs;
if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
- var missingAugmentsTag = isJs && node.parent.kind !== 288;
+ var missingAugmentsTag = isJs && node.parent.kind !== 289;
var diag = minTypeArgumentCount === typeParameters.length
? missingAugmentsTag
? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag
@@ -28867,7 +29064,7 @@ var ts;
}
function getConstrainedTypeVariable(typeVariable, node) {
var constraints;
- while (node && !ts.isStatement(node)) {
+ while (node && !ts.isStatement(node) && node.kind !== 285) {
var parent = node.parent;
if (parent.kind === 170 && node === parent.trueType) {
var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType);
@@ -29279,7 +29476,7 @@ var ts;
includes & 4096 ? includes & 16777216 ? undefinedType : undefinedWideningType :
neverType;
}
- return getUnionTypeFromSortedList(typeSet, aliasSymbol, aliasTypeArguments);
+ return getUnionTypeFromSortedList(typeSet, includes & 8374815 ? 0 : 268435456, aliasSymbol, aliasTypeArguments);
}
function getUnionTypePredicate(signatures) {
var first;
@@ -29313,7 +29510,7 @@ var ts;
? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex
: !ts.isIdentifierTypePredicate(b);
}
- function getUnionTypeFromSortedList(types, aliasSymbol, aliasTypeArguments) {
+ function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) {
if (types.length === 0) {
return neverType;
}
@@ -29324,7 +29521,7 @@ var ts;
var type = unionTypes.get(id);
if (!type) {
var propagatedFlags = getPropagatingFlagsOfTypes(types, 12288);
- type = createType(131072 | propagatedFlags);
+ type = createType(131072 | propagatedFlags | unionOfUnitTypes);
unionTypes.set(id, type);
type.types = types;
type.aliasSymbol = aliasSymbol;
@@ -29335,7 +29532,8 @@ var ts;
function getTypeFromUnionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -29382,6 +29580,28 @@ var ts;
}
}
}
+ function intersectUnionsOfUnitTypes(types) {
+ var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456) !== 0; });
+ var unionType = types[unionIndex];
+ var intersection = unionType.types;
+ var i = types.length - 1;
+ var _loop_5 = function () {
+ var t = types[i];
+ if (t.flags & 268435456) {
+ intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); });
+ ts.orderedRemoveItemAt(types, i);
+ }
+ i--;
+ };
+ while (i > unionIndex) {
+ _loop_5();
+ }
+ if (intersection === unionType.types) {
+ return false;
+ }
+ types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456);
+ return true;
+ }
function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
if (types.length === 0) {
return emptyObjectType;
@@ -29406,6 +29626,9 @@ var ts;
return typeSet[0];
}
if (includes & 131072) {
+ if (includes & 268435456 && intersectUnionsOfUnitTypes(typeSet)) {
+ return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072) !== 0; });
var unionType = typeSet[unionIndex_1];
return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments);
@@ -29425,7 +29648,8 @@ var ts;
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -29691,7 +29915,7 @@ var ts;
var type = createObjectType(32, node.symbol);
type.declaration = node;
type.aliasSymbol = getAliasSymbolForTypeNode(node);
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
links.resolvedType = type;
getConstraintTypeFromMappedType(type);
}
@@ -29773,7 +29997,8 @@ var ts;
var links = getNodeLinks(node);
if (!links.resolvedType) {
var checkType = getTypeFromTypeNode(node.checkType);
- var aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
var allOuterTypeParameters = getOuterTypeParameters(node, true);
var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isPossiblyReferencedInConditionalType(tp, node); });
var root = {
@@ -29786,7 +30011,7 @@ var ts;
inferTypeParameters: getInferTypeParameters(node),
outerTypeParameters: outerTypeParameters,
instantiations: undefined,
- aliasSymbol: getAliasSymbolForTypeNode(node),
+ aliasSymbol: aliasSymbol,
aliasTypeArguments: aliasTypeArguments
};
links.resolvedType = getConditionalType(root, undefined);
@@ -29883,7 +30108,7 @@ var ts;
else {
var type = createObjectType(16, node.symbol);
type.aliasSymbol = aliasSymbol;
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
type = createArrayType(type);
}
@@ -29893,10 +30118,9 @@ var ts;
return links.resolvedType;
}
function getAliasSymbolForTypeNode(node) {
- return (node.parent.kind === 236 || node.parent.kind === 294) ? getSymbolOfNode(node.parent) : undefined;
+ return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined;
}
- function getAliasTypeArgumentsForTypeNode(node) {
- var symbol = getAliasSymbolForTypeNode(node);
+ function getTypeArgumentsForAliasSymbol(symbol) {
return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
}
function getSpreadType(left, right, symbol, typeFlags, objectFlags) {
@@ -30121,6 +30345,7 @@ var ts;
case 165:
case 286:
case 283:
+ case 287:
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
case 174:
return getTypeFromTypeOperatorNode(node);
@@ -30285,6 +30510,15 @@ var ts;
var typeParameters = links.outerTypeParameters;
if (!typeParameters) {
var declaration_1 = symbol.declarations[0];
+ if (ts.isInJavaScriptFile(declaration_1)) {
+ var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag);
+ if (paramTag) {
+ var paramSymbol = ts.getParameterSymbolFromJSDoc(paramTag);
+ if (paramSymbol) {
+ declaration_1 = paramSymbol.valueDeclaration;
+ }
+ }
+ }
var outerTypeParameters = getOuterTypeParameters(declaration_1, true);
if (isJavaScriptConstructor(declaration_1)) {
var templateTagParameters = getTypeParametersFromDeclaration(declaration_1);
@@ -30320,8 +30554,8 @@ var ts;
}
function isTypeParameterPossiblyReferenced(tp, node) {
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
- var container_2 = tp.symbol.declarations[0].parent;
- if (ts.findAncestor(node, function (n) { return n.kind === 212 ? "quit" : n === container_2; })) {
+ var container_3 = tp.symbol.declarations[0].parent;
+ if (ts.findAncestor(node, function (n) { return n.kind === 212 ? "quit" : n === container_3; })) {
return ts.forEachChild(node, containsReference);
}
}
@@ -31049,7 +31283,7 @@ var ts;
if (discriminant) {
return hasExcessProperties(source, discriminant, undefined, reportErrors);
}
- var _loop_5 = function (prop) {
+ var _loop_6 = function (prop) {
if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
if (reportErrors) {
ts.Debug.assert(!!errorNode);
@@ -31080,7 +31314,7 @@ var ts;
};
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
- var state_3 = _loop_5(prop);
+ var state_3 = _loop_6(prop);
if (typeof state_3 === "object")
return state_3.value;
}
@@ -33323,7 +33557,7 @@ var ts;
if (type.flags & 131072) {
var types = type.types;
var filtered = ts.filter(types, f);
- return filtered === types ? type : getUnionTypeFromSortedList(filtered);
+ return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456);
}
return f(type) ? type : neverType;
}
@@ -34925,10 +35159,11 @@ var ts;
links.resolvedSignatures = ts.createMap();
}
var cacheKey = "" + getTypeId(valueType);
- if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) !== resolvingSignaturesArray) {
- signatures = links.resolvedSignatures.get(cacheKey);
+ var cachedResolved = links.resolvedSignatures.get(cacheKey);
+ if (cachedResolved && cachedResolved !== resolvingSignaturesArray) {
+ signatures = cachedResolved;
}
- else if (!links.resolvedSignatures.get(cacheKey)) {
+ else if (!cachedResolved) {
links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray);
links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures));
}
@@ -35880,7 +36115,7 @@ var ts;
else if (!isSourceAttributeTypeAssignableToTarget) {
if (ts.length(openingLikeElement.attributes.properties)) {
var reportedError = false;
- var _loop_6 = function (prop) {
+ var _loop_7 = function (prop) {
if (ts.isJsxSpreadAttribute(prop))
return "continue";
var name = ts.idText(prop.name);
@@ -35893,7 +36128,7 @@ var ts;
};
for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) {
var prop = _c[_b];
- _loop_6(prop);
+ _loop_7(prop);
}
if (reportedError) {
return;
@@ -39671,7 +39906,8 @@ var ts;
switch (d.kind) {
case 235:
case 236:
- case 294:
+ case 296:
+ case 291:
return 2;
case 238:
return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0
@@ -40000,7 +40236,7 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function checkJSDocTypedefTag(node) {
+ function checkJSDocTypeAliasTag(node) {
if (!node.typeExpression) {
error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
}
@@ -40202,7 +40438,7 @@ var ts;
}
function checkUnusedTypeParameters(node, addDiagnostic) {
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (!(node.flags & 4194304) && typeParameters && ts.last(getSymbolOfNode(node).declarations) === node) {
+ if (!(node.flags & 4194304) && ts.last(getSymbolOfNode(node).declarations) === node) {
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
var typeParameter = typeParameters_2[_i];
if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) {
@@ -41211,7 +41447,7 @@ var ts;
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
var declaration = declarations_6[_i];
var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- var numTypeParameters = ts.length(sourceParameters);
+ var numTypeParameters = sourceParameters.length;
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
return false;
}
@@ -41346,7 +41582,7 @@ var ts;
}
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
var issuedMemberError = false;
- var _loop_7 = function (member) {
+ var _loop_8 = function (member) {
if (ts.hasStaticModifier(member)) {
return "continue";
}
@@ -41364,7 +41600,7 @@ var ts;
};
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- _loop_7(member);
+ _loop_8(member);
}
if (!issuedMemberError) {
checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
@@ -42218,11 +42454,12 @@ var ts;
return checkInferType(node);
case 178:
return checkImportType(node);
- case 288:
+ case 289:
return checkJSDocAugmentsTag(node);
- case 294:
- return checkJSDocTypedefTag(node);
- case 290:
+ case 296:
+ case 291:
+ return checkJSDocTypeAliasTag(node);
+ case 292:
return checkJSDocParameterTag(node);
case 283:
checkSignatureDeclaration(node);
@@ -42346,9 +42583,9 @@ var ts;
var parent = node.parent;
var paramTag = parent.parent;
if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) {
- var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
- if (host_2) {
- var lastParamDeclaration = ts.lastOrUndefined(host_2.parameters);
+ var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
+ if (host_1) {
+ var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
if (!lastParamDeclaration ||
symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
@@ -42688,10 +42925,10 @@ var ts;
return entityNameSymbol;
}
}
- if (entityName.parent.kind === 290) {
+ if (entityName.parent.kind === 292) {
return ts.getParameterSymbolFromJSDoc(entityName.parent);
}
- if (entityName.parent.kind === 147 && entityName.parent.parent.kind === 293) {
+ if (entityName.parent.kind === 147 && entityName.parent.parent.kind === 295) {
ts.Debug.assert(!ts.isInJavaScriptFile(entityName));
var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent);
return typeParameter && typeParameter.symbol;
@@ -43129,6 +43366,7 @@ var ts;
function isRequiredInitializedParameter(parameter) {
return strictNullChecks &&
!isOptionalParameter(parameter) &&
+ !ts.isJSDocParameterTag(parameter) &&
parameter.initializer &&
!ts.hasModifier(parameter, 92);
}
@@ -43905,7 +44143,7 @@ var ts;
}
function checkGrammarClassLikeDeclaration(node) {
var file = ts.getSourceFileOfNode(node);
- return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(ts.getEffectiveTypeParameterDeclarations(node), file);
+ return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
}
function checkGrammarArrowFunction(node, file) {
if (!ts.isArrowFunction(node)) {
@@ -44542,8 +44780,8 @@ var ts;
}
function checkGrammarConstructorTypeParameters(node) {
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (typeParameters) {
- var _a = ts.isNodeArray(typeParameters) ? typeParameters : ts.first(typeParameters), pos = _a.pos, end = _a.end;
+ if (ts.isNodeArray(typeParameters)) {
+ var pos = typeParameters.pos, end = typeParameters.end;
return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
}
}
@@ -44957,7 +45195,7 @@ var ts;
ts.updateQualifiedName = updateQualifiedName;
function parenthesizeForComputedName(expression) {
return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26) ||
- expression.kind === 299 ?
+ expression.kind === 301 ?
createParen(expression) :
expression;
}
@@ -46909,28 +47147,28 @@ var ts;
}
ts.getMutableClone = getMutableClone;
function createNotEmittedStatement(original) {
- var node = createSynthesizedNode(297);
+ var node = createSynthesizedNode(299);
node.original = original;
setTextRange(node, original);
return node;
}
ts.createNotEmittedStatement = createNotEmittedStatement;
function createEndOfDeclarationMarker(original) {
- var node = createSynthesizedNode(301);
+ var node = createSynthesizedNode(303);
node.emitNode = {};
node.original = original;
return node;
}
ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker;
function createMergeDeclarationMarker(original) {
- var node = createSynthesizedNode(300);
+ var node = createSynthesizedNode(302);
node.emitNode = {};
node.original = original;
return node;
}
ts.createMergeDeclarationMarker = createMergeDeclarationMarker;
function createPartiallyEmittedExpression(expression, original) {
- var node = createSynthesizedNode(298);
+ var node = createSynthesizedNode(300);
node.expression = expression;
node.original = original;
setTextRange(node, original);
@@ -46946,7 +47184,7 @@ var ts;
ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression;
function flattenCommaElements(node) {
if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
- if (node.kind === 299) {
+ if (node.kind === 301) {
return node.elements;
}
if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) {
@@ -46956,7 +47194,7 @@ var ts;
return node;
}
function createCommaList(elements) {
- var node = createSynthesizedNode(299);
+ var node = createSynthesizedNode(301);
node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
return node;
}
@@ -47923,7 +48161,7 @@ var ts;
function parenthesizeSubexpressionOfConditionalExpression(e) {
var emittedExpression = ts.skipPartiallyEmittedExpressions(e);
return emittedExpression.kind === 199 && emittedExpression.operatorToken.kind === 26 ||
- emittedExpression.kind === 299
+ emittedExpression.kind === 301
? ts.createParen(e)
: e;
}
@@ -47932,7 +48170,7 @@ var ts;
var check = ts.skipPartiallyEmittedExpressions(e);
return (check.kind === 204 ||
check.kind === 191 ||
- check.kind === 299 ||
+ check.kind === 301 ||
ts.isBinaryExpression(check) && check.operatorToken.kind === 26)
? ts.createParen(e)
: e;
@@ -48078,7 +48316,7 @@ var ts;
case 184:
node = node.expression;
continue;
- case 298:
+ case 300:
node = node.expression;
continue;
}
@@ -48108,7 +48346,7 @@ var ts;
case 207:
case 208:
return (kinds & 2) !== 0;
- case 298:
+ case 300:
return (kinds & 4) !== 0;
}
return false;
@@ -48145,7 +48383,7 @@ var ts;
case 189: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression);
case 207: return ts.updateAsExpression(outerExpression, expression, outerExpression.type);
case 208: return ts.updateNonNullExpression(outerExpression, expression);
- case 298: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
+ case 300: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
}
}
function isIgnorableParen(node) {
@@ -48770,9 +49008,9 @@ var ts;
return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
case 273:
return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context));
- case 298:
+ case 300:
return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression));
- case 299:
+ case 301:
return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression));
default:
return node;
@@ -48810,7 +49048,7 @@ var ts;
case 214:
case 205:
case 230:
- case 297:
+ case 299:
break;
case 145:
result = reduceNode(node.left, cbNode, result);
@@ -49173,10 +49411,10 @@ var ts;
case 273:
result = reduceNodes(node.statements, cbNodes, result);
break;
- case 298:
+ case 300:
result = reduceNode(node.expression, cbNode, result);
break;
- case 299:
+ case 301:
result = reduceNodes(node.elements, cbNodes, result);
break;
default:
@@ -57019,9 +57257,9 @@ var ts;
return visitFunctionDeclaration(node);
case 234:
return visitClassDeclaration(node);
- case 300:
+ case 302:
return visitMergeDeclarationMarker(node);
- case 301:
+ case 303:
return visitEndOfDeclarationMarker(node);
default:
return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
@@ -58225,9 +58463,9 @@ var ts;
return visitCatchClause(node);
case 212:
return visitBlock(node);
- case 300:
+ case 302:
return visitMergeDeclarationMarker(node);
- case 301:
+ case 303:
return visitEndOfDeclarationMarker(node);
default:
return destructuringAndImportCallVisitor(node);
@@ -59033,19 +59271,22 @@ var ts;
var lateMarkedStatements;
var lateStatementReplacementMap;
var suppressNewDiagnosticContexts;
+ var host = context.getEmitHost();
var symbolTracker = {
trackSymbol: trackSymbol,
reportInaccessibleThisError: reportInaccessibleThisError,
reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
- reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression
+ reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
+ moduleResolverHost: host,
+ trackReferencedAmbientModule: trackReferencedAmbientModule,
};
var errorNameNode;
var currentSourceFile;
+ var refs;
var resolver = context.getEmitResolver();
var options = context.getCompilerOptions();
var newLine = ts.getNewLineCharacter(options);
var noResolve = options.noResolve, stripInternal = options.stripInternal;
- var host = context.getEmitHost();
return transformRoot;
function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
if (!typeReferenceDirectives) {
@@ -59057,6 +59298,10 @@ var ts;
necessaryTypeRefernces.set(ref, true);
}
}
+ function trackReferencedAmbientModule(node) {
+ var container = ts.getSourceFileOfNode(node);
+ refs.set("" + ts.getOriginalNodeId(container), container);
+ }
function handleSymbolAccessibilityError(symbolAccessibilityResult) {
if (symbolAccessibilityResult.accessibility === 0) {
if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -59160,13 +59405,13 @@ var ts;
lateMarkedStatements = undefined;
lateStatementReplacementMap = ts.createMap();
necessaryTypeRefernces = undefined;
- var refs = collectReferences(currentSourceFile, ts.createMap());
+ refs = collectReferences(currentSourceFile, ts.createMap());
var references = [];
var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
- refs.forEach(referenceVisitor);
var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
+ refs.forEach(referenceVisitor);
var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([]), undefined)])), combinedStatements);
@@ -59177,17 +59422,19 @@ var ts;
return necessaryTypeRefernces ? ts.mapDefined(ts.arrayFrom(necessaryTypeRefernces.keys()), getFileReferenceForTypeName) : [];
}
function getFileReferenceForTypeName(typeName) {
- for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
- var importStatement = emittedImports_1[_i];
- if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
- var expr = importStatement.moduleReference.expression;
- if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ if (emittedImports) {
+ for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
+ var importStatement = emittedImports_1[_i];
+ if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
+ var expr = importStatement.moduleReference.expression;
+ if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ return undefined;
+ }
+ }
+ else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
return undefined;
}
}
- else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
- return undefined;
- }
}
return { fileName: typeName, pos: -1, end: -1 };
}
@@ -59874,7 +60121,7 @@ var ts;
var prop = ts.createProperty(undefined, maskModifiers(node, undefined, (!accessors.setAccessor) ? 64 : 0), node.name, node.questionToken, ensureType(node, accessorType), undefined);
var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile);
if (leadingsSyntheticCommentRanges) {
- var _loop_8 = function (range) {
+ var _loop_9 = function (range) {
if (range.kind === 3) {
var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2);
var lines = text.split(/\r\n?|\n/g);
@@ -59888,7 +60135,7 @@ var ts;
};
for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) {
var range = leadingsSyntheticCommentRanges_1[_i];
- _loop_8(range);
+ _loop_9(range);
}
}
return prop;
@@ -60036,7 +60283,7 @@ var ts;
}
ts.getTransformers = getTransformers;
function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) {
- var enabledSyntaxKindFeatures = new Array(302);
+ var enabledSyntaxKindFeatures = new Array(304);
var lexicalEnvironmentVariableDeclarations;
var lexicalEnvironmentFunctionDeclarations;
var lexicalEnvironmentVariableDeclarationsStack = [];
@@ -60413,7 +60660,7 @@ var ts;
source = undefined;
if (source)
setSourceFile(source);
- if (node.kind !== 297
+ if (node.kind !== 299
&& (emitFlags & 16) === 0
&& pos >= 0) {
emitPos(skipSourceTrivia(pos));
@@ -60430,7 +60677,7 @@ var ts;
}
if (source)
setSourceFile(source);
- if (node.kind !== 297
+ if (node.kind !== 299
&& (emitFlags & 32) === 0
&& end >= 0) {
emitPos(end);
@@ -60572,7 +60819,7 @@ var ts;
if (extendedDiagnostics) {
ts.performance.mark("preEmitNodeWithComment");
}
- var isEmittedNode = node.kind !== 297;
+ var isEmittedNode = node.kind !== 299;
var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 10;
var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 10;
if (!skipLeadingComments) {
@@ -61624,9 +61871,9 @@ var ts;
return emitJsxSelfClosingElement(node);
case 258:
return emitJsxFragment(node);
- case 298:
+ case 300:
return emitPartiallyEmittedExpression(node);
- case 299:
+ case 301:
return emitCommaList(node);
}
}
@@ -65845,14 +66092,14 @@ var ts;
if (options.composite && rootNames.length < files.length) {
var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); });
var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); });
- var _loop_9 = function (file) {
+ var _loop_10 = function (file) {
if (normalizedRootNames.every(function (r) { return r !== file; })) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file));
}
};
for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
var file = sourceFiles_4[_i];
- _loop_9(file);
+ _loop_10(file);
}
}
if (options.paths) {
@@ -69019,7 +69266,7 @@ var ts;
function serializeCompilerOptions(options) {
var result = ts.createMap();
var optionsNameMap = getOptionNameMap().optionNameMap;
- var _loop_10 = function (name) {
+ var _loop_11 = function (name) {
if (ts.hasProperty(options, name)) {
if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
return "continue";
@@ -69043,7 +69290,7 @@ var ts;
}
};
for (var name in options) {
- _loop_10(name);
+ _loop_11(name);
}
return result;
}
@@ -69961,7 +70208,7 @@ var ts;
case 236:
case 165:
return 2;
- case 294:
+ case 296:
return node.name === undefined ? 1 | 2 : 2;
case 272:
case 234:
@@ -70164,7 +70411,7 @@ var ts;
}
ts.isExpressionOfExternalModuleImportEqualsDeclaration = isExpressionOfExternalModuleImportEqualsDeclaration;
function getContainerNode(node) {
- if (node.kind === 294) {
+ if (ts.isJSDocTypeAlias(node)) {
node = node.parent.parent;
}
while (true) {
@@ -70199,7 +70446,10 @@ var ts;
case 204:
return "class";
case 235: return "interface";
- case 236: return "type";
+ case 236:
+ case 291:
+ case 296:
+ return "type";
case 237: return "enum";
case 231:
return getKindOfVariableDeclaration(node);
@@ -70230,8 +70480,6 @@ var ts;
case 251:
case 245:
return "alias";
- case 294:
- return "type";
case 199:
var kind = ts.getSpecialPropertyAssignmentKind(node);
var right = node.right;
@@ -70289,6 +70537,10 @@ var ts;
return startEndContainsRange(r1.pos, r1.end, r2);
}
ts.rangeContainsRange = rangeContainsRange;
+ function rangeContainsPosition(r, pos) {
+ return r.pos <= pos && pos <= r.end;
+ }
+ ts.rangeContainsPosition = rangeContainsPosition;
function startEndContainsRange(start, end, range) {
return start <= range.pos && end >= range.end;
}
@@ -70955,6 +71207,25 @@ var ts;
return propSymbol;
}
ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement;
+ var NodeSet = (function () {
+ function NodeSet() {
+ this.map = ts.createMap();
+ }
+ NodeSet.prototype.add = function (node) {
+ this.map.set(String(ts.getNodeId(node)), node);
+ };
+ NodeSet.prototype.has = function (node) {
+ return this.map.has(String(ts.getNodeId(node)));
+ };
+ NodeSet.prototype.forEach = function (cb) {
+ this.map.forEach(cb);
+ };
+ NodeSet.prototype.some = function (pred) {
+ return ts.forEachEntry(this.map, pred) || false;
+ };
+ return NodeSet;
+ }());
+ ts.NodeSet = NodeSet;
})(ts || (ts = {}));
(function (ts) {
function isFirstDeclarationOfSymbolParameter(symbol) {
@@ -71793,20 +72064,22 @@ var ts;
pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18);
pos = tag.tagName.end;
switch (tag.kind) {
- case 290:
+ case 292:
processJSDocParameterTag(tag);
break;
- case 293:
+ case 295:
processJSDocTemplateTag(tag);
+ pos = tag.end;
break;
- case 292:
+ case 294:
processElement(tag.typeExpression);
+ pos = tag.end;
break;
- case 291:
+ case 293:
processElement(tag.typeExpression);
+ pos = tag.end;
break;
}
- pos = tag.end;
}
}
if (pos !== docComment.end) {
@@ -72124,14 +72397,14 @@ var ts;
for (var path in paths) {
var patterns = paths[path];
if (paths.hasOwnProperty(path) && patterns) {
- var _loop_11 = function (name, kind) {
+ var _loop_12 = function (name, kind) {
if (!result.some(function (entry) { return entry.name === name; })) {
result.push(nameAndKind(name, kind));
}
};
for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host); _i < _a.length; _i++) {
var _b = _a[_i], name = _b.name, kind = _b.kind;
- _loop_11(name, kind);
+ _loop_12(name, kind);
}
}
}
@@ -72145,7 +72418,7 @@ var ts;
if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs) {
var foundGlobal = false;
if (fragmentDirectory === undefined) {
- var _loop_12 = function (moduleName) {
+ var _loop_13 = function (moduleName) {
if (!result.some(function (entry) { return entry.name === moduleName; })) {
foundGlobal = true;
result.push(nameAndKind(moduleName, "external module name"));
@@ -72153,7 +72426,7 @@ var ts;
};
for (var _e = 0, _f = enumerateNodeModulesVisibleToScript(host, scriptPath); _e < _f.length; _e++) {
var moduleName = _f[_e];
- _loop_12(moduleName);
+ _loop_13(moduleName);
}
}
if (!foundGlobal) {
@@ -72918,7 +73191,7 @@ var ts;
currentToken = ts.getTokenAtPosition(sourceFile, position, true);
if (!currentToken ||
(!ts.isDeclarationName(currentToken) &&
- (currentToken.parent.kind !== 295 ||
+ (currentToken.parent.kind !== 297 ||
currentToken.parent.name !== currentToken))) {
insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression);
}
@@ -73056,11 +73329,11 @@ var ts;
return { kind: 0, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer };
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
- case 290:
- case 295:
- case 291:
case 292:
+ case 297:
+ case 293:
case 294:
+ case 296:
return true;
}
}
@@ -73887,7 +74160,7 @@ var ts;
}
function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) {
switch (location.kind) {
- case 296:
+ case 298:
return ts.tryCast(location.parent, ts.isObjectTypeDeclaration);
case 1:
var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration);
@@ -75010,8 +75283,8 @@ var ts;
case "symbol": {
var symbol = def.symbol;
var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind;
- var name_4 = displayParts_1.map(function (p) { return p.text; }).join("");
- return { node: symbol.declarations ? ts.getNameOfDeclaration(ts.first(symbol.declarations)) || ts.first(symbol.declarations) : originalNode, name: name_4, kind: kind_1, displayParts: displayParts_1 };
+ var name_3 = displayParts_1.map(function (p) { return p.text; }).join("");
+ return { node: symbol.declarations ? ts.getNameOfDeclaration(ts.first(symbol.declarations)) || ts.first(symbol.declarations) : originalNode, name: name_3, kind: kind_1, displayParts: displayParts_1 };
}
case "label": {
var node_3 = def.node;
@@ -75019,8 +75292,8 @@ var ts;
}
case "keyword": {
var node_4 = def.node;
- var name_5 = ts.tokenToString(node_4.kind);
- return { node: node_4, name: name_5, kind: "keyword", displayParts: [{ text: name_5, kind: "keyword" }] };
+ var name_4 = ts.tokenToString(node_4.kind);
+ return { node: node_4, name: name_4, kind: "keyword", displayParts: [{ text: name_4, kind: "keyword" }] };
}
case "this": {
var node_5 = def.node;
@@ -76262,6 +76535,7 @@ var ts;
"author",
"argument",
"borrows",
+ "callback",
"class",
"constant",
"constructor",
@@ -76320,10 +76594,12 @@ var ts;
JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations;
function getCommentHavingNodes(declaration) {
switch (declaration.kind) {
- case 295:
+ case 292:
+ case 297:
return [declaration];
- case 294:
- return [declaration.parent];
+ case 291:
+ case 296:
+ return [declaration, declaration.parent];
default:
return ts.getJSDocCommentsAndTags(declaration);
}
@@ -76342,15 +76618,16 @@ var ts;
function getCommentText(tag) {
var comment = tag.comment;
switch (tag.kind) {
- case 288:
+ case 289:
return withNode(tag.class);
- case 293:
- return withList(tag.typeParameters);
- case 292:
- return withNode(tag.typeExpression);
- case 294:
case 295:
- case 290:
+ return withList(tag.typeParameters);
+ case 294:
+ return withNode(tag.typeExpression);
+ case 296:
+ case 291:
+ case 297:
+ case 292:
var name = tag.name;
return name ? withNode(name) : comment;
default:
@@ -76864,7 +77141,7 @@ var ts;
if (!patternMatcher)
return ts.emptyArray;
var rawItems = [];
- var _loop_13 = function (sourceFile) {
+ var _loop_14 = function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) {
return "continue";
@@ -76875,7 +77152,7 @@ var ts;
};
for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) {
var sourceFile = sourceFiles_7[_i];
- _loop_13(sourceFile);
+ _loop_14(sourceFile);
}
rawItems.sort(compareNavigateToItems);
if (maxResultCount !== undefined) {
@@ -77202,7 +77479,7 @@ var ts;
if (ts.hasJSDocNodes(node)) {
ts.forEach(node.jsDoc, function (jsDoc) {
ts.forEach(jsDoc.tags, function (tag) {
- if (tag.kind === 294) {
+ if (ts.isJSDocTypeAlias(tag)) {
addLeafNode(tag);
}
});
@@ -77303,8 +77580,6 @@ var ts;
case 192:
case 204:
return getFunctionOrClassName(node);
- case 294:
- return getJSDocTypedefTagName(node);
default:
return undefined;
}
@@ -77343,29 +77618,10 @@ var ts;
return "()";
case 159:
return "[]";
- case 294:
- return getJSDocTypedefTagName(node);
default:
return "";
}
}
- function getJSDocTypedefTagName(node) {
- if (node.name) {
- return node.name.text;
- }
- else {
- var parentNode = node.parent && node.parent.parent;
- if (parentNode && parentNode.kind === 213) {
- if (parentNode.declarationList.declarations.length > 0) {
- var nameIdentifier = parentNode.declarationList.declarations[0].name;
- if (nameIdentifier.kind === 71) {
- return nameIdentifier.text;
- }
- }
- }
- return "";
- }
- }
function topLevelItems(root) {
var topLevel = [];
function recur(item) {
@@ -77390,7 +77646,8 @@ var ts;
case 238:
case 273:
case 236:
- case 294:
+ case 296:
+ case 291:
return true;
case 154:
case 153:
@@ -78146,13 +78403,13 @@ var ts;
}
function indexOfIgnoringCase(str, value) {
var n = str.length - value.length;
- var _loop_14 = function (start) {
+ var _loop_15 = function (start) {
if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
return { value: start };
}
};
for (var start = 0; start <= n; start++) {
- var state_4 = _loop_14(start);
+ var state_4 = _loop_15(start);
if (typeof state_4 === "object")
return state_4.value;
}
@@ -78725,7 +78982,7 @@ var ts;
var nameToDeclarations = sourceFile.getNamedDeclarations();
var declarations = nameToDeclarations.get(name.text);
if (declarations) {
- var _loop_15 = function (declaration) {
+ var _loop_16 = function (declaration) {
var symbol = declaration.symbol;
if (symbol) {
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
@@ -78739,7 +78996,7 @@ var ts;
};
for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) {
var declaration = declarations_12[_b];
- var state_5 = _loop_15(declaration);
+ var state_5 = _loop_16(declaration);
if (typeof state_5 === "object")
return state_5.value;
}
@@ -79045,7 +79302,7 @@ var ts;
}
}
}
- return diags.concat(checker.getSuggestionDiagnostics(sourceFile));
+ return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort(function (d1, d2) { return d1.start - d2.start; });
}
ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics;
function containsTopLevelCommonjs(sourceFile) {
@@ -79731,7 +79988,7 @@ var ts;
return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; });
});
options = ts.cloneCompilerOptions(options);
- var _loop_16 = function (opt) {
+ var _loop_17 = function (opt) {
if (!ts.hasProperty(options, opt.name)) {
return "continue";
}
@@ -79747,7 +80004,7 @@ var ts;
};
for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
var opt = commandLineOptionsStringToEnum_1[_i];
- _loop_16(opt);
+ _loop_17(opt);
}
return options;
}
@@ -82079,7 +82336,7 @@ var ts;
this.formatContext = formatContext;
this.changes = [];
this.newFiles = [];
- this.deletedNodesInLists = [];
+ this.deletedNodesInLists = new ts.NodeSet();
this.classesWithNodesInsertedAtStart = ts.createMap();
}
ChangeTracker.fromContext = function (context) {
@@ -82122,32 +82379,12 @@ var ts;
this.deleteNode(sourceFile, node);
return this;
}
- var id = ts.getNodeId(node);
- ts.Debug.assert(!this.deletedNodesInLists[id], "Deleting a node twice");
- this.deletedNodesInLists[id] = true;
- if (index !== containingList.length - 1) {
- var nextToken = ts.getTokenAtPosition(sourceFile, node.end, false);
- if (nextToken && isSeparator(node, nextToken)) {
- var startPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), false, true);
- var nextElement = containingList[index + 1];
- var endPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), false, true);
- this.deleteRange(sourceFile, { pos: startPosition, end: endPosition });
- }
- }
- else {
- var prev = containingList[index - 1];
- if (this.deletedNodesInLists[ts.getNodeId(prev)]) {
- var pos = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), false, true);
- var end = getAdjustedEndPosition(sourceFile, node, {});
- this.deleteRange(sourceFile, { pos: pos, end: end });
- }
- else {
- var previousToken = ts.getTokenAtPosition(sourceFile, containingList[index - 1].end, false);
- if (previousToken && isSeparator(node, previousToken)) {
- this.deleteNodeRange(sourceFile, previousToken, node);
- }
- }
- }
+ ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice");
+ this.deletedNodesInLists.add(node);
+ this.deleteRange(sourceFile, {
+ pos: startPositionToDeleteNodeInList(sourceFile, node),
+ end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]),
+ });
return this;
};
ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) {
@@ -82441,8 +82678,22 @@ var ts;
}
});
};
+ ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () {
+ var _this = this;
+ this.deletedNodesInLists.forEach(function (node) {
+ var sourceFile = node.getSourceFile();
+ var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile);
+ if (node !== ts.last(list))
+ return;
+ var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2);
+ if (lastNonDeletedIndex !== -1) {
+ _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) });
+ }
+ });
+ };
ChangeTracker.prototype.getChanges = function (validate) {
this.finishClassesWithNodesInsertedAtStart();
+ this.finishTrailingCommaAfterDeletingNodesInList();
var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate);
for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) {
var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements;
@@ -82456,6 +82707,9 @@ var ts;
return ChangeTracker;
}());
textChanges_3.ChangeTracker = ChangeTracker;
+ function startPositionToDeleteNodeInList(sourceFile, node) {
+ return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), false, true);
+ }
function getClassBraceEnds(cls, sourceFile) {
return [ts.findChildOfKind(cls, 17, sourceFile).end, ts.findChildOfKind(cls, 18, sourceFile).end];
}
@@ -82465,13 +82719,13 @@ var ts;
return ts.group(changes, function (c) { return c.sourceFile.path; }).map(function (changesInFile) {
var sourceFile = changesInFile[0].sourceFile;
var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
- var _loop_17 = function (i) {
+ var _loop_18 = function (i) {
ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
});
};
for (var i = 0; i < normalized.length - 1; i++) {
- _loop_17(i);
+ _loop_18(i);
}
var textChanges = normalized.map(function (c) {
return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate));
@@ -82888,7 +83142,7 @@ var ts;
if (ts.isFunctionLikeDeclaration(decl) && (ts.getJSDocReturnType(decl) || decl.parameters.some(function (p) { return !!ts.getJSDocType(p); }))) {
if (!decl.typeParameters) {
var typeParameters = ts.getJSDocTypeParameterDeclarations(decl);
- if (typeParameters)
+ if (typeParameters.length)
changes.insertTypeParameters(sourceFile, decl, typeParameters);
}
var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 19, sourceFile);
@@ -84545,13 +84799,13 @@ var ts;
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); });
return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)];
}
- var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start); });
+ var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start, undefined); });
if (delDestructure.length) {
return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)];
}
var token = getToken(sourceFile, ts.textSpanEnd(context.span));
var result = [];
- var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token); });
+ var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, undefined); });
if (deletion.length) {
result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations));
}
@@ -84562,48 +84816,57 @@ var ts;
return result;
},
fixIds: [fixIdPrefix, fixIdDelete],
- getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
- var sourceFile = context.sourceFile;
- var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file);
- switch (context.fixId) {
- case fixIdPrefix:
- if (ts.isIdentifier(token) && canPrefix(token)) {
- tryPrefixDeclaration(changes, diag.code, sourceFile, token);
- }
- break;
- case fixIdDelete:
- var importDecl = tryGetFullImport(diag.file, diag.start);
- if (importDecl) {
- changes.deleteNode(sourceFile, importDecl);
- }
- else {
- if (!tryDeleteFullDestructure(changes, sourceFile, diag.start)) {
- tryDeleteDeclaration(changes, sourceFile, token);
+ getAllCodeActions: function (context) {
+ var deleted = new NodeSet();
+ return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ var sourceFile = context.sourceFile;
+ var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file);
+ switch (context.fixId) {
+ case fixIdPrefix:
+ if (ts.isIdentifier(token) && canPrefix(token)) {
+ tryPrefixDeclaration(changes, diag.code, sourceFile, token);
}
- }
- break;
- default:
- ts.Debug.fail(JSON.stringify(context.fixId));
- }
- }); },
+ break;
+ case fixIdDelete:
+ if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); }))
+ break;
+ var importDecl = tryGetFullImport(diag.file, diag.start);
+ if (importDecl) {
+ changes.deleteNode(sourceFile, importDecl);
+ }
+ else {
+ if (!tryDeleteFullDestructure(changes, sourceFile, diag.start, deleted)) {
+ tryDeleteDeclaration(changes, sourceFile, token, deleted);
+ }
+ }
+ break;
+ default:
+ ts.Debug.fail(JSON.stringify(context.fixId));
+ }
+ });
+ },
});
function tryGetFullImport(sourceFile, pos) {
var startToken = ts.getTokenAtPosition(sourceFile, pos, false);
return startToken.kind === 91 ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined;
}
- function tryDeleteFullDestructure(changes, sourceFile, pos) {
+ function tryDeleteFullDestructure(changes, sourceFile, pos, deletedAncestors) {
var startToken = ts.getTokenAtPosition(sourceFile, pos, false);
if (startToken.kind !== 17 || !ts.isObjectBindingPattern(startToken.parent))
return false;
var decl = startToken.parent.parent;
switch (decl.kind) {
case 231:
- tryDeleteVariableDeclaration(changes, sourceFile, decl);
+ tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors);
break;
case 148:
+ if (deletedAncestors)
+ deletedAncestors.add(decl);
changes.deleteNodeInList(sourceFile, decl);
break;
case 181:
+ if (deletedAncestors)
+ deletedAncestors.add(decl);
changes.deleteNode(sourceFile, decl);
break;
default:
@@ -84612,7 +84875,7 @@ var ts;
return true;
}
function getToken(sourceFile, pos) {
- var token = ts.findPrecedingToken(pos, sourceFile);
+ var token = ts.findPrecedingToken(pos, sourceFile, undefined, true);
return token.kind === 22 ? ts.findPrecedingToken(pos - 1, sourceFile) : token;
}
function tryPrefixDeclaration(changes, errorCode, sourceFile, token) {
@@ -84635,38 +84898,45 @@ var ts;
}
return false;
}
- function tryDeleteDeclaration(changes, sourceFile, token) {
+ function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors) {
switch (token.kind) {
case 71:
- tryDeleteIdentifier(changes, sourceFile, token);
+ tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors);
break;
case 151:
case 245:
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent);
changes.deleteNode(sourceFile, token.parent);
break;
default:
- tryDeleteDefault(changes, sourceFile, token);
+ tryDeleteDefault(changes, sourceFile, token, deletedAncestors);
}
}
- function tryDeleteDefault(changes, sourceFile, token) {
+ function tryDeleteDefault(changes, sourceFile, token, deletedAncestors) {
if (ts.isDeclarationName(token)) {
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent);
changes.deleteNode(sourceFile, token.parent);
}
else if (ts.isLiteralComputedPropertyDeclarationName(token)) {
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent.parent);
changes.deleteNode(sourceFile, token.parent.parent);
}
}
- function tryDeleteIdentifier(changes, sourceFile, identifier) {
+ function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors) {
var parent = identifier.parent;
switch (parent.kind) {
case 231:
- tryDeleteVariableDeclaration(changes, sourceFile, parent);
+ tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors);
break;
case 147:
- var typeParameters = parent.parent.typeParameters;
+ var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent);
if (typeParameters.length === 1) {
- var previousToken = ts.getTokenAtPosition(sourceFile, typeParameters.pos - 1, false);
- var nextToken = ts.getTokenAtPosition(sourceFile, typeParameters.end, false);
+ var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end;
+ var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, false);
+ var nextToken = ts.getTokenAtPosition(sourceFile, end, false);
ts.Debug.assert(previousToken.kind === 27);
ts.Debug.assert(nextToken.kind === 29);
changes.deleteNodeRange(sourceFile, previousToken, nextToken);
@@ -84737,7 +85007,7 @@ var ts;
tryDeleteNamedImportBinding(changes, sourceFile, parent);
break;
default:
- tryDeleteDefault(changes, sourceFile, identifier);
+ tryDeleteDefault(changes, sourceFile, identifier, deletedAncestors);
break;
}
}
@@ -84753,15 +85023,19 @@ var ts;
changes.deleteNode(sourceFile, importDecl);
}
}
- function tryDeleteVariableDeclaration(changes, sourceFile, varDecl) {
+ function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) {
switch (varDecl.parent.parent.kind) {
case 219: {
var forStatement = varDecl.parent.parent;
var forInitializer = forStatement.initializer;
if (forInitializer.declarations.length === 1) {
+ if (deletedAncestors)
+ deletedAncestors.add(forInitializer);
changes.deleteNode(sourceFile, forInitializer);
}
else {
+ if (deletedAncestors)
+ deletedAncestors.add(varDecl);
changes.deleteNodeInList(sourceFile, varDecl);
}
break;
@@ -84770,6 +85044,8 @@ var ts;
var forOfStatement = varDecl.parent.parent;
ts.Debug.assert(forOfStatement.initializer.kind === 232);
var forOfInitializer = forOfStatement.initializer;
+ if (deletedAncestors)
+ deletedAncestors.add(forOfInitializer.declarations[0]);
changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral());
break;
case 220:
@@ -84778,13 +85054,29 @@ var ts;
default:
var variableStatement = varDecl.parent.parent;
if (variableStatement.declarationList.declarations.length === 1) {
+ if (deletedAncestors)
+ deletedAncestors.add(variableStatement);
changes.deleteNode(sourceFile, variableStatement);
}
else {
+ if (deletedAncestors)
+ deletedAncestors.add(varDecl);
changes.deleteNodeInList(sourceFile, varDecl);
}
}
}
+ var NodeSet = (function () {
+ function NodeSet() {
+ this.map = ts.createMap();
+ }
+ NodeSet.prototype.add = function (node) {
+ this.map.set(String(ts.getNodeId(node)), node);
+ };
+ NodeSet.prototype.some = function (pred) {
+ return ts.forEachEntry(this.map, pred) || false;
+ };
+ return NodeSet;
+ }());
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
var ts;
@@ -84852,21 +85144,7 @@ var ts;
return arr.slice(index);
}
function split(arr, pred, cb) {
- var start;
- for (var i = 0; i < arr.length; i++) {
- var value = arr[i];
- if (pred(value)) {
- start = start || value;
- }
- else {
- if (start) {
- cb(start, arr[i - 1]);
- start = undefined;
- }
- }
- }
- if (start)
- cb(start, arr[arr.length - 1]);
+ ts.getRangesWhere(arr, pred, function (start, afterEnd) { return cb(arr[start], arr[afterEnd - 1]); });
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -86206,6 +86484,38 @@ var ts;
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
+ var fixId = fixIdAddMissingTypeof;
+ var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, span = context.span;
+ var importType = getImportTypeNode(sourceFile, span.start);
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, importType); });
+ return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_missing_typeof, fixId, ts.Diagnostics.Add_missing_typeof)];
+ },
+ fixIds: [fixId],
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ return doChange(changes, context.sourceFile, getImportTypeNode(diag.file, diag.start));
+ }); },
+ });
+ function getImportTypeNode(sourceFile, pos) {
+ var token = ts.getTokenAtPosition(sourceFile, pos, false);
+ ts.Debug.assert(token.kind === 91);
+ ts.Debug.assert(token.parent.kind === 178);
+ return token.parent;
+ }
+ function doChange(changes, sourceFile, importType) {
+ var newTypeNode = ts.updateImportTypeNode(importType, importType.argument, importType.qualifier, importType.typeArguments, true);
+ changes.replaceNode(sourceFile, importType, newTypeNode);
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+var ts;
(function (ts) {
var refactor;
(function (refactor) {
@@ -87208,8 +87518,8 @@ var ts;
});
i_1++;
}
- if (ts.isDeclarationWithTypeParameters(curr) && curr.typeParameters) {
- for (var _a = 0, _b = curr.typeParameters; _a < _b.length; _a++) {
+ if (ts.isDeclarationWithTypeParameters(curr)) {
+ for (var _a = 0, _b = ts.getEffectiveTypeParameterDeclarations(curr); _a < _b.length; _a++) {
var typeParameterDecl = _b[_a];
var typeParameter = checker.getTypeAtLocation(typeParameterDecl);
if (allTypeParameterUsages.has(typeParameter.id.toString())) {
@@ -87226,7 +87536,7 @@ var ts;
: ts.getEnclosingBlockScopeContainer(scopes[0]);
ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
}
- var _loop_18 = function (i) {
+ var _loop_19 = function (i) {
var scopeUsages = usagesPerScope[i];
if (i > 0 && (scopeUsages.usages.size > 0 || scopeUsages.typeParameterUsages.size > 0)) {
var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range;
@@ -87262,21 +87572,11 @@ var ts;
}
};
for (var i = 0; i < scopes.length; i++) {
- _loop_18(i);
+ _loop_19(i);
}
return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
- function hasTypeParameters(node) {
- return ts.isDeclarationWithTypeParameters(node) &&
- node.typeParameters !== undefined &&
- node.typeParameters.length > 0;
- }
function isInGenericContext(node) {
- for (; node; node = node.parent) {
- if (hasTypeParameters(node)) {
- return true;
- }
- }
- return false;
+ return !!ts.findAncestor(node, function (n) { return ts.isDeclarationWithTypeParameters(n) && ts.getEffectiveTypeParameterDeclarations(n).length !== 0; });
}
function recordTypeParameterUsages(type) {
var symbolWalker = checker.getSymbolWalker(function () { return (cancellationToken.throwIfCancellationRequested(), true); });
@@ -87503,8 +87803,8 @@ var ts;
var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message;
refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions });
function getAvailableActions(context) {
- var file = context.file, startPosition = context.startPosition;
- if (!getConvertibleFieldAtPosition(file, startPosition))
+ var file = context.file;
+ if (!getConvertibleFieldAtPosition(context, file))
return undefined;
return [{
name: actionName,
@@ -87518,8 +87818,8 @@ var ts;
}];
}
function getEditsForAction(context, _actionName) {
- var file = context.file, startPosition = context.startPosition;
- var fieldInfo = getConvertibleFieldAtPosition(file, startPosition);
+ var file = context.file;
+ var fieldInfo = getConvertibleFieldAtPosition(context, file);
if (!fieldInfo)
return undefined;
var isJS = ts.isSourceFileJavaScript(file);
@@ -87578,11 +87878,13 @@ var ts;
function startsWithUnderscore(name) {
return name.charCodeAt(0) === 95;
}
- function getConvertibleFieldAtPosition(file, startPosition) {
+ function getConvertibleFieldAtPosition(context, file) {
+ var startPosition = context.startPosition, endPosition = context.endPosition;
var node = ts.getTokenAtPosition(file, startPosition, false);
var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration);
var meaning = 28 | 32 | 64;
- if (!declaration || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning)
+ if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition)
+ || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning)
return undefined;
var name = declaration.name.text;
var startWithUnderscore = startsWithUnderscore(name);
@@ -87662,7 +87964,7 @@ var ts;
var refactorName = "Move to a new file";
refactor.registerRefactor(refactorName, {
getAvailableActions: function (context) {
- if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined)
+ if (!context.preferences.allowTextChangesInNewFiles || getFirstAndLastStatementToMove(context) === undefined)
return undefined;
var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file);
return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }];
@@ -87674,7 +87976,7 @@ var ts;
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
}
});
- function getStatementsToMove(context) {
+ function getFirstAndLastStatementToMove(context) {
var file = context.file;
var range = ts.createTextRangeFromSpan(ts.getRefactorContextSpan(context));
var statements = file.statements;
@@ -87686,11 +87988,11 @@ var ts;
var afterEndNodeIndex = ts.findIndex(statements, function (s) { return s.end > range.end; }, startNodeIndex);
if (afterEndNodeIndex !== -1 && (afterEndNodeIndex === 0 || statements[afterEndNodeIndex].getStart(file) < range.end))
return undefined;
- return statements.slice(startNodeIndex, afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex);
+ return { first: startNodeIndex, afterLast: afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex };
}
function doChange(oldFile, program, toMove, changes, host) {
var checker = program.getTypeChecker();
- var usage = getUsageInfo(oldFile, toMove, checker);
+ var usage = getUsageInfo(oldFile, toMove.all, checker);
var currentDirectory = ts.getDirectoryPath(oldFile.fileName);
var extension = ts.extensionFromPath(oldFile.fileName);
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host);
@@ -87698,6 +88000,31 @@ var ts;
changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatements(oldFile, usage, changes, toMove, program, newModuleName));
addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host));
}
+ function getStatementsToMove(context) {
+ var statements = context.file.statements;
+ var _a = getFirstAndLastStatementToMove(context), first = _a.first, afterLast = _a.afterLast;
+ var all = [];
+ var ranges = [];
+ var rangeToMove = statements.slice(first, afterLast);
+ ts.getRangesWhere(rangeToMove, function (s) { return !isPureImport(s); }, function (start, afterEnd) {
+ for (var i = start; i < afterEnd; i++)
+ all.push(rangeToMove[i]);
+ ranges.push({ first: rangeToMove[start], last: rangeToMove[afterEnd - 1] });
+ });
+ return { all: all, ranges: ranges };
+ }
+ function isPureImport(node) {
+ switch (node.kind) {
+ case 243:
+ return true;
+ case 242:
+ return !ts.hasModifier(node, 1);
+ case 213:
+ return node.declarationList.declarations.every(function (d) { return ts.isRequireCall(d.initializer, true); });
+ default:
+ return false;
+ }
+ }
function addNewFileToTsconfig(program, changes, oldFileName, newFileNameWithExtension, getCanonicalFileName) {
var cfg = program.getCompilerOptions().configFile;
if (!cfg)
@@ -87715,18 +88042,24 @@ var ts;
function getNewStatements(oldFile, usage, changes, toMove, program, newModuleName) {
var checker = program.getTypeChecker();
if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
- changes.deleteNodeRange(oldFile, ts.first(toMove), ts.last(toMove));
- return toMove;
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
+ return toMove.all;
}
var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator;
var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax);
if (importsFromNewFile) {
changes.insertNodeBefore(oldFile, oldFile.statements[0], importsFromNewFile, true);
}
- deleteUnusedOldImports(oldFile, toMove, changes, usage.unusedImportsFromOldFile, checker);
- changes.deleteNodeRange(oldFile, ts.first(toMove), ts.last(toMove));
+ deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
- return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax));
+ return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax));
+ }
+ function deleteMovedStatements(sourceFile, moved, changes) {
+ for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) {
+ var _a = moved_1[_i], first_1 = _a.first, last_3 = _a.last;
+ changes.deleteNodeRange(sourceFile, first_1, last_3);
+ }
}
function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) {
for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) {
@@ -87738,10 +88071,10 @@ var ts;
}
function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
var checker = program.getTypeChecker();
- var _loop_19 = function (sourceFile) {
+ var _loop_20 = function (sourceFile) {
if (sourceFile === oldFile)
return "continue";
- var _loop_20 = function (statement) {
+ var _loop_21 = function (statement) {
forEachImportInStatement(statement, function (importNode) {
var shouldMove = function (name) {
var symbol = ts.isBindingElement(name.parent)
@@ -87758,12 +88091,12 @@ var ts;
};
for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
var statement = _a[_i];
- _loop_20(statement);
+ _loop_21(statement);
}
};
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
- _loop_19(sourceFile);
+ _loop_20(sourceFile);
}
}
function moduleSpecifierFromImport(i) {
@@ -88008,12 +88341,14 @@ var ts;
}
function isVariableDeclarationInImport(decl) {
return ts.isSourceFile(decl.parent.parent.parent) &&
- ts.isRequireCall(decl.initializer, true);
+ decl.initializer && ts.isRequireCall(decl.initializer, true);
}
function filterImport(i, moduleSpecifier, keep) {
switch (i.kind) {
case 243: {
var clause = i.importClause;
+ if (!clause)
+ return undefined;
var defaultImport = clause.name && keep(clause.name) ? clause.name : undefined;
var namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep);
return defaultImport || namedBindings
@@ -88499,7 +88834,7 @@ var ts;
if (!children.length) {
return undefined;
}
- var child = ts.find(children, function (kid) { return kid.kind < 277 || kid.kind > 295; });
+ var child = ts.find(children, function (kid) { return kid.kind < 277 || kid.kind > 297; });
return child.kind < 145 ?
child :
child.getFirstToken(sourceFile);
@@ -88564,7 +88899,7 @@ var ts;
}
}
function createSyntaxList(nodes, parent) {
- var list = createNode(296, nodes.pos, nodes.end, parent);
+ var list = createNode(298, nodes.pos, nodes.end, parent);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) {
@@ -92921,7 +93256,7 @@ var ts;
}
var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations);
if (this.projectService.globalPlugins) {
- var _loop_21 = function (globalPluginName) {
+ var _loop_22 = function (globalPluginName) {
if (!globalPluginName)
return "continue";
if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; }))
@@ -92932,7 +93267,7 @@ var ts;
var this_1 = this;
for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
var globalPluginName = _a[_i];
- _loop_21(globalPluginName);
+ _loop_22(globalPluginName);
}
}
};
@@ -93719,7 +94054,7 @@ var ts;
}
project.updateGraph();
if (!this.useSingleInferredProject && !project.projectRootPath) {
- var _loop_22 = function (inferredProject) {
+ var _loop_23 = function (inferredProject) {
if (inferredProject === project || inferredProject.isOrphan()) {
return "continue";
}
@@ -93731,7 +94066,7 @@ var ts;
};
for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) {
var inferredProject = _a[_i];
- _loop_22(inferredProject);
+ _loop_23(inferredProject);
}
}
return project;
@@ -94314,7 +94649,7 @@ var ts;
return projects;
function combineProjects(toAddInfo) {
if (toAddInfo !== info) {
- var _loop_23 = function (project) {
+ var _loop_24 = function (project) {
if (project.languageServiceEnabled &&
!project.isOrphan() &&
!project.getCompilerOptions().preserveSymlinks &&
@@ -94330,7 +94665,7 @@ var ts;
};
for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) {
var project = _a[_i];
- _loop_23(project);
+ _loop_24(project);
}
}
}
@@ -94575,13 +94910,13 @@ var ts;
this.printProjects();
};
ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) {
- var _loop_24 = function (proj) {
+ var _loop_25 = function (proj) {
var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; });
result.push(proj.getChangesSinceVersion(knownProject && knownProject.version));
};
for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) {
var proj = currentProjects_1[_i];
- _loop_24(proj);
+ _loop_25(proj);
}
};
ProjectService.prototype.synchronizeProjectList = function (knownProjects) {
@@ -94681,7 +95016,7 @@ var ts;
var excludeRules = [];
var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); });
var excludedFiles = [];
- var _loop_25 = function (name) {
+ var _loop_26 = function (name) {
var rule = this_2.safelist[name];
for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) {
var root = normalizedNames_1[_i];
@@ -94696,7 +95031,7 @@ var ts;
}
}
if (rule.exclude) {
- var _loop_27 = function (exclude) {
+ var _loop_28 = function (exclude) {
var processedRule = root.replace(rule.match, function () {
var groups = [];
for (var _i = 0; _i < arguments.length; _i++) {
@@ -94719,7 +95054,7 @@ var ts;
};
for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) {
var exclude = _d[_c];
- _loop_27(exclude);
+ _loop_28(exclude);
}
}
else {
@@ -94734,11 +95069,11 @@ var ts;
var this_2 = this;
for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) {
var name = _a[_i];
- _loop_25(name);
+ _loop_26(name);
}
var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); });
var filesToKeep = [];
- var _loop_26 = function (i) {
+ var _loop_27 = function (i) {
if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) {
excludedFiles.push(normalizedNames[i]);
}
@@ -94772,7 +95107,7 @@ var ts;
};
var this_3 = this;
for (var i = 0; i < proj.rootFiles.length; i++) {
- _loop_26(i);
+ _loop_27(i);
}
proj.rootFiles = filesToKeep;
return excludedFiles;
diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts
index 67bd6cbe980..ae163fb4f8d 100644
--- a/lib/tsserverlibrary.d.ts
+++ b/lib/tsserverlibrary.d.ts
@@ -349,22 +349,24 @@ declare namespace ts {
JSDocVariadicType = 284,
JSDocComment = 285,
JSDocTypeLiteral = 286,
- JSDocTag = 287,
- JSDocAugmentsTag = 288,
- JSDocClassTag = 289,
- JSDocParameterTag = 290,
- JSDocReturnTag = 291,
- JSDocTypeTag = 292,
- JSDocTemplateTag = 293,
- JSDocTypedefTag = 294,
- JSDocPropertyTag = 295,
- SyntaxList = 296,
- NotEmittedStatement = 297,
- PartiallyEmittedExpression = 298,
- CommaListExpression = 299,
- MergeDeclarationMarker = 300,
- EndOfDeclarationMarker = 301,
- Count = 302,
+ JSDocSignature = 287,
+ JSDocTag = 288,
+ JSDocAugmentsTag = 289,
+ JSDocClassTag = 290,
+ JSDocCallbackTag = 291,
+ JSDocParameterTag = 292,
+ JSDocReturnTag = 293,
+ JSDocTypeTag = 294,
+ JSDocTemplateTag = 295,
+ JSDocTypedefTag = 296,
+ JSDocPropertyTag = 297,
+ SyntaxList = 298,
+ NotEmittedStatement = 299,
+ PartiallyEmittedExpression = 300,
+ CommaListExpression = 301,
+ MergeDeclarationMarker = 302,
+ EndOfDeclarationMarker = 303,
+ Count = 304,
FirstAssignment = 58,
LastAssignment = 70,
FirstCompoundAssignment = 59,
@@ -391,9 +393,9 @@ declare namespace ts {
LastBinaryOperator = 70,
FirstNode = 145,
FirstJSDocNode = 277,
- LastJSDocNode = 295,
- FirstJSDocTagNode = 287,
- LastJSDocTagNode = 295
+ LastJSDocNode = 297,
+ FirstJSDocTagNode = 288,
+ LastJSDocTagNode = 297
}
enum NodeFlags {
None = 0,
@@ -1280,7 +1282,7 @@ declare namespace ts {
block: Block;
}
type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode;
- type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag;
+ type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature;
interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer {
kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression;
name?: Identifier;
@@ -1537,6 +1539,19 @@ declare namespace ts {
name?: Identifier;
typeExpression?: JSDocTypeExpression | JSDocTypeLiteral;
}
+ interface JSDocCallbackTag extends JSDocTag, NamedDeclaration {
+ parent: JSDoc;
+ kind: SyntaxKind.JSDocCallbackTag;
+ fullName?: JSDocNamespaceDeclaration | Identifier;
+ name?: Identifier;
+ typeExpression: JSDocSignature;
+ }
+ interface JSDocSignature extends JSDocType, Declaration {
+ kind: SyntaxKind.JSDocSignature;
+ typeParameters?: ReadonlyArray;
+ parameters: ReadonlyArray;
+ type: JSDocReturnTag | undefined;
+ }
interface JSDocPropertyLikeTag extends JSDocTag, Declaration {
parent: JSDoc;
name: EntityName;
@@ -1885,6 +1900,7 @@ declare namespace ts {
WriteArrayAsGenericType = 2,
GenerateNamesForShadowedTypeParams = 4,
UseStructuralFallback = 8,
+ ForbidIndexedAccessSymbolReferences = 16,
WriteTypeArgumentsOfSignature = 32,
UseFullyQualifiedType = 64,
UseOnlyExternalAliasing = 128,
@@ -2283,7 +2299,7 @@ declare namespace ts {
Construct = 1
}
interface Signature {
- declaration?: SignatureDeclaration;
+ declaration?: SignatureDeclaration | JSDocSignature;
typeParameters?: TypeParameter[];
parameters: Symbol[];
}
@@ -3362,6 +3378,8 @@ declare namespace ts {
function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag;
function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag;
function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral;
+ function isJSDocCallbackTag(node: Node): node is JSDocCallbackTag;
+ function isJSDocSignature(node: Node): node is JSDocSignature;
}
declare namespace ts {
/**
diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js
index a3b09d06f3b..f3ed8bef9be 100644
--- a/lib/tsserverlibrary.js
+++ b/lib/tsserverlibrary.js
@@ -365,25 +365,27 @@ var ts;
SyntaxKind[SyntaxKind["JSDocVariadicType"] = 284] = "JSDocVariadicType";
SyntaxKind[SyntaxKind["JSDocComment"] = 285] = "JSDocComment";
SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral";
- SyntaxKind[SyntaxKind["JSDocTag"] = 287] = "JSDocTag";
- SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 288] = "JSDocAugmentsTag";
- SyntaxKind[SyntaxKind["JSDocClassTag"] = 289] = "JSDocClassTag";
- SyntaxKind[SyntaxKind["JSDocParameterTag"] = 290] = "JSDocParameterTag";
- SyntaxKind[SyntaxKind["JSDocReturnTag"] = 291] = "JSDocReturnTag";
- SyntaxKind[SyntaxKind["JSDocTypeTag"] = 292] = "JSDocTypeTag";
- SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 293] = "JSDocTemplateTag";
- SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 294] = "JSDocTypedefTag";
- SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 295] = "JSDocPropertyTag";
+ SyntaxKind[SyntaxKind["JSDocSignature"] = 287] = "JSDocSignature";
+ SyntaxKind[SyntaxKind["JSDocTag"] = 288] = "JSDocTag";
+ SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 289] = "JSDocAugmentsTag";
+ SyntaxKind[SyntaxKind["JSDocClassTag"] = 290] = "JSDocClassTag";
+ SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 291] = "JSDocCallbackTag";
+ SyntaxKind[SyntaxKind["JSDocParameterTag"] = 292] = "JSDocParameterTag";
+ SyntaxKind[SyntaxKind["JSDocReturnTag"] = 293] = "JSDocReturnTag";
+ SyntaxKind[SyntaxKind["JSDocTypeTag"] = 294] = "JSDocTypeTag";
+ SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 295] = "JSDocTemplateTag";
+ SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 296] = "JSDocTypedefTag";
+ SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 297] = "JSDocPropertyTag";
// Synthesized list
- SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList";
+ SyntaxKind[SyntaxKind["SyntaxList"] = 298] = "SyntaxList";
// Transformation nodes
- SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement";
- SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression";
- SyntaxKind[SyntaxKind["CommaListExpression"] = 299] = "CommaListExpression";
- SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 300] = "MergeDeclarationMarker";
- SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 301] = "EndOfDeclarationMarker";
+ SyntaxKind[SyntaxKind["NotEmittedStatement"] = 299] = "NotEmittedStatement";
+ SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 300] = "PartiallyEmittedExpression";
+ SyntaxKind[SyntaxKind["CommaListExpression"] = 301] = "CommaListExpression";
+ SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 302] = "MergeDeclarationMarker";
+ SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 303] = "EndOfDeclarationMarker";
// Enum value count
- SyntaxKind[SyntaxKind["Count"] = 302] = "Count";
+ SyntaxKind[SyntaxKind["Count"] = 304] = "Count";
// Markers
SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment";
SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment";
@@ -411,9 +413,9 @@ var ts;
SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator";
SyntaxKind[SyntaxKind["FirstNode"] = 145] = "FirstNode";
SyntaxKind[SyntaxKind["FirstJSDocNode"] = 277] = "FirstJSDocNode";
- SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode";
- SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 287] = "FirstJSDocTagNode";
- SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode";
+ SyntaxKind[SyntaxKind["LastJSDocNode"] = 297] = "LastJSDocNode";
+ SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 288] = "FirstJSDocTagNode";
+ SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 297] = "LastJSDocTagNode";
/* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword";
/* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 144] = "LastContextualKeyword";
})(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
@@ -595,7 +597,7 @@ var ts;
NodeBuilderFlags[NodeBuilderFlags["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType";
NodeBuilderFlags[NodeBuilderFlags["GenerateNamesForShadowedTypeParams"] = 4] = "GenerateNamesForShadowedTypeParams";
NodeBuilderFlags[NodeBuilderFlags["UseStructuralFallback"] = 8] = "UseStructuralFallback";
- // empty space
+ NodeBuilderFlags[NodeBuilderFlags["ForbidIndexedAccessSymbolReferences"] = 16] = "ForbidIndexedAccessSymbolReferences";
NodeBuilderFlags[NodeBuilderFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature";
NodeBuilderFlags[NodeBuilderFlags["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType";
NodeBuilderFlags[NodeBuilderFlags["UseOnlyExternalAliasing"] = 128] = "UseOnlyExternalAliasing";
@@ -887,6 +889,8 @@ var ts;
TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 67108864] = "ContainsAnyFunctionType";
TypeFlags[TypeFlags["NonPrimitive"] = 134217728] = "NonPrimitive";
/* @internal */
+ TypeFlags[TypeFlags["UnionOfUnitTypes"] = 268435456] = "UnionOfUnitTypes";
+ /* @internal */
TypeFlags[TypeFlags["GenericMappedType"] = 536870912] = "GenericMappedType";
/* @internal */
TypeFlags[TypeFlags["Nullable"] = 12288] = "Nullable";
@@ -922,6 +926,8 @@ var ts;
TypeFlags[TypeFlags["Narrowable"] = 142575359] = "Narrowable";
TypeFlags[TypeFlags["NotUnionOrUnit"] = 134283777] = "NotUnionOrUnit";
/* @internal */
+ TypeFlags[TypeFlags["NotUnit"] = 8374815] = "NotUnit";
+ /* @internal */
TypeFlags[TypeFlags["RequiresWidening"] = 50331648] = "RequiresWidening";
/* @internal */
TypeFlags[TypeFlags["PropagatingFlags"] = 117440512] = "PropagatingFlags";
@@ -1911,6 +1917,15 @@ var ts;
return -1;
}
ts.findIndex = findIndex;
+ function findLastIndex(array, predicate, startIndex) {
+ for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
+ if (predicate(array[i], i)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+ ts.findLastIndex = findLastIndex;
/**
* Returns the first truthy result of `callback`, or else fails.
* This is like `forEach`, but never returns undefined.
@@ -2263,6 +2278,24 @@ var ts;
return false;
}
ts.some = some;
+ /** Calls the callback with (start, afterEnd) index pairs for each range where 'pred' is true. */
+ function getRangesWhere(arr, pred, cb) {
+ var start;
+ for (var i = 0; i < arr.length; i++) {
+ if (pred(arr[i])) {
+ start = start === undefined ? i : start;
+ }
+ else {
+ if (start !== undefined) {
+ cb(start, i);
+ start = undefined;
+ }
+ }
+ }
+ if (start !== undefined)
+ cb(start, arr.length);
+ }
+ ts.getRangesWhere = getRangesWhere;
function concatenate(array1, array2) {
if (!some(array2))
return array1;
@@ -6743,6 +6776,7 @@ var ts;
Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
+ Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing typeof"),
};
})(ts || (ts = {}));
var ts;
@@ -8493,11 +8527,10 @@ var ts;
}
}
function scanJSDocToken() {
+ startPos = tokenPos = pos;
if (pos >= end) {
return token = 1 /* EndOfFileToken */;
}
- startPos = pos;
- tokenPos = pos;
var ch = text.charCodeAt(pos);
pos++;
switch (ch) {
@@ -8903,7 +8936,7 @@ var ts;
// the syntax list itself considers them as normal trivia. Therefore if we simply skip
// trivia for the list, we may have skipped the JSDocComment as well. So we should process its
// first child to determine the actual position of its first token.
- if (node.kind === 296 /* SyntaxList */ && node._children.length > 0) {
+ if (node.kind === 298 /* SyntaxList */ && node._children.length > 0) {
return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
}
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
@@ -9110,7 +9143,7 @@ var ts;
case 204 /* ClassExpression */:
case 235 /* InterfaceDeclaration */:
case 236 /* TypeAliasDeclaration */:
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
case 233 /* FunctionDeclaration */:
case 153 /* MethodDeclaration */:
case 154 /* Constructor */:
@@ -9118,6 +9151,9 @@ var ts;
case 156 /* SetAccessor */:
case 191 /* FunctionExpression */:
case 192 /* ArrowFunction */:
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 287 /* JSDocSignature */:
return true;
default:
ts.assertTypeIsNever(node);
@@ -9159,13 +9195,7 @@ var ts;
// Gets the nearest enclosing block scope container that has the provided node
// as a descendant, that is not the provided node.
function getEnclosingBlockScopeContainer(node) {
- var current = node.parent;
- while (current) {
- if (isBlockScope(current, current.parent)) {
- return current;
- }
- current = current.parent;
- }
+ return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
}
ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
// Return display name of an identifier
@@ -10354,6 +10384,14 @@ var ts;
node.parameters[0].name.escapedText === "new";
}
ts.isJSDocConstructSignature = isJSDocConstructSignature;
+ function isJSDocTypeAlias(node) {
+ return node.kind === 296 /* JSDocTypedefTag */ || node.kind === 291 /* JSDocCallbackTag */;
+ }
+ ts.isJSDocTypeAlias = isJSDocTypeAlias;
+ function isTypeAlias(node) {
+ return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
+ }
+ ts.isTypeAlias = isTypeAlias;
function getSourceOfAssignment(node) {
return ts.isExpressionStatement(node) &&
node.expression && ts.isBinaryExpression(node.expression) &&
@@ -10375,6 +10413,8 @@ var ts;
return v && v.initializer;
case 151 /* PropertyDeclaration */:
return node.initializer;
+ case 269 /* PropertyAssignment */:
+ return node.initializer;
}
}
function getSingleVariableOfVariableStatement(node) {
@@ -10405,8 +10445,7 @@ var ts;
// * @returns {number}
// */
// var x = function(name) { return name.length; }
- if (parent.parent &&
- (getSingleVariableOfVariableStatement(parent.parent) === node)) {
+ if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) {
getJSDocCommentsAndTagsWorker(parent.parent);
}
if (parent.parent && parent.parent.parent &&
@@ -10451,7 +10490,10 @@ var ts;
}
ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
function getHostSignatureFromJSDoc(node) {
- var host = getJSDocHost(node);
+ return getHostSignatureFromJSDocHost(getJSDocHost(node));
+ }
+ ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ function getHostSignatureFromJSDocHost(host) {
var decl = getSourceOfDefaultedAssignment(host) ||
getSourceOfAssignment(host) ||
getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
@@ -10460,19 +10502,12 @@ var ts;
host;
return decl && ts.isFunctionLike(decl) ? decl : undefined;
}
- ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ ts.getHostSignatureFromJSDocHost = getHostSignatureFromJSDocHost;
function getJSDocHost(node) {
- while (node.parent.kind === 286 /* JSDocTypeLiteral */) {
- if (node.parent.parent.kind === 294 /* JSDocTypedefTag */) {
- node = node.parent.parent;
- }
- else {
- // node.parent.parent is a type expression, child of a parameter type
- node = node.parent.parent.parent;
- }
+ var comment = ts.findAncestor(node.parent, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : node.kind === 285 /* JSDocComment */; });
+ if (comment) {
+ return comment.parent;
}
- ts.Debug.assert(node.parent.kind === 285 /* JSDocComment */);
- return node.parent.parent;
}
ts.getJSDocHost = getJSDocHost;
function getTypeParameterFromJsDoc(node) {
@@ -10487,7 +10522,8 @@ var ts;
}
ts.hasRestParameter = hasRestParameter;
function isRestParameter(node) {
- return node.dotDotDotToken !== undefined || node.type && node.type.kind === 284 /* JSDocVariadicType */;
+ var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
+ return node.dotDotDotToken !== undefined || type && type.kind === 284 /* JSDocVariadicType */;
}
ts.isRestParameter = isRestParameter;
var AssignmentKind;
@@ -11016,7 +11052,7 @@ var ts;
ts.getOperator = getOperator;
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
switch (nodeKind) {
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return 0;
case 203 /* SpreadElement */:
return 1;
@@ -11345,8 +11381,8 @@ var ts;
};
}
ts.createTextWriter = createTextWriter;
- function getResolvedExternalModuleName(host, file) {
- return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
+ function getResolvedExternalModuleName(host, file, referenceFile) {
+ return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
}
ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
@@ -11360,12 +11396,13 @@ var ts;
/**
* Resolves a local path to a path which is absolute to the base of the emit
*/
- function getExternalModuleNameFromPath(host, fileName) {
+ function getExternalModuleNameFromPath(host, fileName, referencePath) {
var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
- var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
+ var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
- return ts.removeFileExtension(relativePath);
+ var extensionless = ts.removeFileExtension(relativePath);
+ return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
}
ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
function getOwnEmitOutputFilePath(sourceFile, host, extension) {
@@ -11459,7 +11496,8 @@ var ts;
}
ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
function getThisParameter(signature) {
- if (signature.parameters.length) {
+ // callback tags do not currently support this parameters
+ if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
var thisParameter = signature.parameters[0];
if (parameterIsThisKeyword(thisParameter)) {
return thisParameter;
@@ -11544,6 +11582,9 @@ var ts;
* JavaScript file, gets the return type annotation from JSDoc.
*/
function getEffectiveReturnTypeNode(node) {
+ if (ts.isJSDocSignature(node)) {
+ return node.type && node.type.typeExpression && node.type.typeExpression.type;
+ }
return node.type || (isInJavaScriptFile(node) ? ts.getJSDocReturnType(node) : undefined);
}
ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
@@ -11552,14 +11593,26 @@ var ts;
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
*/
function getEffectiveTypeParameterDeclarations(node) {
- return ts.isJSDocTypedefTag(node)
- ? getJSDocTypeParameterDeclarations(node)
- : node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined);
+ if (ts.isJSDocSignature(node)) {
+ return ts.emptyArray;
+ }
+ if (isJSDocTypeAlias(node)) {
+ ts.Debug.assert(node.parent.kind === 285 /* JSDocComment */);
+ var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; });
+ var templateTagNodes = templateTags;
+ templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos;
+ templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end;
+ templateTagNodes.hasTrailingComma = false;
+ return templateTagNodes;
+ }
+ return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray);
}
ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
function getJSDocTypeParameterDeclarations(node) {
- var templateTag = ts.getJSDocTemplateTag(node);
- return templateTag && templateTag.typeParameters;
+ var tags = ts.filter(ts.getJSDocTags(node), ts.isJSDocTemplateTag);
+ // template tags are only available when a typedef isn't already using them
+ var tag = ts.find(tags, function (tag) { return !(tag.parent.kind === 285 /* JSDocComment */ && ts.find(tag.parent.tags, isJSDocTypeAlias)); });
+ return (tag && tag.typeParameters) || ts.emptyArray;
}
ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
/**
@@ -12947,8 +13000,8 @@ var ts;
break;
case 71 /* Identifier */:
return declaration;
- case 295 /* JSDocPropertyTag */:
- case 290 /* JSDocParameterTag */: {
+ case 297 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */: {
var name = declaration.name;
if (name.kind === 145 /* QualifiedName */) {
return name.right;
@@ -12967,7 +13020,9 @@ var ts;
return undefined;
}
}
- case 294 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ return declaration.name;
+ case 296 /* JSDocTypedefTag */:
return getNameOfJSDocTypedef(declaration);
case 248 /* ExportAssignment */: {
var expression = declaration.expression;
@@ -13353,7 +13408,7 @@ var ts;
}
ts.isParenthesizedExpression = isParenthesizedExpression;
function skipPartiallyEmittedExpressions(node) {
- while (node.kind === 298 /* PartiallyEmittedExpression */) {
+ while (node.kind === 300 /* PartiallyEmittedExpression */) {
node = node.expression;
}
return node;
@@ -13745,45 +13800,53 @@ var ts;
}
ts.isJSDoc = isJSDoc;
function isJSDocAugmentsTag(node) {
- return node.kind === 288 /* JSDocAugmentsTag */;
+ return node.kind === 289 /* JSDocAugmentsTag */;
}
ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
function isJSDocClassTag(node) {
- return node.kind === 289 /* JSDocClassTag */;
+ return node.kind === 290 /* JSDocClassTag */;
}
ts.isJSDocClassTag = isJSDocClassTag;
function isJSDocParameterTag(node) {
- return node.kind === 290 /* JSDocParameterTag */;
+ return node.kind === 292 /* JSDocParameterTag */;
}
ts.isJSDocParameterTag = isJSDocParameterTag;
function isJSDocReturnTag(node) {
- return node.kind === 291 /* JSDocReturnTag */;
+ return node.kind === 293 /* JSDocReturnTag */;
}
ts.isJSDocReturnTag = isJSDocReturnTag;
function isJSDocTypeTag(node) {
- return node.kind === 292 /* JSDocTypeTag */;
+ return node.kind === 294 /* JSDocTypeTag */;
}
ts.isJSDocTypeTag = isJSDocTypeTag;
function isJSDocTemplateTag(node) {
- return node.kind === 293 /* JSDocTemplateTag */;
+ return node.kind === 295 /* JSDocTemplateTag */;
}
ts.isJSDocTemplateTag = isJSDocTemplateTag;
function isJSDocTypedefTag(node) {
- return node.kind === 294 /* JSDocTypedefTag */;
+ return node.kind === 296 /* JSDocTypedefTag */;
}
ts.isJSDocTypedefTag = isJSDocTypedefTag;
function isJSDocPropertyTag(node) {
- return node.kind === 295 /* JSDocPropertyTag */;
+ return node.kind === 297 /* JSDocPropertyTag */;
}
ts.isJSDocPropertyTag = isJSDocPropertyTag;
function isJSDocPropertyLikeTag(node) {
- return node.kind === 295 /* JSDocPropertyTag */ || node.kind === 290 /* JSDocParameterTag */;
+ return node.kind === 297 /* JSDocPropertyTag */ || node.kind === 292 /* JSDocParameterTag */;
}
ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
function isJSDocTypeLiteral(node) {
return node.kind === 286 /* JSDocTypeLiteral */;
}
ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
+ function isJSDocCallbackTag(node) {
+ return node.kind === 291 /* JSDocCallbackTag */;
+ }
+ ts.isJSDocCallbackTag = isJSDocCallbackTag;
+ function isJSDocSignature(node) {
+ return node.kind === 287 /* JSDocSignature */;
+ }
+ ts.isJSDocSignature = isJSDocSignature;
})(ts || (ts = {}));
// Node tests
//
@@ -13792,7 +13855,7 @@ var ts;
(function (ts) {
/* @internal */
function isSyntaxList(n) {
- return n.kind === 296 /* SyntaxList */;
+ return n.kind === 298 /* SyntaxList */;
}
ts.isSyntaxList = isSyntaxList;
/* @internal */
@@ -13937,6 +14000,7 @@ var ts;
switch (kind) {
case 152 /* MethodSignature */:
case 157 /* CallSignature */:
+ case 287 /* JSDocSignature */:
case 158 /* ConstructSignature */:
case 159 /* IndexSignature */:
case 162 /* FunctionType */:
@@ -14252,8 +14316,8 @@ var ts;
case 203 /* SpreadElement */:
case 207 /* AsExpression */:
case 205 /* OmittedExpression */:
- case 299 /* CommaListExpression */:
- case 298 /* PartiallyEmittedExpression */:
+ case 301 /* CommaListExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return true;
default:
return isUnaryExpressionKind(kind);
@@ -14267,12 +14331,12 @@ var ts;
ts.isAssertionExpression = isAssertionExpression;
/* @internal */
function isPartiallyEmittedExpression(node) {
- return node.kind === 298 /* PartiallyEmittedExpression */;
+ return node.kind === 300 /* PartiallyEmittedExpression */;
}
ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
/* @internal */
function isNotEmittedStatement(node) {
- return node.kind === 297 /* NotEmittedStatement */;
+ return node.kind === 299 /* NotEmittedStatement */;
}
ts.isNotEmittedStatement = isNotEmittedStatement;
/* @internal */
@@ -14383,8 +14447,9 @@ var ts;
|| kind === 236 /* TypeAliasDeclaration */
|| kind === 147 /* TypeParameter */
|| kind === 231 /* VariableDeclaration */
- || kind === 294 /* JSDocTypedefTag */
- || kind === 295 /* JSDocPropertyTag */;
+ || kind === 296 /* JSDocTypedefTag */
+ || kind === 291 /* JSDocCallbackTag */
+ || kind === 297 /* JSDocPropertyTag */;
}
function isDeclarationStatementKind(kind) {
return kind === 233 /* FunctionDeclaration */
@@ -14419,14 +14484,14 @@ var ts;
|| kind === 213 /* VariableStatement */
|| kind === 218 /* WhileStatement */
|| kind === 225 /* WithStatement */
- || kind === 297 /* NotEmittedStatement */
- || kind === 301 /* EndOfDeclarationMarker */
- || kind === 300 /* MergeDeclarationMarker */;
+ || kind === 299 /* NotEmittedStatement */
+ || kind === 303 /* EndOfDeclarationMarker */
+ || kind === 302 /* MergeDeclarationMarker */;
}
/* @internal */
function isDeclaration(node) {
if (node.kind === 147 /* TypeParameter */) {
- return node.parent.kind !== 293 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node);
+ return node.parent.kind !== 295 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node);
}
return isDeclarationKind(node.kind);
}
@@ -14521,18 +14586,18 @@ var ts;
/** True if node is of some JSDoc syntax kind. */
/* @internal */
function isJSDocNode(node) {
- return node.kind >= 277 /* FirstJSDocNode */ && node.kind <= 295 /* LastJSDocNode */;
+ return node.kind >= 277 /* FirstJSDocNode */ && node.kind <= 297 /* LastJSDocNode */;
}
ts.isJSDocNode = isJSDocNode;
/** True if node is of a kind that may contain comment text. */
function isJSDocCommentContainingNode(node) {
- return node.kind === 285 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node);
+ return node.kind === 285 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node);
}
ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
// TODO: determine what this does before making it public.
/* @internal */
function isJSDocTag(node) {
- return node.kind >= 287 /* FirstJSDocTagNode */ && node.kind <= 295 /* LastJSDocTagNode */;
+ return node.kind >= 288 /* FirstJSDocTagNode */ && node.kind <= 297 /* LastJSDocTagNode */;
}
ts.isJSDocTag = isJSDocTag;
function isSetAccessor(node) {
@@ -15078,7 +15143,7 @@ var ts;
return visitNode(cbNode, node.expression);
case 252 /* MissingDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators);
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return visitNodes(cbNode, cbNodes, node.elements);
case 254 /* JsxElement */:
return visitNode(cbNode, node.openingElement) ||
@@ -15120,8 +15185,8 @@ var ts;
return visitNode(cbNode, node.type);
case 285 /* JSDocComment */:
return visitNodes(cbNode, cbNodes, node.tags);
- case 290 /* JSDocParameterTag */:
- case 295 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */:
+ case 297 /* JSDocPropertyTag */:
if (node.isNameFirst) {
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.typeExpression);
@@ -15130,15 +15195,15 @@ var ts;
return visitNode(cbNode, node.typeExpression) ||
visitNode(cbNode, node.name);
}
- case 291 /* JSDocReturnTag */:
+ case 293 /* JSDocReturnTag */:
return visitNode(cbNode, node.typeExpression);
- case 292 /* JSDocTypeTag */:
+ case 294 /* JSDocTypeTag */:
return visitNode(cbNode, node.typeExpression);
- case 288 /* JSDocAugmentsTag */:
+ case 289 /* JSDocAugmentsTag */:
return visitNode(cbNode, node.class);
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
return visitNodes(cbNode, cbNodes, node.typeParameters);
- case 294 /* JSDocTypedefTag */:
+ case 296 /* JSDocTypedefTag */:
if (node.typeExpression &&
node.typeExpression.kind === 277 /* JSDocTypeExpression */) {
return visitNode(cbNode, node.typeExpression) ||
@@ -15148,6 +15213,15 @@ var ts;
return visitNode(cbNode, node.fullName) ||
visitNode(cbNode, node.typeExpression);
}
+ case 291 /* JSDocCallbackTag */:
+ return visitNode(cbNode, node.fullName) ||
+ visitNode(cbNode, node.typeExpression);
+ case 287 /* JSDocSignature */:
+ return visitNodes(cbNode, cbNodes, node.decorators) ||
+ visitNodes(cbNode, cbNodes, node.modifiers) ||
+ visitNodes(cbNode, cbNodes, node.typeParameters) ||
+ visitNodes(cbNode, cbNodes, node.parameters) ||
+ visitNode(cbNode, node.type);
case 286 /* JSDocTypeLiteral */:
if (node.jsDocPropertyTags) {
for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
@@ -15156,7 +15230,7 @@ var ts;
}
}
return;
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return visitNode(cbNode, node.expression);
}
}
@@ -20305,8 +20379,9 @@ var ts;
})(JSDocState || (JSDocState = {}));
var PropertyLikeParse;
(function (PropertyLikeParse) {
- PropertyLikeParse[PropertyLikeParse["Property"] = 0] = "Property";
- PropertyLikeParse[PropertyLikeParse["Parameter"] = 1] = "Parameter";
+ PropertyLikeParse[PropertyLikeParse["Property"] = 1] = "Property";
+ PropertyLikeParse[PropertyLikeParse["Parameter"] = 2] = "Parameter";
+ PropertyLikeParse[PropertyLikeParse["CallbackParameter"] = 4] = "CallbackParameter";
})(PropertyLikeParse || (PropertyLikeParse = {}));
function parseJSDocCommentWorker(start, length) {
var content = sourceText;
@@ -20354,7 +20429,7 @@ var ts;
case 57 /* AtToken */:
if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) {
removeTrailingNewlines(comments);
- parseTag(indent);
+ addTag(parseTag(indent));
// NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag.
// Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning
// for malformed examples like `/** @param {string} x @returns {number} the length */`
@@ -20433,7 +20508,24 @@ var ts;
result.comment = comments.length ? comments.join("") : undefined;
return finishNode(result, end);
}
+ function isNextNonwhitespaceTokenEndOfFile() {
+ // We must use infinite lookahead, as there could be any number of newlines :(
+ while (true) {
+ nextJSDocToken();
+ if (token() === 1 /* EndOfFileToken */) {
+ return true;
+ }
+ if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) {
+ return false;
+ }
+ }
+ }
function skipWhitespace() {
+ if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
+ if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
+ return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range
+ }
+ }
while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
nextJSDocToken();
}
@@ -20462,8 +20554,7 @@ var ts;
case "arg":
case "argument":
case "param":
- addTag(parseParameterOrPropertyTag(atToken, tagName, 1 /* Parameter */, indent));
- return;
+ return parseParameterOrPropertyTag(atToken, tagName, 2 /* Parameter */, indent);
case "return":
case "returns":
tag = parseReturnTag(atToken, tagName);
@@ -20475,7 +20566,10 @@ var ts;
tag = parseTypeTag(atToken, tagName);
break;
case "typedef":
- tag = parseTypedefTag(atToken, tagName);
+ tag = parseTypedefTag(atToken, tagName, indent);
+ break;
+ case "callback":
+ tag = parseCallbackTag(atToken, tagName, indent);
break;
default:
tag = parseUnknownTag(atToken, tagName);
@@ -20489,8 +20583,11 @@ var ts;
// a badly malformed tag should not be added to the list of tags
return;
}
- tag.comment = parseTagComments(indent + tag.end - tag.pos);
- addTag(tag);
+ if (!tag.comment) {
+ // some tags, like typedef and callback, have already parsed their comments earlier
+ tag.comment = parseTagComments(indent + tag.end - tag.pos);
+ }
+ return tag;
}
function parseTagComments(indent) {
var comments = [];
@@ -20553,12 +20650,15 @@ var ts;
return comments.length === 0 ? undefined : comments.join("");
}
function parseUnknownTag(atToken, tagName) {
- var result = createNode(287 /* JSDocTag */, atToken.pos);
+ var result = createNode(288 /* JSDocTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
return finishNode(result);
}
function addTag(tag) {
+ if (!tag) {
+ return;
+ }
if (!tags) {
tags = [tag];
tagsPos = tag.pos;
@@ -20609,9 +20709,9 @@ var ts;
if (isNameFirst) {
typeExpression = tryParseTypeExpression();
}
- var result = target === 1 /* Parameter */ ?
- createNode(290 /* JSDocParameterTag */, atToken.pos) :
- createNode(295 /* JSDocPropertyTag */, atToken.pos);
+ var result = target === 1 /* Property */ ?
+ createNode(297 /* JSDocPropertyTag */, atToken.pos) :
+ createNode(292 /* JSDocParameterTag */, atToken.pos);
var comment;
if (indent !== undefined)
comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
@@ -20637,7 +20737,7 @@ var ts;
var start_2 = scanner.getStartPos();
var children = void 0;
while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) {
- if (child.kind === 290 /* JSDocParameterTag */ || child.kind === 295 /* JSDocPropertyTag */) {
+ if (child.kind === 292 /* JSDocParameterTag */ || child.kind === 297 /* JSDocPropertyTag */) {
children = ts.append(children, child);
}
}
@@ -20653,27 +20753,27 @@ var ts;
}
}
function parseReturnTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 291 /* JSDocReturnTag */; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 293 /* JSDocReturnTag */; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(291 /* JSDocReturnTag */, atToken.pos);
+ var result = createNode(293 /* JSDocReturnTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result);
}
function parseTypeTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 292 /* JSDocTypeTag */; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocTypeTag */; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(292 /* JSDocTypeTag */, atToken.pos);
+ var result = createNode(294 /* JSDocTypeTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
return finishNode(result);
}
function parseAugmentsTag(atToken, tagName) {
- var result = createNode(288 /* JSDocAugmentsTag */, atToken.pos);
+ var result = createNode(289 /* JSDocAugmentsTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.class = parseExpressionWithTypeArgumentsForAugments();
@@ -20701,32 +20801,23 @@ var ts;
return node;
}
function parseClassTag(atToken, tagName) {
- var tag = createNode(289 /* JSDocClassTag */, atToken.pos);
+ var tag = createNode(290 /* JSDocClassTag */, atToken.pos);
tag.atToken = atToken;
tag.tagName = tagName;
return finishNode(tag);
}
- function parseTypedefTag(atToken, tagName) {
+ function parseTypedefTag(atToken, tagName, indent) {
var typeExpression = tryParseTypeExpression();
skipWhitespace();
- var typedefTag = createNode(294 /* JSDocTypedefTag */, atToken.pos);
+ var typedefTag = createNode(296 /* JSDocTypedefTag */, atToken.pos);
typedefTag.atToken = atToken;
typedefTag.tagName = tagName;
- typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0);
- if (typedefTag.fullName) {
- var rightNode = typedefTag.fullName;
- while (true) {
- if (rightNode.kind === 71 /* Identifier */ || !rightNode.body) {
- // if node is identifier - use it as name
- // otherwise use name of the rightmost part that we were able to parse
- typedefTag.name = rightNode.kind === 71 /* Identifier */ ? rightNode : rightNode.name;
- break;
- }
- rightNode = rightNode.body;
- }
- }
+ typedefTag.fullName = parseJSDocTypeNameWithNamespace();
+ typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
skipWhitespace();
+ typedefTag.comment = parseTagComments(indent);
typedefTag.typeExpression = typeExpression;
+ var end;
if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
var child = void 0;
var jsdocTypeLiteral = void 0;
@@ -20736,7 +20827,7 @@ var ts;
if (!jsdocTypeLiteral) {
jsdocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, start_3);
}
- if (child.kind === 292 /* JSDocTypeTag */) {
+ if (child.kind === 294 /* JSDocTypeTag */) {
if (childTypeTag) {
break;
}
@@ -20755,23 +20846,68 @@ var ts;
typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
childTypeTag.typeExpression :
finishNode(jsdocTypeLiteral);
+ end = typedefTag.typeExpression.end;
}
}
- return finishNode(typedefTag);
- function parseJSDocTypeNameWithNamespace(flags) {
- var pos = scanner.getTokenPos();
- var typeNameOrNamespaceName = parseJSDocIdentifierName();
- if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) {
- var jsDocNamespaceNode = createNode(238 /* ModuleDeclaration */, pos);
- jsDocNamespaceNode.flags |= flags;
- jsDocNamespaceNode.name = typeNameOrNamespaceName;
- jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */);
- return finishNode(jsDocNamespaceNode);
+ // Only include the characters between the name end and the next token if a comment was actually parsed out - otherwise it's just whitespace
+ return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
+ }
+ function parseJSDocTypeNameWithNamespace(nested) {
+ var pos = scanner.getTokenPos();
+ var typeNameOrNamespaceName = parseJSDocIdentifierName();
+ if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) {
+ var jsDocNamespaceNode = createNode(238 /* ModuleDeclaration */, pos);
+ if (nested) {
+ jsDocNamespaceNode.flags |= 4 /* NestedNamespace */;
}
- if (typeNameOrNamespaceName && flags & 4 /* NestedNamespace */) {
- typeNameOrNamespaceName.isInJSDocNamespace = true;
+ jsDocNamespaceNode.name = typeNameOrNamespaceName;
+ jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(/*nested*/ true);
+ return finishNode(jsDocNamespaceNode);
+ }
+ if (typeNameOrNamespaceName && nested) {
+ typeNameOrNamespaceName.isInJSDocNamespace = true;
+ }
+ return typeNameOrNamespaceName;
+ }
+ function parseCallbackTag(atToken, tagName, indent) {
+ var callbackTag = createNode(291 /* JSDocCallbackTag */, atToken.pos);
+ callbackTag.atToken = atToken;
+ callbackTag.tagName = tagName;
+ callbackTag.fullName = parseJSDocTypeNameWithNamespace();
+ callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
+ skipWhitespace();
+ callbackTag.comment = parseTagComments(indent);
+ var child;
+ var start = scanner.getStartPos();
+ var jsdocSignature = createNode(287 /* JSDocSignature */, start);
+ jsdocSignature.parameters = [];
+ while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) {
+ jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
+ }
+ var returnTag = tryParse(function () {
+ if (token() === 57 /* AtToken */) {
+ nextJSDocToken();
+ var tag = parseTag(indent);
+ if (tag && tag.kind === 293 /* JSDocReturnTag */) {
+ return tag;
+ }
+ }
+ });
+ if (returnTag) {
+ jsdocSignature.type = returnTag;
+ }
+ callbackTag.typeExpression = finishNode(jsdocSignature);
+ return finishNode(callbackTag);
+ }
+ function getJSDocTypeAliasName(fullName) {
+ if (fullName) {
+ var rightNode = fullName;
+ while (true) {
+ if (ts.isIdentifier(rightNode) || !rightNode.body) {
+ return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
+ }
+ rightNode = rightNode.body;
}
- return typeNameOrNamespaceName;
}
}
function escapedTextsEqual(a, b) {
@@ -20787,7 +20923,7 @@ var ts;
return a.escapedText === b.escapedText;
}
function parseChildPropertyTag() {
- return parseChildParameterOrPropertyTag(0 /* Property */);
+ return parseChildParameterOrPropertyTag(1 /* Property */);
}
function parseChildParameterOrPropertyTag(target, name) {
var canParseTag = true;
@@ -20797,7 +20933,8 @@ var ts;
case 57 /* AtToken */:
if (canParseTag) {
var child = tryParseChildTag(target);
- if (child && child.kind === 290 /* JSDocParameterTag */ &&
+ if (child && child.kind === 292 /* JSDocParameterTag */ &&
+ target !== 4 /* CallbackParameter */ &&
(ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
return false;
}
@@ -20836,20 +20973,20 @@ var ts;
var t;
switch (tagName.escapedText) {
case "type":
- return target === 0 /* Property */ && parseTypeTag(atToken, tagName);
+ return target === 1 /* Property */ && parseTypeTag(atToken, tagName);
case "prop":
case "property":
- t = 0 /* Property */;
+ t = 1 /* Property */;
break;
case "arg":
case "argument":
case "param":
- t = 1 /* Parameter */;
+ t = 2 /* Parameter */ | 4 /* CallbackParameter */;
break;
default:
return false;
}
- if (target !== t) {
+ if (!(target & t)) {
return false;
}
var tag = parseParameterOrPropertyTag(atToken, tagName, target, /*indent*/ undefined);
@@ -20882,7 +21019,7 @@ var ts;
break;
}
}
- var result = createNode(293 /* JSDocTemplateTag */, atToken.pos);
+ var result = createNode(295 /* JSDocTemplateTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
@@ -20931,7 +21068,7 @@ var ts;
var pos = scanner.getTokenPos();
var end = scanner.getTextPos();
var result = createNode(71 /* Identifier */, pos);
- result.escapedText = ts.escapeLeadingUnderscores(content.substring(pos, end));
+ result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText());
finishNode(result, end);
nextJSDocToken();
return result;
@@ -21735,7 +21872,7 @@ var ts;
var thisParentContainer; // Container one level up
var blockScopeContainer;
var lastContainer;
- var delayedTypedefs;
+ var delayedTypeAliases;
var seenThisKeyword;
// state used by control flow analysis
var currentFlow;
@@ -21793,7 +21930,7 @@ var ts;
thisParentContainer = undefined;
blockScopeContainer = undefined;
lastContainer = undefined;
- delayedTypedefs = undefined;
+ delayedTypeAliases = undefined;
seenThisKeyword = false;
currentFlow = undefined;
currentBreakTarget = undefined;
@@ -21867,6 +22004,7 @@ var ts;
return "__constructor" /* Constructor */;
case 162 /* FunctionType */:
case 157 /* CallSignature */:
+ case 287 /* JSDocSignature */:
return "__call" /* Call */;
case 163 /* ConstructorType */:
case 158 /* ConstructSignature */:
@@ -21895,9 +22033,6 @@ var ts;
var functionType = node.parent;
var index = functionType.parameters.indexOf(node);
return "arg" + index;
- case 294 /* JSDocTypedefTag */:
- var name_2 = ts.getNameOfJSDocTypedef(node);
- return typeof name_2 !== "undefined" ? name_2.escapedText : undefined;
}
}
function getDisplayName(node) {
@@ -22035,9 +22170,9 @@ var ts;
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
// and this case is specially handled. Module augmentations should only be merged with original module definition
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
- if (node.kind === 294 /* JSDocTypedefTag */)
+ if (ts.isJSDocTypeAlias(node))
ts.Debug.assert(ts.isInJavaScriptFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
- if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypedefTag(node)) {
+ if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) {
if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) {
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
}
@@ -22202,23 +22337,6 @@ var ts;
ts.forEachChild(node, bind, bindEach);
}
function bindChildrenWorker(node) {
- // Binding of JsDocComment should be done before the current block scope container changes.
- // because the scope of JsDocComment should not be affected by whether the current node is a
- // container or not.
- if (ts.hasJSDocNodes(node)) {
- if (ts.isInJavaScriptFile(node)) {
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var j = _a[_i];
- bind(j);
- }
- }
- else {
- for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
- var j = _c[_b];
- setParentPointers(node, j);
- }
- }
- }
if (checkUnreachable(node)) {
bindEachChild(node);
return;
@@ -22284,11 +22402,9 @@ var ts;
case 186 /* CallExpression */:
bindCallExpressionFlow(node);
break;
- case 285 /* JSDocComment */:
- bindJSDocComment(node);
- break;
- case 294 /* JSDocTypedefTag */:
- bindJSDocTypedefTag(node);
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ bindJSDocTypeAlias(node);
break;
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
case 273 /* SourceFile */:
@@ -22303,6 +22419,7 @@ var ts;
bindEachChild(node);
break;
}
+ bindJSDoc(node);
}
function isNarrowingExpression(expr) {
switch (expr.kind) {
@@ -22904,23 +23021,10 @@ var ts;
bindInitializedVariableFlow(node);
}
}
- function bindJSDocComment(node) {
- ts.forEachChild(node, function (n) {
- if (n.kind !== 294 /* JSDocTypedefTag */) {
- bind(n);
- }
- });
- }
- function bindJSDocTypedefTag(node) {
- ts.forEachChild(node, function (n) {
- // if the node has a fullName "A.B.C", that means symbol "C" was already bound
- // when we visit "fullName"; so when we visit the name "C" as the next child of
- // the jsDocTypedefTag, we should skip binding it.
- if (node.fullName && n === node.name && node.fullName.kind !== 71 /* Identifier */) {
- return;
- }
- bind(n);
- });
+ function bindJSDocTypeAlias(node) {
+ if (node.fullName) {
+ setParentPointers(node, node.fullName);
+ }
}
function bindCallExpressionFlow(node) {
// If the target of the call expression is a function expression or arrow function we have
@@ -22974,6 +23078,7 @@ var ts;
case 155 /* GetAccessor */:
case 156 /* SetAccessor */:
case 157 /* CallSignature */:
+ case 287 /* JSDocSignature */:
case 283 /* JSDocFunctionType */:
case 162 /* FunctionType */:
case 158 /* ConstructSignature */:
@@ -23050,6 +23155,7 @@ var ts;
case 163 /* ConstructorType */:
case 157 /* CallSignature */:
case 158 /* ConstructSignature */:
+ case 287 /* JSDocSignature */:
case 159 /* IndexSignature */:
case 153 /* MethodDeclaration */:
case 152 /* MethodSignature */:
@@ -23060,6 +23166,8 @@ var ts;
case 191 /* FunctionExpression */:
case 192 /* ArrowFunction */:
case 283 /* JSDocFunctionType */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
case 236 /* TypeAliasDeclaration */:
case 176 /* MappedType */:
// All the children of these container types are never visible through another
@@ -23234,22 +23342,35 @@ var ts;
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 67216319 /* BlockScopedVariableExcludes */);
}
function delayedBindJSDocTypedefTag() {
- if (!delayedTypedefs) {
+ if (!delayedTypeAliases) {
return;
}
var saveContainer = container;
var saveLastContainer = lastContainer;
var saveBlockScopeContainer = blockScopeContainer;
var saveParent = parent;
- for (var _i = 0, delayedTypedefs_1 = delayedTypedefs; _i < delayedTypedefs_1.length; _i++) {
- var delay = delayedTypedefs_1[_i];
- (container = delay.container, lastContainer = delay.lastContainer, blockScopeContainer = delay.blockScopeContainer, parent = delay.parent);
- bindBlockScopedDeclaration(delay.typedef, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */);
+ var saveCurrentFlow = currentFlow;
+ for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
+ var typeAlias = delayedTypeAliases_1[_i];
+ var host = ts.getJSDocHost(typeAlias);
+ container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file;
+ blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
+ currentFlow = { flags: 2 /* Start */ };
+ parent = typeAlias;
+ bind(typeAlias.typeExpression);
+ if (!typeAlias.fullName || typeAlias.fullName.kind === 71 /* Identifier */) {
+ parent = typeAlias.parent;
+ bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */);
+ }
+ else {
+ bind(typeAlias.fullName);
+ }
}
container = saveContainer;
lastContainer = saveLastContainer;
blockScopeContainer = saveBlockScopeContainer;
parent = saveParent;
+ currentFlow = saveCurrentFlow;
}
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
// check for reserved words used as identifiers in strict mode code.
@@ -23401,8 +23522,6 @@ var ts;
// Here the current node is "foo", which is a container, but the scope of "MyType" should
// not be inside "foo". Therefore we always bind @typedef before bind the parent node,
// and skip binding this tag later when binding all the other jsdoc tags.
- if (ts.isInJavaScriptFile(node))
- bindJSDocTypedefTagIfAny(node);
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
// and then potentially add the symbol to an appropriate symbol table. Possible
// destination symbol tables are:
@@ -23433,25 +23552,22 @@ var ts;
}
else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) {
subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
+ bindJSDoc(node);
}
inStrictMode = saveInStrictMode;
}
- function bindJSDocTypedefTagIfAny(node) {
- if (!ts.hasJSDocNodes(node)) {
- return;
- }
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var jsDoc = _a[_i];
- if (!jsDoc.tags) {
- continue;
+ function bindJSDoc(node) {
+ if (ts.hasJSDocNodes(node)) {
+ if (ts.isInJavaScriptFile(node)) {
+ for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
+ var j = _a[_i];
+ bind(j);
+ }
}
- for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) {
- var tag = _c[_b];
- if (tag.kind === 294 /* JSDocTypedefTag */) {
- var savedParent = parent;
- parent = jsDoc;
- bind(tag);
- parent = savedParent;
+ else {
+ for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
+ var j = _c[_b];
+ setParentPointers(node, j);
}
}
}
@@ -23486,7 +23602,7 @@ var ts;
// current "blockScopeContainer" needs to be set to its immediate namespace parent.
if (node.isInJSDocNamespace) {
var parentNode = node.parent;
- while (parentNode && parentNode.kind !== 294 /* JSDocTypedefTag */) {
+ while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
parentNode = parentNode.parent;
}
bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */);
@@ -23589,6 +23705,7 @@ var ts;
return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */);
case 162 /* FunctionType */:
case 283 /* JSDocFunctionType */:
+ case 287 /* JSDocSignature */:
case 163 /* ConstructorType */:
return bindFunctionOrConstructorType(node);
case 165 /* TypeLiteral */:
@@ -23648,24 +23765,23 @@ var ts;
// falls through
case 239 /* ModuleBlock */:
return updateStrictModeStatementList(node.statements);
- case 290 /* JSDocParameterTag */:
+ case 292 /* JSDocParameterTag */:
+ if (node.parent.kind === 287 /* JSDocSignature */) {
+ return bindParameter(node);
+ }
if (node.parent.kind !== 286 /* JSDocTypeLiteral */) {
break;
}
// falls through
- case 295 /* JSDocPropertyTag */:
+ case 297 /* JSDocPropertyTag */:
var propTag = node;
var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 /* JSDocOptionalType */ ?
4 /* Property */ | 16777216 /* Optional */ :
4 /* Property */;
return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */);
- case 294 /* JSDocTypedefTag */: {
- var fullName = node.fullName;
- if (!fullName || fullName.kind === 71 /* Identifier */) {
- (delayedTypedefs || (delayedTypedefs = [])).push({ typedef: node, container: container, lastContainer: lastContainer, blockScopeContainer: blockScopeContainer, parent: parent });
- }
- break;
- }
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
}
}
function bindPropertyWorker(node) {
@@ -24025,6 +24141,9 @@ var ts;
}
}
function bindParameter(node) {
+ if (node.kind === 292 /* JSDocParameterTag */ && container.kind !== 287 /* JSDocSignature */) {
+ return;
+ }
if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) {
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
@@ -24083,24 +24202,30 @@ var ts;
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
function getInferTypeContainer(node) {
- while (node) {
- var parent_2 = node.parent;
- if (parent_2 && parent_2.kind === 170 /* ConditionalType */ && parent_2.extendsType === node) {
- return parent_2;
- }
- node = parent_2;
- }
- return undefined;
+ var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
+ return extendsType && extendsType.parent;
}
function bindTypeParameter(node) {
- if (node.parent.kind === 171 /* InferType */) {
- var container_1 = getInferTypeContainer(node.parent);
+ if (ts.isJSDocTemplateTag(node.parent)) {
+ var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
if (container_1) {
if (!container_1.locals) {
container_1.locals = ts.createSymbolTable();
}
declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */);
}
+ else {
+ declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */);
+ }
+ }
+ else if (node.parent.kind === 171 /* InferType */) {
+ var container_2 = getInferTypeContainer(node.parent);
+ if (container_2) {
+ if (!container_2.locals) {
+ container_2.locals = ts.createSymbolTable();
+ }
+ declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */);
+ }
else {
bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node));
}
@@ -24725,7 +24850,7 @@ var ts;
break;
case 189 /* TypeAssertionExpression */:
case 207 /* AsExpression */:
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
// These nodes are TypeScript syntax.
transformFlags |= 3 /* AssertTypeScript */;
excludeFlags = 536872257 /* OuterExpressionExcludes */;
@@ -24997,7 +25122,7 @@ var ts;
return 940049729 /* BindingPatternExcludes */;
case 189 /* TypeAssertionExpression */:
case 207 /* AsExpression */:
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
case 190 /* ParenthesizedExpression */:
case 97 /* SuperKeyword */:
return 536872257 /* OuterExpressionExcludes */;
@@ -25015,7 +25140,7 @@ var ts;
*/
function setParentPointers(parent, child) {
child.parent = parent;
- ts.forEachChild(child, function (childsChild) { return setParentPointers(child, childsChild); });
+ ts.forEachChild(child, function (grandchild) { return setParentPointers(child, grandchild); });
}
})(ts || (ts = {}));
/** @internal */
@@ -27671,6 +27796,12 @@ var ts;
location = location.parent;
}
break;
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ // js type aliases do not resolve names from their host, so skip past it
+ lastLocation = location;
+ location = ts.getJSDocHost(location).parent;
+ continue;
}
if (isSelfReferenceLocation(location)) {
lastSelfReferenceLocation = location;
@@ -27786,9 +27917,11 @@ var ts;
function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
- if (decl.kind === 147 /* TypeParameter */ && parent === container) {
- return true;
+ if (decl.kind === 147 /* TypeParameter */) {
+ var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
+ if (parent === container) {
+ return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
+ }
}
}
return false;
@@ -28252,7 +28385,7 @@ var ts;
var symbol;
if (name.kind === 71 /* Identifier */) {
var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0;
- var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSPrototype(name, meaning) : undefined;
+ var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSSpecialAssignment(name, meaning) : undefined;
symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true);
if (!symbol) {
return symbolFromJSPrototype;
@@ -28306,24 +28439,38 @@ var ts;
return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
}
/**
- * For prototype-property methods like `A.prototype.m = function () ...`, try to resolve names in the scope of `A` too.
+ * 1. For prototype-property methods like `A.prototype.m = function () ...`, try to resolve names in the scope of `A` too.
* Note that prototype-property assignment to locations outside the current file (eg globals) doesn't work, so
* name resolution won't work either.
+ * 2. For property assignments like `{ x: function f () { } }`, try to resolve names in the scope of `f` too.
*/
- function resolveEntityNameFromJSPrototype(name, meaning) {
- if (isJSDocTypeReference(name.parent) && ts.isJSDocTag(name.parent.parent.parent)) {
- var host_1 = ts.getJSDocHost(name.parent.parent.parent);
- if (ts.isExpressionStatement(host_1) &&
- ts.isBinaryExpression(host_1.expression) &&
- ts.getSpecialPropertyAssignmentKind(host_1.expression) === 3 /* PrototypeProperty */) {
- var symbol = getSymbolOfNode(host_1.expression.left);
- if (symbol) {
- var secondaryLocation = symbol.parent.valueDeclaration;
- return resolveName(secondaryLocation, name.escapedText, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ true);
- }
+ function resolveEntityNameFromJSSpecialAssignment(name, meaning) {
+ if (isJSDocTypeReference(name.parent)) {
+ var secondaryLocation = getJSSpecialAssignmentLocation(name.parent);
+ if (secondaryLocation) {
+ return resolveName(secondaryLocation, name.escapedText, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ true);
}
}
}
+ function getJSSpecialAssignmentLocation(node) {
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
+ if (typeAlias) {
+ return;
+ }
+ var host = ts.getJSDocHost(node);
+ if (host &&
+ ts.isExpressionStatement(host) &&
+ ts.isBinaryExpression(host.expression) &&
+ ts.getSpecialPropertyAssignmentKind(host.expression) === 3 /* PrototypeProperty */) {
+ var symbol = getSymbolOfNode(host.expression.left);
+ return symbol && symbol.parent.valueDeclaration;
+ }
+ var sig = ts.getHostSignatureFromJSDocHost(host);
+ if (sig) {
+ var symbol = getSymbolOfNode(sig);
+ return symbol && symbol.valueDeclaration;
+ }
+ }
function resolveExternalModuleName(location, moduleReferenceExpression) {
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0);
}
@@ -28863,6 +29010,14 @@ var ts;
}
return hasAccessibleDeclarations;
}
+ else {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol)) {
+ // Any meaning of a module symbol is always accessible via an `import` type
+ return {
+ accessibility: 0 /* Accessible */
+ };
+ }
+ }
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
@@ -29100,7 +29255,7 @@ var ts;
flags: flags,
tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop },
encounteredError: false,
- symbolStack: undefined,
+ visitedSymbols: undefined,
inferTypeParameters: undefined
};
}
@@ -29207,9 +29362,10 @@ var ts;
return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined);
}
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
- var name = symbolToTypeReferenceName(type.aliasSymbol);
var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
- return ts.createTypeReferenceNode(name, typeArgumentNodes);
+ if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
+ return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes);
+ return symbolToTypeNode(type.aliasSymbol, context, 67901928 /* Type */, typeArgumentNodes);
}
if (type.flags & (131072 /* Union */ | 262144 /* Intersection */)) {
var types = type.flags & 131072 /* Union */ ? formatUnionTypes(type.types) : type.types;
@@ -29274,7 +29430,10 @@ var ts;
}
function createAnonymousTypeNode(type) {
var symbol = type.symbol;
+ var id;
if (symbol) {
+ var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */;
+ id = (isConstructorObject ? "+" : "") + getSymbolId(symbol);
if (isJavaScriptConstructor(symbol.valueDeclaration)) {
// Instance and static types share the same symbol; only add 'typeof' for the static side.
var isInstanceType = type === getInferredClassType(symbol) ? 67901928 /* Type */ : 67216319 /* Value */;
@@ -29286,7 +29445,7 @@ var ts;
shouldWriteTypeOfFunctionSymbol()) {
return symbolToTypeNode(symbol, context, 67216319 /* Value */);
}
- else if (ts.contains(context.symbolStack, symbol)) {
+ else if (context.visitedSymbols && context.visitedSymbols.has(id)) {
// If type is an anonymous type literal in a type alias declaration, use type alias name
var typeAlias = getTypeAliasForTypeLiteral(type);
if (typeAlias) {
@@ -29300,19 +29459,13 @@ var ts;
else {
// Since instantiations of the same anonymous type have the same symbol, tracking symbols instead
// of types allows us to catch circular references to instantiations of the same anonymous type
- if (!context.symbolStack) {
- context.symbolStack = [];
- }
- var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */;
- if (isConstructorObject) {
- return createTypeNodeFromObjectType(type);
- }
- else {
- context.symbolStack.push(symbol);
- var result = createTypeNodeFromObjectType(type);
- context.symbolStack.pop();
- return result;
+ if (!context.visitedSymbols) {
+ context.visitedSymbols = ts.createMap();
}
+ context.visitedSymbols.set(id, true);
+ var result = createTypeNodeFromObjectType(type);
+ context.visitedSymbols.delete(id);
+ return result;
}
}
else {
@@ -29329,7 +29482,7 @@ var ts;
}));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
// typeof is allowed only for static/non local functions
- return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ts.contains(context.symbolStack, symbol)) && // it is type of the symbol uses itself recursively
+ return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively
(!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed
}
}
@@ -29361,11 +29514,6 @@ var ts;
var typeLiteralNode = ts.createTypeLiteralNode(members);
return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */);
}
- function symbolToTypeReferenceName(symbol) {
- // Unnamed function expressions and arrow functions have reserved names that we don't want to display
- var entityName = symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.escapedName) ? symbolToName(symbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false) : ts.createIdentifier("");
- return entityName;
- }
function typeReferenceToTypeNode(type) {
var typeArguments = type.typeArguments || ts.emptyArray;
if (type.target === globalArrayType) {
@@ -29398,7 +29546,7 @@ var ts;
else {
var outerTypeParameters = type.target.outerTypeParameters;
var i = 0;
- var qualifiedName = void 0;
+ var resultType = void 0;
if (outerTypeParameters) {
var length_1 = outerTypeParameters.length;
while (i < length_1) {
@@ -29412,55 +29560,65 @@ var ts;
// the default outer type arguments), we don't show the group.
if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
- var typeArgumentNodes_1 = typeArgumentSlice && ts.createNodeArray(typeArgumentSlice);
- var namePart = symbolToTypeReferenceName(parent);
- (namePart.kind === 71 /* Identifier */ ? namePart : namePart.right).typeArguments = typeArgumentNodes_1;
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, namePart);
- qualifiedName = ts.createQualifiedName(qualifiedName, /*right*/ undefined);
- }
- else {
- qualifiedName = ts.createQualifiedName(namePart, /*right*/ undefined);
- }
+ var flags_2 = context.flags;
+ context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */;
+ var ref = symbolToTypeNode(parent, context, 67901928 /* Type */, typeArgumentSlice);
+ context.flags = flags_2;
+ resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
}
}
}
- var entityName = void 0;
- var nameIdentifier = symbolToTypeReferenceName(type.symbol);
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, nameIdentifier);
- entityName = qualifiedName;
- }
- else {
- entityName = nameIdentifier;
- }
var typeArgumentNodes = void 0;
if (typeArguments.length > 0) {
var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
}
- if (typeArgumentNodes) {
- var lastIdentifier = entityName.kind === 71 /* Identifier */ ? entityName : entityName.right;
- lastIdentifier.typeArguments = undefined;
- }
- return ts.createTypeReferenceNode(entityName, typeArgumentNodes);
+ var flags = context.flags;
+ context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */;
+ var finalRef = symbolToTypeNode(type.symbol, context, 67901928 /* Type */, typeArgumentNodes);
+ context.flags = flags;
+ return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
}
}
- function addToQualifiedNameMissingRightIdentifier(left, right) {
- ts.Debug.assert(left.right === undefined);
- if (right.kind === 71 /* Identifier */) {
- left.right = right;
- return left;
+ function appendReferenceToType(root, ref) {
+ if (ts.isImportTypeNode(root)) {
+ // first shift type arguments
+ var innerParams = root.typeArguments;
+ if (root.qualifier) {
+ (ts.isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams;
+ }
+ root.typeArguments = ref.typeArguments;
+ // then move qualifiers
+ var ids = getAccessStack(ref);
+ for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
+ var id = ids_1[_i];
+ root.qualifier = root.qualifier ? ts.createQualifiedName(root.qualifier, id) : id;
+ }
+ return root;
}
- var rightPart = right;
- while (rightPart.left.kind !== 71 /* Identifier */) {
- rightPart = rightPart.left;
+ else {
+ // first shift type arguments
+ var innerParams = root.typeArguments;
+ (ts.isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams;
+ root.typeArguments = ref.typeArguments;
+ // then move qualifiers
+ var ids = getAccessStack(ref);
+ for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
+ var id = ids_2[_a];
+ root.typeName = ts.createQualifiedName(root.typeName, id);
+ }
+ return root;
}
- left.right = rightPart.left;
- rightPart.left = left;
- return right;
+ }
+ function getAccessStack(ref) {
+ var state = ref.typeName;
+ var ids = [];
+ while (!ts.isIdentifier(state)) {
+ ids.unshift(state.right);
+ state = state.left;
+ }
+ ids.unshift(state);
+ return ids;
}
function createTypeNodesFromResolvedType(resolvedType) {
var typeElements = [];
@@ -29632,7 +29790,9 @@ var ts;
}
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) {
var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148 /* Parameter */);
- ts.Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol));
+ if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) {
+ parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292 /* JSDocParameterTag */);
+ }
var parameterType = getTypeOfSymbol(parameterSymbol);
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
parameterType = getOptionalType(parameterType);
@@ -29643,9 +29803,9 @@ var ts;
var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined;
var name = parameterDeclaration
? parameterDeclaration.name ?
- parameterDeclaration.name.kind === 71 /* Identifier */ ?
- ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) :
- cloneBindingName(parameterDeclaration.name) :
+ parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) :
+ parameterDeclaration.name.kind === 145 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) :
+ cloneBindingName(parameterDeclaration.name) :
ts.symbolName(parameterSymbol)
: ts.symbolName(parameterSymbol);
var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined;
@@ -29665,7 +29825,7 @@ var ts;
}
}
}
- function lookupSymbolChain(symbol, context, meaning) {
+ function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
// Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration.
var chain;
@@ -29701,7 +29861,7 @@ var ts;
// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
endOfChain ||
// If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
- !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) &&
+ (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) &&
// If a parent symbol is an anonymous type, don't write it.
!(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
return [symbol];
@@ -29742,8 +29902,8 @@ var ts;
}
return top;
}
- function symbolToTypeNode(symbol, context, meaning) {
- var chain = lookupSymbolChain(symbol, context, meaning);
+ function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
+ var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
context.flags |= 16777216 /* InInitialEntityName */;
var rootName = getNameOfSymbolAsWritten(chain[0], context);
context.flags ^= 16777216 /* InInitialEntityName */;
@@ -29751,9 +29911,13 @@ var ts;
if (ambientModuleSymbolRegex.test(rootName)) {
// module is root, must use `ImportTypeNode`
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
- var typeParameterNodes = lookupTypeParameterNodes(chain, 0, context);
+ var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1)));
if (!nonRootParts || ts.isEntityName(nonRootParts)) {
+ if (nonRootParts) {
+ var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
+ lastId.typeArguments = undefined;
+ }
return ts.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
}
else {
@@ -29766,9 +29930,17 @@ var ts;
if (ts.isIndexedAccessTypeNode(entityName)) {
return entityName; // Indexed accesses can never be `typeof`
}
- return isTypeOf ? ts.createTypeQueryNode(entityName) : ts.createTypeReferenceNode(entityName, /*typeArguments*/ undefined);
+ if (isTypeOf) {
+ return ts.createTypeQueryNode(entityName);
+ }
+ else {
+ var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
+ var lastTypeArgs = lastId.typeArguments;
+ lastId.typeArguments = undefined;
+ return ts.createTypeReferenceNode(entityName, lastTypeArgs);
+ }
function createAccessFromSymbolChain(chain, index, stopper) {
- var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
+ var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
var symbol = chain[index];
if (index === 0) {
context.flags |= 16777216 /* InInitialEntityName */;
@@ -29778,7 +29950,7 @@ var ts;
context.flags ^= 16777216 /* InInitialEntityName */;
}
var parent = chain[index - 1];
- if (parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
+ if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
// Should use an indexed access
var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
if (ts.isIndexedAccessTypeNode(LHS)) {
@@ -29946,6 +30118,24 @@ var ts;
return "default";
}
if (symbol.declarations && symbol.declarations.length) {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) {
+ var file_3 = ts.getDeclarationOfKind(symbol, 273 /* SourceFile */);
+ if (!file_3 || !context.tracker.moduleResolverHost) {
+ if (context.tracker.trackReferencedAmbientModule) {
+ var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
+ if (ts.length(ambientDecls)) {
+ for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
+ var decl = ambientDecls_1[_i];
+ context.tracker.trackReferencedAmbientModule(decl);
+ }
+ }
+ }
+ // ambient module, just use declaration/symbol name (fallthrough)
+ }
+ else {
+ return "\"" + ts.getResolvedExternalModuleName(context.tracker.moduleResolverHost, file_3, ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration))) + "\"";
+ }
+ }
var declaration = symbol.declarations[0];
var name = ts.getNameOfDeclaration(declaration);
if (name) {
@@ -29987,8 +30177,9 @@ var ts;
return false;
function determineIfDeclarationIsVisible() {
switch (node.kind) {
- case 294 /* JSDocTypedefTag */:
- // Top-level jsdoc typedefs are considered exported
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ // Top-level jsdoc type aliases are considered exported
// First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file
return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
case 181 /* BindingElement */:
@@ -30703,7 +30894,7 @@ var ts;
if (symbol.flags & 4194304 /* Prototype */) {
return links.type = getTypeOfPrototypeProperty(symbol);
}
- // CommonsJS require/module/exports all have type any.
+ // CommonsJS require and module both have type any.
if (symbol === requireSymbol || symbol === moduleSymbol) {
return links.type = anyType;
}
@@ -30737,7 +30928,7 @@ var ts;
declaration.kind === 184 /* PropertyAccessExpression */ && declaration.parent.kind === 199 /* BinaryExpression */) {
type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol);
}
- else if (ts.isJSDocPropertyTag(declaration)
+ else if (ts.isJSDocPropertyLikeTag(declaration)
|| ts.isPropertyAccessExpression(declaration)
|| ts.isIdentifier(declaration)
|| (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
@@ -31014,7 +31205,9 @@ var ts;
case 191 /* FunctionExpression */:
case 192 /* ArrowFunction */:
case 236 /* TypeAliasDeclaration */:
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
case 176 /* MappedType */:
case 170 /* ConditionalType */:
var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
@@ -31024,7 +31217,7 @@ var ts;
else if (node.kind === 170 /* ConditionalType */) {
return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
}
- var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray);
+ var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
var thisType = includeThisTypes &&
(node.kind === 234 /* ClassDeclaration */ || node.kind === 204 /* ClassExpression */ || node.kind === 235 /* InterfaceDeclaration */) &&
getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
@@ -31043,13 +31236,12 @@ var ts;
var result;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var node = _a[_i];
- if (node.kind === 235 /* InterfaceDeclaration */ || node.kind === 234 /* ClassDeclaration */ ||
- node.kind === 204 /* ClassExpression */ || node.kind === 236 /* TypeAliasDeclaration */ || node.kind === 294 /* JSDocTypedefTag */) {
+ if (node.kind === 235 /* InterfaceDeclaration */ ||
+ node.kind === 234 /* ClassDeclaration */ ||
+ node.kind === 204 /* ClassExpression */ ||
+ ts.isTypeAlias(node)) {
var declaration = node;
- var typeParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- if (typeParameters) {
- result = appendTypeParameters(result, typeParameters);
- }
+ result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
}
}
return result;
@@ -31326,9 +31518,9 @@ var ts;
return unknownType;
}
var declaration = ts.find(symbol.declarations, function (d) {
- return d.kind === 294 /* JSDocTypedefTag */ || d.kind === 236 /* TypeAliasDeclaration */;
+ return ts.isJSDocTypeAlias(d) || d.kind === 236 /* TypeAliasDeclaration */;
});
- var typeNode = declaration.kind === 294 /* JSDocTypedefTag */ ? declaration.typeExpression : declaration.type;
+ var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
// If typeNode is missing, we will error in checkJSDocTypedefTag.
var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType;
if (popTypeResolution()) {
@@ -31533,7 +31725,7 @@ var ts;
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
return (node.kind === 154 /* Constructor */ || (returnType && isThislessType(returnType))) &&
node.parameters.every(isThislessVariableLikeDeclaration) &&
- (!typeParameters || typeParameters.every(isThislessTypeParameter));
+ typeParameters.every(isThislessTypeParameter);
}
/**
* Returns true if the class or interface member given by the symbol is free of "this" references. The
@@ -31714,9 +31906,9 @@ var ts;
// If we have an existing early-bound member, combine its declarations so that we can
// report an error at each declaration.
var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
- var name_3 = ts.declarationNameToString(decl.name);
- ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_3); });
- error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_3);
+ var name_2 = ts.declarationNameToString(decl.name);
+ ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_2); });
+ error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_2);
lateSymbol = createSymbol(0 /* None */, memberName, 1024 /* Late */);
}
lateSymbol.nameType = type;
@@ -32783,9 +32975,10 @@ var ts;
// type checking functions).
function getTypeParametersFromDeclaration(declaration) {
var result;
- ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) {
+ for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
+ var node = _a[_i];
result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
- });
+ }
return result;
}
function symbolsToArray(symbols) {
@@ -32815,7 +33008,7 @@ var ts;
return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
}
function isOptionalParameter(node) {
- if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) {
+ if (ts.hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) {
return true;
}
if (node.initializer) {
@@ -32832,6 +33025,13 @@ var ts;
}
return false;
}
+ function isOptionalJSDocParameterTag(node) {
+ if (!ts.isJSDocParameterTag(node)) {
+ return false;
+ }
+ var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
+ return isBracketed || !!typeExpression && typeExpression.type.kind === 282 /* JSDocOptionalType */;
+ }
function createTypePredicateFromTypePredicateNode(node) {
var parameterName = node.parameterName;
var type = getTypeFromTypeNode(node.type);
@@ -32920,6 +33120,7 @@ var ts;
for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
var param = declaration.parameters[i];
var paramSymbol = param.symbol;
+ var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
// Include parameter symbol instead of property symbol in the signature
if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) {
var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67216319 /* Value */, undefined, undefined, /*isUse*/ false);
@@ -32932,12 +33133,13 @@ var ts;
else {
parameters.push(paramSymbol);
}
- if (param.type && param.type.kind === 177 /* LiteralType */) {
+ if (type && type.kind === 177 /* LiteralType */) {
hasLiteralTypes = true;
}
// Record a new minimum argument count if this is not an optional parameter
- var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken ||
- iife && parameters.length > iife.arguments.length && !param.type ||
+ var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) ||
+ param.initializer || param.questionToken || param.dotDotDotToken ||
+ iife && parameters.length > iife.arguments.length && !type ||
isUntypedSignatureInJSFile ||
isJSDocOptionalParameter(param);
if (!isOptionalParameter_1) {
@@ -32971,7 +33173,7 @@ var ts;
* 2. It has at least one parameter, and the last parameter has a matching `@param` with a type that starts with `...`
*/
function maybeAddJsSyntheticRestParameter(declaration, parameters) {
- if (!containsArgumentsReference(declaration)) {
+ if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
return false;
}
var lastParam = ts.lastOrUndefined(declaration.parameters);
@@ -33364,7 +33566,7 @@ var ts;
var isJs = ts.isInJavaScriptFile(node);
var isJsImplicitAny = !noImplicitAny && isJs;
if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
- var missingAugmentsTag = isJs && node.parent.kind !== 288 /* JSDocAugmentsTag */;
+ var missingAugmentsTag = isJs && node.parent.kind !== 289 /* JSDocAugmentsTag */;
var diag = minTypeArgumentCount === typeParameters.length
? missingAugmentsTag
? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag
@@ -33515,7 +33717,7 @@ var ts;
}
function getConstrainedTypeVariable(typeVariable, node) {
var constraints;
- while (node && !ts.isStatement(node)) {
+ while (node && !ts.isStatement(node) && node.kind !== 285 /* JSDocComment */) {
var parent = node.parent;
if (parent.kind === 170 /* ConditionalType */ && node === parent.trueType) {
var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType);
@@ -33965,7 +34167,7 @@ var ts;
includes & 4096 /* Undefined */ ? includes & 16777216 /* NonWideningType */ ? undefinedType : undefinedWideningType :
neverType;
}
- return getUnionTypeFromSortedList(typeSet, aliasSymbol, aliasTypeArguments);
+ return getUnionTypeFromSortedList(typeSet, includes & 8374815 /* NotUnit */ ? 0 : 268435456 /* UnionOfUnitTypes */, aliasSymbol, aliasTypeArguments);
}
function getUnionTypePredicate(signatures) {
var first;
@@ -34002,7 +34204,7 @@ var ts;
: !ts.isIdentifierTypePredicate(b);
}
// This function assumes the constituent type list is sorted and deduplicated.
- function getUnionTypeFromSortedList(types, aliasSymbol, aliasTypeArguments) {
+ function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) {
if (types.length === 0) {
return neverType;
}
@@ -34013,7 +34215,7 @@ var ts;
var type = unionTypes.get(id);
if (!type) {
var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 12288 /* Nullable */);
- type = createType(131072 /* Union */ | propagatedFlags);
+ type = createType(131072 /* Union */ | propagatedFlags | unionOfUnitTypes);
unionTypes.set(id, type);
type.types = types;
/*
@@ -34030,7 +34232,8 @@ var ts;
function getTypeFromUnionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -34079,6 +34282,31 @@ var ts;
}
}
}
+ // When intersecting unions of unit types we can simply intersect based on type identity.
+ // Here we remove all unions of unit types from the given list and replace them with a
+ // a single union containing an intersection of the unit types.
+ function intersectUnionsOfUnitTypes(types) {
+ var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456 /* UnionOfUnitTypes */) !== 0; });
+ var unionType = types[unionIndex];
+ var intersection = unionType.types;
+ var i = types.length - 1;
+ var _loop_5 = function () {
+ var t = types[i];
+ if (t.flags & 268435456 /* UnionOfUnitTypes */) {
+ intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); });
+ ts.orderedRemoveItemAt(types, i);
+ }
+ i--;
+ };
+ while (i > unionIndex) {
+ _loop_5();
+ }
+ if (intersection === unionType.types) {
+ return false;
+ }
+ types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456 /* UnionOfUnitTypes */);
+ return true;
+ }
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
@@ -34113,6 +34341,12 @@ var ts;
return typeSet[0];
}
if (includes & 131072 /* Union */) {
+ if (includes & 268435456 /* UnionOfUnitTypes */ && intersectUnionsOfUnitTypes(typeSet)) {
+ // When the intersection creates a reduced set (which might mean that *all* union types have
+ // disappeared), we restart the operation to get a new set of combined flags. Once we have
+ // reduced we'll never reduce again, so this occurs at most once.
+ return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
// We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
// the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072 /* Union */) !== 0; });
@@ -34134,7 +34368,8 @@ var ts;
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -34425,7 +34660,7 @@ var ts;
var type = createObjectType(32 /* Mapped */, node.symbol);
type.declaration = node;
type.aliasSymbol = getAliasSymbolForTypeNode(node);
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
links.resolvedType = type;
// Eagerly resolve the constraint type which forces an error if the constraint type circularly
// references itself through one or more type aliases.
@@ -34526,7 +34761,8 @@ var ts;
var links = getNodeLinks(node);
if (!links.resolvedType) {
var checkType = getTypeFromTypeNode(node.checkType);
- var aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
var allOuterTypeParameters = getOuterTypeParameters(node, /*includeThisTypes*/ true);
var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isPossiblyReferencedInConditionalType(tp, node); });
var root = {
@@ -34539,7 +34775,7 @@ var ts;
inferTypeParameters: getInferTypeParameters(node),
outerTypeParameters: outerTypeParameters,
instantiations: undefined,
- aliasSymbol: getAliasSymbolForTypeNode(node),
+ aliasSymbol: aliasSymbol,
aliasTypeArguments: aliasTypeArguments
};
links.resolvedType = getConditionalType(root, /*mapper*/ undefined);
@@ -34638,7 +34874,7 @@ var ts;
else {
var type = createObjectType(16 /* Anonymous */, node.symbol);
type.aliasSymbol = aliasSymbol;
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
type = createArrayType(type);
}
@@ -34648,10 +34884,9 @@ var ts;
return links.resolvedType;
}
function getAliasSymbolForTypeNode(node) {
- return (node.parent.kind === 236 /* TypeAliasDeclaration */ || node.parent.kind === 294 /* JSDocTypedefTag */) ? getSymbolOfNode(node.parent) : undefined;
+ return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined;
}
- function getAliasTypeArgumentsForTypeNode(node) {
- var symbol = getAliasSymbolForTypeNode(node);
+ function getTypeArgumentsForAliasSymbol(symbol) {
return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
}
/**
@@ -34887,6 +35122,7 @@ var ts;
case 165 /* TypeLiteral */:
case 286 /* JSDocTypeLiteral */:
case 283 /* JSDocFunctionType */:
+ case 287 /* JSDocSignature */:
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
case 174 /* TypeOperator */:
return getTypeFromTypeOperatorNode(node);
@@ -35076,6 +35312,15 @@ var ts;
// aren't the right hand side of a generic type alias declaration we optimize by reducing the
// set of type parameters to those that are possibly referenced in the literal.
var declaration_1 = symbol.declarations[0];
+ if (ts.isInJavaScriptFile(declaration_1)) {
+ var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag);
+ if (paramTag) {
+ var paramSymbol = ts.getParameterSymbolFromJSDoc(paramTag);
+ if (paramSymbol) {
+ declaration_1 = paramSymbol.valueDeclaration;
+ }
+ }
+ }
var outerTypeParameters = getOuterTypeParameters(declaration_1, /*includeThisTypes*/ true);
if (isJavaScriptConstructor(declaration_1)) {
var templateTagParameters = getTypeParametersFromDeclaration(declaration_1);
@@ -35117,8 +35362,8 @@ var ts;
// between the node and the type parameter declaration, if the node contains actual references to the
// type parameter, or if the node contains type queries, we consider the type parameter possibly referenced.
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
- var container_2 = tp.symbol.declarations[0].parent;
- if (ts.findAncestor(node, function (n) { return n.kind === 212 /* Block */ ? "quit" : n === container_2; })) {
+ var container_3 = tp.symbol.declarations[0].parent;
+ if (ts.findAncestor(node, function (n) { return n.kind === 212 /* Block */ ? "quit" : n === container_3; })) {
return ts.forEachChild(node, containsReference);
}
}
@@ -35968,7 +36213,7 @@ var ts;
// check excess properties against discriminant type only, not the entire union
return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors);
}
- var _loop_5 = function (prop) {
+ var _loop_6 = function (prop) {
if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
if (reportErrors) {
// We know *exactly* where things went wrong when comparing the types.
@@ -36005,7 +36250,7 @@ var ts;
};
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
- var state_3 = _loop_5(prop);
+ var state_3 = _loop_6(prop);
if (typeof state_3 === "object")
return state_3.value;
}
@@ -38558,7 +38803,7 @@ var ts;
if (type.flags & 131072 /* Union */) {
var types = type.types;
var filtered = ts.filter(types, f);
- return filtered === types ? type : getUnionTypeFromSortedList(filtered);
+ return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456 /* UnionOfUnitTypes */);
}
return f(type) ? type : neverType;
}
@@ -40514,10 +40759,11 @@ var ts;
links.resolvedSignatures = ts.createMap();
}
var cacheKey = "" + getTypeId(valueType);
- if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) !== resolvingSignaturesArray) {
- signatures = links.resolvedSignatures.get(cacheKey);
+ var cachedResolved = links.resolvedSignatures.get(cacheKey);
+ if (cachedResolved && cachedResolved !== resolvingSignaturesArray) {
+ signatures = cachedResolved;
}
- else if (!links.resolvedSignatures.get(cacheKey)) {
+ else if (!cachedResolved) {
links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray);
links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures));
}
@@ -41739,7 +41985,7 @@ var ts;
// Assignability failure - check each prop individually, and if that fails, fall back on the bad error span
if (ts.length(openingLikeElement.attributes.properties)) {
var reportedError = false;
- var _loop_6 = function (prop) {
+ var _loop_7 = function (prop) {
if (ts.isJsxSpreadAttribute(prop))
return "continue";
var name = ts.idText(prop.name);
@@ -41753,7 +41999,7 @@ var ts;
};
for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) {
var prop = _c[_b];
- _loop_6(prop);
+ _loop_7(prop);
}
if (reportedError) {
return;
@@ -43780,8 +44026,8 @@ var ts;
if (allowSyntheticDefaultImports && type && type !== unknownType) {
var synthType = type;
if (!synthType.syntheticType) {
- var file_3 = ts.find(originalSymbol.declarations, ts.isSourceFile);
- var hasSyntheticDefault = canHaveSyntheticDefault(file_3, originalSymbol, /*dontResolveAlias*/ false);
+ var file_4 = ts.find(originalSymbol.declarations, ts.isSourceFile);
+ var hasSyntheticDefault = canHaveSyntheticDefault(file_4, originalSymbol, /*dontResolveAlias*/ false);
if (hasSyntheticDefault) {
var memberTable = ts.createSymbolTable();
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
@@ -46298,8 +46544,9 @@ var ts;
switch (d.kind) {
case 235 /* InterfaceDeclaration */:
case 236 /* TypeAliasDeclaration */:
- // A jsdoc typedef is, by definition, a type alias
- case 294 /* JSDocTypedefTag */:
+ // A jsdoc typedef and callback are, by definition, type aliases
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
return 2 /* ExportType */;
case 238 /* ModuleDeclaration */:
return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */
@@ -46768,7 +47015,7 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function checkJSDocTypedefTag(node) {
+ function checkJSDocTypeAliasTag(node) {
if (!node.typeExpression) {
// If the node had `@property` tags, `typeExpression` would have been set to the first property tag.
error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
@@ -47002,7 +47249,7 @@ var ts;
// Only report errors on the last declaration for the type parameter container;
// this ensures that all uses have been accounted for.
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (!(node.flags & 4194304 /* Ambient */) && typeParameters && ts.last(getSymbolOfNode(node).declarations) === node) {
+ if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) {
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
var typeParameter = typeParameters_2[_i];
if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) {
@@ -48270,7 +48517,7 @@ var ts;
var declaration = declarations_6[_i];
// If this declaration has too few or too many type parameters, we report an error
var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- var numTypeParameters = ts.length(sourceParameters);
+ var numTypeParameters = sourceParameters.length;
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
return false;
}
@@ -48418,7 +48665,7 @@ var ts;
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
var issuedMemberError = false;
- var _loop_7 = function (member) {
+ var _loop_8 = function (member) {
if (ts.hasStaticModifier(member)) {
return "continue";
}
@@ -48437,7 +48684,7 @@ var ts;
};
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- _loop_7(member);
+ _loop_8(member);
}
if (!issuedMemberError) {
// check again with diagnostics to generate a less-specific error
@@ -49394,11 +49641,12 @@ var ts;
return checkInferType(node);
case 178 /* ImportType */:
return checkImportType(node);
- case 288 /* JSDocAugmentsTag */:
+ case 289 /* JSDocAugmentsTag */:
return checkJSDocAugmentsTag(node);
- case 294 /* JSDocTypedefTag */:
- return checkJSDocTypedefTag(node);
- case 290 /* JSDocParameterTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ return checkJSDocTypeAliasTag(node);
+ case 292 /* JSDocParameterTag */:
return checkJSDocParameterTag(node);
case 283 /* JSDocFunctionType */:
checkSignatureDeclaration(node);
@@ -49526,8 +49774,8 @@ var ts;
var paramTag = parent.parent;
if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) {
// Else we will add a diagnostic, see `checkJSDocVariadicType`.
- var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
- if (host_2) {
+ var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
+ if (host_1) {
/*
Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters.
So in the following situation we will not create an array type:
@@ -49535,7 +49783,7 @@ var ts;
function f(a) {}
Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type.
*/
- var lastParamDeclaration = ts.lastOrUndefined(host_2.parameters);
+ var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
if (!lastParamDeclaration ||
symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
@@ -49927,10 +50175,10 @@ var ts;
return entityNameSymbol;
}
}
- if (entityName.parent.kind === 290 /* JSDocParameterTag */) {
+ if (entityName.parent.kind === 292 /* JSDocParameterTag */) {
return ts.getParameterSymbolFromJSDoc(entityName.parent);
}
- if (entityName.parent.kind === 147 /* TypeParameter */ && entityName.parent.parent.kind === 293 /* JSDocTemplateTag */) {
+ if (entityName.parent.kind === 147 /* TypeParameter */ && entityName.parent.parent.kind === 295 /* JSDocTemplateTag */) {
ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true.
var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent);
return typeParameter && typeParameter.symbol;
@@ -50470,6 +50718,7 @@ var ts;
function isRequiredInitializedParameter(parameter) {
return strictNullChecks &&
!isOptionalParameter(parameter) &&
+ !ts.isJSDocParameterTag(parameter) &&
parameter.initializer &&
!ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */);
}
@@ -50771,8 +51020,8 @@ var ts;
var decl = _a[_i];
// check meaning of the local symbol to see if declaration needs to be analyzed further
if (decl.symbol && decl.symbol.flags & meaning) {
- var file_4 = ts.getSourceFileOfNode(decl);
- var typeReferenceDirective = fileToDirective.get(file_4.path);
+ var file_5 = ts.getSourceFileOfNode(decl);
+ var typeReferenceDirective = fileToDirective.get(file_5.path);
if (typeReferenceDirective) {
(typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
}
@@ -50807,8 +51056,8 @@ var ts;
// check that at least one declaration of top level symbol originates from type declaration file
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var file_5 = ts.getSourceFileOfNode(decl);
- if (fileToDirective.has(file_5.path)) {
+ var file_6 = ts.getSourceFileOfNode(decl);
+ if (fileToDirective.has(file_6.path)) {
return true;
}
}
@@ -50826,25 +51075,25 @@ var ts;
function initializeTypeChecker() {
// Bind all source files and propagate errors
for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
- var file_6 = _a[_i];
- ts.bindSourceFile(file_6, compilerOptions);
+ var file_7 = _a[_i];
+ ts.bindSourceFile(file_7, compilerOptions);
}
// Initialize global symbol table
var augmentations;
for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
- var file_7 = _c[_b];
- if (!ts.isExternalOrCommonJsModule(file_7)) {
- mergeSymbolTable(globals, file_7.locals);
+ var file_8 = _c[_b];
+ if (!ts.isExternalOrCommonJsModule(file_8)) {
+ mergeSymbolTable(globals, file_8.locals);
}
- if (file_7.patternAmbientModules && file_7.patternAmbientModules.length) {
- patternAmbientModules = ts.concatenate(patternAmbientModules, file_7.patternAmbientModules);
+ if (file_8.patternAmbientModules && file_8.patternAmbientModules.length) {
+ patternAmbientModules = ts.concatenate(patternAmbientModules, file_8.patternAmbientModules);
}
- if (file_7.moduleAugmentations.length) {
- (augmentations || (augmentations = [])).push(file_7.moduleAugmentations);
+ if (file_8.moduleAugmentations.length) {
+ (augmentations || (augmentations = [])).push(file_8.moduleAugmentations);
}
- if (file_7.symbol && file_7.symbol.globalExports) {
+ if (file_8.symbol && file_8.symbol.globalExports) {
// Merge in UMD exports with first-in-wins semantics (see #9771)
- var source = file_7.symbol.globalExports;
+ var source = file_8.symbol.globalExports;
source.forEach(function (sourceSymbol, id) {
if (!globals.has(id)) {
globals.set(id, sourceSymbol);
@@ -51296,7 +51545,7 @@ var ts;
}
function checkGrammarClassLikeDeclaration(node) {
var file = ts.getSourceFileOfNode(node);
- return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(ts.getEffectiveTypeParameterDeclarations(node), file);
+ return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
}
function checkGrammarArrowFunction(node, file) {
if (!ts.isArrowFunction(node)) {
@@ -51981,8 +52230,8 @@ var ts;
}
function checkGrammarConstructorTypeParameters(node) {
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (typeParameters) {
- var _a = ts.isNodeArray(typeParameters) ? typeParameters : ts.first(typeParameters), pos = _a.pos, end = _a.end;
+ if (ts.isNodeArray(typeParameters)) {
+ var pos = typeParameters.pos, end = typeParameters.end;
return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
}
}
@@ -52446,7 +52695,7 @@ var ts;
ts.updateQualifiedName = updateQualifiedName;
function parenthesizeForComputedName(expression) {
return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) ||
- expression.kind === 299 /* CommaListExpression */ ?
+ expression.kind === 301 /* CommaListExpression */ ?
createParen(expression) :
expression;
}
@@ -54425,7 +54674,7 @@ var ts;
* @param original The original statement.
*/
function createNotEmittedStatement(original) {
- var node = createSynthesizedNode(297 /* NotEmittedStatement */);
+ var node = createSynthesizedNode(299 /* NotEmittedStatement */);
node.original = original;
setTextRange(node, original);
return node;
@@ -54437,7 +54686,7 @@ var ts;
*/
/* @internal */
function createEndOfDeclarationMarker(original) {
- var node = createSynthesizedNode(301 /* EndOfDeclarationMarker */);
+ var node = createSynthesizedNode(303 /* EndOfDeclarationMarker */);
node.emitNode = {};
node.original = original;
return node;
@@ -54449,7 +54698,7 @@ var ts;
*/
/* @internal */
function createMergeDeclarationMarker(original) {
- var node = createSynthesizedNode(300 /* MergeDeclarationMarker */);
+ var node = createSynthesizedNode(302 /* MergeDeclarationMarker */);
node.emitNode = {};
node.original = original;
return node;
@@ -54464,7 +54713,7 @@ var ts;
* @param location The location for the expression. Defaults to the positions from "original" if provided.
*/
function createPartiallyEmittedExpression(expression, original) {
- var node = createSynthesizedNode(298 /* PartiallyEmittedExpression */);
+ var node = createSynthesizedNode(300 /* PartiallyEmittedExpression */);
node.expression = expression;
node.original = original;
setTextRange(node, original);
@@ -54480,7 +54729,7 @@ var ts;
ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression;
function flattenCommaElements(node) {
if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
- if (node.kind === 299 /* CommaListExpression */) {
+ if (node.kind === 301 /* CommaListExpression */) {
return node.elements;
}
if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) {
@@ -54490,7 +54739,7 @@ var ts;
return node;
}
function createCommaList(elements) {
- var node = createSynthesizedNode(299 /* CommaListExpression */);
+ var node = createSynthesizedNode(301 /* CommaListExpression */);
node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
return node;
}
@@ -55778,7 +56027,7 @@ var ts;
// if should be wrapped in parens since comma operator has the lowest precedence
var emittedExpression = ts.skipPartiallyEmittedExpressions(e);
return emittedExpression.kind === 199 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ ||
- emittedExpression.kind === 299 /* CommaListExpression */
+ emittedExpression.kind === 301 /* CommaListExpression */
? ts.createParen(e)
: e;
}
@@ -55798,7 +56047,7 @@ var ts;
var check = ts.skipPartiallyEmittedExpressions(e);
return (check.kind === 204 /* ClassExpression */ ||
check.kind === 191 /* FunctionExpression */ ||
- check.kind === 299 /* CommaListExpression */ ||
+ check.kind === 301 /* CommaListExpression */ ||
ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */)
? ts.createParen(e)
: e;
@@ -55963,7 +56212,7 @@ var ts;
case 184 /* PropertyAccessExpression */:
node = node.expression;
continue;
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
node = node.expression;
continue;
}
@@ -55993,7 +56242,7 @@ var ts;
case 207 /* AsExpression */:
case 208 /* NonNullExpression */:
return (kinds & 2 /* Assertions */) !== 0;
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0;
}
return false;
@@ -56030,7 +56279,7 @@ var ts;
case 189 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression);
case 207 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type);
case 208 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression);
- case 298 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
+ case 300 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
}
}
/**
@@ -56815,9 +57064,9 @@ var ts;
case 273 /* SourceFile */:
return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context));
// Transformation nodes
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression));
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression));
default:
// No need to visit nodes with no children.
@@ -56873,7 +57122,7 @@ var ts;
case 214 /* EmptyStatement */:
case 205 /* OmittedExpression */:
case 230 /* DebuggerStatement */:
- case 297 /* NotEmittedStatement */:
+ case 299 /* NotEmittedStatement */:
// No need to visit nodes with no children.
break;
// Names
@@ -57252,10 +57501,10 @@ var ts;
result = reduceNodes(node.statements, cbNodes, result);
break;
// Transformation nodes
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
result = reduceNode(node.expression, cbNode, result);
break;
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
result = reduceNodes(node.elements, cbNodes, result);
break;
default:
@@ -68885,9 +69134,9 @@ var ts;
return visitFunctionDeclaration(node);
case 234 /* ClassDeclaration */:
return visitClassDeclaration(node);
- case 300 /* MergeDeclarationMarker */:
+ case 302 /* MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 301 /* EndOfDeclarationMarker */:
+ case 303 /* EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
@@ -70819,9 +71068,9 @@ var ts;
return visitCatchClause(node);
case 212 /* Block */:
return visitBlock(node);
- case 300 /* MergeDeclarationMarker */:
+ case 302 /* MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 301 /* EndOfDeclarationMarker */:
+ case 303 /* EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return destructuringAndImportCallVisitor(node);
@@ -71888,19 +72137,22 @@ var ts;
var lateMarkedStatements;
var lateStatementReplacementMap;
var suppressNewDiagnosticContexts;
+ var host = context.getEmitHost();
var symbolTracker = {
trackSymbol: trackSymbol,
reportInaccessibleThisError: reportInaccessibleThisError,
reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
- reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression
+ reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
+ moduleResolverHost: host,
+ trackReferencedAmbientModule: trackReferencedAmbientModule,
};
var errorNameNode;
var currentSourceFile;
+ var refs;
var resolver = context.getEmitResolver();
var options = context.getCompilerOptions();
var newLine = ts.getNewLineCharacter(options);
var noResolve = options.noResolve, stripInternal = options.stripInternal;
- var host = context.getEmitHost();
return transformRoot;
function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
if (!typeReferenceDirectives) {
@@ -71912,6 +72164,10 @@ var ts;
necessaryTypeRefernces.set(ref, true);
}
}
+ function trackReferencedAmbientModule(node) {
+ var container = ts.getSourceFileOfNode(node);
+ refs.set("" + ts.getOriginalNodeId(container), container);
+ }
function handleSymbolAccessibilityError(symbolAccessibilityResult) {
if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
// Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info
@@ -72019,13 +72275,13 @@ var ts;
lateMarkedStatements = undefined;
lateStatementReplacementMap = ts.createMap();
necessaryTypeRefernces = undefined;
- var refs = collectReferences(currentSourceFile, ts.createMap());
+ refs = collectReferences(currentSourceFile, ts.createMap());
var references = [];
var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath));
var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
- refs.forEach(referenceVisitor);
var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
+ refs.forEach(referenceVisitor);
var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined)])), combinedStatements);
@@ -72037,17 +72293,19 @@ var ts;
}
function getFileReferenceForTypeName(typeName) {
// Elide type references for which we have imports
- for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
- var importStatement = emittedImports_1[_i];
- if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
- var expr = importStatement.moduleReference.expression;
- if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ if (emittedImports) {
+ for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
+ var importStatement = emittedImports_1[_i];
+ if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
+ var expr = importStatement.moduleReference.expression;
+ if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ return undefined;
+ }
+ }
+ else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
return undefined;
}
}
- else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
- return undefined;
- }
}
return { fileName: typeName, pos: -1, end: -1 };
}
@@ -72808,7 +73066,7 @@ var ts;
var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined);
var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile);
if (leadingsSyntheticCommentRanges) {
- var _loop_8 = function (range) {
+ var _loop_9 = function (range) {
if (range.kind === 3 /* MultiLineCommentTrivia */) {
var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2);
var lines = text.split(/\r\n?|\n/g);
@@ -72822,7 +73080,7 @@ var ts;
};
for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) {
var range = leadingsSyntheticCommentRanges_1[_i];
- _loop_8(range);
+ _loop_9(range);
}
}
return prop;
@@ -72984,7 +73242,7 @@ 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(302 /* Count */);
+ var enabledSyntaxKindFeatures = new Array(304 /* Count */);
var lexicalEnvironmentVariableDeclarations;
var lexicalEnvironmentFunctionDeclarations;
var lexicalEnvironmentVariableDeclarationsStack = [];
@@ -73479,7 +73737,7 @@ var ts;
source = undefined;
if (source)
setSourceFile(source);
- if (node.kind !== 297 /* NotEmittedStatement */
+ if (node.kind !== 299 /* NotEmittedStatement */
&& (emitFlags & 16 /* NoLeadingSourceMap */) === 0
&& pos >= 0) {
emitPos(skipSourceTrivia(pos));
@@ -73496,7 +73754,7 @@ var ts;
}
if (source)
setSourceFile(source);
- if (node.kind !== 297 /* NotEmittedStatement */
+ if (node.kind !== 299 /* NotEmittedStatement */
&& (emitFlags & 32 /* NoTrailingSourceMap */) === 0
&& end >= 0) {
emitPos(end);
@@ -73672,7 +73930,7 @@ var ts;
if (extendedDiagnostics) {
ts.performance.mark("preEmitNodeWithComment");
}
- var isEmittedNode = node.kind !== 297 /* NotEmittedStatement */;
+ var isEmittedNode = node.kind !== 299 /* 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 === 10 /* JsxText */;
@@ -74817,9 +75075,9 @@ var ts;
case 258 /* JsxFragment */:
return emitJsxFragment(node);
// Transformation nodes
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return emitPartiallyEmittedExpression(node);
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return emitCommaList(node);
}
}
@@ -77790,11 +78048,11 @@ var ts;
var diagnostic = diagnostics_2[_i];
var context_2 = "";
if (diagnostic.file) {
- var start = diagnostic.start, length_4 = diagnostic.length, file_8 = diagnostic.file;
- var _a = ts.getLineAndCharacterOfPosition(file_8, start), firstLine = _a.line, firstLineChar = _a.character;
- var _b = ts.getLineAndCharacterOfPosition(file_8, start + length_4), lastLine = _b.line, lastLineChar = _b.character;
- var lastLineInFile = ts.getLineAndCharacterOfPosition(file_8, file_8.text.length).line;
- var relativeFileName = host ? ts.convertToRelativePath(file_8.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_8.fileName;
+ var start = diagnostic.start, length_4 = diagnostic.length, file_9 = diagnostic.file;
+ var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character;
+ var _b = ts.getLineAndCharacterOfPosition(file_9, start + length_4), lastLine = _b.line, lastLineChar = _b.character;
+ var lastLineInFile = ts.getLineAndCharacterOfPosition(file_9, file_9.text.length).line;
+ var relativeFileName = host ? ts.convertToRelativePath(file_9.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_9.fileName;
var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
var gutterWidth = (lastLine + 1 + "").length;
if (hasMoreThanFiveLines) {
@@ -77808,9 +78066,9 @@ var ts;
context_2 += formatColorAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
i = lastLine - 1;
}
- var lineStart = ts.getPositionOfLineAndCharacter(file_8, i, 0);
- var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file_8, i + 1, 0) : file_8.text.length;
- var lineContent = file_8.text.slice(lineStart, lineEnd);
+ var lineStart = ts.getPositionOfLineAndCharacter(file_9, i, 0);
+ var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file_9, i + 1, 0) : file_9.text.length;
+ var lineContent = file_9.text.slice(lineStart, lineEnd);
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.
@@ -79180,31 +79438,31 @@ var ts;
// Get source file from normalized fileName
function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd, packageId) {
if (filesByName.has(path)) {
- var file_9 = filesByName.get(path);
+ var file_10 = filesByName.get(path);
// try to check if we've already seen this file but with a different casing in path
// NOTE: this only makes sense for case-insensitive file systems
- if (file_9 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_9.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
- reportFileNamesDifferOnlyInCasingError(fileName, file_9.fileName, refFile, refPos, refEnd);
+ if (file_10 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_10.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
+ reportFileNamesDifferOnlyInCasingError(fileName, file_10.fileName, refFile, refPos, refEnd);
}
// If the file was previously found via a node_modules search, but is now being processed as a root file,
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
- if (file_9 && sourceFilesFoundSearchingNodeModules.get(file_9.path) && currentNodeModulesDepth === 0) {
- sourceFilesFoundSearchingNodeModules.set(file_9.path, false);
+ if (file_10 && sourceFilesFoundSearchingNodeModules.get(file_10.path) && currentNodeModulesDepth === 0) {
+ sourceFilesFoundSearchingNodeModules.set(file_10.path, false);
if (!options.noResolve) {
- processReferencedFiles(file_9, isDefaultLib);
- processTypeReferenceDirectives(file_9);
+ processReferencedFiles(file_10, isDefaultLib);
+ processTypeReferenceDirectives(file_10);
}
- modulesWithElidedImports.set(file_9.path, false);
- processImportedModules(file_9);
+ modulesWithElidedImports.set(file_10.path, false);
+ processImportedModules(file_10);
}
// See if we need to reprocess the imports due to prior skipped imports
- else if (file_9 && modulesWithElidedImports.get(file_9.path)) {
+ else if (file_10 && modulesWithElidedImports.get(file_10.path)) {
if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
- modulesWithElidedImports.set(file_9.path, false);
- processImportedModules(file_9);
+ modulesWithElidedImports.set(file_10.path, false);
+ processImportedModules(file_10);
}
}
- return file_9;
+ return file_10;
}
var redirectedPath;
if (refFile) {
@@ -79431,9 +79689,9 @@ var ts;
function computeCommonSourceDirectory(sourceFiles) {
var fileNames = [];
for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
- var file_10 = sourceFiles_2[_i];
- if (!file_10.isDeclarationFile) {
- fileNames.push(file_10.fileName);
+ var file_11 = sourceFiles_2[_i];
+ if (!file_11.isDeclarationFile) {
+ fileNames.push(file_11.fileName);
}
}
return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
@@ -79537,14 +79795,14 @@ var ts;
if (options.composite && rootNames.length < files.length) {
var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); });
var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); });
- var _loop_9 = function (file_11) {
- if (normalizedRootNames.every(function (r) { return r !== file_11; })) {
- programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file_11));
+ var _loop_10 = function (file_12) {
+ if (normalizedRootNames.every(function (r) { return r !== file_12; })) {
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file_12));
}
};
for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
- var file_11 = sourceFiles_4[_i];
- _loop_9(file_11);
+ var file_12 = sourceFiles_4[_i];
+ _loop_10(file_12);
}
}
if (options.paths) {
@@ -83139,7 +83397,7 @@ var ts;
function serializeCompilerOptions(options) {
var result = ts.createMap();
var optionsNameMap = getOptionNameMap().optionNameMap;
- var _loop_10 = function (name) {
+ var _loop_11 = function (name) {
if (ts.hasProperty(options, name)) {
// tsconfig only options cannot be specified via command line,
// so we can assume that only types that can appear here string | number | boolean
@@ -83168,7 +83426,7 @@ var ts;
}
};
for (var name in options) {
- _loop_10(name);
+ _loop_11(name);
}
return result;
}
@@ -83814,30 +84072,30 @@ var ts;
if (filesSpecs) {
for (var _i = 0, filesSpecs_1 = filesSpecs; _i < filesSpecs_1.length; _i++) {
var fileName = filesSpecs_1[_i];
- var file_12 = ts.getNormalizedAbsolutePath(fileName, basePath);
- literalFileMap.set(keyMapper(file_12), file_12);
+ var file_13 = ts.getNormalizedAbsolutePath(fileName, basePath);
+ literalFileMap.set(keyMapper(file_13), file_13);
}
}
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
- var file_13 = _b[_a];
+ var file_14 = _b[_a];
// If we have already included a literal or wildcard path with a
// higher priority extension, we should skip this file.
//
// This handles cases where we may encounter both .ts and
// .d.ts (or .js if "allowJs" is enabled) in the same
// directory when they are compilation outputs.
- if (hasFileWithHigherPriorityExtension(file_13, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
+ if (hasFileWithHigherPriorityExtension(file_14, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
continue;
}
// We may have included a wildcard path with a lower priority
// extension due to the user-defined order of entries in the
// "include" array. If there is a lower priority extension in the
// same directory, we should remove it.
- removeWildcardFilesWithLowerPriorityExtension(file_13, wildcardFileMap, supportedExtensions, keyMapper);
- var key = keyMapper(file_13);
+ removeWildcardFilesWithLowerPriorityExtension(file_14, wildcardFileMap, supportedExtensions, keyMapper);
+ var key = keyMapper(file_14);
if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
- wildcardFileMap.set(key, file_13);
+ wildcardFileMap.set(key, file_14);
}
}
}
@@ -83899,8 +84157,8 @@ var ts;
if (include !== undefined) {
var recursiveKeys = [];
for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
- var file_14 = include_1[_i];
- var spec = ts.normalizePath(ts.combinePaths(path, file_14));
+ var file_15 = include_1[_i];
+ var spec = ts.normalizePath(ts.combinePaths(path, file_15));
if (excludeRegex && excludeRegex.test(spec)) {
continue;
}
@@ -84307,7 +84565,7 @@ var ts;
case 236 /* TypeAliasDeclaration */:
case 165 /* TypeLiteral */:
return 2 /* Type */;
- case 294 /* JSDocTypedefTag */:
+ case 296 /* 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 272 /* EnumMember */:
@@ -84516,7 +84774,7 @@ var ts;
}
ts.isExpressionOfExternalModuleImportEqualsDeclaration = isExpressionOfExternalModuleImportEqualsDeclaration;
function getContainerNode(node) {
- if (node.kind === 294 /* JSDocTypedefTag */) {
+ if (ts.isJSDocTypeAlias(node)) {
// This doesn't just apply to the node immediately under the comment, but to everything in its parent's scope.
// node.parent = the JSDoc comment, node.parent.parent = the node having the comment.
// Then we get parent again in the loop.
@@ -84554,7 +84812,10 @@ var ts;
case 204 /* ClassExpression */:
return "class" /* classElement */;
case 235 /* InterfaceDeclaration */: return "interface" /* interfaceElement */;
- case 236 /* TypeAliasDeclaration */: return "type" /* typeElement */;
+ case 236 /* TypeAliasDeclaration */:
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ return "type" /* typeElement */;
case 237 /* EnumDeclaration */: return "enum" /* enumElement */;
case 231 /* VariableDeclaration */:
return getKindOfVariableDeclaration(node);
@@ -84585,8 +84846,6 @@ var ts;
case 251 /* ExportSpecifier */:
case 245 /* NamespaceImport */:
return "alias" /* alias */;
- case 294 /* JSDocTypedefTag */:
- return "type" /* typeElement */;
case 199 /* BinaryExpression */:
var kind = ts.getSpecialPropertyAssignmentKind(node);
var right = node.right;
@@ -84648,6 +84907,10 @@ var ts;
return startEndContainsRange(r1.pos, r1.end, r2);
}
ts.rangeContainsRange = rangeContainsRange;
+ function rangeContainsPosition(r, pos) {
+ return r.pos <= pos && pos <= r.end;
+ }
+ ts.rangeContainsPosition = rangeContainsPosition;
function startEndContainsRange(start, end, range) {
return start <= range.pos && end >= range.end;
}
@@ -85429,6 +85692,25 @@ var ts;
return propSymbol;
}
ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement;
+ var NodeSet = /** @class */ (function () {
+ function NodeSet() {
+ this.map = ts.createMap();
+ }
+ NodeSet.prototype.add = function (node) {
+ this.map.set(String(ts.getNodeId(node)), node);
+ };
+ NodeSet.prototype.has = function (node) {
+ return this.map.has(String(ts.getNodeId(node)));
+ };
+ NodeSet.prototype.forEach = function (cb) {
+ this.map.forEach(cb);
+ };
+ NodeSet.prototype.some = function (pred) {
+ return ts.forEachEntry(this.map, pred) || false;
+ };
+ return NodeSet;
+ }());
+ ts.NodeSet = NodeSet;
})(ts || (ts = {}));
// Display-part writer helpers
/* @internal */
@@ -86430,20 +86712,22 @@ 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 290 /* JSDocParameterTag */:
+ case 292 /* JSDocParameterTag */:
processJSDocParameterTag(tag);
break;
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
processJSDocTemplateTag(tag);
+ pos = tag.end;
break;
- case 292 /* JSDocTypeTag */:
+ case 294 /* JSDocTypeTag */:
processElement(tag.typeExpression);
+ pos = tag.end;
break;
- case 291 /* JSDocReturnTag */:
+ case 293 /* JSDocReturnTag */:
processElement(tag.typeExpression);
+ pos = tag.end;
break;
}
- pos = tag.end;
}
}
if (pos !== docComment.end) {
@@ -86811,7 +87095,7 @@ var ts;
for (var path in paths) {
var patterns = paths[path];
if (paths.hasOwnProperty(path) && patterns) {
- var _loop_11 = function (name, kind) {
+ var _loop_12 = function (name, kind) {
// Path mappings may provide a duplicate way to get to something we've already added, so don't add again.
if (!result.some(function (entry) { return entry.name === name; })) {
result.push(nameAndKind(name, kind));
@@ -86819,7 +87103,7 @@ var ts;
};
for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host); _i < _a.length; _i++) {
var _b = _a[_i], name = _b.name, kind = _b.kind;
- _loop_11(name, kind);
+ _loop_12(name, kind);
}
}
}
@@ -86835,7 +87119,7 @@ var ts;
// (But do if we didn't find anything, e.g. 'package.json' missing.)
var foundGlobal = false;
if (fragmentDirectory === undefined) {
- var _loop_12 = function (moduleName) {
+ var _loop_13 = function (moduleName) {
if (!result.some(function (entry) { return entry.name === moduleName; })) {
foundGlobal = true;
result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */));
@@ -86843,7 +87127,7 @@ var ts;
};
for (var _e = 0, _f = enumerateNodeModulesVisibleToScript(host, scriptPath); _e < _f.length; _e++) {
var moduleName = _f[_e];
- _loop_12(moduleName);
+ _loop_13(moduleName);
}
}
if (!foundGlobal) {
@@ -87736,7 +88020,7 @@ var ts;
currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true);
if (!currentToken ||
(!ts.isDeclarationName(currentToken) &&
- (currentToken.parent.kind !== 295 /* JSDocPropertyTag */ ||
+ (currentToken.parent.kind !== 297 /* JSDocPropertyTag */ ||
currentToken.parent.name !== currentToken))) {
// Use as type location if inside tag's type expression
insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression);
@@ -87897,11 +88181,11 @@ var ts;
return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer };
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
- case 290 /* JSDocParameterTag */:
- case 295 /* JSDocPropertyTag */:
- case 291 /* JSDocReturnTag */:
- case 292 /* JSDocTypeTag */:
- case 294 /* JSDocTypedefTag */:
+ case 292 /* JSDocParameterTag */:
+ case 297 /* JSDocPropertyTag */:
+ case 293 /* JSDocReturnTag */:
+ case 294 /* JSDocTypeTag */:
+ case 296 /* JSDocTypedefTag */:
return true;
}
}
@@ -88939,7 +89223,7 @@ var ts;
function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) {
// class c { method() { } | method2() { } }
switch (location.kind) {
- case 296 /* SyntaxList */:
+ case 298 /* 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);
@@ -90189,8 +90473,8 @@ var ts;
case "symbol": {
var symbol = def.symbol;
var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind;
- var name_4 = displayParts_1.map(function (p) { return p.text; }).join("");
- return { node: symbol.declarations ? ts.getNameOfDeclaration(ts.first(symbol.declarations)) || ts.first(symbol.declarations) : originalNode, name: name_4, kind: kind_1, displayParts: displayParts_1 };
+ var name_3 = displayParts_1.map(function (p) { return p.text; }).join("");
+ return { node: symbol.declarations ? ts.getNameOfDeclaration(ts.first(symbol.declarations)) || ts.first(symbol.declarations) : originalNode, name: name_3, kind: kind_1, displayParts: displayParts_1 };
}
case "label": {
var node_3 = def.node;
@@ -90198,8 +90482,8 @@ var ts;
}
case "keyword": {
var node_4 = def.node;
- var name_5 = ts.tokenToString(node_4.kind);
- return { node: node_4, name: name_5, kind: "keyword" /* keyword */, displayParts: [{ text: name_5, kind: "keyword" /* keyword */ }] };
+ var name_4 = ts.tokenToString(node_4.kind);
+ return { node: node_4, name: name_4, kind: "keyword" /* keyword */, displayParts: [{ text: name_4, kind: "keyword" /* keyword */ }] };
}
case "this": {
var node_5 = def.node;
@@ -91568,14 +91852,14 @@ var ts;
function getReferenceAtPosition(sourceFile, position, program) {
var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position);
if (referencePath) {
- var file_15 = ts.tryResolveScriptReference(program, sourceFile, referencePath);
- return file_15 && { fileName: referencePath.fileName, file: file_15 };
+ var file_16 = ts.tryResolveScriptReference(program, sourceFile, referencePath);
+ return file_16 && { fileName: referencePath.fileName, file: file_16 };
}
var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
if (typeReferenceDirective) {
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
- var file_16 = reference && program.getSourceFile(reference.resolvedFileName);
- return file_16 && { fileName: typeReferenceDirective.fileName, file: file_16 };
+ var file_17 = reference && program.getSourceFile(reference.resolvedFileName);
+ return file_17 && { fileName: typeReferenceDirective.fileName, file: file_17 };
}
return undefined;
}
@@ -91747,6 +92031,7 @@ var ts;
"author",
"argument",
"borrows",
+ "callback",
"class",
"constant",
"constructor",
@@ -91811,10 +92096,12 @@ var ts;
JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations;
function getCommentHavingNodes(declaration) {
switch (declaration.kind) {
- case 295 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */:
+ case 297 /* JSDocPropertyTag */:
return [declaration];
- case 294 /* JSDocTypedefTag */:
- return [declaration.parent];
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ return [declaration, declaration.parent];
default:
return ts.getJSDocCommentsAndTags(declaration);
}
@@ -91834,15 +92121,16 @@ var ts;
function getCommentText(tag) {
var comment = tag.comment;
switch (tag.kind) {
- case 288 /* JSDocAugmentsTag */:
+ case 289 /* JSDocAugmentsTag */:
return withNode(tag.class);
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
return withList(tag.typeParameters);
- case 292 /* JSDocTypeTag */:
+ case 294 /* JSDocTypeTag */:
return withNode(tag.typeExpression);
- case 294 /* JSDocTypedefTag */:
- case 295 /* JSDocPropertyTag */:
- case 290 /* JSDocParameterTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ case 297 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */:
var name = tag.name;
return name ? withNode(name) : comment;
default:
@@ -92460,7 +92748,7 @@ var ts;
if (!patternMatcher)
return ts.emptyArray;
var rawItems = [];
- var _loop_13 = function (sourceFile) {
+ var _loop_14 = function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) {
return "continue";
@@ -92472,7 +92760,7 @@ var ts;
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) {
var sourceFile = sourceFiles_7[_i];
- _loop_13(sourceFile);
+ _loop_14(sourceFile);
}
rawItems.sort(compareNavigateToItems);
if (maxResultCount !== undefined) {
@@ -92849,7 +93137,7 @@ var ts;
if (ts.hasJSDocNodes(node)) {
ts.forEach(node.jsDoc, function (jsDoc) {
ts.forEach(jsDoc.tags, function (tag) {
- if (tag.kind === 294 /* JSDocTypedefTag */) {
+ if (ts.isJSDocTypeAlias(tag)) {
addLeafNode(tag);
}
});
@@ -92962,8 +93250,6 @@ var ts;
case 192 /* ArrowFunction */:
case 204 /* ClassExpression */:
return getFunctionOrClassName(node);
- case 294 /* JSDocTypedefTag */:
- return getJSDocTypedefTagName(node);
default:
return undefined;
}
@@ -93005,29 +93291,10 @@ var ts;
return "()";
case 159 /* IndexSignature */:
return "[]";
- case 294 /* JSDocTypedefTag */:
- return getJSDocTypedefTagName(node);
default:
return "";
}
}
- function getJSDocTypedefTagName(node) {
- if (node.name) {
- return node.name.text;
- }
- else {
- var parentNode = node.parent && node.parent.parent;
- if (parentNode && parentNode.kind === 213 /* VariableStatement */) {
- if (parentNode.declarationList.declarations.length > 0) {
- var nameIdentifier = parentNode.declarationList.declarations[0].name;
- if (nameIdentifier.kind === 71 /* Identifier */) {
- return nameIdentifier.text;
- }
- }
- }
- return "";
- }
- }
/** Flattens the NavNode tree to a list, keeping only the top-level items. */
function topLevelItems(root) {
var topLevel = [];
@@ -93053,7 +93320,8 @@ var ts;
case 238 /* ModuleDeclaration */:
case 273 /* SourceFile */:
case 236 /* TypeAliasDeclaration */:
- case 294 /* JSDocTypedefTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
return true;
case 154 /* Constructor */:
case 153 /* MethodDeclaration */:
@@ -93979,13 +94247,13 @@ var ts;
// Assumes 'value' is already lowercase.
function indexOfIgnoringCase(str, value) {
var n = str.length - value.length;
- var _loop_14 = function (start) {
+ var _loop_15 = function (start) {
if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
return { value: start };
}
};
for (var start = 0; start <= n; start++) {
- var state_4 = _loop_14(start);
+ var state_4 = _loop_15(start);
if (typeof state_4 === "object")
return state_4.value;
}
@@ -94653,7 +94921,7 @@ var ts;
var nameToDeclarations = sourceFile.getNamedDeclarations();
var declarations = nameToDeclarations.get(name.text);
if (declarations) {
- var _loop_15 = function (declaration) {
+ var _loop_16 = function (declaration) {
var symbol = declaration.symbol;
if (symbol) {
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
@@ -94667,7 +94935,7 @@ var ts;
};
for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) {
var declaration = declarations_12[_b];
- var state_5 = _loop_15(declaration);
+ var state_5 = _loop_16(declaration);
if (typeof state_5 === "object")
return state_5.value;
}
@@ -95065,7 +95333,7 @@ var ts;
}
}
}
- return diags.concat(checker.getSuggestionDiagnostics(sourceFile));
+ return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort(function (d1, d2) { return d1.start - d2.start; });
}
ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics;
// convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
@@ -95821,7 +96089,7 @@ var ts;
return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; });
});
options = ts.cloneCompilerOptions(options);
- var _loop_16 = function (opt) {
+ var _loop_17 = function (opt) {
if (!ts.hasProperty(options, opt.name)) {
return "continue";
}
@@ -95840,7 +96108,7 @@ var ts;
};
for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
var opt = commandLineOptionsStringToEnum_1[_i];
- _loop_16(opt);
+ _loop_17(opt);
}
return options;
}
@@ -98584,7 +98852,7 @@ var ts;
this.formatContext = formatContext;
this.changes = [];
this.newFiles = [];
- this.deletedNodesInLists = []; // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
+ this.deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
this.classesWithNodesInsertedAtStart = ts.createMap(); // Set implemented as Map
}
ChangeTracker.fromContext = function (context) {
@@ -98628,35 +98896,14 @@ var ts;
this.deleteNode(sourceFile, node);
return this;
}
- var id = ts.getNodeId(node);
- ts.Debug.assert(!this.deletedNodesInLists[id], "Deleting a node twice");
- this.deletedNodesInLists[id] = true;
- if (index !== containingList.length - 1) {
- var nextToken = ts.getTokenAtPosition(sourceFile, node.end, /*includeJsDocComment*/ false);
- if (nextToken && isSeparator(node, nextToken)) {
- // find first non-whitespace position in the leading trivia of the node
- var startPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
- var nextElement = containingList[index + 1];
- /// find first non-whitespace position in the leading trivia of the next node
- var endPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
- // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node
- this.deleteRange(sourceFile, { pos: startPosition, end: endPosition });
- }
- }
- else {
- var prev = containingList[index - 1];
- if (this.deletedNodesInLists[ts.getNodeId(prev)]) {
- var pos = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
- var end = getAdjustedEndPosition(sourceFile, node, {});
- this.deleteRange(sourceFile, { pos: pos, end: end });
- }
- else {
- var previousToken = ts.getTokenAtPosition(sourceFile, containingList[index - 1].end, /*includeJsDocComment*/ false);
- if (previousToken && isSeparator(node, previousToken)) {
- this.deleteNodeRange(sourceFile, previousToken, node);
- }
- }
- }
+ // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node.
+ // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`.
+ ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice");
+ this.deletedNodesInLists.add(node);
+ this.deleteRange(sourceFile, {
+ pos: startPositionToDeleteNodeInList(sourceFile, node),
+ end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]),
+ });
return this;
};
ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) {
@@ -99017,6 +99264,19 @@ var ts;
}
});
};
+ ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () {
+ var _this = this;
+ this.deletedNodesInLists.forEach(function (node) {
+ var sourceFile = node.getSourceFile();
+ var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile);
+ if (node !== ts.last(list))
+ return;
+ var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2);
+ if (lastNonDeletedIndex !== -1) {
+ _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) });
+ }
+ });
+ };
/**
* Note: after calling this, the TextChanges object must be discarded!
* @param validate only for tests
@@ -99025,6 +99285,7 @@ var ts;
*/
ChangeTracker.prototype.getChanges = function (validate) {
this.finishClassesWithNodesInsertedAtStart();
+ this.finishTrailingCommaAfterDeletingNodesInList();
var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate);
for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) {
var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements;
@@ -99038,6 +99299,10 @@ var ts;
return ChangeTracker;
}());
textChanges_3.ChangeTracker = ChangeTracker;
+ // find first non-whitespace position in the leading trivia of the node
+ function startPositionToDeleteNodeInList(sourceFile, node) {
+ return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
+ }
function getClassBraceEnds(cls, sourceFile) {
return [ts.findChildOfKind(cls, 17 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile).end];
}
@@ -99049,14 +99314,14 @@ var ts;
// 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.
var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
- var _loop_17 = function (i) {
+ var _loop_18 = function (i) {
ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
});
};
// verify that change intervals do not overlap, except possibly at end points.
for (var i = 0; i < normalized.length - 1; i++) {
- _loop_17(i);
+ _loop_18(i);
}
var textChanges = normalized.map(function (c) {
return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate));
@@ -99491,7 +99756,7 @@ var ts;
if (ts.isFunctionLikeDeclaration(decl) && (ts.getJSDocReturnType(decl) || decl.parameters.some(function (p) { return !!ts.getJSDocType(p); }))) {
if (!decl.typeParameters) {
var typeParameters = ts.getJSDocTypeParameterDeclarations(decl);
- if (typeParameters)
+ if (typeParameters.length)
changes.insertTypeParameters(sourceFile, decl, typeParameters);
}
var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 19 /* OpenParenToken */, sourceFile);
@@ -101335,13 +101600,13 @@ var ts;
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); });
return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)];
}
- var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start); });
+ var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start, /*deleted*/ undefined); });
if (delDestructure.length) {
return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)];
}
var token = getToken(sourceFile, ts.textSpanEnd(context.span));
var result = [];
- var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token); });
+ var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined); });
if (deletion.length) {
result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations));
}
@@ -101352,49 +101617,60 @@ var ts;
return result;
},
fixIds: [fixIdPrefix, fixIdDelete],
- getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
- var sourceFile = context.sourceFile;
- var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file);
- switch (context.fixId) {
- case fixIdPrefix:
- if (ts.isIdentifier(token) && canPrefix(token)) {
- tryPrefixDeclaration(changes, diag.code, sourceFile, token);
- }
- break;
- case fixIdDelete:
- var importDecl = tryGetFullImport(diag.file, diag.start);
- if (importDecl) {
- changes.deleteNode(sourceFile, importDecl);
- }
- else {
- if (!tryDeleteFullDestructure(changes, sourceFile, diag.start)) {
- tryDeleteDeclaration(changes, sourceFile, token);
+ getAllCodeActions: function (context) {
+ // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors.
+ var deleted = new NodeSet();
+ return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ var sourceFile = context.sourceFile;
+ var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file);
+ switch (context.fixId) {
+ case fixIdPrefix:
+ if (ts.isIdentifier(token) && canPrefix(token)) {
+ tryPrefixDeclaration(changes, diag.code, sourceFile, token);
}
- }
- break;
- default:
- ts.Debug.fail(JSON.stringify(context.fixId));
- }
- }); },
+ break;
+ case fixIdDelete:
+ // Ignore if this range was already deleted.
+ if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); }))
+ break;
+ var importDecl = tryGetFullImport(diag.file, diag.start);
+ if (importDecl) {
+ changes.deleteNode(sourceFile, importDecl);
+ }
+ else {
+ if (!tryDeleteFullDestructure(changes, sourceFile, diag.start, deleted)) {
+ tryDeleteDeclaration(changes, sourceFile, token, deleted);
+ }
+ }
+ break;
+ default:
+ ts.Debug.fail(JSON.stringify(context.fixId));
+ }
+ });
+ },
});
// Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing.
function tryGetFullImport(sourceFile, pos) {
var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined;
}
- function tryDeleteFullDestructure(changes, sourceFile, pos) {
+ function tryDeleteFullDestructure(changes, sourceFile, pos, deletedAncestors) {
var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent))
return false;
var decl = startToken.parent.parent;
switch (decl.kind) {
case 231 /* VariableDeclaration */:
- tryDeleteVariableDeclaration(changes, sourceFile, decl);
+ tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors);
break;
case 148 /* Parameter */:
+ if (deletedAncestors)
+ deletedAncestors.add(decl);
changes.deleteNodeInList(sourceFile, decl);
break;
case 181 /* BindingElement */:
+ if (deletedAncestors)
+ deletedAncestors.add(decl);
changes.deleteNode(sourceFile, decl);
break;
default:
@@ -101403,7 +101679,7 @@ var ts;
return true;
}
function getToken(sourceFile, pos) {
- var token = ts.findPrecedingToken(pos, sourceFile);
+ var token = ts.findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true);
// this handles var ["computed"] = 12;
return token.kind === 22 /* CloseBracketToken */ ? ts.findPrecedingToken(pos - 1, sourceFile) : token;
}
@@ -101428,38 +101704,45 @@ var ts;
}
return false;
}
- function tryDeleteDeclaration(changes, sourceFile, token) {
+ function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors) {
switch (token.kind) {
case 71 /* Identifier */:
- tryDeleteIdentifier(changes, sourceFile, token);
+ tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors);
break;
case 151 /* PropertyDeclaration */:
case 245 /* NamespaceImport */:
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent);
changes.deleteNode(sourceFile, token.parent);
break;
default:
- tryDeleteDefault(changes, sourceFile, token);
+ tryDeleteDefault(changes, sourceFile, token, deletedAncestors);
}
}
- function tryDeleteDefault(changes, sourceFile, token) {
+ function tryDeleteDefault(changes, sourceFile, token, deletedAncestors) {
if (ts.isDeclarationName(token)) {
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent);
changes.deleteNode(sourceFile, token.parent);
}
else if (ts.isLiteralComputedPropertyDeclarationName(token)) {
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent.parent);
changes.deleteNode(sourceFile, token.parent.parent);
}
}
- function tryDeleteIdentifier(changes, sourceFile, identifier) {
+ function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors) {
var parent = identifier.parent;
switch (parent.kind) {
case 231 /* VariableDeclaration */:
- tryDeleteVariableDeclaration(changes, sourceFile, parent);
+ tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors);
break;
case 147 /* TypeParameter */:
- var typeParameters = parent.parent.typeParameters;
+ var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent);
if (typeParameters.length === 1) {
- var previousToken = ts.getTokenAtPosition(sourceFile, typeParameters.pos - 1, /*includeJsDocComment*/ false);
- var nextToken = ts.getTokenAtPosition(sourceFile, typeParameters.end, /*includeJsDocComment*/ false);
+ var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end;
+ var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false);
+ var nextToken = ts.getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false);
ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */);
ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */);
changes.deleteNodeRange(sourceFile, previousToken, nextToken);
@@ -101542,7 +101825,7 @@ var ts;
tryDeleteNamedImportBinding(changes, sourceFile, parent);
break;
default:
- tryDeleteDefault(changes, sourceFile, identifier);
+ tryDeleteDefault(changes, sourceFile, identifier, deletedAncestors);
break;
}
}
@@ -101565,15 +101848,19 @@ var ts;
}
}
// token.parent is a variableDeclaration
- function tryDeleteVariableDeclaration(changes, sourceFile, varDecl) {
+ function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) {
switch (varDecl.parent.parent.kind) {
case 219 /* ForStatement */: {
var forStatement = varDecl.parent.parent;
var forInitializer = forStatement.initializer;
if (forInitializer.declarations.length === 1) {
+ if (deletedAncestors)
+ deletedAncestors.add(forInitializer);
changes.deleteNode(sourceFile, forInitializer);
}
else {
+ if (deletedAncestors)
+ deletedAncestors.add(varDecl);
changes.deleteNodeInList(sourceFile, varDecl);
}
break;
@@ -101582,6 +101869,8 @@ var ts;
var forOfStatement = varDecl.parent.parent;
ts.Debug.assert(forOfStatement.initializer.kind === 232 /* VariableDeclarationList */);
var forOfInitializer = forOfStatement.initializer;
+ if (deletedAncestors)
+ deletedAncestors.add(forOfInitializer.declarations[0]);
changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral());
break;
case 220 /* ForInStatement */:
@@ -101590,13 +101879,29 @@ var ts;
default:
var variableStatement = varDecl.parent.parent;
if (variableStatement.declarationList.declarations.length === 1) {
+ if (deletedAncestors)
+ deletedAncestors.add(variableStatement);
changes.deleteNode(sourceFile, variableStatement);
}
else {
+ if (deletedAncestors)
+ deletedAncestors.add(varDecl);
changes.deleteNodeInList(sourceFile, varDecl);
}
}
}
+ var NodeSet = /** @class */ (function () {
+ function NodeSet() {
+ this.map = ts.createMap();
+ }
+ NodeSet.prototype.add = function (node) {
+ this.map.set(String(ts.getNodeId(node)), node);
+ };
+ NodeSet.prototype.some = function (pred) {
+ return ts.forEachEntry(this.map, pred) || false;
+ };
+ return NodeSet;
+ }());
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
/* @internal */
@@ -101669,21 +101974,7 @@ var ts;
}
// Calls 'cb' with the start and end of each range where 'pred' is true.
function split(arr, pred, cb) {
- var start;
- for (var i = 0; i < arr.length; i++) {
- var value = arr[i];
- if (pred(value)) {
- start = start || value;
- }
- else {
- if (start) {
- cb(start, arr[i - 1]);
- start = undefined;
- }
- }
- }
- if (start)
- cb(start, arr[arr.length - 1]);
+ ts.getRangesWhere(arr, pred, function (start, afterEnd) { return cb(arr[start], arr[afterEnd - 1]); });
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -103169,6 +103460,39 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
+ var fixId = fixIdAddMissingTypeof;
+ var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, span = context.span;
+ var importType = getImportTypeNode(sourceFile, span.start);
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, importType); });
+ return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_missing_typeof, fixId, ts.Diagnostics.Add_missing_typeof)];
+ },
+ fixIds: [fixId],
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ return doChange(changes, context.sourceFile, getImportTypeNode(diag.file, diag.start));
+ }); },
+ });
+ function getImportTypeNode(sourceFile, pos) {
+ var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
+ ts.Debug.assert(token.kind === 91 /* ImportKeyword */);
+ ts.Debug.assert(token.parent.kind === 178 /* ImportType */);
+ return token.parent;
+ }
+ function doChange(changes, sourceFile, importType) {
+ var newTypeNode = ts.updateImportTypeNode(importType, importType.argument, importType.qualifier, importType.typeArguments, /* isTypeOf */ true);
+ changes.replaceNode(sourceFile, importType, newTypeNode);
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var refactor;
(function (refactor) {
@@ -104362,8 +104686,8 @@ var ts;
i_1++;
}
// Note that we add the current node's type parameters *after* updating the corresponding scope.
- if (ts.isDeclarationWithTypeParameters(curr) && curr.typeParameters) {
- for (var _a = 0, _b = curr.typeParameters; _a < _b.length; _a++) {
+ if (ts.isDeclarationWithTypeParameters(curr)) {
+ for (var _a = 0, _b = ts.getEffectiveTypeParameterDeclarations(curr); _a < _b.length; _a++) {
var typeParameterDecl = _b[_a];
var typeParameter = checker.getTypeAtLocation(typeParameterDecl);
if (allTypeParameterUsages.has(typeParameter.id.toString())) {
@@ -104385,7 +104709,7 @@ var ts;
: ts.getEnclosingBlockScopeContainer(scopes[0]);
ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
}
- var _loop_18 = function (i) {
+ var _loop_19 = function (i) {
var scopeUsages = usagesPerScope[i];
// Special case: in the innermost scope, all usages are available.
// (The computed value reflects the value at the top-level of the scope, but the
@@ -104425,21 +104749,11 @@ var ts;
}
};
for (var i = 0; i < scopes.length; i++) {
- _loop_18(i);
+ _loop_19(i);
}
return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
- function hasTypeParameters(node) {
- return ts.isDeclarationWithTypeParameters(node) &&
- node.typeParameters !== undefined &&
- node.typeParameters.length > 0;
- }
function isInGenericContext(node) {
- for (; node; node = node.parent) {
- if (hasTypeParameters(node)) {
- return true;
- }
- }
- return false;
+ return !!ts.findAncestor(node, function (n) { return ts.isDeclarationWithTypeParameters(n) && ts.getEffectiveTypeParameterDeclarations(n).length !== 0; });
}
function recordTypeParameterUsages(type) {
// PERF: This is potentially very expensive. `type` could be a library type with
@@ -104704,8 +105018,8 @@ var ts;
var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message;
refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions });
function getAvailableActions(context) {
- var file = context.file, startPosition = context.startPosition;
- if (!getConvertibleFieldAtPosition(file, startPosition))
+ var file = context.file;
+ if (!getConvertibleFieldAtPosition(context, file))
return undefined;
return [{
name: actionName,
@@ -104719,8 +105033,8 @@ var ts;
}];
}
function getEditsForAction(context, _actionName) {
- var file = context.file, startPosition = context.startPosition;
- var fieldInfo = getConvertibleFieldAtPosition(file, startPosition);
+ var file = context.file;
+ var fieldInfo = getConvertibleFieldAtPosition(context, file);
if (!fieldInfo)
return undefined;
var isJS = ts.isSourceFileJavaScript(file);
@@ -104781,12 +105095,14 @@ var ts;
function startsWithUnderscore(name) {
return name.charCodeAt(0) === 95 /* _ */;
}
- function getConvertibleFieldAtPosition(file, startPosition) {
+ function getConvertibleFieldAtPosition(context, file) {
+ var startPosition = context.startPosition, endPosition = context.endPosition;
var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false);
var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration);
// make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier
var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */;
- if (!declaration || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning)
+ if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition)
+ || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning)
return undefined;
var name = declaration.name.text;
var startWithUnderscore = startsWithUnderscore(name);
@@ -104874,7 +105190,7 @@ var ts;
var refactorName = "Move to a new file";
refactor.registerRefactor(refactorName, {
getAvailableActions: function (context) {
- if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined)
+ if (!context.preferences.allowTextChangesInNewFiles || getFirstAndLastStatementToMove(context) === undefined)
return undefined;
var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file);
return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }];
@@ -104886,7 +105202,7 @@ var ts;
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
}
});
- function getStatementsToMove(context) {
+ function getFirstAndLastStatementToMove(context) {
var file = context.file;
var range = ts.createTextRangeFromSpan(ts.getRefactorContextSpan(context));
var statements = file.statements;
@@ -104900,11 +105216,11 @@ var ts;
// Can't be partially into the next node
if (afterEndNodeIndex !== -1 && (afterEndNodeIndex === 0 || statements[afterEndNodeIndex].getStart(file) < range.end))
return undefined;
- return statements.slice(startNodeIndex, afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex);
+ return { first: startNodeIndex, afterLast: afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex };
}
function doChange(oldFile, program, toMove, changes, host) {
var checker = program.getTypeChecker();
- var usage = getUsageInfo(oldFile, toMove, checker);
+ var usage = getUsageInfo(oldFile, toMove.all, checker);
var currentDirectory = ts.getDirectoryPath(oldFile.fileName);
var extension = ts.extensionFromPath(oldFile.fileName);
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host);
@@ -104913,6 +105229,32 @@ var ts;
changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatements(oldFile, usage, changes, toMove, program, newModuleName));
addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host));
}
+ // Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file.
+ function getStatementsToMove(context) {
+ var statements = context.file.statements;
+ var _a = getFirstAndLastStatementToMove(context), first = _a.first, afterLast = _a.afterLast;
+ var all = [];
+ var ranges = [];
+ var rangeToMove = statements.slice(first, afterLast);
+ ts.getRangesWhere(rangeToMove, function (s) { return !isPureImport(s); }, function (start, afterEnd) {
+ for (var i = start; i < afterEnd; i++)
+ all.push(rangeToMove[i]);
+ ranges.push({ first: rangeToMove[start], last: rangeToMove[afterEnd - 1] });
+ });
+ return { all: all, ranges: ranges };
+ }
+ function isPureImport(node) {
+ switch (node.kind) {
+ case 243 /* ImportDeclaration */:
+ return true;
+ case 242 /* ImportEqualsDeclaration */:
+ return !ts.hasModifier(node, 1 /* Export */);
+ case 213 /* VariableStatement */:
+ return node.declarationList.declarations.every(function (d) { return ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); });
+ default:
+ return false;
+ }
+ }
function addNewFileToTsconfig(program, changes, oldFileName, newFileNameWithExtension, getCanonicalFileName) {
var cfg = program.getCompilerOptions().configFile;
if (!cfg)
@@ -104930,18 +105272,24 @@ var ts;
function getNewStatements(oldFile, usage, changes, toMove, program, newModuleName) {
var checker = program.getTypeChecker();
if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
- changes.deleteNodeRange(oldFile, ts.first(toMove), ts.last(toMove));
- return toMove;
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
+ return toMove.all;
}
var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator;
var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax);
if (importsFromNewFile) {
changes.insertNodeBefore(oldFile, oldFile.statements[0], importsFromNewFile, /*blankLineBetween*/ true);
}
- deleteUnusedOldImports(oldFile, toMove, changes, usage.unusedImportsFromOldFile, checker);
- changes.deleteNodeRange(oldFile, ts.first(toMove), ts.last(toMove));
+ deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
- return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax));
+ return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax));
+ }
+ function deleteMovedStatements(sourceFile, moved, changes) {
+ for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) {
+ var _a = moved_1[_i], first_1 = _a.first, last_3 = _a.last;
+ changes.deleteNodeRange(sourceFile, first_1, last_3);
+ }
}
function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) {
for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) {
@@ -104953,10 +105301,10 @@ var ts;
}
function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
var checker = program.getTypeChecker();
- var _loop_19 = function (sourceFile) {
+ var _loop_20 = function (sourceFile) {
if (sourceFile === oldFile)
return "continue";
- var _loop_20 = function (statement) {
+ var _loop_21 = function (statement) {
forEachImportInStatement(statement, function (importNode) {
var shouldMove = function (name) {
var symbol = ts.isBindingElement(name.parent)
@@ -104973,12 +105321,12 @@ var ts;
};
for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
var statement = _a[_i];
- _loop_20(statement);
+ _loop_21(statement);
}
};
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
- _loop_19(sourceFile);
+ _loop_20(sourceFile);
}
}
function moduleSpecifierFromImport(i) {
@@ -105225,12 +105573,14 @@ var ts;
}
function isVariableDeclarationInImport(decl) {
return ts.isSourceFile(decl.parent.parent.parent) &&
- ts.isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true);
+ decl.initializer && ts.isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true);
}
function filterImport(i, moduleSpecifier, keep) {
switch (i.kind) {
case 243 /* ImportDeclaration */: {
var clause = i.importClause;
+ if (!clause)
+ return undefined;
var defaultImport = clause.name && keep(clause.name) ? clause.name : undefined;
var namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep);
return defaultImport || namedBindings
@@ -105754,7 +106104,7 @@ var ts;
if (!children.length) {
return undefined;
}
- var child = ts.find(children, function (kid) { return kid.kind < 277 /* FirstJSDocNode */ || kid.kind > 295 /* LastJSDocNode */; });
+ var child = ts.find(children, function (kid) { return kid.kind < 277 /* FirstJSDocNode */ || kid.kind > 297 /* LastJSDocNode */; });
return child.kind < 145 /* FirstNode */ ?
child :
child.getFirstToken(sourceFile);
@@ -105824,7 +106174,7 @@ var ts;
}
}
function createSyntaxList(nodes, parent) {
- var list = createNode(296 /* SyntaxList */, nodes.pos, nodes.end, parent);
+ var list = createNode(298 /* SyntaxList */, nodes.pos, nodes.end, parent);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) {
@@ -106961,15 +107311,15 @@ var ts;
if (original === void 0) { original = input; }
var info = extract(input);
if (ts.endsWith(info.fileName, ".d.ts" /* Dts */)) {
- var file_17 = program.getSourceFile(info.fileName);
- if (!file_17) {
+ var file_18 = program.getSourceFile(info.fileName);
+ if (!file_18) {
var path = ts.toPath(info.fileName, currentDirectory, getCanonicalFileName);
- file_17 = sourcemappedFileCache.get(path);
+ file_18 = sourcemappedFileCache.get(path);
}
- if (!file_17) {
+ if (!file_18) {
return input;
}
- var mapper = getSourceMapper(info.fileName, file_17);
+ var mapper = getSourceMapper(info.fileName, file_18);
var newLoc = mapper.getOriginalPosition(info);
if (newLoc === info)
return input;
@@ -110660,9 +111010,9 @@ var ts;
this.hasAddedorRemovedFiles = false;
var changedFiles = this.resolutionCache.finishRecordingFilesWithChangedResolutions() || server.emptyArray;
for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) {
- var file_18 = changedFiles_1[_i];
+ var file_19 = changedFiles_1[_i];
// delete cached information for changed files
- this.cachedUnresolvedImportsPerFile.delete(file_18);
+ this.cachedUnresolvedImportsPerFile.delete(file_19);
}
// update builder only if language service is enabled
// otherwise tell it to drop its internal state
@@ -110806,8 +111156,8 @@ var ts;
var strBuilder = "\tFiles (" + sourceFiles.length + ")\n";
if (writeProjectFileNames) {
for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) {
- var file_19 = sourceFiles_8[_i];
- strBuilder += "\t" + file_19.fileName + "\n";
+ var file_20 = sourceFiles_8[_i];
+ strBuilder += "\t" + file_20.fileName + "\n";
}
}
return strBuilder;
@@ -110893,7 +111243,7 @@ var ts;
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations);
if (this.projectService.globalPlugins) {
- var _loop_21 = function (globalPluginName) {
+ var _loop_22 = function (globalPluginName) {
// Skip empty names from odd commandline parses
if (!globalPluginName)
return "continue";
@@ -110908,7 +111258,7 @@ var ts;
// Enable global plugins with synthetic configuration entries
for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
var globalPluginName = _a[_i];
- _loop_21(globalPluginName);
+ _loop_22(globalPluginName);
}
}
};
@@ -111875,7 +112225,7 @@ var ts;
}
project.updateGraph();
if (!this.useSingleInferredProject && !project.projectRootPath) {
- var _loop_22 = function (inferredProject) {
+ var _loop_23 = function (inferredProject) {
if (inferredProject === project || inferredProject.isOrphan()) {
return "continue";
}
@@ -111896,7 +112246,7 @@ var ts;
// Note that we need to create a copy of the array since the list of project can change
for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) {
var inferredProject = _a[_i];
- _loop_22(inferredProject);
+ _loop_23(inferredProject);
}
}
return project;
@@ -112624,7 +112974,7 @@ var ts;
return projects;
function combineProjects(toAddInfo) {
if (toAddInfo !== info) {
- var _loop_23 = function (project) {
+ var _loop_24 = function (project) {
// Add the projects only if they can use symLink targets and not already in the list
if (project.languageServiceEnabled &&
!project.isOrphan() &&
@@ -112641,7 +112991,7 @@ var ts;
};
for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) {
var project = _a[_i];
- _loop_23(project);
+ _loop_24(project);
}
}
}
@@ -112980,13 +113330,13 @@ var ts;
this.printProjects();
};
ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) {
- var _loop_24 = function (proj) {
+ var _loop_25 = function (proj) {
var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; });
result.push(proj.getChangesSinceVersion(knownProject && knownProject.version));
};
for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) {
var proj = currentProjects_1[_i];
- _loop_24(proj);
+ _loop_25(proj);
}
};
/* @internal */
@@ -113001,25 +113351,25 @@ var ts;
ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) {
if (openFiles) {
for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) {
- var file_20 = openFiles_1[_i];
- var scriptInfo = this.getScriptInfo(file_20.fileName);
+ var file_21 = openFiles_1[_i];
+ var scriptInfo = this.getScriptInfo(file_21.fileName);
ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen(), "Script should not exist and not be open already");
- var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file_20.fileName);
- this.openClientFileWithNormalizedPath(normalizedPath, file_20.content, tryConvertScriptKindName(file_20.scriptKind), file_20.hasMixedContent);
+ var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file_21.fileName);
+ this.openClientFileWithNormalizedPath(normalizedPath, file_21.content, tryConvertScriptKindName(file_21.scriptKind), file_21.hasMixedContent);
}
}
if (changedFiles) {
for (var _a = 0, changedFiles_2 = changedFiles; _a < changedFiles_2.length; _a++) {
- var file_21 = changedFiles_2[_a];
- var scriptInfo = this.getScriptInfo(file_21.fileName);
+ var file_22 = changedFiles_2[_a];
+ var scriptInfo = this.getScriptInfo(file_22.fileName);
ts.Debug.assert(!!scriptInfo);
- this.applyChangesToFile(scriptInfo, file_21.changes);
+ this.applyChangesToFile(scriptInfo, file_22.changes);
}
}
if (closedFiles) {
for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) {
- var file_22 = closedFiles_1[_b];
- this.closeClientFile(file_22);
+ var file_23 = closedFiles_1[_b];
+ this.closeClientFile(file_23);
}
}
};
@@ -113095,7 +113445,7 @@ var ts;
var excludeRules = [];
var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); });
var excludedFiles = [];
- var _loop_25 = function (name) {
+ var _loop_26 = function (name) {
var rule_2 = this_2.safelist[name];
for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) {
var root = normalizedNames_1[_i];
@@ -113113,7 +113463,7 @@ var ts;
}
}
if (rule_2.exclude) {
- var _loop_27 = function (exclude) {
+ var _loop_28 = function (exclude) {
var processedRule = root.replace(rule_2.match, function () {
var groups = [];
for (var _i = 0; _i < arguments.length; _i++) {
@@ -113140,7 +113490,7 @@ var ts;
};
for (var _c = 0, _d = rule_2.exclude; _c < _d.length; _c++) {
var exclude = _d[_c];
- _loop_27(exclude);
+ _loop_28(exclude);
}
}
else {
@@ -113156,11 +113506,11 @@ var ts;
var this_2 = this;
for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) {
var name = _a[_i];
- _loop_25(name);
+ _loop_26(name);
}
var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); });
var filesToKeep = [];
- var _loop_26 = function (i) {
+ var _loop_27 = function (i) {
if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) {
excludedFiles.push(normalizedNames[i]);
}
@@ -113198,7 +113548,7 @@ var ts;
};
var this_3 = this;
for (var i = 0; i < proj.rootFiles.length; i++) {
- _loop_26(i);
+ _loop_27(i);
}
proj.rootFiles = filesToKeep;
return excludedFiles;
@@ -113220,15 +113570,15 @@ var ts;
var tsConfigFiles;
var rootFiles = [];
for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) {
- var file_23 = _a[_i];
- var normalized = server.toNormalizedPath(file_23.fileName);
+ var file_24 = _a[_i];
+ var normalized = server.toNormalizedPath(file_24.fileName);
if (server.getBaseConfigFileName(normalized)) {
if (!this.syntaxOnly && this.host.fileExists(normalized)) {
(tsConfigFiles || (tsConfigFiles = [])).push(normalized);
}
}
else {
- rootFiles.push(file_23);
+ rootFiles.push(file_24);
}
}
// sort config files to simplify comparison later
diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts
index ef435632a36..89552e727c2 100644
--- a/lib/typescript.d.ts
+++ b/lib/typescript.d.ts
@@ -349,22 +349,24 @@ declare namespace ts {
JSDocVariadicType = 284,
JSDocComment = 285,
JSDocTypeLiteral = 286,
- JSDocTag = 287,
- JSDocAugmentsTag = 288,
- JSDocClassTag = 289,
- JSDocParameterTag = 290,
- JSDocReturnTag = 291,
- JSDocTypeTag = 292,
- JSDocTemplateTag = 293,
- JSDocTypedefTag = 294,
- JSDocPropertyTag = 295,
- SyntaxList = 296,
- NotEmittedStatement = 297,
- PartiallyEmittedExpression = 298,
- CommaListExpression = 299,
- MergeDeclarationMarker = 300,
- EndOfDeclarationMarker = 301,
- Count = 302,
+ JSDocSignature = 287,
+ JSDocTag = 288,
+ JSDocAugmentsTag = 289,
+ JSDocClassTag = 290,
+ JSDocCallbackTag = 291,
+ JSDocParameterTag = 292,
+ JSDocReturnTag = 293,
+ JSDocTypeTag = 294,
+ JSDocTemplateTag = 295,
+ JSDocTypedefTag = 296,
+ JSDocPropertyTag = 297,
+ SyntaxList = 298,
+ NotEmittedStatement = 299,
+ PartiallyEmittedExpression = 300,
+ CommaListExpression = 301,
+ MergeDeclarationMarker = 302,
+ EndOfDeclarationMarker = 303,
+ Count = 304,
FirstAssignment = 58,
LastAssignment = 70,
FirstCompoundAssignment = 59,
@@ -391,9 +393,9 @@ declare namespace ts {
LastBinaryOperator = 70,
FirstNode = 145,
FirstJSDocNode = 277,
- LastJSDocNode = 295,
- FirstJSDocTagNode = 287,
- LastJSDocTagNode = 295
+ LastJSDocNode = 297,
+ FirstJSDocTagNode = 288,
+ LastJSDocTagNode = 297
}
enum NodeFlags {
None = 0,
@@ -1280,7 +1282,7 @@ declare namespace ts {
block: Block;
}
type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode;
- type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag;
+ type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature;
interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer {
kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression;
name?: Identifier;
@@ -1537,6 +1539,19 @@ declare namespace ts {
name?: Identifier;
typeExpression?: JSDocTypeExpression | JSDocTypeLiteral;
}
+ interface JSDocCallbackTag extends JSDocTag, NamedDeclaration {
+ parent: JSDoc;
+ kind: SyntaxKind.JSDocCallbackTag;
+ fullName?: JSDocNamespaceDeclaration | Identifier;
+ name?: Identifier;
+ typeExpression: JSDocSignature;
+ }
+ interface JSDocSignature extends JSDocType, Declaration {
+ kind: SyntaxKind.JSDocSignature;
+ typeParameters?: ReadonlyArray;
+ parameters: ReadonlyArray;
+ type: JSDocReturnTag | undefined;
+ }
interface JSDocPropertyLikeTag extends JSDocTag, Declaration {
parent: JSDoc;
name: EntityName;
@@ -1885,6 +1900,7 @@ declare namespace ts {
WriteArrayAsGenericType = 2,
GenerateNamesForShadowedTypeParams = 4,
UseStructuralFallback = 8,
+ ForbidIndexedAccessSymbolReferences = 16,
WriteTypeArgumentsOfSignature = 32,
UseFullyQualifiedType = 64,
UseOnlyExternalAliasing = 128,
@@ -2283,7 +2299,7 @@ declare namespace ts {
Construct = 1
}
interface Signature {
- declaration?: SignatureDeclaration;
+ declaration?: SignatureDeclaration | JSDocSignature;
typeParameters?: TypeParameter[];
parameters: Symbol[];
}
@@ -3362,6 +3378,8 @@ declare namespace ts {
function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag;
function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag;
function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral;
+ function isJSDocCallbackTag(node: Node): node is JSDocCallbackTag;
+ function isJSDocSignature(node: Node): node is JSDocSignature;
}
declare namespace ts {
/**
diff --git a/lib/typescript.js b/lib/typescript.js
index 68f66dc8dca..9ccb026f1fd 100644
--- a/lib/typescript.js
+++ b/lib/typescript.js
@@ -365,25 +365,27 @@ var ts;
SyntaxKind[SyntaxKind["JSDocVariadicType"] = 284] = "JSDocVariadicType";
SyntaxKind[SyntaxKind["JSDocComment"] = 285] = "JSDocComment";
SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral";
- SyntaxKind[SyntaxKind["JSDocTag"] = 287] = "JSDocTag";
- SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 288] = "JSDocAugmentsTag";
- SyntaxKind[SyntaxKind["JSDocClassTag"] = 289] = "JSDocClassTag";
- SyntaxKind[SyntaxKind["JSDocParameterTag"] = 290] = "JSDocParameterTag";
- SyntaxKind[SyntaxKind["JSDocReturnTag"] = 291] = "JSDocReturnTag";
- SyntaxKind[SyntaxKind["JSDocTypeTag"] = 292] = "JSDocTypeTag";
- SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 293] = "JSDocTemplateTag";
- SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 294] = "JSDocTypedefTag";
- SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 295] = "JSDocPropertyTag";
+ SyntaxKind[SyntaxKind["JSDocSignature"] = 287] = "JSDocSignature";
+ SyntaxKind[SyntaxKind["JSDocTag"] = 288] = "JSDocTag";
+ SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 289] = "JSDocAugmentsTag";
+ SyntaxKind[SyntaxKind["JSDocClassTag"] = 290] = "JSDocClassTag";
+ SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 291] = "JSDocCallbackTag";
+ SyntaxKind[SyntaxKind["JSDocParameterTag"] = 292] = "JSDocParameterTag";
+ SyntaxKind[SyntaxKind["JSDocReturnTag"] = 293] = "JSDocReturnTag";
+ SyntaxKind[SyntaxKind["JSDocTypeTag"] = 294] = "JSDocTypeTag";
+ SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 295] = "JSDocTemplateTag";
+ SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 296] = "JSDocTypedefTag";
+ SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 297] = "JSDocPropertyTag";
// Synthesized list
- SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList";
+ SyntaxKind[SyntaxKind["SyntaxList"] = 298] = "SyntaxList";
// Transformation nodes
- SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement";
- SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression";
- SyntaxKind[SyntaxKind["CommaListExpression"] = 299] = "CommaListExpression";
- SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 300] = "MergeDeclarationMarker";
- SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 301] = "EndOfDeclarationMarker";
+ SyntaxKind[SyntaxKind["NotEmittedStatement"] = 299] = "NotEmittedStatement";
+ SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 300] = "PartiallyEmittedExpression";
+ SyntaxKind[SyntaxKind["CommaListExpression"] = 301] = "CommaListExpression";
+ SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 302] = "MergeDeclarationMarker";
+ SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 303] = "EndOfDeclarationMarker";
// Enum value count
- SyntaxKind[SyntaxKind["Count"] = 302] = "Count";
+ SyntaxKind[SyntaxKind["Count"] = 304] = "Count";
// Markers
SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment";
SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment";
@@ -411,9 +413,9 @@ var ts;
SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator";
SyntaxKind[SyntaxKind["FirstNode"] = 145] = "FirstNode";
SyntaxKind[SyntaxKind["FirstJSDocNode"] = 277] = "FirstJSDocNode";
- SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode";
- SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 287] = "FirstJSDocTagNode";
- SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode";
+ SyntaxKind[SyntaxKind["LastJSDocNode"] = 297] = "LastJSDocNode";
+ SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 288] = "FirstJSDocTagNode";
+ SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 297] = "LastJSDocTagNode";
/* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword";
/* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 144] = "LastContextualKeyword";
})(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
@@ -595,7 +597,7 @@ var ts;
NodeBuilderFlags[NodeBuilderFlags["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType";
NodeBuilderFlags[NodeBuilderFlags["GenerateNamesForShadowedTypeParams"] = 4] = "GenerateNamesForShadowedTypeParams";
NodeBuilderFlags[NodeBuilderFlags["UseStructuralFallback"] = 8] = "UseStructuralFallback";
- // empty space
+ NodeBuilderFlags[NodeBuilderFlags["ForbidIndexedAccessSymbolReferences"] = 16] = "ForbidIndexedAccessSymbolReferences";
NodeBuilderFlags[NodeBuilderFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature";
NodeBuilderFlags[NodeBuilderFlags["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType";
NodeBuilderFlags[NodeBuilderFlags["UseOnlyExternalAliasing"] = 128] = "UseOnlyExternalAliasing";
@@ -887,6 +889,8 @@ var ts;
TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 67108864] = "ContainsAnyFunctionType";
TypeFlags[TypeFlags["NonPrimitive"] = 134217728] = "NonPrimitive";
/* @internal */
+ TypeFlags[TypeFlags["UnionOfUnitTypes"] = 268435456] = "UnionOfUnitTypes";
+ /* @internal */
TypeFlags[TypeFlags["GenericMappedType"] = 536870912] = "GenericMappedType";
/* @internal */
TypeFlags[TypeFlags["Nullable"] = 12288] = "Nullable";
@@ -922,6 +926,8 @@ var ts;
TypeFlags[TypeFlags["Narrowable"] = 142575359] = "Narrowable";
TypeFlags[TypeFlags["NotUnionOrUnit"] = 134283777] = "NotUnionOrUnit";
/* @internal */
+ TypeFlags[TypeFlags["NotUnit"] = 8374815] = "NotUnit";
+ /* @internal */
TypeFlags[TypeFlags["RequiresWidening"] = 50331648] = "RequiresWidening";
/* @internal */
TypeFlags[TypeFlags["PropagatingFlags"] = 117440512] = "PropagatingFlags";
@@ -1911,6 +1917,15 @@ var ts;
return -1;
}
ts.findIndex = findIndex;
+ function findLastIndex(array, predicate, startIndex) {
+ for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
+ if (predicate(array[i], i)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+ ts.findLastIndex = findLastIndex;
/**
* Returns the first truthy result of `callback`, or else fails.
* This is like `forEach`, but never returns undefined.
@@ -2263,6 +2278,24 @@ var ts;
return false;
}
ts.some = some;
+ /** Calls the callback with (start, afterEnd) index pairs for each range where 'pred' is true. */
+ function getRangesWhere(arr, pred, cb) {
+ var start;
+ for (var i = 0; i < arr.length; i++) {
+ if (pred(arr[i])) {
+ start = start === undefined ? i : start;
+ }
+ else {
+ if (start !== undefined) {
+ cb(start, i);
+ start = undefined;
+ }
+ }
+ }
+ if (start !== undefined)
+ cb(start, arr.length);
+ }
+ ts.getRangesWhere = getRangesWhere;
function concatenate(array1, array2) {
if (!some(array2))
return array1;
@@ -6743,6 +6776,7 @@ var ts;
Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
+ Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing typeof"),
};
})(ts || (ts = {}));
var ts;
@@ -8493,11 +8527,10 @@ var ts;
}
}
function scanJSDocToken() {
+ startPos = tokenPos = pos;
if (pos >= end) {
return token = 1 /* EndOfFileToken */;
}
- startPos = pos;
- tokenPos = pos;
var ch = text.charCodeAt(pos);
pos++;
switch (ch) {
@@ -8903,7 +8936,7 @@ var ts;
// the syntax list itself considers them as normal trivia. Therefore if we simply skip
// trivia for the list, we may have skipped the JSDocComment as well. So we should process its
// first child to determine the actual position of its first token.
- if (node.kind === 296 /* SyntaxList */ && node._children.length > 0) {
+ if (node.kind === 298 /* SyntaxList */ && node._children.length > 0) {
return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
}
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
@@ -9110,7 +9143,7 @@ var ts;
case 204 /* ClassExpression */:
case 235 /* InterfaceDeclaration */:
case 236 /* TypeAliasDeclaration */:
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
case 233 /* FunctionDeclaration */:
case 153 /* MethodDeclaration */:
case 154 /* Constructor */:
@@ -9118,6 +9151,9 @@ var ts;
case 156 /* SetAccessor */:
case 191 /* FunctionExpression */:
case 192 /* ArrowFunction */:
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 287 /* JSDocSignature */:
return true;
default:
ts.assertTypeIsNever(node);
@@ -9159,13 +9195,7 @@ var ts;
// Gets the nearest enclosing block scope container that has the provided node
// as a descendant, that is not the provided node.
function getEnclosingBlockScopeContainer(node) {
- var current = node.parent;
- while (current) {
- if (isBlockScope(current, current.parent)) {
- return current;
- }
- current = current.parent;
- }
+ return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
}
ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
// Return display name of an identifier
@@ -10354,6 +10384,14 @@ var ts;
node.parameters[0].name.escapedText === "new";
}
ts.isJSDocConstructSignature = isJSDocConstructSignature;
+ function isJSDocTypeAlias(node) {
+ return node.kind === 296 /* JSDocTypedefTag */ || node.kind === 291 /* JSDocCallbackTag */;
+ }
+ ts.isJSDocTypeAlias = isJSDocTypeAlias;
+ function isTypeAlias(node) {
+ return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
+ }
+ ts.isTypeAlias = isTypeAlias;
function getSourceOfAssignment(node) {
return ts.isExpressionStatement(node) &&
node.expression && ts.isBinaryExpression(node.expression) &&
@@ -10375,6 +10413,8 @@ var ts;
return v && v.initializer;
case 151 /* PropertyDeclaration */:
return node.initializer;
+ case 269 /* PropertyAssignment */:
+ return node.initializer;
}
}
function getSingleVariableOfVariableStatement(node) {
@@ -10405,8 +10445,7 @@ var ts;
// * @returns {number}
// */
// var x = function(name) { return name.length; }
- if (parent.parent &&
- (getSingleVariableOfVariableStatement(parent.parent) === node)) {
+ if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) {
getJSDocCommentsAndTagsWorker(parent.parent);
}
if (parent.parent && parent.parent.parent &&
@@ -10451,7 +10490,10 @@ var ts;
}
ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
function getHostSignatureFromJSDoc(node) {
- var host = getJSDocHost(node);
+ return getHostSignatureFromJSDocHost(getJSDocHost(node));
+ }
+ ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ function getHostSignatureFromJSDocHost(host) {
var decl = getSourceOfDefaultedAssignment(host) ||
getSourceOfAssignment(host) ||
getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
@@ -10460,19 +10502,12 @@ var ts;
host;
return decl && ts.isFunctionLike(decl) ? decl : undefined;
}
- ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ ts.getHostSignatureFromJSDocHost = getHostSignatureFromJSDocHost;
function getJSDocHost(node) {
- while (node.parent.kind === 286 /* JSDocTypeLiteral */) {
- if (node.parent.parent.kind === 294 /* JSDocTypedefTag */) {
- node = node.parent.parent;
- }
- else {
- // node.parent.parent is a type expression, child of a parameter type
- node = node.parent.parent.parent;
- }
+ var comment = ts.findAncestor(node.parent, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : node.kind === 285 /* JSDocComment */; });
+ if (comment) {
+ return comment.parent;
}
- ts.Debug.assert(node.parent.kind === 285 /* JSDocComment */);
- return node.parent.parent;
}
ts.getJSDocHost = getJSDocHost;
function getTypeParameterFromJsDoc(node) {
@@ -10487,7 +10522,8 @@ var ts;
}
ts.hasRestParameter = hasRestParameter;
function isRestParameter(node) {
- return node.dotDotDotToken !== undefined || node.type && node.type.kind === 284 /* JSDocVariadicType */;
+ var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
+ return node.dotDotDotToken !== undefined || type && type.kind === 284 /* JSDocVariadicType */;
}
ts.isRestParameter = isRestParameter;
var AssignmentKind;
@@ -11016,7 +11052,7 @@ var ts;
ts.getOperator = getOperator;
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
switch (nodeKind) {
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return 0;
case 203 /* SpreadElement */:
return 1;
@@ -11345,8 +11381,8 @@ var ts;
};
}
ts.createTextWriter = createTextWriter;
- function getResolvedExternalModuleName(host, file) {
- return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
+ function getResolvedExternalModuleName(host, file, referenceFile) {
+ return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
}
ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
@@ -11360,12 +11396,13 @@ var ts;
/**
* Resolves a local path to a path which is absolute to the base of the emit
*/
- function getExternalModuleNameFromPath(host, fileName) {
+ function getExternalModuleNameFromPath(host, fileName, referencePath) {
var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
- var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
+ var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
- return ts.removeFileExtension(relativePath);
+ var extensionless = ts.removeFileExtension(relativePath);
+ return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
}
ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
function getOwnEmitOutputFilePath(sourceFile, host, extension) {
@@ -11459,7 +11496,8 @@ var ts;
}
ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
function getThisParameter(signature) {
- if (signature.parameters.length) {
+ // callback tags do not currently support this parameters
+ if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
var thisParameter = signature.parameters[0];
if (parameterIsThisKeyword(thisParameter)) {
return thisParameter;
@@ -11544,6 +11582,9 @@ var ts;
* JavaScript file, gets the return type annotation from JSDoc.
*/
function getEffectiveReturnTypeNode(node) {
+ if (ts.isJSDocSignature(node)) {
+ return node.type && node.type.typeExpression && node.type.typeExpression.type;
+ }
return node.type || (isInJavaScriptFile(node) ? ts.getJSDocReturnType(node) : undefined);
}
ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
@@ -11552,14 +11593,26 @@ var ts;
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
*/
function getEffectiveTypeParameterDeclarations(node) {
- return ts.isJSDocTypedefTag(node)
- ? getJSDocTypeParameterDeclarations(node)
- : node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined);
+ if (ts.isJSDocSignature(node)) {
+ return ts.emptyArray;
+ }
+ if (isJSDocTypeAlias(node)) {
+ ts.Debug.assert(node.parent.kind === 285 /* JSDocComment */);
+ var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; });
+ var templateTagNodes = templateTags;
+ templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos;
+ templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end;
+ templateTagNodes.hasTrailingComma = false;
+ return templateTagNodes;
+ }
+ return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray);
}
ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
function getJSDocTypeParameterDeclarations(node) {
- var templateTag = ts.getJSDocTemplateTag(node);
- return templateTag && templateTag.typeParameters;
+ var tags = ts.filter(ts.getJSDocTags(node), ts.isJSDocTemplateTag);
+ // template tags are only available when a typedef isn't already using them
+ var tag = ts.find(tags, function (tag) { return !(tag.parent.kind === 285 /* JSDocComment */ && ts.find(tag.parent.tags, isJSDocTypeAlias)); });
+ return (tag && tag.typeParameters) || ts.emptyArray;
}
ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
/**
@@ -12947,8 +13000,8 @@ var ts;
break;
case 71 /* Identifier */:
return declaration;
- case 295 /* JSDocPropertyTag */:
- case 290 /* JSDocParameterTag */: {
+ case 297 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */: {
var name = declaration.name;
if (name.kind === 145 /* QualifiedName */) {
return name.right;
@@ -12967,7 +13020,9 @@ var ts;
return undefined;
}
}
- case 294 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ return declaration.name;
+ case 296 /* JSDocTypedefTag */:
return getNameOfJSDocTypedef(declaration);
case 248 /* ExportAssignment */: {
var expression = declaration.expression;
@@ -13353,7 +13408,7 @@ var ts;
}
ts.isParenthesizedExpression = isParenthesizedExpression;
function skipPartiallyEmittedExpressions(node) {
- while (node.kind === 298 /* PartiallyEmittedExpression */) {
+ while (node.kind === 300 /* PartiallyEmittedExpression */) {
node = node.expression;
}
return node;
@@ -13745,45 +13800,53 @@ var ts;
}
ts.isJSDoc = isJSDoc;
function isJSDocAugmentsTag(node) {
- return node.kind === 288 /* JSDocAugmentsTag */;
+ return node.kind === 289 /* JSDocAugmentsTag */;
}
ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
function isJSDocClassTag(node) {
- return node.kind === 289 /* JSDocClassTag */;
+ return node.kind === 290 /* JSDocClassTag */;
}
ts.isJSDocClassTag = isJSDocClassTag;
function isJSDocParameterTag(node) {
- return node.kind === 290 /* JSDocParameterTag */;
+ return node.kind === 292 /* JSDocParameterTag */;
}
ts.isJSDocParameterTag = isJSDocParameterTag;
function isJSDocReturnTag(node) {
- return node.kind === 291 /* JSDocReturnTag */;
+ return node.kind === 293 /* JSDocReturnTag */;
}
ts.isJSDocReturnTag = isJSDocReturnTag;
function isJSDocTypeTag(node) {
- return node.kind === 292 /* JSDocTypeTag */;
+ return node.kind === 294 /* JSDocTypeTag */;
}
ts.isJSDocTypeTag = isJSDocTypeTag;
function isJSDocTemplateTag(node) {
- return node.kind === 293 /* JSDocTemplateTag */;
+ return node.kind === 295 /* JSDocTemplateTag */;
}
ts.isJSDocTemplateTag = isJSDocTemplateTag;
function isJSDocTypedefTag(node) {
- return node.kind === 294 /* JSDocTypedefTag */;
+ return node.kind === 296 /* JSDocTypedefTag */;
}
ts.isJSDocTypedefTag = isJSDocTypedefTag;
function isJSDocPropertyTag(node) {
- return node.kind === 295 /* JSDocPropertyTag */;
+ return node.kind === 297 /* JSDocPropertyTag */;
}
ts.isJSDocPropertyTag = isJSDocPropertyTag;
function isJSDocPropertyLikeTag(node) {
- return node.kind === 295 /* JSDocPropertyTag */ || node.kind === 290 /* JSDocParameterTag */;
+ return node.kind === 297 /* JSDocPropertyTag */ || node.kind === 292 /* JSDocParameterTag */;
}
ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
function isJSDocTypeLiteral(node) {
return node.kind === 286 /* JSDocTypeLiteral */;
}
ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
+ function isJSDocCallbackTag(node) {
+ return node.kind === 291 /* JSDocCallbackTag */;
+ }
+ ts.isJSDocCallbackTag = isJSDocCallbackTag;
+ function isJSDocSignature(node) {
+ return node.kind === 287 /* JSDocSignature */;
+ }
+ ts.isJSDocSignature = isJSDocSignature;
})(ts || (ts = {}));
// Node tests
//
@@ -13792,7 +13855,7 @@ var ts;
(function (ts) {
/* @internal */
function isSyntaxList(n) {
- return n.kind === 296 /* SyntaxList */;
+ return n.kind === 298 /* SyntaxList */;
}
ts.isSyntaxList = isSyntaxList;
/* @internal */
@@ -13937,6 +14000,7 @@ var ts;
switch (kind) {
case 152 /* MethodSignature */:
case 157 /* CallSignature */:
+ case 287 /* JSDocSignature */:
case 158 /* ConstructSignature */:
case 159 /* IndexSignature */:
case 162 /* FunctionType */:
@@ -14252,8 +14316,8 @@ var ts;
case 203 /* SpreadElement */:
case 207 /* AsExpression */:
case 205 /* OmittedExpression */:
- case 299 /* CommaListExpression */:
- case 298 /* PartiallyEmittedExpression */:
+ case 301 /* CommaListExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return true;
default:
return isUnaryExpressionKind(kind);
@@ -14267,12 +14331,12 @@ var ts;
ts.isAssertionExpression = isAssertionExpression;
/* @internal */
function isPartiallyEmittedExpression(node) {
- return node.kind === 298 /* PartiallyEmittedExpression */;
+ return node.kind === 300 /* PartiallyEmittedExpression */;
}
ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
/* @internal */
function isNotEmittedStatement(node) {
- return node.kind === 297 /* NotEmittedStatement */;
+ return node.kind === 299 /* NotEmittedStatement */;
}
ts.isNotEmittedStatement = isNotEmittedStatement;
/* @internal */
@@ -14383,8 +14447,9 @@ var ts;
|| kind === 236 /* TypeAliasDeclaration */
|| kind === 147 /* TypeParameter */
|| kind === 231 /* VariableDeclaration */
- || kind === 294 /* JSDocTypedefTag */
- || kind === 295 /* JSDocPropertyTag */;
+ || kind === 296 /* JSDocTypedefTag */
+ || kind === 291 /* JSDocCallbackTag */
+ || kind === 297 /* JSDocPropertyTag */;
}
function isDeclarationStatementKind(kind) {
return kind === 233 /* FunctionDeclaration */
@@ -14419,14 +14484,14 @@ var ts;
|| kind === 213 /* VariableStatement */
|| kind === 218 /* WhileStatement */
|| kind === 225 /* WithStatement */
- || kind === 297 /* NotEmittedStatement */
- || kind === 301 /* EndOfDeclarationMarker */
- || kind === 300 /* MergeDeclarationMarker */;
+ || kind === 299 /* NotEmittedStatement */
+ || kind === 303 /* EndOfDeclarationMarker */
+ || kind === 302 /* MergeDeclarationMarker */;
}
/* @internal */
function isDeclaration(node) {
if (node.kind === 147 /* TypeParameter */) {
- return node.parent.kind !== 293 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node);
+ return node.parent.kind !== 295 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node);
}
return isDeclarationKind(node.kind);
}
@@ -14521,18 +14586,18 @@ var ts;
/** True if node is of some JSDoc syntax kind. */
/* @internal */
function isJSDocNode(node) {
- return node.kind >= 277 /* FirstJSDocNode */ && node.kind <= 295 /* LastJSDocNode */;
+ return node.kind >= 277 /* FirstJSDocNode */ && node.kind <= 297 /* LastJSDocNode */;
}
ts.isJSDocNode = isJSDocNode;
/** True if node is of a kind that may contain comment text. */
function isJSDocCommentContainingNode(node) {
- return node.kind === 285 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node);
+ return node.kind === 285 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node);
}
ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
// TODO: determine what this does before making it public.
/* @internal */
function isJSDocTag(node) {
- return node.kind >= 287 /* FirstJSDocTagNode */ && node.kind <= 295 /* LastJSDocTagNode */;
+ return node.kind >= 288 /* FirstJSDocTagNode */ && node.kind <= 297 /* LastJSDocTagNode */;
}
ts.isJSDocTag = isJSDocTag;
function isSetAccessor(node) {
@@ -15078,7 +15143,7 @@ var ts;
return visitNode(cbNode, node.expression);
case 252 /* MissingDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators);
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return visitNodes(cbNode, cbNodes, node.elements);
case 254 /* JsxElement */:
return visitNode(cbNode, node.openingElement) ||
@@ -15120,8 +15185,8 @@ var ts;
return visitNode(cbNode, node.type);
case 285 /* JSDocComment */:
return visitNodes(cbNode, cbNodes, node.tags);
- case 290 /* JSDocParameterTag */:
- case 295 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */:
+ case 297 /* JSDocPropertyTag */:
if (node.isNameFirst) {
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.typeExpression);
@@ -15130,15 +15195,15 @@ var ts;
return visitNode(cbNode, node.typeExpression) ||
visitNode(cbNode, node.name);
}
- case 291 /* JSDocReturnTag */:
+ case 293 /* JSDocReturnTag */:
return visitNode(cbNode, node.typeExpression);
- case 292 /* JSDocTypeTag */:
+ case 294 /* JSDocTypeTag */:
return visitNode(cbNode, node.typeExpression);
- case 288 /* JSDocAugmentsTag */:
+ case 289 /* JSDocAugmentsTag */:
return visitNode(cbNode, node.class);
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
return visitNodes(cbNode, cbNodes, node.typeParameters);
- case 294 /* JSDocTypedefTag */:
+ case 296 /* JSDocTypedefTag */:
if (node.typeExpression &&
node.typeExpression.kind === 277 /* JSDocTypeExpression */) {
return visitNode(cbNode, node.typeExpression) ||
@@ -15148,6 +15213,15 @@ var ts;
return visitNode(cbNode, node.fullName) ||
visitNode(cbNode, node.typeExpression);
}
+ case 291 /* JSDocCallbackTag */:
+ return visitNode(cbNode, node.fullName) ||
+ visitNode(cbNode, node.typeExpression);
+ case 287 /* JSDocSignature */:
+ return visitNodes(cbNode, cbNodes, node.decorators) ||
+ visitNodes(cbNode, cbNodes, node.modifiers) ||
+ visitNodes(cbNode, cbNodes, node.typeParameters) ||
+ visitNodes(cbNode, cbNodes, node.parameters) ||
+ visitNode(cbNode, node.type);
case 286 /* JSDocTypeLiteral */:
if (node.jsDocPropertyTags) {
for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
@@ -15156,7 +15230,7 @@ var ts;
}
}
return;
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return visitNode(cbNode, node.expression);
}
}
@@ -20305,8 +20379,9 @@ var ts;
})(JSDocState || (JSDocState = {}));
var PropertyLikeParse;
(function (PropertyLikeParse) {
- PropertyLikeParse[PropertyLikeParse["Property"] = 0] = "Property";
- PropertyLikeParse[PropertyLikeParse["Parameter"] = 1] = "Parameter";
+ PropertyLikeParse[PropertyLikeParse["Property"] = 1] = "Property";
+ PropertyLikeParse[PropertyLikeParse["Parameter"] = 2] = "Parameter";
+ PropertyLikeParse[PropertyLikeParse["CallbackParameter"] = 4] = "CallbackParameter";
})(PropertyLikeParse || (PropertyLikeParse = {}));
function parseJSDocCommentWorker(start, length) {
var content = sourceText;
@@ -20354,7 +20429,7 @@ var ts;
case 57 /* AtToken */:
if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) {
removeTrailingNewlines(comments);
- parseTag(indent);
+ addTag(parseTag(indent));
// NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag.
// Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning
// for malformed examples like `/** @param {string} x @returns {number} the length */`
@@ -20433,7 +20508,24 @@ var ts;
result.comment = comments.length ? comments.join("") : undefined;
return finishNode(result, end);
}
+ function isNextNonwhitespaceTokenEndOfFile() {
+ // We must use infinite lookahead, as there could be any number of newlines :(
+ while (true) {
+ nextJSDocToken();
+ if (token() === 1 /* EndOfFileToken */) {
+ return true;
+ }
+ if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) {
+ return false;
+ }
+ }
+ }
function skipWhitespace() {
+ if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
+ if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
+ return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range
+ }
+ }
while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
nextJSDocToken();
}
@@ -20462,8 +20554,7 @@ var ts;
case "arg":
case "argument":
case "param":
- addTag(parseParameterOrPropertyTag(atToken, tagName, 1 /* Parameter */, indent));
- return;
+ return parseParameterOrPropertyTag(atToken, tagName, 2 /* Parameter */, indent);
case "return":
case "returns":
tag = parseReturnTag(atToken, tagName);
@@ -20475,7 +20566,10 @@ var ts;
tag = parseTypeTag(atToken, tagName);
break;
case "typedef":
- tag = parseTypedefTag(atToken, tagName);
+ tag = parseTypedefTag(atToken, tagName, indent);
+ break;
+ case "callback":
+ tag = parseCallbackTag(atToken, tagName, indent);
break;
default:
tag = parseUnknownTag(atToken, tagName);
@@ -20489,8 +20583,11 @@ var ts;
// a badly malformed tag should not be added to the list of tags
return;
}
- tag.comment = parseTagComments(indent + tag.end - tag.pos);
- addTag(tag);
+ if (!tag.comment) {
+ // some tags, like typedef and callback, have already parsed their comments earlier
+ tag.comment = parseTagComments(indent + tag.end - tag.pos);
+ }
+ return tag;
}
function parseTagComments(indent) {
var comments = [];
@@ -20553,12 +20650,15 @@ var ts;
return comments.length === 0 ? undefined : comments.join("");
}
function parseUnknownTag(atToken, tagName) {
- var result = createNode(287 /* JSDocTag */, atToken.pos);
+ var result = createNode(288 /* JSDocTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
return finishNode(result);
}
function addTag(tag) {
+ if (!tag) {
+ return;
+ }
if (!tags) {
tags = [tag];
tagsPos = tag.pos;
@@ -20609,9 +20709,9 @@ var ts;
if (isNameFirst) {
typeExpression = tryParseTypeExpression();
}
- var result = target === 1 /* Parameter */ ?
- createNode(290 /* JSDocParameterTag */, atToken.pos) :
- createNode(295 /* JSDocPropertyTag */, atToken.pos);
+ var result = target === 1 /* Property */ ?
+ createNode(297 /* JSDocPropertyTag */, atToken.pos) :
+ createNode(292 /* JSDocParameterTag */, atToken.pos);
var comment;
if (indent !== undefined)
comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
@@ -20637,7 +20737,7 @@ var ts;
var start_2 = scanner.getStartPos();
var children = void 0;
while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) {
- if (child.kind === 290 /* JSDocParameterTag */ || child.kind === 295 /* JSDocPropertyTag */) {
+ if (child.kind === 292 /* JSDocParameterTag */ || child.kind === 297 /* JSDocPropertyTag */) {
children = ts.append(children, child);
}
}
@@ -20653,27 +20753,27 @@ var ts;
}
}
function parseReturnTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 291 /* JSDocReturnTag */; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 293 /* JSDocReturnTag */; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(291 /* JSDocReturnTag */, atToken.pos);
+ var result = createNode(293 /* JSDocReturnTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result);
}
function parseTypeTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 292 /* JSDocTypeTag */; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocTypeTag */; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(292 /* JSDocTypeTag */, atToken.pos);
+ var result = createNode(294 /* JSDocTypeTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
return finishNode(result);
}
function parseAugmentsTag(atToken, tagName) {
- var result = createNode(288 /* JSDocAugmentsTag */, atToken.pos);
+ var result = createNode(289 /* JSDocAugmentsTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.class = parseExpressionWithTypeArgumentsForAugments();
@@ -20701,32 +20801,23 @@ var ts;
return node;
}
function parseClassTag(atToken, tagName) {
- var tag = createNode(289 /* JSDocClassTag */, atToken.pos);
+ var tag = createNode(290 /* JSDocClassTag */, atToken.pos);
tag.atToken = atToken;
tag.tagName = tagName;
return finishNode(tag);
}
- function parseTypedefTag(atToken, tagName) {
+ function parseTypedefTag(atToken, tagName, indent) {
var typeExpression = tryParseTypeExpression();
skipWhitespace();
- var typedefTag = createNode(294 /* JSDocTypedefTag */, atToken.pos);
+ var typedefTag = createNode(296 /* JSDocTypedefTag */, atToken.pos);
typedefTag.atToken = atToken;
typedefTag.tagName = tagName;
- typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0);
- if (typedefTag.fullName) {
- var rightNode = typedefTag.fullName;
- while (true) {
- if (rightNode.kind === 71 /* Identifier */ || !rightNode.body) {
- // if node is identifier - use it as name
- // otherwise use name of the rightmost part that we were able to parse
- typedefTag.name = rightNode.kind === 71 /* Identifier */ ? rightNode : rightNode.name;
- break;
- }
- rightNode = rightNode.body;
- }
- }
+ typedefTag.fullName = parseJSDocTypeNameWithNamespace();
+ typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
skipWhitespace();
+ typedefTag.comment = parseTagComments(indent);
typedefTag.typeExpression = typeExpression;
+ var end;
if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
var child = void 0;
var jsdocTypeLiteral = void 0;
@@ -20736,7 +20827,7 @@ var ts;
if (!jsdocTypeLiteral) {
jsdocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, start_3);
}
- if (child.kind === 292 /* JSDocTypeTag */) {
+ if (child.kind === 294 /* JSDocTypeTag */) {
if (childTypeTag) {
break;
}
@@ -20755,23 +20846,68 @@ var ts;
typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
childTypeTag.typeExpression :
finishNode(jsdocTypeLiteral);
+ end = typedefTag.typeExpression.end;
}
}
- return finishNode(typedefTag);
- function parseJSDocTypeNameWithNamespace(flags) {
- var pos = scanner.getTokenPos();
- var typeNameOrNamespaceName = parseJSDocIdentifierName();
- if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) {
- var jsDocNamespaceNode = createNode(238 /* ModuleDeclaration */, pos);
- jsDocNamespaceNode.flags |= flags;
- jsDocNamespaceNode.name = typeNameOrNamespaceName;
- jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */);
- return finishNode(jsDocNamespaceNode);
+ // Only include the characters between the name end and the next token if a comment was actually parsed out - otherwise it's just whitespace
+ return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
+ }
+ function parseJSDocTypeNameWithNamespace(nested) {
+ var pos = scanner.getTokenPos();
+ var typeNameOrNamespaceName = parseJSDocIdentifierName();
+ if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) {
+ var jsDocNamespaceNode = createNode(238 /* ModuleDeclaration */, pos);
+ if (nested) {
+ jsDocNamespaceNode.flags |= 4 /* NestedNamespace */;
}
- if (typeNameOrNamespaceName && flags & 4 /* NestedNamespace */) {
- typeNameOrNamespaceName.isInJSDocNamespace = true;
+ jsDocNamespaceNode.name = typeNameOrNamespaceName;
+ jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(/*nested*/ true);
+ return finishNode(jsDocNamespaceNode);
+ }
+ if (typeNameOrNamespaceName && nested) {
+ typeNameOrNamespaceName.isInJSDocNamespace = true;
+ }
+ return typeNameOrNamespaceName;
+ }
+ function parseCallbackTag(atToken, tagName, indent) {
+ var callbackTag = createNode(291 /* JSDocCallbackTag */, atToken.pos);
+ callbackTag.atToken = atToken;
+ callbackTag.tagName = tagName;
+ callbackTag.fullName = parseJSDocTypeNameWithNamespace();
+ callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
+ skipWhitespace();
+ callbackTag.comment = parseTagComments(indent);
+ var child;
+ var start = scanner.getStartPos();
+ var jsdocSignature = createNode(287 /* JSDocSignature */, start);
+ jsdocSignature.parameters = [];
+ while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) {
+ jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
+ }
+ var returnTag = tryParse(function () {
+ if (token() === 57 /* AtToken */) {
+ nextJSDocToken();
+ var tag = parseTag(indent);
+ if (tag && tag.kind === 293 /* JSDocReturnTag */) {
+ return tag;
+ }
+ }
+ });
+ if (returnTag) {
+ jsdocSignature.type = returnTag;
+ }
+ callbackTag.typeExpression = finishNode(jsdocSignature);
+ return finishNode(callbackTag);
+ }
+ function getJSDocTypeAliasName(fullName) {
+ if (fullName) {
+ var rightNode = fullName;
+ while (true) {
+ if (ts.isIdentifier(rightNode) || !rightNode.body) {
+ return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
+ }
+ rightNode = rightNode.body;
}
- return typeNameOrNamespaceName;
}
}
function escapedTextsEqual(a, b) {
@@ -20787,7 +20923,7 @@ var ts;
return a.escapedText === b.escapedText;
}
function parseChildPropertyTag() {
- return parseChildParameterOrPropertyTag(0 /* Property */);
+ return parseChildParameterOrPropertyTag(1 /* Property */);
}
function parseChildParameterOrPropertyTag(target, name) {
var canParseTag = true;
@@ -20797,7 +20933,8 @@ var ts;
case 57 /* AtToken */:
if (canParseTag) {
var child = tryParseChildTag(target);
- if (child && child.kind === 290 /* JSDocParameterTag */ &&
+ if (child && child.kind === 292 /* JSDocParameterTag */ &&
+ target !== 4 /* CallbackParameter */ &&
(ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
return false;
}
@@ -20836,20 +20973,20 @@ var ts;
var t;
switch (tagName.escapedText) {
case "type":
- return target === 0 /* Property */ && parseTypeTag(atToken, tagName);
+ return target === 1 /* Property */ && parseTypeTag(atToken, tagName);
case "prop":
case "property":
- t = 0 /* Property */;
+ t = 1 /* Property */;
break;
case "arg":
case "argument":
case "param":
- t = 1 /* Parameter */;
+ t = 2 /* Parameter */ | 4 /* CallbackParameter */;
break;
default:
return false;
}
- if (target !== t) {
+ if (!(target & t)) {
return false;
}
var tag = parseParameterOrPropertyTag(atToken, tagName, target, /*indent*/ undefined);
@@ -20882,7 +21019,7 @@ var ts;
break;
}
}
- var result = createNode(293 /* JSDocTemplateTag */, atToken.pos);
+ var result = createNode(295 /* JSDocTemplateTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
@@ -20931,7 +21068,7 @@ var ts;
var pos = scanner.getTokenPos();
var end = scanner.getTextPos();
var result = createNode(71 /* Identifier */, pos);
- result.escapedText = ts.escapeLeadingUnderscores(content.substring(pos, end));
+ result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText());
finishNode(result, end);
nextJSDocToken();
return result;
@@ -21735,7 +21872,7 @@ var ts;
var thisParentContainer; // Container one level up
var blockScopeContainer;
var lastContainer;
- var delayedTypedefs;
+ var delayedTypeAliases;
var seenThisKeyword;
// state used by control flow analysis
var currentFlow;
@@ -21793,7 +21930,7 @@ var ts;
thisParentContainer = undefined;
blockScopeContainer = undefined;
lastContainer = undefined;
- delayedTypedefs = undefined;
+ delayedTypeAliases = undefined;
seenThisKeyword = false;
currentFlow = undefined;
currentBreakTarget = undefined;
@@ -21867,6 +22004,7 @@ var ts;
return "__constructor" /* Constructor */;
case 162 /* FunctionType */:
case 157 /* CallSignature */:
+ case 287 /* JSDocSignature */:
return "__call" /* Call */;
case 163 /* ConstructorType */:
case 158 /* ConstructSignature */:
@@ -21895,9 +22033,6 @@ var ts;
var functionType = node.parent;
var index = functionType.parameters.indexOf(node);
return "arg" + index;
- case 294 /* JSDocTypedefTag */:
- var name_2 = ts.getNameOfJSDocTypedef(node);
- return typeof name_2 !== "undefined" ? name_2.escapedText : undefined;
}
}
function getDisplayName(node) {
@@ -22035,9 +22170,9 @@ var ts;
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
// and this case is specially handled. Module augmentations should only be merged with original module definition
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
- if (node.kind === 294 /* JSDocTypedefTag */)
+ if (ts.isJSDocTypeAlias(node))
ts.Debug.assert(ts.isInJavaScriptFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
- if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypedefTag(node)) {
+ if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) {
if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) {
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
}
@@ -22202,23 +22337,6 @@ var ts;
ts.forEachChild(node, bind, bindEach);
}
function bindChildrenWorker(node) {
- // Binding of JsDocComment should be done before the current block scope container changes.
- // because the scope of JsDocComment should not be affected by whether the current node is a
- // container or not.
- if (ts.hasJSDocNodes(node)) {
- if (ts.isInJavaScriptFile(node)) {
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var j = _a[_i];
- bind(j);
- }
- }
- else {
- for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
- var j = _c[_b];
- setParentPointers(node, j);
- }
- }
- }
if (checkUnreachable(node)) {
bindEachChild(node);
return;
@@ -22284,11 +22402,9 @@ var ts;
case 186 /* CallExpression */:
bindCallExpressionFlow(node);
break;
- case 285 /* JSDocComment */:
- bindJSDocComment(node);
- break;
- case 294 /* JSDocTypedefTag */:
- bindJSDocTypedefTag(node);
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ bindJSDocTypeAlias(node);
break;
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
case 273 /* SourceFile */:
@@ -22303,6 +22419,7 @@ var ts;
bindEachChild(node);
break;
}
+ bindJSDoc(node);
}
function isNarrowingExpression(expr) {
switch (expr.kind) {
@@ -22904,23 +23021,10 @@ var ts;
bindInitializedVariableFlow(node);
}
}
- function bindJSDocComment(node) {
- ts.forEachChild(node, function (n) {
- if (n.kind !== 294 /* JSDocTypedefTag */) {
- bind(n);
- }
- });
- }
- function bindJSDocTypedefTag(node) {
- ts.forEachChild(node, function (n) {
- // if the node has a fullName "A.B.C", that means symbol "C" was already bound
- // when we visit "fullName"; so when we visit the name "C" as the next child of
- // the jsDocTypedefTag, we should skip binding it.
- if (node.fullName && n === node.name && node.fullName.kind !== 71 /* Identifier */) {
- return;
- }
- bind(n);
- });
+ function bindJSDocTypeAlias(node) {
+ if (node.fullName) {
+ setParentPointers(node, node.fullName);
+ }
}
function bindCallExpressionFlow(node) {
// If the target of the call expression is a function expression or arrow function we have
@@ -22974,6 +23078,7 @@ var ts;
case 155 /* GetAccessor */:
case 156 /* SetAccessor */:
case 157 /* CallSignature */:
+ case 287 /* JSDocSignature */:
case 283 /* JSDocFunctionType */:
case 162 /* FunctionType */:
case 158 /* ConstructSignature */:
@@ -23050,6 +23155,7 @@ var ts;
case 163 /* ConstructorType */:
case 157 /* CallSignature */:
case 158 /* ConstructSignature */:
+ case 287 /* JSDocSignature */:
case 159 /* IndexSignature */:
case 153 /* MethodDeclaration */:
case 152 /* MethodSignature */:
@@ -23060,6 +23166,8 @@ var ts;
case 191 /* FunctionExpression */:
case 192 /* ArrowFunction */:
case 283 /* JSDocFunctionType */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
case 236 /* TypeAliasDeclaration */:
case 176 /* MappedType */:
// All the children of these container types are never visible through another
@@ -23234,22 +23342,35 @@ var ts;
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 67216319 /* BlockScopedVariableExcludes */);
}
function delayedBindJSDocTypedefTag() {
- if (!delayedTypedefs) {
+ if (!delayedTypeAliases) {
return;
}
var saveContainer = container;
var saveLastContainer = lastContainer;
var saveBlockScopeContainer = blockScopeContainer;
var saveParent = parent;
- for (var _i = 0, delayedTypedefs_1 = delayedTypedefs; _i < delayedTypedefs_1.length; _i++) {
- var delay = delayedTypedefs_1[_i];
- (container = delay.container, lastContainer = delay.lastContainer, blockScopeContainer = delay.blockScopeContainer, parent = delay.parent);
- bindBlockScopedDeclaration(delay.typedef, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */);
+ var saveCurrentFlow = currentFlow;
+ for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
+ var typeAlias = delayedTypeAliases_1[_i];
+ var host = ts.getJSDocHost(typeAlias);
+ container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file;
+ blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
+ currentFlow = { flags: 2 /* Start */ };
+ parent = typeAlias;
+ bind(typeAlias.typeExpression);
+ if (!typeAlias.fullName || typeAlias.fullName.kind === 71 /* Identifier */) {
+ parent = typeAlias.parent;
+ bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */);
+ }
+ else {
+ bind(typeAlias.fullName);
+ }
}
container = saveContainer;
lastContainer = saveLastContainer;
blockScopeContainer = saveBlockScopeContainer;
parent = saveParent;
+ currentFlow = saveCurrentFlow;
}
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
// check for reserved words used as identifiers in strict mode code.
@@ -23401,8 +23522,6 @@ var ts;
// Here the current node is "foo", which is a container, but the scope of "MyType" should
// not be inside "foo". Therefore we always bind @typedef before bind the parent node,
// and skip binding this tag later when binding all the other jsdoc tags.
- if (ts.isInJavaScriptFile(node))
- bindJSDocTypedefTagIfAny(node);
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
// and then potentially add the symbol to an appropriate symbol table. Possible
// destination symbol tables are:
@@ -23433,25 +23552,22 @@ var ts;
}
else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) {
subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
+ bindJSDoc(node);
}
inStrictMode = saveInStrictMode;
}
- function bindJSDocTypedefTagIfAny(node) {
- if (!ts.hasJSDocNodes(node)) {
- return;
- }
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var jsDoc = _a[_i];
- if (!jsDoc.tags) {
- continue;
+ function bindJSDoc(node) {
+ if (ts.hasJSDocNodes(node)) {
+ if (ts.isInJavaScriptFile(node)) {
+ for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
+ var j = _a[_i];
+ bind(j);
+ }
}
- for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) {
- var tag = _c[_b];
- if (tag.kind === 294 /* JSDocTypedefTag */) {
- var savedParent = parent;
- parent = jsDoc;
- bind(tag);
- parent = savedParent;
+ else {
+ for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
+ var j = _c[_b];
+ setParentPointers(node, j);
}
}
}
@@ -23486,7 +23602,7 @@ var ts;
// current "blockScopeContainer" needs to be set to its immediate namespace parent.
if (node.isInJSDocNamespace) {
var parentNode = node.parent;
- while (parentNode && parentNode.kind !== 294 /* JSDocTypedefTag */) {
+ while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
parentNode = parentNode.parent;
}
bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */);
@@ -23589,6 +23705,7 @@ var ts;
return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */);
case 162 /* FunctionType */:
case 283 /* JSDocFunctionType */:
+ case 287 /* JSDocSignature */:
case 163 /* ConstructorType */:
return bindFunctionOrConstructorType(node);
case 165 /* TypeLiteral */:
@@ -23648,24 +23765,23 @@ var ts;
// falls through
case 239 /* ModuleBlock */:
return updateStrictModeStatementList(node.statements);
- case 290 /* JSDocParameterTag */:
+ case 292 /* JSDocParameterTag */:
+ if (node.parent.kind === 287 /* JSDocSignature */) {
+ return bindParameter(node);
+ }
if (node.parent.kind !== 286 /* JSDocTypeLiteral */) {
break;
}
// falls through
- case 295 /* JSDocPropertyTag */:
+ case 297 /* JSDocPropertyTag */:
var propTag = node;
var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 /* JSDocOptionalType */ ?
4 /* Property */ | 16777216 /* Optional */ :
4 /* Property */;
return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */);
- case 294 /* JSDocTypedefTag */: {
- var fullName = node.fullName;
- if (!fullName || fullName.kind === 71 /* Identifier */) {
- (delayedTypedefs || (delayedTypedefs = [])).push({ typedef: node, container: container, lastContainer: lastContainer, blockScopeContainer: blockScopeContainer, parent: parent });
- }
- break;
- }
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
}
}
function bindPropertyWorker(node) {
@@ -24025,6 +24141,9 @@ var ts;
}
}
function bindParameter(node) {
+ if (node.kind === 292 /* JSDocParameterTag */ && container.kind !== 287 /* JSDocSignature */) {
+ return;
+ }
if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) {
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
@@ -24083,24 +24202,30 @@ var ts;
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
function getInferTypeContainer(node) {
- while (node) {
- var parent_2 = node.parent;
- if (parent_2 && parent_2.kind === 170 /* ConditionalType */ && parent_2.extendsType === node) {
- return parent_2;
- }
- node = parent_2;
- }
- return undefined;
+ var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
+ return extendsType && extendsType.parent;
}
function bindTypeParameter(node) {
- if (node.parent.kind === 171 /* InferType */) {
- var container_1 = getInferTypeContainer(node.parent);
+ if (ts.isJSDocTemplateTag(node.parent)) {
+ var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
if (container_1) {
if (!container_1.locals) {
container_1.locals = ts.createSymbolTable();
}
declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */);
}
+ else {
+ declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */);
+ }
+ }
+ else if (node.parent.kind === 171 /* InferType */) {
+ var container_2 = getInferTypeContainer(node.parent);
+ if (container_2) {
+ if (!container_2.locals) {
+ container_2.locals = ts.createSymbolTable();
+ }
+ declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */);
+ }
else {
bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node));
}
@@ -24725,7 +24850,7 @@ var ts;
break;
case 189 /* TypeAssertionExpression */:
case 207 /* AsExpression */:
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
// These nodes are TypeScript syntax.
transformFlags |= 3 /* AssertTypeScript */;
excludeFlags = 536872257 /* OuterExpressionExcludes */;
@@ -24997,7 +25122,7 @@ var ts;
return 940049729 /* BindingPatternExcludes */;
case 189 /* TypeAssertionExpression */:
case 207 /* AsExpression */:
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
case 190 /* ParenthesizedExpression */:
case 97 /* SuperKeyword */:
return 536872257 /* OuterExpressionExcludes */;
@@ -25015,7 +25140,7 @@ var ts;
*/
function setParentPointers(parent, child) {
child.parent = parent;
- ts.forEachChild(child, function (childsChild) { return setParentPointers(child, childsChild); });
+ ts.forEachChild(child, function (grandchild) { return setParentPointers(child, grandchild); });
}
})(ts || (ts = {}));
/** @internal */
@@ -27671,6 +27796,12 @@ var ts;
location = location.parent;
}
break;
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ // js type aliases do not resolve names from their host, so skip past it
+ lastLocation = location;
+ location = ts.getJSDocHost(location).parent;
+ continue;
}
if (isSelfReferenceLocation(location)) {
lastSelfReferenceLocation = location;
@@ -27786,9 +27917,11 @@ var ts;
function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
- if (decl.kind === 147 /* TypeParameter */ && parent === container) {
- return true;
+ if (decl.kind === 147 /* TypeParameter */) {
+ var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
+ if (parent === container) {
+ return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
+ }
}
}
return false;
@@ -28252,7 +28385,7 @@ var ts;
var symbol;
if (name.kind === 71 /* Identifier */) {
var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0;
- var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSPrototype(name, meaning) : undefined;
+ var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSSpecialAssignment(name, meaning) : undefined;
symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true);
if (!symbol) {
return symbolFromJSPrototype;
@@ -28306,24 +28439,38 @@ var ts;
return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
}
/**
- * For prototype-property methods like `A.prototype.m = function () ...`, try to resolve names in the scope of `A` too.
+ * 1. For prototype-property methods like `A.prototype.m = function () ...`, try to resolve names in the scope of `A` too.
* Note that prototype-property assignment to locations outside the current file (eg globals) doesn't work, so
* name resolution won't work either.
+ * 2. For property assignments like `{ x: function f () { } }`, try to resolve names in the scope of `f` too.
*/
- function resolveEntityNameFromJSPrototype(name, meaning) {
- if (isJSDocTypeReference(name.parent) && ts.isJSDocTag(name.parent.parent.parent)) {
- var host_1 = ts.getJSDocHost(name.parent.parent.parent);
- if (ts.isExpressionStatement(host_1) &&
- ts.isBinaryExpression(host_1.expression) &&
- ts.getSpecialPropertyAssignmentKind(host_1.expression) === 3 /* PrototypeProperty */) {
- var symbol = getSymbolOfNode(host_1.expression.left);
- if (symbol) {
- var secondaryLocation = symbol.parent.valueDeclaration;
- return resolveName(secondaryLocation, name.escapedText, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ true);
- }
+ function resolveEntityNameFromJSSpecialAssignment(name, meaning) {
+ if (isJSDocTypeReference(name.parent)) {
+ var secondaryLocation = getJSSpecialAssignmentLocation(name.parent);
+ if (secondaryLocation) {
+ return resolveName(secondaryLocation, name.escapedText, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ true);
}
}
}
+ function getJSSpecialAssignmentLocation(node) {
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
+ if (typeAlias) {
+ return;
+ }
+ var host = ts.getJSDocHost(node);
+ if (host &&
+ ts.isExpressionStatement(host) &&
+ ts.isBinaryExpression(host.expression) &&
+ ts.getSpecialPropertyAssignmentKind(host.expression) === 3 /* PrototypeProperty */) {
+ var symbol = getSymbolOfNode(host.expression.left);
+ return symbol && symbol.parent.valueDeclaration;
+ }
+ var sig = ts.getHostSignatureFromJSDocHost(host);
+ if (sig) {
+ var symbol = getSymbolOfNode(sig);
+ return symbol && symbol.valueDeclaration;
+ }
+ }
function resolveExternalModuleName(location, moduleReferenceExpression) {
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0);
}
@@ -28863,6 +29010,14 @@ var ts;
}
return hasAccessibleDeclarations;
}
+ else {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol)) {
+ // Any meaning of a module symbol is always accessible via an `import` type
+ return {
+ accessibility: 0 /* Accessible */
+ };
+ }
+ }
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
@@ -29100,7 +29255,7 @@ var ts;
flags: flags,
tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop },
encounteredError: false,
- symbolStack: undefined,
+ visitedSymbols: undefined,
inferTypeParameters: undefined
};
}
@@ -29207,9 +29362,10 @@ var ts;
return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined);
}
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
- var name = symbolToTypeReferenceName(type.aliasSymbol);
var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
- return ts.createTypeReferenceNode(name, typeArgumentNodes);
+ if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
+ return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes);
+ return symbolToTypeNode(type.aliasSymbol, context, 67901928 /* Type */, typeArgumentNodes);
}
if (type.flags & (131072 /* Union */ | 262144 /* Intersection */)) {
var types = type.flags & 131072 /* Union */ ? formatUnionTypes(type.types) : type.types;
@@ -29274,7 +29430,10 @@ var ts;
}
function createAnonymousTypeNode(type) {
var symbol = type.symbol;
+ var id;
if (symbol) {
+ var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */;
+ id = (isConstructorObject ? "+" : "") + getSymbolId(symbol);
if (isJavaScriptConstructor(symbol.valueDeclaration)) {
// Instance and static types share the same symbol; only add 'typeof' for the static side.
var isInstanceType = type === getInferredClassType(symbol) ? 67901928 /* Type */ : 67216319 /* Value */;
@@ -29286,7 +29445,7 @@ var ts;
shouldWriteTypeOfFunctionSymbol()) {
return symbolToTypeNode(symbol, context, 67216319 /* Value */);
}
- else if (ts.contains(context.symbolStack, symbol)) {
+ else if (context.visitedSymbols && context.visitedSymbols.has(id)) {
// If type is an anonymous type literal in a type alias declaration, use type alias name
var typeAlias = getTypeAliasForTypeLiteral(type);
if (typeAlias) {
@@ -29300,19 +29459,13 @@ var ts;
else {
// Since instantiations of the same anonymous type have the same symbol, tracking symbols instead
// of types allows us to catch circular references to instantiations of the same anonymous type
- if (!context.symbolStack) {
- context.symbolStack = [];
- }
- var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */;
- if (isConstructorObject) {
- return createTypeNodeFromObjectType(type);
- }
- else {
- context.symbolStack.push(symbol);
- var result = createTypeNodeFromObjectType(type);
- context.symbolStack.pop();
- return result;
+ if (!context.visitedSymbols) {
+ context.visitedSymbols = ts.createMap();
}
+ context.visitedSymbols.set(id, true);
+ var result = createTypeNodeFromObjectType(type);
+ context.visitedSymbols.delete(id);
+ return result;
}
}
else {
@@ -29329,7 +29482,7 @@ var ts;
}));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
// typeof is allowed only for static/non local functions
- return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ts.contains(context.symbolStack, symbol)) && // it is type of the symbol uses itself recursively
+ return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively
(!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed
}
}
@@ -29361,11 +29514,6 @@ var ts;
var typeLiteralNode = ts.createTypeLiteralNode(members);
return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */);
}
- function symbolToTypeReferenceName(symbol) {
- // Unnamed function expressions and arrow functions have reserved names that we don't want to display
- var entityName = symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.escapedName) ? symbolToName(symbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false) : ts.createIdentifier("");
- return entityName;
- }
function typeReferenceToTypeNode(type) {
var typeArguments = type.typeArguments || ts.emptyArray;
if (type.target === globalArrayType) {
@@ -29398,7 +29546,7 @@ var ts;
else {
var outerTypeParameters = type.target.outerTypeParameters;
var i = 0;
- var qualifiedName = void 0;
+ var resultType = void 0;
if (outerTypeParameters) {
var length_1 = outerTypeParameters.length;
while (i < length_1) {
@@ -29412,55 +29560,65 @@ var ts;
// the default outer type arguments), we don't show the group.
if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
- var typeArgumentNodes_1 = typeArgumentSlice && ts.createNodeArray(typeArgumentSlice);
- var namePart = symbolToTypeReferenceName(parent);
- (namePart.kind === 71 /* Identifier */ ? namePart : namePart.right).typeArguments = typeArgumentNodes_1;
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, namePart);
- qualifiedName = ts.createQualifiedName(qualifiedName, /*right*/ undefined);
- }
- else {
- qualifiedName = ts.createQualifiedName(namePart, /*right*/ undefined);
- }
+ var flags_2 = context.flags;
+ context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */;
+ var ref = symbolToTypeNode(parent, context, 67901928 /* Type */, typeArgumentSlice);
+ context.flags = flags_2;
+ resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
}
}
}
- var entityName = void 0;
- var nameIdentifier = symbolToTypeReferenceName(type.symbol);
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, nameIdentifier);
- entityName = qualifiedName;
- }
- else {
- entityName = nameIdentifier;
- }
var typeArgumentNodes = void 0;
if (typeArguments.length > 0) {
var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
}
- if (typeArgumentNodes) {
- var lastIdentifier = entityName.kind === 71 /* Identifier */ ? entityName : entityName.right;
- lastIdentifier.typeArguments = undefined;
- }
- return ts.createTypeReferenceNode(entityName, typeArgumentNodes);
+ var flags = context.flags;
+ context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */;
+ var finalRef = symbolToTypeNode(type.symbol, context, 67901928 /* Type */, typeArgumentNodes);
+ context.flags = flags;
+ return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
}
}
- function addToQualifiedNameMissingRightIdentifier(left, right) {
- ts.Debug.assert(left.right === undefined);
- if (right.kind === 71 /* Identifier */) {
- left.right = right;
- return left;
+ function appendReferenceToType(root, ref) {
+ if (ts.isImportTypeNode(root)) {
+ // first shift type arguments
+ var innerParams = root.typeArguments;
+ if (root.qualifier) {
+ (ts.isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams;
+ }
+ root.typeArguments = ref.typeArguments;
+ // then move qualifiers
+ var ids = getAccessStack(ref);
+ for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
+ var id = ids_1[_i];
+ root.qualifier = root.qualifier ? ts.createQualifiedName(root.qualifier, id) : id;
+ }
+ return root;
}
- var rightPart = right;
- while (rightPart.left.kind !== 71 /* Identifier */) {
- rightPart = rightPart.left;
+ else {
+ // first shift type arguments
+ var innerParams = root.typeArguments;
+ (ts.isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams;
+ root.typeArguments = ref.typeArguments;
+ // then move qualifiers
+ var ids = getAccessStack(ref);
+ for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
+ var id = ids_2[_a];
+ root.typeName = ts.createQualifiedName(root.typeName, id);
+ }
+ return root;
}
- left.right = rightPart.left;
- rightPart.left = left;
- return right;
+ }
+ function getAccessStack(ref) {
+ var state = ref.typeName;
+ var ids = [];
+ while (!ts.isIdentifier(state)) {
+ ids.unshift(state.right);
+ state = state.left;
+ }
+ ids.unshift(state);
+ return ids;
}
function createTypeNodesFromResolvedType(resolvedType) {
var typeElements = [];
@@ -29632,7 +29790,9 @@ var ts;
}
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) {
var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148 /* Parameter */);
- ts.Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol));
+ if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) {
+ parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292 /* JSDocParameterTag */);
+ }
var parameterType = getTypeOfSymbol(parameterSymbol);
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
parameterType = getOptionalType(parameterType);
@@ -29643,9 +29803,9 @@ var ts;
var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined;
var name = parameterDeclaration
? parameterDeclaration.name ?
- parameterDeclaration.name.kind === 71 /* Identifier */ ?
- ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) :
- cloneBindingName(parameterDeclaration.name) :
+ parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) :
+ parameterDeclaration.name.kind === 145 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) :
+ cloneBindingName(parameterDeclaration.name) :
ts.symbolName(parameterSymbol)
: ts.symbolName(parameterSymbol);
var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined;
@@ -29665,7 +29825,7 @@ var ts;
}
}
}
- function lookupSymbolChain(symbol, context, meaning) {
+ function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
// Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration.
var chain;
@@ -29701,7 +29861,7 @@ var ts;
// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
endOfChain ||
// If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
- !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) &&
+ (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) &&
// If a parent symbol is an anonymous type, don't write it.
!(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
return [symbol];
@@ -29742,8 +29902,8 @@ var ts;
}
return top;
}
- function symbolToTypeNode(symbol, context, meaning) {
- var chain = lookupSymbolChain(symbol, context, meaning);
+ function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
+ var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
context.flags |= 16777216 /* InInitialEntityName */;
var rootName = getNameOfSymbolAsWritten(chain[0], context);
context.flags ^= 16777216 /* InInitialEntityName */;
@@ -29751,9 +29911,13 @@ var ts;
if (ambientModuleSymbolRegex.test(rootName)) {
// module is root, must use `ImportTypeNode`
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
- var typeParameterNodes = lookupTypeParameterNodes(chain, 0, context);
+ var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1)));
if (!nonRootParts || ts.isEntityName(nonRootParts)) {
+ if (nonRootParts) {
+ var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
+ lastId.typeArguments = undefined;
+ }
return ts.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
}
else {
@@ -29766,9 +29930,17 @@ var ts;
if (ts.isIndexedAccessTypeNode(entityName)) {
return entityName; // Indexed accesses can never be `typeof`
}
- return isTypeOf ? ts.createTypeQueryNode(entityName) : ts.createTypeReferenceNode(entityName, /*typeArguments*/ undefined);
+ if (isTypeOf) {
+ return ts.createTypeQueryNode(entityName);
+ }
+ else {
+ var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
+ var lastTypeArgs = lastId.typeArguments;
+ lastId.typeArguments = undefined;
+ return ts.createTypeReferenceNode(entityName, lastTypeArgs);
+ }
function createAccessFromSymbolChain(chain, index, stopper) {
- var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
+ var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
var symbol = chain[index];
if (index === 0) {
context.flags |= 16777216 /* InInitialEntityName */;
@@ -29778,7 +29950,7 @@ var ts;
context.flags ^= 16777216 /* InInitialEntityName */;
}
var parent = chain[index - 1];
- if (parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
+ if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
// Should use an indexed access
var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
if (ts.isIndexedAccessTypeNode(LHS)) {
@@ -29946,6 +30118,24 @@ var ts;
return "default";
}
if (symbol.declarations && symbol.declarations.length) {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) {
+ var file_3 = ts.getDeclarationOfKind(symbol, 273 /* SourceFile */);
+ if (!file_3 || !context.tracker.moduleResolverHost) {
+ if (context.tracker.trackReferencedAmbientModule) {
+ var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
+ if (ts.length(ambientDecls)) {
+ for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
+ var decl = ambientDecls_1[_i];
+ context.tracker.trackReferencedAmbientModule(decl);
+ }
+ }
+ }
+ // ambient module, just use declaration/symbol name (fallthrough)
+ }
+ else {
+ return "\"" + ts.getResolvedExternalModuleName(context.tracker.moduleResolverHost, file_3, ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration))) + "\"";
+ }
+ }
var declaration = symbol.declarations[0];
var name = ts.getNameOfDeclaration(declaration);
if (name) {
@@ -29987,8 +30177,9 @@ var ts;
return false;
function determineIfDeclarationIsVisible() {
switch (node.kind) {
- case 294 /* JSDocTypedefTag */:
- // Top-level jsdoc typedefs are considered exported
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ // Top-level jsdoc type aliases are considered exported
// First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file
return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
case 181 /* BindingElement */:
@@ -30703,7 +30894,7 @@ var ts;
if (symbol.flags & 4194304 /* Prototype */) {
return links.type = getTypeOfPrototypeProperty(symbol);
}
- // CommonsJS require/module/exports all have type any.
+ // CommonsJS require and module both have type any.
if (symbol === requireSymbol || symbol === moduleSymbol) {
return links.type = anyType;
}
@@ -30737,7 +30928,7 @@ var ts;
declaration.kind === 184 /* PropertyAccessExpression */ && declaration.parent.kind === 199 /* BinaryExpression */) {
type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol);
}
- else if (ts.isJSDocPropertyTag(declaration)
+ else if (ts.isJSDocPropertyLikeTag(declaration)
|| ts.isPropertyAccessExpression(declaration)
|| ts.isIdentifier(declaration)
|| (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
@@ -31014,7 +31205,9 @@ var ts;
case 191 /* FunctionExpression */:
case 192 /* ArrowFunction */:
case 236 /* TypeAliasDeclaration */:
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
case 176 /* MappedType */:
case 170 /* ConditionalType */:
var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
@@ -31024,7 +31217,7 @@ var ts;
else if (node.kind === 170 /* ConditionalType */) {
return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
}
- var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray);
+ var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
var thisType = includeThisTypes &&
(node.kind === 234 /* ClassDeclaration */ || node.kind === 204 /* ClassExpression */ || node.kind === 235 /* InterfaceDeclaration */) &&
getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
@@ -31043,13 +31236,12 @@ var ts;
var result;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var node = _a[_i];
- if (node.kind === 235 /* InterfaceDeclaration */ || node.kind === 234 /* ClassDeclaration */ ||
- node.kind === 204 /* ClassExpression */ || node.kind === 236 /* TypeAliasDeclaration */ || node.kind === 294 /* JSDocTypedefTag */) {
+ if (node.kind === 235 /* InterfaceDeclaration */ ||
+ node.kind === 234 /* ClassDeclaration */ ||
+ node.kind === 204 /* ClassExpression */ ||
+ ts.isTypeAlias(node)) {
var declaration = node;
- var typeParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- if (typeParameters) {
- result = appendTypeParameters(result, typeParameters);
- }
+ result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
}
}
return result;
@@ -31326,9 +31518,9 @@ var ts;
return unknownType;
}
var declaration = ts.find(symbol.declarations, function (d) {
- return d.kind === 294 /* JSDocTypedefTag */ || d.kind === 236 /* TypeAliasDeclaration */;
+ return ts.isJSDocTypeAlias(d) || d.kind === 236 /* TypeAliasDeclaration */;
});
- var typeNode = declaration.kind === 294 /* JSDocTypedefTag */ ? declaration.typeExpression : declaration.type;
+ var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
// If typeNode is missing, we will error in checkJSDocTypedefTag.
var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType;
if (popTypeResolution()) {
@@ -31533,7 +31725,7 @@ var ts;
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
return (node.kind === 154 /* Constructor */ || (returnType && isThislessType(returnType))) &&
node.parameters.every(isThislessVariableLikeDeclaration) &&
- (!typeParameters || typeParameters.every(isThislessTypeParameter));
+ typeParameters.every(isThislessTypeParameter);
}
/**
* Returns true if the class or interface member given by the symbol is free of "this" references. The
@@ -31714,9 +31906,9 @@ var ts;
// If we have an existing early-bound member, combine its declarations so that we can
// report an error at each declaration.
var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
- var name_3 = ts.declarationNameToString(decl.name);
- ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_3); });
- error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_3);
+ var name_2 = ts.declarationNameToString(decl.name);
+ ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_2); });
+ error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_2);
lateSymbol = createSymbol(0 /* None */, memberName, 1024 /* Late */);
}
lateSymbol.nameType = type;
@@ -32783,9 +32975,10 @@ var ts;
// type checking functions).
function getTypeParametersFromDeclaration(declaration) {
var result;
- ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) {
+ for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
+ var node = _a[_i];
result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
- });
+ }
return result;
}
function symbolsToArray(symbols) {
@@ -32815,7 +33008,7 @@ var ts;
return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
}
function isOptionalParameter(node) {
- if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) {
+ if (ts.hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) {
return true;
}
if (node.initializer) {
@@ -32832,6 +33025,13 @@ var ts;
}
return false;
}
+ function isOptionalJSDocParameterTag(node) {
+ if (!ts.isJSDocParameterTag(node)) {
+ return false;
+ }
+ var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
+ return isBracketed || !!typeExpression && typeExpression.type.kind === 282 /* JSDocOptionalType */;
+ }
function createTypePredicateFromTypePredicateNode(node) {
var parameterName = node.parameterName;
var type = getTypeFromTypeNode(node.type);
@@ -32920,6 +33120,7 @@ var ts;
for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
var param = declaration.parameters[i];
var paramSymbol = param.symbol;
+ var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
// Include parameter symbol instead of property symbol in the signature
if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) {
var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67216319 /* Value */, undefined, undefined, /*isUse*/ false);
@@ -32932,12 +33133,13 @@ var ts;
else {
parameters.push(paramSymbol);
}
- if (param.type && param.type.kind === 177 /* LiteralType */) {
+ if (type && type.kind === 177 /* LiteralType */) {
hasLiteralTypes = true;
}
// Record a new minimum argument count if this is not an optional parameter
- var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken ||
- iife && parameters.length > iife.arguments.length && !param.type ||
+ var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) ||
+ param.initializer || param.questionToken || param.dotDotDotToken ||
+ iife && parameters.length > iife.arguments.length && !type ||
isUntypedSignatureInJSFile ||
isJSDocOptionalParameter(param);
if (!isOptionalParameter_1) {
@@ -32971,7 +33173,7 @@ var ts;
* 2. It has at least one parameter, and the last parameter has a matching `@param` with a type that starts with `...`
*/
function maybeAddJsSyntheticRestParameter(declaration, parameters) {
- if (!containsArgumentsReference(declaration)) {
+ if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
return false;
}
var lastParam = ts.lastOrUndefined(declaration.parameters);
@@ -33364,7 +33566,7 @@ var ts;
var isJs = ts.isInJavaScriptFile(node);
var isJsImplicitAny = !noImplicitAny && isJs;
if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
- var missingAugmentsTag = isJs && node.parent.kind !== 288 /* JSDocAugmentsTag */;
+ var missingAugmentsTag = isJs && node.parent.kind !== 289 /* JSDocAugmentsTag */;
var diag = minTypeArgumentCount === typeParameters.length
? missingAugmentsTag
? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag
@@ -33515,7 +33717,7 @@ var ts;
}
function getConstrainedTypeVariable(typeVariable, node) {
var constraints;
- while (node && !ts.isStatement(node)) {
+ while (node && !ts.isStatement(node) && node.kind !== 285 /* JSDocComment */) {
var parent = node.parent;
if (parent.kind === 170 /* ConditionalType */ && node === parent.trueType) {
var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType);
@@ -33965,7 +34167,7 @@ var ts;
includes & 4096 /* Undefined */ ? includes & 16777216 /* NonWideningType */ ? undefinedType : undefinedWideningType :
neverType;
}
- return getUnionTypeFromSortedList(typeSet, aliasSymbol, aliasTypeArguments);
+ return getUnionTypeFromSortedList(typeSet, includes & 8374815 /* NotUnit */ ? 0 : 268435456 /* UnionOfUnitTypes */, aliasSymbol, aliasTypeArguments);
}
function getUnionTypePredicate(signatures) {
var first;
@@ -34002,7 +34204,7 @@ var ts;
: !ts.isIdentifierTypePredicate(b);
}
// This function assumes the constituent type list is sorted and deduplicated.
- function getUnionTypeFromSortedList(types, aliasSymbol, aliasTypeArguments) {
+ function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) {
if (types.length === 0) {
return neverType;
}
@@ -34013,7 +34215,7 @@ var ts;
var type = unionTypes.get(id);
if (!type) {
var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 12288 /* Nullable */);
- type = createType(131072 /* Union */ | propagatedFlags);
+ type = createType(131072 /* Union */ | propagatedFlags | unionOfUnitTypes);
unionTypes.set(id, type);
type.types = types;
/*
@@ -34030,7 +34232,8 @@ var ts;
function getTypeFromUnionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -34079,6 +34282,31 @@ var ts;
}
}
}
+ // When intersecting unions of unit types we can simply intersect based on type identity.
+ // Here we remove all unions of unit types from the given list and replace them with a
+ // a single union containing an intersection of the unit types.
+ function intersectUnionsOfUnitTypes(types) {
+ var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456 /* UnionOfUnitTypes */) !== 0; });
+ var unionType = types[unionIndex];
+ var intersection = unionType.types;
+ var i = types.length - 1;
+ var _loop_5 = function () {
+ var t = types[i];
+ if (t.flags & 268435456 /* UnionOfUnitTypes */) {
+ intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); });
+ ts.orderedRemoveItemAt(types, i);
+ }
+ i--;
+ };
+ while (i > unionIndex) {
+ _loop_5();
+ }
+ if (intersection === unionType.types) {
+ return false;
+ }
+ types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456 /* UnionOfUnitTypes */);
+ return true;
+ }
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
@@ -34113,6 +34341,12 @@ var ts;
return typeSet[0];
}
if (includes & 131072 /* Union */) {
+ if (includes & 268435456 /* UnionOfUnitTypes */ && intersectUnionsOfUnitTypes(typeSet)) {
+ // When the intersection creates a reduced set (which might mean that *all* union types have
+ // disappeared), we restart the operation to get a new set of combined flags. Once we have
+ // reduced we'll never reduce again, so this occurs at most once.
+ return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
// We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
// the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072 /* Union */) !== 0; });
@@ -34134,7 +34368,8 @@ var ts;
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -34425,7 +34660,7 @@ var ts;
var type = createObjectType(32 /* Mapped */, node.symbol);
type.declaration = node;
type.aliasSymbol = getAliasSymbolForTypeNode(node);
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
links.resolvedType = type;
// Eagerly resolve the constraint type which forces an error if the constraint type circularly
// references itself through one or more type aliases.
@@ -34526,7 +34761,8 @@ var ts;
var links = getNodeLinks(node);
if (!links.resolvedType) {
var checkType = getTypeFromTypeNode(node.checkType);
- var aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
var allOuterTypeParameters = getOuterTypeParameters(node, /*includeThisTypes*/ true);
var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isPossiblyReferencedInConditionalType(tp, node); });
var root = {
@@ -34539,7 +34775,7 @@ var ts;
inferTypeParameters: getInferTypeParameters(node),
outerTypeParameters: outerTypeParameters,
instantiations: undefined,
- aliasSymbol: getAliasSymbolForTypeNode(node),
+ aliasSymbol: aliasSymbol,
aliasTypeArguments: aliasTypeArguments
};
links.resolvedType = getConditionalType(root, /*mapper*/ undefined);
@@ -34638,7 +34874,7 @@ var ts;
else {
var type = createObjectType(16 /* Anonymous */, node.symbol);
type.aliasSymbol = aliasSymbol;
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
type = createArrayType(type);
}
@@ -34648,10 +34884,9 @@ var ts;
return links.resolvedType;
}
function getAliasSymbolForTypeNode(node) {
- return (node.parent.kind === 236 /* TypeAliasDeclaration */ || node.parent.kind === 294 /* JSDocTypedefTag */) ? getSymbolOfNode(node.parent) : undefined;
+ return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined;
}
- function getAliasTypeArgumentsForTypeNode(node) {
- var symbol = getAliasSymbolForTypeNode(node);
+ function getTypeArgumentsForAliasSymbol(symbol) {
return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
}
/**
@@ -34887,6 +35122,7 @@ var ts;
case 165 /* TypeLiteral */:
case 286 /* JSDocTypeLiteral */:
case 283 /* JSDocFunctionType */:
+ case 287 /* JSDocSignature */:
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
case 174 /* TypeOperator */:
return getTypeFromTypeOperatorNode(node);
@@ -35076,6 +35312,15 @@ var ts;
// aren't the right hand side of a generic type alias declaration we optimize by reducing the
// set of type parameters to those that are possibly referenced in the literal.
var declaration_1 = symbol.declarations[0];
+ if (ts.isInJavaScriptFile(declaration_1)) {
+ var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag);
+ if (paramTag) {
+ var paramSymbol = ts.getParameterSymbolFromJSDoc(paramTag);
+ if (paramSymbol) {
+ declaration_1 = paramSymbol.valueDeclaration;
+ }
+ }
+ }
var outerTypeParameters = getOuterTypeParameters(declaration_1, /*includeThisTypes*/ true);
if (isJavaScriptConstructor(declaration_1)) {
var templateTagParameters = getTypeParametersFromDeclaration(declaration_1);
@@ -35117,8 +35362,8 @@ var ts;
// between the node and the type parameter declaration, if the node contains actual references to the
// type parameter, or if the node contains type queries, we consider the type parameter possibly referenced.
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
- var container_2 = tp.symbol.declarations[0].parent;
- if (ts.findAncestor(node, function (n) { return n.kind === 212 /* Block */ ? "quit" : n === container_2; })) {
+ var container_3 = tp.symbol.declarations[0].parent;
+ if (ts.findAncestor(node, function (n) { return n.kind === 212 /* Block */ ? "quit" : n === container_3; })) {
return ts.forEachChild(node, containsReference);
}
}
@@ -35968,7 +36213,7 @@ var ts;
// check excess properties against discriminant type only, not the entire union
return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors);
}
- var _loop_5 = function (prop) {
+ var _loop_6 = function (prop) {
if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
if (reportErrors) {
// We know *exactly* where things went wrong when comparing the types.
@@ -36005,7 +36250,7 @@ var ts;
};
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
- var state_3 = _loop_5(prop);
+ var state_3 = _loop_6(prop);
if (typeof state_3 === "object")
return state_3.value;
}
@@ -38558,7 +38803,7 @@ var ts;
if (type.flags & 131072 /* Union */) {
var types = type.types;
var filtered = ts.filter(types, f);
- return filtered === types ? type : getUnionTypeFromSortedList(filtered);
+ return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456 /* UnionOfUnitTypes */);
}
return f(type) ? type : neverType;
}
@@ -40514,10 +40759,11 @@ var ts;
links.resolvedSignatures = ts.createMap();
}
var cacheKey = "" + getTypeId(valueType);
- if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) !== resolvingSignaturesArray) {
- signatures = links.resolvedSignatures.get(cacheKey);
+ var cachedResolved = links.resolvedSignatures.get(cacheKey);
+ if (cachedResolved && cachedResolved !== resolvingSignaturesArray) {
+ signatures = cachedResolved;
}
- else if (!links.resolvedSignatures.get(cacheKey)) {
+ else if (!cachedResolved) {
links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray);
links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures));
}
@@ -41739,7 +41985,7 @@ var ts;
// Assignability failure - check each prop individually, and if that fails, fall back on the bad error span
if (ts.length(openingLikeElement.attributes.properties)) {
var reportedError = false;
- var _loop_6 = function (prop) {
+ var _loop_7 = function (prop) {
if (ts.isJsxSpreadAttribute(prop))
return "continue";
var name = ts.idText(prop.name);
@@ -41753,7 +41999,7 @@ var ts;
};
for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) {
var prop = _c[_b];
- _loop_6(prop);
+ _loop_7(prop);
}
if (reportedError) {
return;
@@ -43780,8 +44026,8 @@ var ts;
if (allowSyntheticDefaultImports && type && type !== unknownType) {
var synthType = type;
if (!synthType.syntheticType) {
- var file_3 = ts.find(originalSymbol.declarations, ts.isSourceFile);
- var hasSyntheticDefault = canHaveSyntheticDefault(file_3, originalSymbol, /*dontResolveAlias*/ false);
+ var file_4 = ts.find(originalSymbol.declarations, ts.isSourceFile);
+ var hasSyntheticDefault = canHaveSyntheticDefault(file_4, originalSymbol, /*dontResolveAlias*/ false);
if (hasSyntheticDefault) {
var memberTable = ts.createSymbolTable();
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
@@ -46298,8 +46544,9 @@ var ts;
switch (d.kind) {
case 235 /* InterfaceDeclaration */:
case 236 /* TypeAliasDeclaration */:
- // A jsdoc typedef is, by definition, a type alias
- case 294 /* JSDocTypedefTag */:
+ // A jsdoc typedef and callback are, by definition, type aliases
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
return 2 /* ExportType */;
case 238 /* ModuleDeclaration */:
return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */
@@ -46768,7 +47015,7 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function checkJSDocTypedefTag(node) {
+ function checkJSDocTypeAliasTag(node) {
if (!node.typeExpression) {
// If the node had `@property` tags, `typeExpression` would have been set to the first property tag.
error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
@@ -47002,7 +47249,7 @@ var ts;
// Only report errors on the last declaration for the type parameter container;
// this ensures that all uses have been accounted for.
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (!(node.flags & 4194304 /* Ambient */) && typeParameters && ts.last(getSymbolOfNode(node).declarations) === node) {
+ if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) {
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
var typeParameter = typeParameters_2[_i];
if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) {
@@ -48270,7 +48517,7 @@ var ts;
var declaration = declarations_6[_i];
// If this declaration has too few or too many type parameters, we report an error
var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- var numTypeParameters = ts.length(sourceParameters);
+ var numTypeParameters = sourceParameters.length;
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
return false;
}
@@ -48418,7 +48665,7 @@ var ts;
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
var issuedMemberError = false;
- var _loop_7 = function (member) {
+ var _loop_8 = function (member) {
if (ts.hasStaticModifier(member)) {
return "continue";
}
@@ -48437,7 +48684,7 @@ var ts;
};
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- _loop_7(member);
+ _loop_8(member);
}
if (!issuedMemberError) {
// check again with diagnostics to generate a less-specific error
@@ -49394,11 +49641,12 @@ var ts;
return checkInferType(node);
case 178 /* ImportType */:
return checkImportType(node);
- case 288 /* JSDocAugmentsTag */:
+ case 289 /* JSDocAugmentsTag */:
return checkJSDocAugmentsTag(node);
- case 294 /* JSDocTypedefTag */:
- return checkJSDocTypedefTag(node);
- case 290 /* JSDocParameterTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ return checkJSDocTypeAliasTag(node);
+ case 292 /* JSDocParameterTag */:
return checkJSDocParameterTag(node);
case 283 /* JSDocFunctionType */:
checkSignatureDeclaration(node);
@@ -49526,8 +49774,8 @@ var ts;
var paramTag = parent.parent;
if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) {
// Else we will add a diagnostic, see `checkJSDocVariadicType`.
- var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
- if (host_2) {
+ var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
+ if (host_1) {
/*
Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters.
So in the following situation we will not create an array type:
@@ -49535,7 +49783,7 @@ var ts;
function f(a) {}
Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type.
*/
- var lastParamDeclaration = ts.lastOrUndefined(host_2.parameters);
+ var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
if (!lastParamDeclaration ||
symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
@@ -49927,10 +50175,10 @@ var ts;
return entityNameSymbol;
}
}
- if (entityName.parent.kind === 290 /* JSDocParameterTag */) {
+ if (entityName.parent.kind === 292 /* JSDocParameterTag */) {
return ts.getParameterSymbolFromJSDoc(entityName.parent);
}
- if (entityName.parent.kind === 147 /* TypeParameter */ && entityName.parent.parent.kind === 293 /* JSDocTemplateTag */) {
+ if (entityName.parent.kind === 147 /* TypeParameter */ && entityName.parent.parent.kind === 295 /* JSDocTemplateTag */) {
ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true.
var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent);
return typeParameter && typeParameter.symbol;
@@ -50470,6 +50718,7 @@ var ts;
function isRequiredInitializedParameter(parameter) {
return strictNullChecks &&
!isOptionalParameter(parameter) &&
+ !ts.isJSDocParameterTag(parameter) &&
parameter.initializer &&
!ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */);
}
@@ -50771,8 +51020,8 @@ var ts;
var decl = _a[_i];
// check meaning of the local symbol to see if declaration needs to be analyzed further
if (decl.symbol && decl.symbol.flags & meaning) {
- var file_4 = ts.getSourceFileOfNode(decl);
- var typeReferenceDirective = fileToDirective.get(file_4.path);
+ var file_5 = ts.getSourceFileOfNode(decl);
+ var typeReferenceDirective = fileToDirective.get(file_5.path);
if (typeReferenceDirective) {
(typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
}
@@ -50807,8 +51056,8 @@ var ts;
// check that at least one declaration of top level symbol originates from type declaration file
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var file_5 = ts.getSourceFileOfNode(decl);
- if (fileToDirective.has(file_5.path)) {
+ var file_6 = ts.getSourceFileOfNode(decl);
+ if (fileToDirective.has(file_6.path)) {
return true;
}
}
@@ -50826,25 +51075,25 @@ var ts;
function initializeTypeChecker() {
// Bind all source files and propagate errors
for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
- var file_6 = _a[_i];
- ts.bindSourceFile(file_6, compilerOptions);
+ var file_7 = _a[_i];
+ ts.bindSourceFile(file_7, compilerOptions);
}
// Initialize global symbol table
var augmentations;
for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
- var file_7 = _c[_b];
- if (!ts.isExternalOrCommonJsModule(file_7)) {
- mergeSymbolTable(globals, file_7.locals);
+ var file_8 = _c[_b];
+ if (!ts.isExternalOrCommonJsModule(file_8)) {
+ mergeSymbolTable(globals, file_8.locals);
}
- if (file_7.patternAmbientModules && file_7.patternAmbientModules.length) {
- patternAmbientModules = ts.concatenate(patternAmbientModules, file_7.patternAmbientModules);
+ if (file_8.patternAmbientModules && file_8.patternAmbientModules.length) {
+ patternAmbientModules = ts.concatenate(patternAmbientModules, file_8.patternAmbientModules);
}
- if (file_7.moduleAugmentations.length) {
- (augmentations || (augmentations = [])).push(file_7.moduleAugmentations);
+ if (file_8.moduleAugmentations.length) {
+ (augmentations || (augmentations = [])).push(file_8.moduleAugmentations);
}
- if (file_7.symbol && file_7.symbol.globalExports) {
+ if (file_8.symbol && file_8.symbol.globalExports) {
// Merge in UMD exports with first-in-wins semantics (see #9771)
- var source = file_7.symbol.globalExports;
+ var source = file_8.symbol.globalExports;
source.forEach(function (sourceSymbol, id) {
if (!globals.has(id)) {
globals.set(id, sourceSymbol);
@@ -51296,7 +51545,7 @@ var ts;
}
function checkGrammarClassLikeDeclaration(node) {
var file = ts.getSourceFileOfNode(node);
- return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(ts.getEffectiveTypeParameterDeclarations(node), file);
+ return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
}
function checkGrammarArrowFunction(node, file) {
if (!ts.isArrowFunction(node)) {
@@ -51981,8 +52230,8 @@ var ts;
}
function checkGrammarConstructorTypeParameters(node) {
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (typeParameters) {
- var _a = ts.isNodeArray(typeParameters) ? typeParameters : ts.first(typeParameters), pos = _a.pos, end = _a.end;
+ if (ts.isNodeArray(typeParameters)) {
+ var pos = typeParameters.pos, end = typeParameters.end;
return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
}
}
@@ -52446,7 +52695,7 @@ var ts;
ts.updateQualifiedName = updateQualifiedName;
function parenthesizeForComputedName(expression) {
return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) ||
- expression.kind === 299 /* CommaListExpression */ ?
+ expression.kind === 301 /* CommaListExpression */ ?
createParen(expression) :
expression;
}
@@ -54425,7 +54674,7 @@ var ts;
* @param original The original statement.
*/
function createNotEmittedStatement(original) {
- var node = createSynthesizedNode(297 /* NotEmittedStatement */);
+ var node = createSynthesizedNode(299 /* NotEmittedStatement */);
node.original = original;
setTextRange(node, original);
return node;
@@ -54437,7 +54686,7 @@ var ts;
*/
/* @internal */
function createEndOfDeclarationMarker(original) {
- var node = createSynthesizedNode(301 /* EndOfDeclarationMarker */);
+ var node = createSynthesizedNode(303 /* EndOfDeclarationMarker */);
node.emitNode = {};
node.original = original;
return node;
@@ -54449,7 +54698,7 @@ var ts;
*/
/* @internal */
function createMergeDeclarationMarker(original) {
- var node = createSynthesizedNode(300 /* MergeDeclarationMarker */);
+ var node = createSynthesizedNode(302 /* MergeDeclarationMarker */);
node.emitNode = {};
node.original = original;
return node;
@@ -54464,7 +54713,7 @@ var ts;
* @param location The location for the expression. Defaults to the positions from "original" if provided.
*/
function createPartiallyEmittedExpression(expression, original) {
- var node = createSynthesizedNode(298 /* PartiallyEmittedExpression */);
+ var node = createSynthesizedNode(300 /* PartiallyEmittedExpression */);
node.expression = expression;
node.original = original;
setTextRange(node, original);
@@ -54480,7 +54729,7 @@ var ts;
ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression;
function flattenCommaElements(node) {
if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
- if (node.kind === 299 /* CommaListExpression */) {
+ if (node.kind === 301 /* CommaListExpression */) {
return node.elements;
}
if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) {
@@ -54490,7 +54739,7 @@ var ts;
return node;
}
function createCommaList(elements) {
- var node = createSynthesizedNode(299 /* CommaListExpression */);
+ var node = createSynthesizedNode(301 /* CommaListExpression */);
node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
return node;
}
@@ -55778,7 +56027,7 @@ var ts;
// if should be wrapped in parens since comma operator has the lowest precedence
var emittedExpression = ts.skipPartiallyEmittedExpressions(e);
return emittedExpression.kind === 199 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ ||
- emittedExpression.kind === 299 /* CommaListExpression */
+ emittedExpression.kind === 301 /* CommaListExpression */
? ts.createParen(e)
: e;
}
@@ -55798,7 +56047,7 @@ var ts;
var check = ts.skipPartiallyEmittedExpressions(e);
return (check.kind === 204 /* ClassExpression */ ||
check.kind === 191 /* FunctionExpression */ ||
- check.kind === 299 /* CommaListExpression */ ||
+ check.kind === 301 /* CommaListExpression */ ||
ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */)
? ts.createParen(e)
: e;
@@ -55963,7 +56212,7 @@ var ts;
case 184 /* PropertyAccessExpression */:
node = node.expression;
continue;
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
node = node.expression;
continue;
}
@@ -55993,7 +56242,7 @@ var ts;
case 207 /* AsExpression */:
case 208 /* NonNullExpression */:
return (kinds & 2 /* Assertions */) !== 0;
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0;
}
return false;
@@ -56030,7 +56279,7 @@ var ts;
case 189 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression);
case 207 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type);
case 208 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression);
- case 298 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
+ case 300 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
}
}
/**
@@ -56815,9 +57064,9 @@ var ts;
case 273 /* SourceFile */:
return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context));
// Transformation nodes
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression));
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression));
default:
// No need to visit nodes with no children.
@@ -56873,7 +57122,7 @@ var ts;
case 214 /* EmptyStatement */:
case 205 /* OmittedExpression */:
case 230 /* DebuggerStatement */:
- case 297 /* NotEmittedStatement */:
+ case 299 /* NotEmittedStatement */:
// No need to visit nodes with no children.
break;
// Names
@@ -57252,10 +57501,10 @@ var ts;
result = reduceNodes(node.statements, cbNodes, result);
break;
// Transformation nodes
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
result = reduceNode(node.expression, cbNode, result);
break;
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
result = reduceNodes(node.elements, cbNodes, result);
break;
default:
@@ -68885,9 +69134,9 @@ var ts;
return visitFunctionDeclaration(node);
case 234 /* ClassDeclaration */:
return visitClassDeclaration(node);
- case 300 /* MergeDeclarationMarker */:
+ case 302 /* MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 301 /* EndOfDeclarationMarker */:
+ case 303 /* EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
@@ -70819,9 +71068,9 @@ var ts;
return visitCatchClause(node);
case 212 /* Block */:
return visitBlock(node);
- case 300 /* MergeDeclarationMarker */:
+ case 302 /* MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 301 /* EndOfDeclarationMarker */:
+ case 303 /* EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return destructuringAndImportCallVisitor(node);
@@ -71888,19 +72137,22 @@ var ts;
var lateMarkedStatements;
var lateStatementReplacementMap;
var suppressNewDiagnosticContexts;
+ var host = context.getEmitHost();
var symbolTracker = {
trackSymbol: trackSymbol,
reportInaccessibleThisError: reportInaccessibleThisError,
reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
- reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression
+ reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
+ moduleResolverHost: host,
+ trackReferencedAmbientModule: trackReferencedAmbientModule,
};
var errorNameNode;
var currentSourceFile;
+ var refs;
var resolver = context.getEmitResolver();
var options = context.getCompilerOptions();
var newLine = ts.getNewLineCharacter(options);
var noResolve = options.noResolve, stripInternal = options.stripInternal;
- var host = context.getEmitHost();
return transformRoot;
function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
if (!typeReferenceDirectives) {
@@ -71912,6 +72164,10 @@ var ts;
necessaryTypeRefernces.set(ref, true);
}
}
+ function trackReferencedAmbientModule(node) {
+ var container = ts.getSourceFileOfNode(node);
+ refs.set("" + ts.getOriginalNodeId(container), container);
+ }
function handleSymbolAccessibilityError(symbolAccessibilityResult) {
if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
// Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info
@@ -72019,13 +72275,13 @@ var ts;
lateMarkedStatements = undefined;
lateStatementReplacementMap = ts.createMap();
necessaryTypeRefernces = undefined;
- var refs = collectReferences(currentSourceFile, ts.createMap());
+ refs = collectReferences(currentSourceFile, ts.createMap());
var references = [];
var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath));
var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
- refs.forEach(referenceVisitor);
var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
+ refs.forEach(referenceVisitor);
var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined)])), combinedStatements);
@@ -72037,17 +72293,19 @@ var ts;
}
function getFileReferenceForTypeName(typeName) {
// Elide type references for which we have imports
- for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
- var importStatement = emittedImports_1[_i];
- if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
- var expr = importStatement.moduleReference.expression;
- if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ if (emittedImports) {
+ for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
+ var importStatement = emittedImports_1[_i];
+ if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
+ var expr = importStatement.moduleReference.expression;
+ if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ return undefined;
+ }
+ }
+ else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
return undefined;
}
}
- else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
- return undefined;
- }
}
return { fileName: typeName, pos: -1, end: -1 };
}
@@ -72808,7 +73066,7 @@ var ts;
var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined);
var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile);
if (leadingsSyntheticCommentRanges) {
- var _loop_8 = function (range) {
+ var _loop_9 = function (range) {
if (range.kind === 3 /* MultiLineCommentTrivia */) {
var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2);
var lines = text.split(/\r\n?|\n/g);
@@ -72822,7 +73080,7 @@ var ts;
};
for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) {
var range = leadingsSyntheticCommentRanges_1[_i];
- _loop_8(range);
+ _loop_9(range);
}
}
return prop;
@@ -72984,7 +73242,7 @@ 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(302 /* Count */);
+ var enabledSyntaxKindFeatures = new Array(304 /* Count */);
var lexicalEnvironmentVariableDeclarations;
var lexicalEnvironmentFunctionDeclarations;
var lexicalEnvironmentVariableDeclarationsStack = [];
@@ -73479,7 +73737,7 @@ var ts;
source = undefined;
if (source)
setSourceFile(source);
- if (node.kind !== 297 /* NotEmittedStatement */
+ if (node.kind !== 299 /* NotEmittedStatement */
&& (emitFlags & 16 /* NoLeadingSourceMap */) === 0
&& pos >= 0) {
emitPos(skipSourceTrivia(pos));
@@ -73496,7 +73754,7 @@ var ts;
}
if (source)
setSourceFile(source);
- if (node.kind !== 297 /* NotEmittedStatement */
+ if (node.kind !== 299 /* NotEmittedStatement */
&& (emitFlags & 32 /* NoTrailingSourceMap */) === 0
&& end >= 0) {
emitPos(end);
@@ -73672,7 +73930,7 @@ var ts;
if (extendedDiagnostics) {
ts.performance.mark("preEmitNodeWithComment");
}
- var isEmittedNode = node.kind !== 297 /* NotEmittedStatement */;
+ var isEmittedNode = node.kind !== 299 /* 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 === 10 /* JsxText */;
@@ -74817,9 +75075,9 @@ var ts;
case 258 /* JsxFragment */:
return emitJsxFragment(node);
// Transformation nodes
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return emitPartiallyEmittedExpression(node);
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return emitCommaList(node);
}
}
@@ -77790,11 +78048,11 @@ var ts;
var diagnostic = diagnostics_2[_i];
var context_2 = "";
if (diagnostic.file) {
- var start = diagnostic.start, length_4 = diagnostic.length, file_8 = diagnostic.file;
- var _a = ts.getLineAndCharacterOfPosition(file_8, start), firstLine = _a.line, firstLineChar = _a.character;
- var _b = ts.getLineAndCharacterOfPosition(file_8, start + length_4), lastLine = _b.line, lastLineChar = _b.character;
- var lastLineInFile = ts.getLineAndCharacterOfPosition(file_8, file_8.text.length).line;
- var relativeFileName = host ? ts.convertToRelativePath(file_8.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_8.fileName;
+ var start = diagnostic.start, length_4 = diagnostic.length, file_9 = diagnostic.file;
+ var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character;
+ var _b = ts.getLineAndCharacterOfPosition(file_9, start + length_4), lastLine = _b.line, lastLineChar = _b.character;
+ var lastLineInFile = ts.getLineAndCharacterOfPosition(file_9, file_9.text.length).line;
+ var relativeFileName = host ? ts.convertToRelativePath(file_9.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_9.fileName;
var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
var gutterWidth = (lastLine + 1 + "").length;
if (hasMoreThanFiveLines) {
@@ -77808,9 +78066,9 @@ var ts;
context_2 += formatColorAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
i = lastLine - 1;
}
- var lineStart = ts.getPositionOfLineAndCharacter(file_8, i, 0);
- var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file_8, i + 1, 0) : file_8.text.length;
- var lineContent = file_8.text.slice(lineStart, lineEnd);
+ var lineStart = ts.getPositionOfLineAndCharacter(file_9, i, 0);
+ var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file_9, i + 1, 0) : file_9.text.length;
+ var lineContent = file_9.text.slice(lineStart, lineEnd);
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.
@@ -79180,31 +79438,31 @@ var ts;
// Get source file from normalized fileName
function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd, packageId) {
if (filesByName.has(path)) {
- var file_9 = filesByName.get(path);
+ var file_10 = filesByName.get(path);
// try to check if we've already seen this file but with a different casing in path
// NOTE: this only makes sense for case-insensitive file systems
- if (file_9 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_9.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
- reportFileNamesDifferOnlyInCasingError(fileName, file_9.fileName, refFile, refPos, refEnd);
+ if (file_10 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_10.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
+ reportFileNamesDifferOnlyInCasingError(fileName, file_10.fileName, refFile, refPos, refEnd);
}
// If the file was previously found via a node_modules search, but is now being processed as a root file,
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
- if (file_9 && sourceFilesFoundSearchingNodeModules.get(file_9.path) && currentNodeModulesDepth === 0) {
- sourceFilesFoundSearchingNodeModules.set(file_9.path, false);
+ if (file_10 && sourceFilesFoundSearchingNodeModules.get(file_10.path) && currentNodeModulesDepth === 0) {
+ sourceFilesFoundSearchingNodeModules.set(file_10.path, false);
if (!options.noResolve) {
- processReferencedFiles(file_9, isDefaultLib);
- processTypeReferenceDirectives(file_9);
+ processReferencedFiles(file_10, isDefaultLib);
+ processTypeReferenceDirectives(file_10);
}
- modulesWithElidedImports.set(file_9.path, false);
- processImportedModules(file_9);
+ modulesWithElidedImports.set(file_10.path, false);
+ processImportedModules(file_10);
}
// See if we need to reprocess the imports due to prior skipped imports
- else if (file_9 && modulesWithElidedImports.get(file_9.path)) {
+ else if (file_10 && modulesWithElidedImports.get(file_10.path)) {
if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
- modulesWithElidedImports.set(file_9.path, false);
- processImportedModules(file_9);
+ modulesWithElidedImports.set(file_10.path, false);
+ processImportedModules(file_10);
}
}
- return file_9;
+ return file_10;
}
var redirectedPath;
if (refFile) {
@@ -79431,9 +79689,9 @@ var ts;
function computeCommonSourceDirectory(sourceFiles) {
var fileNames = [];
for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
- var file_10 = sourceFiles_2[_i];
- if (!file_10.isDeclarationFile) {
- fileNames.push(file_10.fileName);
+ var file_11 = sourceFiles_2[_i];
+ if (!file_11.isDeclarationFile) {
+ fileNames.push(file_11.fileName);
}
}
return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
@@ -79537,14 +79795,14 @@ var ts;
if (options.composite && rootNames.length < files.length) {
var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); });
var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); });
- var _loop_9 = function (file_11) {
- if (normalizedRootNames.every(function (r) { return r !== file_11; })) {
- programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file_11));
+ var _loop_10 = function (file_12) {
+ if (normalizedRootNames.every(function (r) { return r !== file_12; })) {
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file_12));
}
};
for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
- var file_11 = sourceFiles_4[_i];
- _loop_9(file_11);
+ var file_12 = sourceFiles_4[_i];
+ _loop_10(file_12);
}
}
if (options.paths) {
@@ -83139,7 +83397,7 @@ var ts;
function serializeCompilerOptions(options) {
var result = ts.createMap();
var optionsNameMap = getOptionNameMap().optionNameMap;
- var _loop_10 = function (name) {
+ var _loop_11 = function (name) {
if (ts.hasProperty(options, name)) {
// tsconfig only options cannot be specified via command line,
// so we can assume that only types that can appear here string | number | boolean
@@ -83168,7 +83426,7 @@ var ts;
}
};
for (var name in options) {
- _loop_10(name);
+ _loop_11(name);
}
return result;
}
@@ -83814,30 +84072,30 @@ var ts;
if (filesSpecs) {
for (var _i = 0, filesSpecs_1 = filesSpecs; _i < filesSpecs_1.length; _i++) {
var fileName = filesSpecs_1[_i];
- var file_12 = ts.getNormalizedAbsolutePath(fileName, basePath);
- literalFileMap.set(keyMapper(file_12), file_12);
+ var file_13 = ts.getNormalizedAbsolutePath(fileName, basePath);
+ literalFileMap.set(keyMapper(file_13), file_13);
}
}
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
- var file_13 = _b[_a];
+ var file_14 = _b[_a];
// If we have already included a literal or wildcard path with a
// higher priority extension, we should skip this file.
//
// This handles cases where we may encounter both .ts and
// .d.ts (or .js if "allowJs" is enabled) in the same
// directory when they are compilation outputs.
- if (hasFileWithHigherPriorityExtension(file_13, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
+ if (hasFileWithHigherPriorityExtension(file_14, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
continue;
}
// We may have included a wildcard path with a lower priority
// extension due to the user-defined order of entries in the
// "include" array. If there is a lower priority extension in the
// same directory, we should remove it.
- removeWildcardFilesWithLowerPriorityExtension(file_13, wildcardFileMap, supportedExtensions, keyMapper);
- var key = keyMapper(file_13);
+ removeWildcardFilesWithLowerPriorityExtension(file_14, wildcardFileMap, supportedExtensions, keyMapper);
+ var key = keyMapper(file_14);
if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
- wildcardFileMap.set(key, file_13);
+ wildcardFileMap.set(key, file_14);
}
}
}
@@ -83899,8 +84157,8 @@ var ts;
if (include !== undefined) {
var recursiveKeys = [];
for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
- var file_14 = include_1[_i];
- var spec = ts.normalizePath(ts.combinePaths(path, file_14));
+ var file_15 = include_1[_i];
+ var spec = ts.normalizePath(ts.combinePaths(path, file_15));
if (excludeRegex && excludeRegex.test(spec)) {
continue;
}
@@ -84307,7 +84565,7 @@ var ts;
case 236 /* TypeAliasDeclaration */:
case 165 /* TypeLiteral */:
return 2 /* Type */;
- case 294 /* JSDocTypedefTag */:
+ case 296 /* 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 272 /* EnumMember */:
@@ -84516,7 +84774,7 @@ var ts;
}
ts.isExpressionOfExternalModuleImportEqualsDeclaration = isExpressionOfExternalModuleImportEqualsDeclaration;
function getContainerNode(node) {
- if (node.kind === 294 /* JSDocTypedefTag */) {
+ if (ts.isJSDocTypeAlias(node)) {
// This doesn't just apply to the node immediately under the comment, but to everything in its parent's scope.
// node.parent = the JSDoc comment, node.parent.parent = the node having the comment.
// Then we get parent again in the loop.
@@ -84554,7 +84812,10 @@ var ts;
case 204 /* ClassExpression */:
return "class" /* classElement */;
case 235 /* InterfaceDeclaration */: return "interface" /* interfaceElement */;
- case 236 /* TypeAliasDeclaration */: return "type" /* typeElement */;
+ case 236 /* TypeAliasDeclaration */:
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ return "type" /* typeElement */;
case 237 /* EnumDeclaration */: return "enum" /* enumElement */;
case 231 /* VariableDeclaration */:
return getKindOfVariableDeclaration(node);
@@ -84585,8 +84846,6 @@ var ts;
case 251 /* ExportSpecifier */:
case 245 /* NamespaceImport */:
return "alias" /* alias */;
- case 294 /* JSDocTypedefTag */:
- return "type" /* typeElement */;
case 199 /* BinaryExpression */:
var kind = ts.getSpecialPropertyAssignmentKind(node);
var right = node.right;
@@ -84648,6 +84907,10 @@ var ts;
return startEndContainsRange(r1.pos, r1.end, r2);
}
ts.rangeContainsRange = rangeContainsRange;
+ function rangeContainsPosition(r, pos) {
+ return r.pos <= pos && pos <= r.end;
+ }
+ ts.rangeContainsPosition = rangeContainsPosition;
function startEndContainsRange(start, end, range) {
return start <= range.pos && end >= range.end;
}
@@ -85429,6 +85692,25 @@ var ts;
return propSymbol;
}
ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement;
+ var NodeSet = /** @class */ (function () {
+ function NodeSet() {
+ this.map = ts.createMap();
+ }
+ NodeSet.prototype.add = function (node) {
+ this.map.set(String(ts.getNodeId(node)), node);
+ };
+ NodeSet.prototype.has = function (node) {
+ return this.map.has(String(ts.getNodeId(node)));
+ };
+ NodeSet.prototype.forEach = function (cb) {
+ this.map.forEach(cb);
+ };
+ NodeSet.prototype.some = function (pred) {
+ return ts.forEachEntry(this.map, pred) || false;
+ };
+ return NodeSet;
+ }());
+ ts.NodeSet = NodeSet;
})(ts || (ts = {}));
// Display-part writer helpers
/* @internal */
@@ -86430,20 +86712,22 @@ 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 290 /* JSDocParameterTag */:
+ case 292 /* JSDocParameterTag */:
processJSDocParameterTag(tag);
break;
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
processJSDocTemplateTag(tag);
+ pos = tag.end;
break;
- case 292 /* JSDocTypeTag */:
+ case 294 /* JSDocTypeTag */:
processElement(tag.typeExpression);
+ pos = tag.end;
break;
- case 291 /* JSDocReturnTag */:
+ case 293 /* JSDocReturnTag */:
processElement(tag.typeExpression);
+ pos = tag.end;
break;
}
- pos = tag.end;
}
}
if (pos !== docComment.end) {
@@ -86811,7 +87095,7 @@ var ts;
for (var path in paths) {
var patterns = paths[path];
if (paths.hasOwnProperty(path) && patterns) {
- var _loop_11 = function (name, kind) {
+ var _loop_12 = function (name, kind) {
// Path mappings may provide a duplicate way to get to something we've already added, so don't add again.
if (!result.some(function (entry) { return entry.name === name; })) {
result.push(nameAndKind(name, kind));
@@ -86819,7 +87103,7 @@ var ts;
};
for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host); _i < _a.length; _i++) {
var _b = _a[_i], name = _b.name, kind = _b.kind;
- _loop_11(name, kind);
+ _loop_12(name, kind);
}
}
}
@@ -86835,7 +87119,7 @@ var ts;
// (But do if we didn't find anything, e.g. 'package.json' missing.)
var foundGlobal = false;
if (fragmentDirectory === undefined) {
- var _loop_12 = function (moduleName) {
+ var _loop_13 = function (moduleName) {
if (!result.some(function (entry) { return entry.name === moduleName; })) {
foundGlobal = true;
result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */));
@@ -86843,7 +87127,7 @@ var ts;
};
for (var _e = 0, _f = enumerateNodeModulesVisibleToScript(host, scriptPath); _e < _f.length; _e++) {
var moduleName = _f[_e];
- _loop_12(moduleName);
+ _loop_13(moduleName);
}
}
if (!foundGlobal) {
@@ -87736,7 +88020,7 @@ var ts;
currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true);
if (!currentToken ||
(!ts.isDeclarationName(currentToken) &&
- (currentToken.parent.kind !== 295 /* JSDocPropertyTag */ ||
+ (currentToken.parent.kind !== 297 /* JSDocPropertyTag */ ||
currentToken.parent.name !== currentToken))) {
// Use as type location if inside tag's type expression
insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression);
@@ -87897,11 +88181,11 @@ var ts;
return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer };
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
- case 290 /* JSDocParameterTag */:
- case 295 /* JSDocPropertyTag */:
- case 291 /* JSDocReturnTag */:
- case 292 /* JSDocTypeTag */:
- case 294 /* JSDocTypedefTag */:
+ case 292 /* JSDocParameterTag */:
+ case 297 /* JSDocPropertyTag */:
+ case 293 /* JSDocReturnTag */:
+ case 294 /* JSDocTypeTag */:
+ case 296 /* JSDocTypedefTag */:
return true;
}
}
@@ -88939,7 +89223,7 @@ var ts;
function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) {
// class c { method() { } | method2() { } }
switch (location.kind) {
- case 296 /* SyntaxList */:
+ case 298 /* 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);
@@ -90189,8 +90473,8 @@ var ts;
case "symbol": {
var symbol = def.symbol;
var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind;
- var name_4 = displayParts_1.map(function (p) { return p.text; }).join("");
- return { node: symbol.declarations ? ts.getNameOfDeclaration(ts.first(symbol.declarations)) || ts.first(symbol.declarations) : originalNode, name: name_4, kind: kind_1, displayParts: displayParts_1 };
+ var name_3 = displayParts_1.map(function (p) { return p.text; }).join("");
+ return { node: symbol.declarations ? ts.getNameOfDeclaration(ts.first(symbol.declarations)) || ts.first(symbol.declarations) : originalNode, name: name_3, kind: kind_1, displayParts: displayParts_1 };
}
case "label": {
var node_3 = def.node;
@@ -90198,8 +90482,8 @@ var ts;
}
case "keyword": {
var node_4 = def.node;
- var name_5 = ts.tokenToString(node_4.kind);
- return { node: node_4, name: name_5, kind: "keyword" /* keyword */, displayParts: [{ text: name_5, kind: "keyword" /* keyword */ }] };
+ var name_4 = ts.tokenToString(node_4.kind);
+ return { node: node_4, name: name_4, kind: "keyword" /* keyword */, displayParts: [{ text: name_4, kind: "keyword" /* keyword */ }] };
}
case "this": {
var node_5 = def.node;
@@ -91568,14 +91852,14 @@ var ts;
function getReferenceAtPosition(sourceFile, position, program) {
var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position);
if (referencePath) {
- var file_15 = ts.tryResolveScriptReference(program, sourceFile, referencePath);
- return file_15 && { fileName: referencePath.fileName, file: file_15 };
+ var file_16 = ts.tryResolveScriptReference(program, sourceFile, referencePath);
+ return file_16 && { fileName: referencePath.fileName, file: file_16 };
}
var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
if (typeReferenceDirective) {
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
- var file_16 = reference && program.getSourceFile(reference.resolvedFileName);
- return file_16 && { fileName: typeReferenceDirective.fileName, file: file_16 };
+ var file_17 = reference && program.getSourceFile(reference.resolvedFileName);
+ return file_17 && { fileName: typeReferenceDirective.fileName, file: file_17 };
}
return undefined;
}
@@ -91747,6 +92031,7 @@ var ts;
"author",
"argument",
"borrows",
+ "callback",
"class",
"constant",
"constructor",
@@ -91811,10 +92096,12 @@ var ts;
JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations;
function getCommentHavingNodes(declaration) {
switch (declaration.kind) {
- case 295 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */:
+ case 297 /* JSDocPropertyTag */:
return [declaration];
- case 294 /* JSDocTypedefTag */:
- return [declaration.parent];
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ return [declaration, declaration.parent];
default:
return ts.getJSDocCommentsAndTags(declaration);
}
@@ -91834,15 +92121,16 @@ var ts;
function getCommentText(tag) {
var comment = tag.comment;
switch (tag.kind) {
- case 288 /* JSDocAugmentsTag */:
+ case 289 /* JSDocAugmentsTag */:
return withNode(tag.class);
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
return withList(tag.typeParameters);
- case 292 /* JSDocTypeTag */:
+ case 294 /* JSDocTypeTag */:
return withNode(tag.typeExpression);
- case 294 /* JSDocTypedefTag */:
- case 295 /* JSDocPropertyTag */:
- case 290 /* JSDocParameterTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ case 297 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */:
var name = tag.name;
return name ? withNode(name) : comment;
default:
@@ -92460,7 +92748,7 @@ var ts;
if (!patternMatcher)
return ts.emptyArray;
var rawItems = [];
- var _loop_13 = function (sourceFile) {
+ var _loop_14 = function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) {
return "continue";
@@ -92472,7 +92760,7 @@ var ts;
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) {
var sourceFile = sourceFiles_7[_i];
- _loop_13(sourceFile);
+ _loop_14(sourceFile);
}
rawItems.sort(compareNavigateToItems);
if (maxResultCount !== undefined) {
@@ -92849,7 +93137,7 @@ var ts;
if (ts.hasJSDocNodes(node)) {
ts.forEach(node.jsDoc, function (jsDoc) {
ts.forEach(jsDoc.tags, function (tag) {
- if (tag.kind === 294 /* JSDocTypedefTag */) {
+ if (ts.isJSDocTypeAlias(tag)) {
addLeafNode(tag);
}
});
@@ -92962,8 +93250,6 @@ var ts;
case 192 /* ArrowFunction */:
case 204 /* ClassExpression */:
return getFunctionOrClassName(node);
- case 294 /* JSDocTypedefTag */:
- return getJSDocTypedefTagName(node);
default:
return undefined;
}
@@ -93005,29 +93291,10 @@ var ts;
return "()";
case 159 /* IndexSignature */:
return "[]";
- case 294 /* JSDocTypedefTag */:
- return getJSDocTypedefTagName(node);
default:
return "";
}
}
- function getJSDocTypedefTagName(node) {
- if (node.name) {
- return node.name.text;
- }
- else {
- var parentNode = node.parent && node.parent.parent;
- if (parentNode && parentNode.kind === 213 /* VariableStatement */) {
- if (parentNode.declarationList.declarations.length > 0) {
- var nameIdentifier = parentNode.declarationList.declarations[0].name;
- if (nameIdentifier.kind === 71 /* Identifier */) {
- return nameIdentifier.text;
- }
- }
- }
- return "";
- }
- }
/** Flattens the NavNode tree to a list, keeping only the top-level items. */
function topLevelItems(root) {
var topLevel = [];
@@ -93053,7 +93320,8 @@ var ts;
case 238 /* ModuleDeclaration */:
case 273 /* SourceFile */:
case 236 /* TypeAliasDeclaration */:
- case 294 /* JSDocTypedefTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
return true;
case 154 /* Constructor */:
case 153 /* MethodDeclaration */:
@@ -93979,13 +94247,13 @@ var ts;
// Assumes 'value' is already lowercase.
function indexOfIgnoringCase(str, value) {
var n = str.length - value.length;
- var _loop_14 = function (start) {
+ var _loop_15 = function (start) {
if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
return { value: start };
}
};
for (var start = 0; start <= n; start++) {
- var state_4 = _loop_14(start);
+ var state_4 = _loop_15(start);
if (typeof state_4 === "object")
return state_4.value;
}
@@ -94653,7 +94921,7 @@ var ts;
var nameToDeclarations = sourceFile.getNamedDeclarations();
var declarations = nameToDeclarations.get(name.text);
if (declarations) {
- var _loop_15 = function (declaration) {
+ var _loop_16 = function (declaration) {
var symbol = declaration.symbol;
if (symbol) {
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
@@ -94667,7 +94935,7 @@ var ts;
};
for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) {
var declaration = declarations_12[_b];
- var state_5 = _loop_15(declaration);
+ var state_5 = _loop_16(declaration);
if (typeof state_5 === "object")
return state_5.value;
}
@@ -95065,7 +95333,7 @@ var ts;
}
}
}
- return diags.concat(checker.getSuggestionDiagnostics(sourceFile));
+ return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort(function (d1, d2) { return d1.start - d2.start; });
}
ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics;
// convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
@@ -95821,7 +96089,7 @@ var ts;
return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; });
});
options = ts.cloneCompilerOptions(options);
- var _loop_16 = function (opt) {
+ var _loop_17 = function (opt) {
if (!ts.hasProperty(options, opt.name)) {
return "continue";
}
@@ -95840,7 +96108,7 @@ var ts;
};
for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
var opt = commandLineOptionsStringToEnum_1[_i];
- _loop_16(opt);
+ _loop_17(opt);
}
return options;
}
@@ -98584,7 +98852,7 @@ var ts;
this.formatContext = formatContext;
this.changes = [];
this.newFiles = [];
- this.deletedNodesInLists = []; // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
+ this.deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
this.classesWithNodesInsertedAtStart = ts.createMap(); // Set implemented as Map
}
ChangeTracker.fromContext = function (context) {
@@ -98628,35 +98896,14 @@ var ts;
this.deleteNode(sourceFile, node);
return this;
}
- var id = ts.getNodeId(node);
- ts.Debug.assert(!this.deletedNodesInLists[id], "Deleting a node twice");
- this.deletedNodesInLists[id] = true;
- if (index !== containingList.length - 1) {
- var nextToken = ts.getTokenAtPosition(sourceFile, node.end, /*includeJsDocComment*/ false);
- if (nextToken && isSeparator(node, nextToken)) {
- // find first non-whitespace position in the leading trivia of the node
- var startPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
- var nextElement = containingList[index + 1];
- /// find first non-whitespace position in the leading trivia of the next node
- var endPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
- // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node
- this.deleteRange(sourceFile, { pos: startPosition, end: endPosition });
- }
- }
- else {
- var prev = containingList[index - 1];
- if (this.deletedNodesInLists[ts.getNodeId(prev)]) {
- var pos = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
- var end = getAdjustedEndPosition(sourceFile, node, {});
- this.deleteRange(sourceFile, { pos: pos, end: end });
- }
- else {
- var previousToken = ts.getTokenAtPosition(sourceFile, containingList[index - 1].end, /*includeJsDocComment*/ false);
- if (previousToken && isSeparator(node, previousToken)) {
- this.deleteNodeRange(sourceFile, previousToken, node);
- }
- }
- }
+ // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node.
+ // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`.
+ ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice");
+ this.deletedNodesInLists.add(node);
+ this.deleteRange(sourceFile, {
+ pos: startPositionToDeleteNodeInList(sourceFile, node),
+ end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]),
+ });
return this;
};
ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) {
@@ -99017,6 +99264,19 @@ var ts;
}
});
};
+ ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () {
+ var _this = this;
+ this.deletedNodesInLists.forEach(function (node) {
+ var sourceFile = node.getSourceFile();
+ var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile);
+ if (node !== ts.last(list))
+ return;
+ var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2);
+ if (lastNonDeletedIndex !== -1) {
+ _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) });
+ }
+ });
+ };
/**
* Note: after calling this, the TextChanges object must be discarded!
* @param validate only for tests
@@ -99025,6 +99285,7 @@ var ts;
*/
ChangeTracker.prototype.getChanges = function (validate) {
this.finishClassesWithNodesInsertedAtStart();
+ this.finishTrailingCommaAfterDeletingNodesInList();
var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate);
for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) {
var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements;
@@ -99038,6 +99299,10 @@ var ts;
return ChangeTracker;
}());
textChanges_3.ChangeTracker = ChangeTracker;
+ // find first non-whitespace position in the leading trivia of the node
+ function startPositionToDeleteNodeInList(sourceFile, node) {
+ return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
+ }
function getClassBraceEnds(cls, sourceFile) {
return [ts.findChildOfKind(cls, 17 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile).end];
}
@@ -99049,14 +99314,14 @@ var ts;
// 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.
var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
- var _loop_17 = function (i) {
+ var _loop_18 = function (i) {
ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
});
};
// verify that change intervals do not overlap, except possibly at end points.
for (var i = 0; i < normalized.length - 1; i++) {
- _loop_17(i);
+ _loop_18(i);
}
var textChanges = normalized.map(function (c) {
return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate));
@@ -99491,7 +99756,7 @@ var ts;
if (ts.isFunctionLikeDeclaration(decl) && (ts.getJSDocReturnType(decl) || decl.parameters.some(function (p) { return !!ts.getJSDocType(p); }))) {
if (!decl.typeParameters) {
var typeParameters = ts.getJSDocTypeParameterDeclarations(decl);
- if (typeParameters)
+ if (typeParameters.length)
changes.insertTypeParameters(sourceFile, decl, typeParameters);
}
var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 19 /* OpenParenToken */, sourceFile);
@@ -101335,13 +101600,13 @@ var ts;
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); });
return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)];
}
- var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start); });
+ var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start, /*deleted*/ undefined); });
if (delDestructure.length) {
return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)];
}
var token = getToken(sourceFile, ts.textSpanEnd(context.span));
var result = [];
- var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token); });
+ var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined); });
if (deletion.length) {
result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations));
}
@@ -101352,49 +101617,60 @@ var ts;
return result;
},
fixIds: [fixIdPrefix, fixIdDelete],
- getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
- var sourceFile = context.sourceFile;
- var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file);
- switch (context.fixId) {
- case fixIdPrefix:
- if (ts.isIdentifier(token) && canPrefix(token)) {
- tryPrefixDeclaration(changes, diag.code, sourceFile, token);
- }
- break;
- case fixIdDelete:
- var importDecl = tryGetFullImport(diag.file, diag.start);
- if (importDecl) {
- changes.deleteNode(sourceFile, importDecl);
- }
- else {
- if (!tryDeleteFullDestructure(changes, sourceFile, diag.start)) {
- tryDeleteDeclaration(changes, sourceFile, token);
+ getAllCodeActions: function (context) {
+ // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors.
+ var deleted = new NodeSet();
+ return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ var sourceFile = context.sourceFile;
+ var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file);
+ switch (context.fixId) {
+ case fixIdPrefix:
+ if (ts.isIdentifier(token) && canPrefix(token)) {
+ tryPrefixDeclaration(changes, diag.code, sourceFile, token);
}
- }
- break;
- default:
- ts.Debug.fail(JSON.stringify(context.fixId));
- }
- }); },
+ break;
+ case fixIdDelete:
+ // Ignore if this range was already deleted.
+ if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); }))
+ break;
+ var importDecl = tryGetFullImport(diag.file, diag.start);
+ if (importDecl) {
+ changes.deleteNode(sourceFile, importDecl);
+ }
+ else {
+ if (!tryDeleteFullDestructure(changes, sourceFile, diag.start, deleted)) {
+ tryDeleteDeclaration(changes, sourceFile, token, deleted);
+ }
+ }
+ break;
+ default:
+ ts.Debug.fail(JSON.stringify(context.fixId));
+ }
+ });
+ },
});
// Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing.
function tryGetFullImport(sourceFile, pos) {
var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined;
}
- function tryDeleteFullDestructure(changes, sourceFile, pos) {
+ function tryDeleteFullDestructure(changes, sourceFile, pos, deletedAncestors) {
var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent))
return false;
var decl = startToken.parent.parent;
switch (decl.kind) {
case 231 /* VariableDeclaration */:
- tryDeleteVariableDeclaration(changes, sourceFile, decl);
+ tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors);
break;
case 148 /* Parameter */:
+ if (deletedAncestors)
+ deletedAncestors.add(decl);
changes.deleteNodeInList(sourceFile, decl);
break;
case 181 /* BindingElement */:
+ if (deletedAncestors)
+ deletedAncestors.add(decl);
changes.deleteNode(sourceFile, decl);
break;
default:
@@ -101403,7 +101679,7 @@ var ts;
return true;
}
function getToken(sourceFile, pos) {
- var token = ts.findPrecedingToken(pos, sourceFile);
+ var token = ts.findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true);
// this handles var ["computed"] = 12;
return token.kind === 22 /* CloseBracketToken */ ? ts.findPrecedingToken(pos - 1, sourceFile) : token;
}
@@ -101428,38 +101704,45 @@ var ts;
}
return false;
}
- function tryDeleteDeclaration(changes, sourceFile, token) {
+ function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors) {
switch (token.kind) {
case 71 /* Identifier */:
- tryDeleteIdentifier(changes, sourceFile, token);
+ tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors);
break;
case 151 /* PropertyDeclaration */:
case 245 /* NamespaceImport */:
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent);
changes.deleteNode(sourceFile, token.parent);
break;
default:
- tryDeleteDefault(changes, sourceFile, token);
+ tryDeleteDefault(changes, sourceFile, token, deletedAncestors);
}
}
- function tryDeleteDefault(changes, sourceFile, token) {
+ function tryDeleteDefault(changes, sourceFile, token, deletedAncestors) {
if (ts.isDeclarationName(token)) {
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent);
changes.deleteNode(sourceFile, token.parent);
}
else if (ts.isLiteralComputedPropertyDeclarationName(token)) {
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent.parent);
changes.deleteNode(sourceFile, token.parent.parent);
}
}
- function tryDeleteIdentifier(changes, sourceFile, identifier) {
+ function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors) {
var parent = identifier.parent;
switch (parent.kind) {
case 231 /* VariableDeclaration */:
- tryDeleteVariableDeclaration(changes, sourceFile, parent);
+ tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors);
break;
case 147 /* TypeParameter */:
- var typeParameters = parent.parent.typeParameters;
+ var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent);
if (typeParameters.length === 1) {
- var previousToken = ts.getTokenAtPosition(sourceFile, typeParameters.pos - 1, /*includeJsDocComment*/ false);
- var nextToken = ts.getTokenAtPosition(sourceFile, typeParameters.end, /*includeJsDocComment*/ false);
+ var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end;
+ var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false);
+ var nextToken = ts.getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false);
ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */);
ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */);
changes.deleteNodeRange(sourceFile, previousToken, nextToken);
@@ -101542,7 +101825,7 @@ var ts;
tryDeleteNamedImportBinding(changes, sourceFile, parent);
break;
default:
- tryDeleteDefault(changes, sourceFile, identifier);
+ tryDeleteDefault(changes, sourceFile, identifier, deletedAncestors);
break;
}
}
@@ -101565,15 +101848,19 @@ var ts;
}
}
// token.parent is a variableDeclaration
- function tryDeleteVariableDeclaration(changes, sourceFile, varDecl) {
+ function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) {
switch (varDecl.parent.parent.kind) {
case 219 /* ForStatement */: {
var forStatement = varDecl.parent.parent;
var forInitializer = forStatement.initializer;
if (forInitializer.declarations.length === 1) {
+ if (deletedAncestors)
+ deletedAncestors.add(forInitializer);
changes.deleteNode(sourceFile, forInitializer);
}
else {
+ if (deletedAncestors)
+ deletedAncestors.add(varDecl);
changes.deleteNodeInList(sourceFile, varDecl);
}
break;
@@ -101582,6 +101869,8 @@ var ts;
var forOfStatement = varDecl.parent.parent;
ts.Debug.assert(forOfStatement.initializer.kind === 232 /* VariableDeclarationList */);
var forOfInitializer = forOfStatement.initializer;
+ if (deletedAncestors)
+ deletedAncestors.add(forOfInitializer.declarations[0]);
changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral());
break;
case 220 /* ForInStatement */:
@@ -101590,13 +101879,29 @@ var ts;
default:
var variableStatement = varDecl.parent.parent;
if (variableStatement.declarationList.declarations.length === 1) {
+ if (deletedAncestors)
+ deletedAncestors.add(variableStatement);
changes.deleteNode(sourceFile, variableStatement);
}
else {
+ if (deletedAncestors)
+ deletedAncestors.add(varDecl);
changes.deleteNodeInList(sourceFile, varDecl);
}
}
}
+ var NodeSet = /** @class */ (function () {
+ function NodeSet() {
+ this.map = ts.createMap();
+ }
+ NodeSet.prototype.add = function (node) {
+ this.map.set(String(ts.getNodeId(node)), node);
+ };
+ NodeSet.prototype.some = function (pred) {
+ return ts.forEachEntry(this.map, pred) || false;
+ };
+ return NodeSet;
+ }());
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
/* @internal */
@@ -101669,21 +101974,7 @@ var ts;
}
// Calls 'cb' with the start and end of each range where 'pred' is true.
function split(arr, pred, cb) {
- var start;
- for (var i = 0; i < arr.length; i++) {
- var value = arr[i];
- if (pred(value)) {
- start = start || value;
- }
- else {
- if (start) {
- cb(start, arr[i - 1]);
- start = undefined;
- }
- }
- }
- if (start)
- cb(start, arr[arr.length - 1]);
+ ts.getRangesWhere(arr, pred, function (start, afterEnd) { return cb(arr[start], arr[afterEnd - 1]); });
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -103169,6 +103460,39 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
+ var fixId = fixIdAddMissingTypeof;
+ var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, span = context.span;
+ var importType = getImportTypeNode(sourceFile, span.start);
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, importType); });
+ return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_missing_typeof, fixId, ts.Diagnostics.Add_missing_typeof)];
+ },
+ fixIds: [fixId],
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ return doChange(changes, context.sourceFile, getImportTypeNode(diag.file, diag.start));
+ }); },
+ });
+ function getImportTypeNode(sourceFile, pos) {
+ var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
+ ts.Debug.assert(token.kind === 91 /* ImportKeyword */);
+ ts.Debug.assert(token.parent.kind === 178 /* ImportType */);
+ return token.parent;
+ }
+ function doChange(changes, sourceFile, importType) {
+ var newTypeNode = ts.updateImportTypeNode(importType, importType.argument, importType.qualifier, importType.typeArguments, /* isTypeOf */ true);
+ changes.replaceNode(sourceFile, importType, newTypeNode);
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var refactor;
(function (refactor) {
@@ -104362,8 +104686,8 @@ var ts;
i_1++;
}
// Note that we add the current node's type parameters *after* updating the corresponding scope.
- if (ts.isDeclarationWithTypeParameters(curr) && curr.typeParameters) {
- for (var _a = 0, _b = curr.typeParameters; _a < _b.length; _a++) {
+ if (ts.isDeclarationWithTypeParameters(curr)) {
+ for (var _a = 0, _b = ts.getEffectiveTypeParameterDeclarations(curr); _a < _b.length; _a++) {
var typeParameterDecl = _b[_a];
var typeParameter = checker.getTypeAtLocation(typeParameterDecl);
if (allTypeParameterUsages.has(typeParameter.id.toString())) {
@@ -104385,7 +104709,7 @@ var ts;
: ts.getEnclosingBlockScopeContainer(scopes[0]);
ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
}
- var _loop_18 = function (i) {
+ var _loop_19 = function (i) {
var scopeUsages = usagesPerScope[i];
// Special case: in the innermost scope, all usages are available.
// (The computed value reflects the value at the top-level of the scope, but the
@@ -104425,21 +104749,11 @@ var ts;
}
};
for (var i = 0; i < scopes.length; i++) {
- _loop_18(i);
+ _loop_19(i);
}
return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
- function hasTypeParameters(node) {
- return ts.isDeclarationWithTypeParameters(node) &&
- node.typeParameters !== undefined &&
- node.typeParameters.length > 0;
- }
function isInGenericContext(node) {
- for (; node; node = node.parent) {
- if (hasTypeParameters(node)) {
- return true;
- }
- }
- return false;
+ return !!ts.findAncestor(node, function (n) { return ts.isDeclarationWithTypeParameters(n) && ts.getEffectiveTypeParameterDeclarations(n).length !== 0; });
}
function recordTypeParameterUsages(type) {
// PERF: This is potentially very expensive. `type` could be a library type with
@@ -104704,8 +105018,8 @@ var ts;
var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message;
refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions });
function getAvailableActions(context) {
- var file = context.file, startPosition = context.startPosition;
- if (!getConvertibleFieldAtPosition(file, startPosition))
+ var file = context.file;
+ if (!getConvertibleFieldAtPosition(context, file))
return undefined;
return [{
name: actionName,
@@ -104719,8 +105033,8 @@ var ts;
}];
}
function getEditsForAction(context, _actionName) {
- var file = context.file, startPosition = context.startPosition;
- var fieldInfo = getConvertibleFieldAtPosition(file, startPosition);
+ var file = context.file;
+ var fieldInfo = getConvertibleFieldAtPosition(context, file);
if (!fieldInfo)
return undefined;
var isJS = ts.isSourceFileJavaScript(file);
@@ -104781,12 +105095,14 @@ var ts;
function startsWithUnderscore(name) {
return name.charCodeAt(0) === 95 /* _ */;
}
- function getConvertibleFieldAtPosition(file, startPosition) {
+ function getConvertibleFieldAtPosition(context, file) {
+ var startPosition = context.startPosition, endPosition = context.endPosition;
var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false);
var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration);
// make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier
var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */;
- if (!declaration || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning)
+ if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition)
+ || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning)
return undefined;
var name = declaration.name.text;
var startWithUnderscore = startsWithUnderscore(name);
@@ -104874,7 +105190,7 @@ var ts;
var refactorName = "Move to a new file";
refactor.registerRefactor(refactorName, {
getAvailableActions: function (context) {
- if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined)
+ if (!context.preferences.allowTextChangesInNewFiles || getFirstAndLastStatementToMove(context) === undefined)
return undefined;
var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file);
return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }];
@@ -104886,7 +105202,7 @@ var ts;
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
}
});
- function getStatementsToMove(context) {
+ function getFirstAndLastStatementToMove(context) {
var file = context.file;
var range = ts.createTextRangeFromSpan(ts.getRefactorContextSpan(context));
var statements = file.statements;
@@ -104900,11 +105216,11 @@ var ts;
// Can't be partially into the next node
if (afterEndNodeIndex !== -1 && (afterEndNodeIndex === 0 || statements[afterEndNodeIndex].getStart(file) < range.end))
return undefined;
- return statements.slice(startNodeIndex, afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex);
+ return { first: startNodeIndex, afterLast: afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex };
}
function doChange(oldFile, program, toMove, changes, host) {
var checker = program.getTypeChecker();
- var usage = getUsageInfo(oldFile, toMove, checker);
+ var usage = getUsageInfo(oldFile, toMove.all, checker);
var currentDirectory = ts.getDirectoryPath(oldFile.fileName);
var extension = ts.extensionFromPath(oldFile.fileName);
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host);
@@ -104913,6 +105229,32 @@ var ts;
changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatements(oldFile, usage, changes, toMove, program, newModuleName));
addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host));
}
+ // Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file.
+ function getStatementsToMove(context) {
+ var statements = context.file.statements;
+ var _a = getFirstAndLastStatementToMove(context), first = _a.first, afterLast = _a.afterLast;
+ var all = [];
+ var ranges = [];
+ var rangeToMove = statements.slice(first, afterLast);
+ ts.getRangesWhere(rangeToMove, function (s) { return !isPureImport(s); }, function (start, afterEnd) {
+ for (var i = start; i < afterEnd; i++)
+ all.push(rangeToMove[i]);
+ ranges.push({ first: rangeToMove[start], last: rangeToMove[afterEnd - 1] });
+ });
+ return { all: all, ranges: ranges };
+ }
+ function isPureImport(node) {
+ switch (node.kind) {
+ case 243 /* ImportDeclaration */:
+ return true;
+ case 242 /* ImportEqualsDeclaration */:
+ return !ts.hasModifier(node, 1 /* Export */);
+ case 213 /* VariableStatement */:
+ return node.declarationList.declarations.every(function (d) { return ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); });
+ default:
+ return false;
+ }
+ }
function addNewFileToTsconfig(program, changes, oldFileName, newFileNameWithExtension, getCanonicalFileName) {
var cfg = program.getCompilerOptions().configFile;
if (!cfg)
@@ -104930,18 +105272,24 @@ var ts;
function getNewStatements(oldFile, usage, changes, toMove, program, newModuleName) {
var checker = program.getTypeChecker();
if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
- changes.deleteNodeRange(oldFile, ts.first(toMove), ts.last(toMove));
- return toMove;
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
+ return toMove.all;
}
var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator;
var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax);
if (importsFromNewFile) {
changes.insertNodeBefore(oldFile, oldFile.statements[0], importsFromNewFile, /*blankLineBetween*/ true);
}
- deleteUnusedOldImports(oldFile, toMove, changes, usage.unusedImportsFromOldFile, checker);
- changes.deleteNodeRange(oldFile, ts.first(toMove), ts.last(toMove));
+ deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
- return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax));
+ return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax));
+ }
+ function deleteMovedStatements(sourceFile, moved, changes) {
+ for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) {
+ var _a = moved_1[_i], first_1 = _a.first, last_3 = _a.last;
+ changes.deleteNodeRange(sourceFile, first_1, last_3);
+ }
}
function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) {
for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) {
@@ -104953,10 +105301,10 @@ var ts;
}
function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
var checker = program.getTypeChecker();
- var _loop_19 = function (sourceFile) {
+ var _loop_20 = function (sourceFile) {
if (sourceFile === oldFile)
return "continue";
- var _loop_20 = function (statement) {
+ var _loop_21 = function (statement) {
forEachImportInStatement(statement, function (importNode) {
var shouldMove = function (name) {
var symbol = ts.isBindingElement(name.parent)
@@ -104973,12 +105321,12 @@ var ts;
};
for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
var statement = _a[_i];
- _loop_20(statement);
+ _loop_21(statement);
}
};
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
- _loop_19(sourceFile);
+ _loop_20(sourceFile);
}
}
function moduleSpecifierFromImport(i) {
@@ -105225,12 +105573,14 @@ var ts;
}
function isVariableDeclarationInImport(decl) {
return ts.isSourceFile(decl.parent.parent.parent) &&
- ts.isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true);
+ decl.initializer && ts.isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true);
}
function filterImport(i, moduleSpecifier, keep) {
switch (i.kind) {
case 243 /* ImportDeclaration */: {
var clause = i.importClause;
+ if (!clause)
+ return undefined;
var defaultImport = clause.name && keep(clause.name) ? clause.name : undefined;
var namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep);
return defaultImport || namedBindings
@@ -105754,7 +106104,7 @@ var ts;
if (!children.length) {
return undefined;
}
- var child = ts.find(children, function (kid) { return kid.kind < 277 /* FirstJSDocNode */ || kid.kind > 295 /* LastJSDocNode */; });
+ var child = ts.find(children, function (kid) { return kid.kind < 277 /* FirstJSDocNode */ || kid.kind > 297 /* LastJSDocNode */; });
return child.kind < 145 /* FirstNode */ ?
child :
child.getFirstToken(sourceFile);
@@ -105824,7 +106174,7 @@ var ts;
}
}
function createSyntaxList(nodes, parent) {
- var list = createNode(296 /* SyntaxList */, nodes.pos, nodes.end, parent);
+ var list = createNode(298 /* SyntaxList */, nodes.pos, nodes.end, parent);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) {
@@ -106961,15 +107311,15 @@ var ts;
if (original === void 0) { original = input; }
var info = extract(input);
if (ts.endsWith(info.fileName, ".d.ts" /* Dts */)) {
- var file_17 = program.getSourceFile(info.fileName);
- if (!file_17) {
+ var file_18 = program.getSourceFile(info.fileName);
+ if (!file_18) {
var path = ts.toPath(info.fileName, currentDirectory, getCanonicalFileName);
- file_17 = sourcemappedFileCache.get(path);
+ file_18 = sourcemappedFileCache.get(path);
}
- if (!file_17) {
+ if (!file_18) {
return input;
}
- var mapper = getSourceMapper(info.fileName, file_17);
+ var mapper = getSourceMapper(info.fileName, file_18);
var newLoc = mapper.getOriginalPosition(info);
if (newLoc === info)
return input;
diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts
index 9715edb70b5..299e0387760 100644
--- a/lib/typescriptServices.d.ts
+++ b/lib/typescriptServices.d.ts
@@ -349,22 +349,24 @@ declare namespace ts {
JSDocVariadicType = 284,
JSDocComment = 285,
JSDocTypeLiteral = 286,
- JSDocTag = 287,
- JSDocAugmentsTag = 288,
- JSDocClassTag = 289,
- JSDocParameterTag = 290,
- JSDocReturnTag = 291,
- JSDocTypeTag = 292,
- JSDocTemplateTag = 293,
- JSDocTypedefTag = 294,
- JSDocPropertyTag = 295,
- SyntaxList = 296,
- NotEmittedStatement = 297,
- PartiallyEmittedExpression = 298,
- CommaListExpression = 299,
- MergeDeclarationMarker = 300,
- EndOfDeclarationMarker = 301,
- Count = 302,
+ JSDocSignature = 287,
+ JSDocTag = 288,
+ JSDocAugmentsTag = 289,
+ JSDocClassTag = 290,
+ JSDocCallbackTag = 291,
+ JSDocParameterTag = 292,
+ JSDocReturnTag = 293,
+ JSDocTypeTag = 294,
+ JSDocTemplateTag = 295,
+ JSDocTypedefTag = 296,
+ JSDocPropertyTag = 297,
+ SyntaxList = 298,
+ NotEmittedStatement = 299,
+ PartiallyEmittedExpression = 300,
+ CommaListExpression = 301,
+ MergeDeclarationMarker = 302,
+ EndOfDeclarationMarker = 303,
+ Count = 304,
FirstAssignment = 58,
LastAssignment = 70,
FirstCompoundAssignment = 59,
@@ -391,9 +393,9 @@ declare namespace ts {
LastBinaryOperator = 70,
FirstNode = 145,
FirstJSDocNode = 277,
- LastJSDocNode = 295,
- FirstJSDocTagNode = 287,
- LastJSDocTagNode = 295
+ LastJSDocNode = 297,
+ FirstJSDocTagNode = 288,
+ LastJSDocTagNode = 297
}
enum NodeFlags {
None = 0,
@@ -1280,7 +1282,7 @@ declare namespace ts {
block: Block;
}
type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode;
- type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag;
+ type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature;
interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer {
kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression;
name?: Identifier;
@@ -1537,6 +1539,19 @@ declare namespace ts {
name?: Identifier;
typeExpression?: JSDocTypeExpression | JSDocTypeLiteral;
}
+ interface JSDocCallbackTag extends JSDocTag, NamedDeclaration {
+ parent: JSDoc;
+ kind: SyntaxKind.JSDocCallbackTag;
+ fullName?: JSDocNamespaceDeclaration | Identifier;
+ name?: Identifier;
+ typeExpression: JSDocSignature;
+ }
+ interface JSDocSignature extends JSDocType, Declaration {
+ kind: SyntaxKind.JSDocSignature;
+ typeParameters?: ReadonlyArray;
+ parameters: ReadonlyArray;
+ type: JSDocReturnTag | undefined;
+ }
interface JSDocPropertyLikeTag extends JSDocTag, Declaration {
parent: JSDoc;
name: EntityName;
@@ -1885,6 +1900,7 @@ declare namespace ts {
WriteArrayAsGenericType = 2,
GenerateNamesForShadowedTypeParams = 4,
UseStructuralFallback = 8,
+ ForbidIndexedAccessSymbolReferences = 16,
WriteTypeArgumentsOfSignature = 32,
UseFullyQualifiedType = 64,
UseOnlyExternalAliasing = 128,
@@ -2283,7 +2299,7 @@ declare namespace ts {
Construct = 1
}
interface Signature {
- declaration?: SignatureDeclaration;
+ declaration?: SignatureDeclaration | JSDocSignature;
typeParameters?: TypeParameter[];
parameters: Symbol[];
}
@@ -3362,6 +3378,8 @@ declare namespace ts {
function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag;
function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag;
function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral;
+ function isJSDocCallbackTag(node: Node): node is JSDocCallbackTag;
+ function isJSDocSignature(node: Node): node is JSDocSignature;
}
declare namespace ts {
/**
diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js
index 68f66dc8dca..9ccb026f1fd 100644
--- a/lib/typescriptServices.js
+++ b/lib/typescriptServices.js
@@ -365,25 +365,27 @@ var ts;
SyntaxKind[SyntaxKind["JSDocVariadicType"] = 284] = "JSDocVariadicType";
SyntaxKind[SyntaxKind["JSDocComment"] = 285] = "JSDocComment";
SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral";
- SyntaxKind[SyntaxKind["JSDocTag"] = 287] = "JSDocTag";
- SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 288] = "JSDocAugmentsTag";
- SyntaxKind[SyntaxKind["JSDocClassTag"] = 289] = "JSDocClassTag";
- SyntaxKind[SyntaxKind["JSDocParameterTag"] = 290] = "JSDocParameterTag";
- SyntaxKind[SyntaxKind["JSDocReturnTag"] = 291] = "JSDocReturnTag";
- SyntaxKind[SyntaxKind["JSDocTypeTag"] = 292] = "JSDocTypeTag";
- SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 293] = "JSDocTemplateTag";
- SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 294] = "JSDocTypedefTag";
- SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 295] = "JSDocPropertyTag";
+ SyntaxKind[SyntaxKind["JSDocSignature"] = 287] = "JSDocSignature";
+ SyntaxKind[SyntaxKind["JSDocTag"] = 288] = "JSDocTag";
+ SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 289] = "JSDocAugmentsTag";
+ SyntaxKind[SyntaxKind["JSDocClassTag"] = 290] = "JSDocClassTag";
+ SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 291] = "JSDocCallbackTag";
+ SyntaxKind[SyntaxKind["JSDocParameterTag"] = 292] = "JSDocParameterTag";
+ SyntaxKind[SyntaxKind["JSDocReturnTag"] = 293] = "JSDocReturnTag";
+ SyntaxKind[SyntaxKind["JSDocTypeTag"] = 294] = "JSDocTypeTag";
+ SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 295] = "JSDocTemplateTag";
+ SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 296] = "JSDocTypedefTag";
+ SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 297] = "JSDocPropertyTag";
// Synthesized list
- SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList";
+ SyntaxKind[SyntaxKind["SyntaxList"] = 298] = "SyntaxList";
// Transformation nodes
- SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement";
- SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression";
- SyntaxKind[SyntaxKind["CommaListExpression"] = 299] = "CommaListExpression";
- SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 300] = "MergeDeclarationMarker";
- SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 301] = "EndOfDeclarationMarker";
+ SyntaxKind[SyntaxKind["NotEmittedStatement"] = 299] = "NotEmittedStatement";
+ SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 300] = "PartiallyEmittedExpression";
+ SyntaxKind[SyntaxKind["CommaListExpression"] = 301] = "CommaListExpression";
+ SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 302] = "MergeDeclarationMarker";
+ SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 303] = "EndOfDeclarationMarker";
// Enum value count
- SyntaxKind[SyntaxKind["Count"] = 302] = "Count";
+ SyntaxKind[SyntaxKind["Count"] = 304] = "Count";
// Markers
SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment";
SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment";
@@ -411,9 +413,9 @@ var ts;
SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator";
SyntaxKind[SyntaxKind["FirstNode"] = 145] = "FirstNode";
SyntaxKind[SyntaxKind["FirstJSDocNode"] = 277] = "FirstJSDocNode";
- SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode";
- SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 287] = "FirstJSDocTagNode";
- SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode";
+ SyntaxKind[SyntaxKind["LastJSDocNode"] = 297] = "LastJSDocNode";
+ SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 288] = "FirstJSDocTagNode";
+ SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 297] = "LastJSDocTagNode";
/* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword";
/* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 144] = "LastContextualKeyword";
})(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
@@ -595,7 +597,7 @@ var ts;
NodeBuilderFlags[NodeBuilderFlags["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType";
NodeBuilderFlags[NodeBuilderFlags["GenerateNamesForShadowedTypeParams"] = 4] = "GenerateNamesForShadowedTypeParams";
NodeBuilderFlags[NodeBuilderFlags["UseStructuralFallback"] = 8] = "UseStructuralFallback";
- // empty space
+ NodeBuilderFlags[NodeBuilderFlags["ForbidIndexedAccessSymbolReferences"] = 16] = "ForbidIndexedAccessSymbolReferences";
NodeBuilderFlags[NodeBuilderFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature";
NodeBuilderFlags[NodeBuilderFlags["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType";
NodeBuilderFlags[NodeBuilderFlags["UseOnlyExternalAliasing"] = 128] = "UseOnlyExternalAliasing";
@@ -887,6 +889,8 @@ var ts;
TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 67108864] = "ContainsAnyFunctionType";
TypeFlags[TypeFlags["NonPrimitive"] = 134217728] = "NonPrimitive";
/* @internal */
+ TypeFlags[TypeFlags["UnionOfUnitTypes"] = 268435456] = "UnionOfUnitTypes";
+ /* @internal */
TypeFlags[TypeFlags["GenericMappedType"] = 536870912] = "GenericMappedType";
/* @internal */
TypeFlags[TypeFlags["Nullable"] = 12288] = "Nullable";
@@ -922,6 +926,8 @@ var ts;
TypeFlags[TypeFlags["Narrowable"] = 142575359] = "Narrowable";
TypeFlags[TypeFlags["NotUnionOrUnit"] = 134283777] = "NotUnionOrUnit";
/* @internal */
+ TypeFlags[TypeFlags["NotUnit"] = 8374815] = "NotUnit";
+ /* @internal */
TypeFlags[TypeFlags["RequiresWidening"] = 50331648] = "RequiresWidening";
/* @internal */
TypeFlags[TypeFlags["PropagatingFlags"] = 117440512] = "PropagatingFlags";
@@ -1911,6 +1917,15 @@ var ts;
return -1;
}
ts.findIndex = findIndex;
+ function findLastIndex(array, predicate, startIndex) {
+ for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
+ if (predicate(array[i], i)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+ ts.findLastIndex = findLastIndex;
/**
* Returns the first truthy result of `callback`, or else fails.
* This is like `forEach`, but never returns undefined.
@@ -2263,6 +2278,24 @@ var ts;
return false;
}
ts.some = some;
+ /** Calls the callback with (start, afterEnd) index pairs for each range where 'pred' is true. */
+ function getRangesWhere(arr, pred, cb) {
+ var start;
+ for (var i = 0; i < arr.length; i++) {
+ if (pred(arr[i])) {
+ start = start === undefined ? i : start;
+ }
+ else {
+ if (start !== undefined) {
+ cb(start, i);
+ start = undefined;
+ }
+ }
+ }
+ if (start !== undefined)
+ cb(start, arr.length);
+ }
+ ts.getRangesWhere = getRangesWhere;
function concatenate(array1, array2) {
if (!some(array2))
return array1;
@@ -6743,6 +6776,7 @@ var ts;
Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
+ Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing typeof"),
};
})(ts || (ts = {}));
var ts;
@@ -8493,11 +8527,10 @@ var ts;
}
}
function scanJSDocToken() {
+ startPos = tokenPos = pos;
if (pos >= end) {
return token = 1 /* EndOfFileToken */;
}
- startPos = pos;
- tokenPos = pos;
var ch = text.charCodeAt(pos);
pos++;
switch (ch) {
@@ -8903,7 +8936,7 @@ var ts;
// the syntax list itself considers them as normal trivia. Therefore if we simply skip
// trivia for the list, we may have skipped the JSDocComment as well. So we should process its
// first child to determine the actual position of its first token.
- if (node.kind === 296 /* SyntaxList */ && node._children.length > 0) {
+ if (node.kind === 298 /* SyntaxList */ && node._children.length > 0) {
return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
}
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
@@ -9110,7 +9143,7 @@ var ts;
case 204 /* ClassExpression */:
case 235 /* InterfaceDeclaration */:
case 236 /* TypeAliasDeclaration */:
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
case 233 /* FunctionDeclaration */:
case 153 /* MethodDeclaration */:
case 154 /* Constructor */:
@@ -9118,6 +9151,9 @@ var ts;
case 156 /* SetAccessor */:
case 191 /* FunctionExpression */:
case 192 /* ArrowFunction */:
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 287 /* JSDocSignature */:
return true;
default:
ts.assertTypeIsNever(node);
@@ -9159,13 +9195,7 @@ var ts;
// Gets the nearest enclosing block scope container that has the provided node
// as a descendant, that is not the provided node.
function getEnclosingBlockScopeContainer(node) {
- var current = node.parent;
- while (current) {
- if (isBlockScope(current, current.parent)) {
- return current;
- }
- current = current.parent;
- }
+ return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
}
ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
// Return display name of an identifier
@@ -10354,6 +10384,14 @@ var ts;
node.parameters[0].name.escapedText === "new";
}
ts.isJSDocConstructSignature = isJSDocConstructSignature;
+ function isJSDocTypeAlias(node) {
+ return node.kind === 296 /* JSDocTypedefTag */ || node.kind === 291 /* JSDocCallbackTag */;
+ }
+ ts.isJSDocTypeAlias = isJSDocTypeAlias;
+ function isTypeAlias(node) {
+ return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
+ }
+ ts.isTypeAlias = isTypeAlias;
function getSourceOfAssignment(node) {
return ts.isExpressionStatement(node) &&
node.expression && ts.isBinaryExpression(node.expression) &&
@@ -10375,6 +10413,8 @@ var ts;
return v && v.initializer;
case 151 /* PropertyDeclaration */:
return node.initializer;
+ case 269 /* PropertyAssignment */:
+ return node.initializer;
}
}
function getSingleVariableOfVariableStatement(node) {
@@ -10405,8 +10445,7 @@ var ts;
// * @returns {number}
// */
// var x = function(name) { return name.length; }
- if (parent.parent &&
- (getSingleVariableOfVariableStatement(parent.parent) === node)) {
+ if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) {
getJSDocCommentsAndTagsWorker(parent.parent);
}
if (parent.parent && parent.parent.parent &&
@@ -10451,7 +10490,10 @@ var ts;
}
ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
function getHostSignatureFromJSDoc(node) {
- var host = getJSDocHost(node);
+ return getHostSignatureFromJSDocHost(getJSDocHost(node));
+ }
+ ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ function getHostSignatureFromJSDocHost(host) {
var decl = getSourceOfDefaultedAssignment(host) ||
getSourceOfAssignment(host) ||
getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
@@ -10460,19 +10502,12 @@ var ts;
host;
return decl && ts.isFunctionLike(decl) ? decl : undefined;
}
- ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ ts.getHostSignatureFromJSDocHost = getHostSignatureFromJSDocHost;
function getJSDocHost(node) {
- while (node.parent.kind === 286 /* JSDocTypeLiteral */) {
- if (node.parent.parent.kind === 294 /* JSDocTypedefTag */) {
- node = node.parent.parent;
- }
- else {
- // node.parent.parent is a type expression, child of a parameter type
- node = node.parent.parent.parent;
- }
+ var comment = ts.findAncestor(node.parent, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : node.kind === 285 /* JSDocComment */; });
+ if (comment) {
+ return comment.parent;
}
- ts.Debug.assert(node.parent.kind === 285 /* JSDocComment */);
- return node.parent.parent;
}
ts.getJSDocHost = getJSDocHost;
function getTypeParameterFromJsDoc(node) {
@@ -10487,7 +10522,8 @@ var ts;
}
ts.hasRestParameter = hasRestParameter;
function isRestParameter(node) {
- return node.dotDotDotToken !== undefined || node.type && node.type.kind === 284 /* JSDocVariadicType */;
+ var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
+ return node.dotDotDotToken !== undefined || type && type.kind === 284 /* JSDocVariadicType */;
}
ts.isRestParameter = isRestParameter;
var AssignmentKind;
@@ -11016,7 +11052,7 @@ var ts;
ts.getOperator = getOperator;
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
switch (nodeKind) {
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return 0;
case 203 /* SpreadElement */:
return 1;
@@ -11345,8 +11381,8 @@ var ts;
};
}
ts.createTextWriter = createTextWriter;
- function getResolvedExternalModuleName(host, file) {
- return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
+ function getResolvedExternalModuleName(host, file, referenceFile) {
+ return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
}
ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
@@ -11360,12 +11396,13 @@ var ts;
/**
* Resolves a local path to a path which is absolute to the base of the emit
*/
- function getExternalModuleNameFromPath(host, fileName) {
+ function getExternalModuleNameFromPath(host, fileName, referencePath) {
var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
- var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
+ var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
- return ts.removeFileExtension(relativePath);
+ var extensionless = ts.removeFileExtension(relativePath);
+ return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
}
ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
function getOwnEmitOutputFilePath(sourceFile, host, extension) {
@@ -11459,7 +11496,8 @@ var ts;
}
ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
function getThisParameter(signature) {
- if (signature.parameters.length) {
+ // callback tags do not currently support this parameters
+ if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
var thisParameter = signature.parameters[0];
if (parameterIsThisKeyword(thisParameter)) {
return thisParameter;
@@ -11544,6 +11582,9 @@ var ts;
* JavaScript file, gets the return type annotation from JSDoc.
*/
function getEffectiveReturnTypeNode(node) {
+ if (ts.isJSDocSignature(node)) {
+ return node.type && node.type.typeExpression && node.type.typeExpression.type;
+ }
return node.type || (isInJavaScriptFile(node) ? ts.getJSDocReturnType(node) : undefined);
}
ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
@@ -11552,14 +11593,26 @@ var ts;
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
*/
function getEffectiveTypeParameterDeclarations(node) {
- return ts.isJSDocTypedefTag(node)
- ? getJSDocTypeParameterDeclarations(node)
- : node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined);
+ if (ts.isJSDocSignature(node)) {
+ return ts.emptyArray;
+ }
+ if (isJSDocTypeAlias(node)) {
+ ts.Debug.assert(node.parent.kind === 285 /* JSDocComment */);
+ var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; });
+ var templateTagNodes = templateTags;
+ templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos;
+ templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end;
+ templateTagNodes.hasTrailingComma = false;
+ return templateTagNodes;
+ }
+ return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray);
}
ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
function getJSDocTypeParameterDeclarations(node) {
- var templateTag = ts.getJSDocTemplateTag(node);
- return templateTag && templateTag.typeParameters;
+ var tags = ts.filter(ts.getJSDocTags(node), ts.isJSDocTemplateTag);
+ // template tags are only available when a typedef isn't already using them
+ var tag = ts.find(tags, function (tag) { return !(tag.parent.kind === 285 /* JSDocComment */ && ts.find(tag.parent.tags, isJSDocTypeAlias)); });
+ return (tag && tag.typeParameters) || ts.emptyArray;
}
ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
/**
@@ -12947,8 +13000,8 @@ var ts;
break;
case 71 /* Identifier */:
return declaration;
- case 295 /* JSDocPropertyTag */:
- case 290 /* JSDocParameterTag */: {
+ case 297 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */: {
var name = declaration.name;
if (name.kind === 145 /* QualifiedName */) {
return name.right;
@@ -12967,7 +13020,9 @@ var ts;
return undefined;
}
}
- case 294 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ return declaration.name;
+ case 296 /* JSDocTypedefTag */:
return getNameOfJSDocTypedef(declaration);
case 248 /* ExportAssignment */: {
var expression = declaration.expression;
@@ -13353,7 +13408,7 @@ var ts;
}
ts.isParenthesizedExpression = isParenthesizedExpression;
function skipPartiallyEmittedExpressions(node) {
- while (node.kind === 298 /* PartiallyEmittedExpression */) {
+ while (node.kind === 300 /* PartiallyEmittedExpression */) {
node = node.expression;
}
return node;
@@ -13745,45 +13800,53 @@ var ts;
}
ts.isJSDoc = isJSDoc;
function isJSDocAugmentsTag(node) {
- return node.kind === 288 /* JSDocAugmentsTag */;
+ return node.kind === 289 /* JSDocAugmentsTag */;
}
ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
function isJSDocClassTag(node) {
- return node.kind === 289 /* JSDocClassTag */;
+ return node.kind === 290 /* JSDocClassTag */;
}
ts.isJSDocClassTag = isJSDocClassTag;
function isJSDocParameterTag(node) {
- return node.kind === 290 /* JSDocParameterTag */;
+ return node.kind === 292 /* JSDocParameterTag */;
}
ts.isJSDocParameterTag = isJSDocParameterTag;
function isJSDocReturnTag(node) {
- return node.kind === 291 /* JSDocReturnTag */;
+ return node.kind === 293 /* JSDocReturnTag */;
}
ts.isJSDocReturnTag = isJSDocReturnTag;
function isJSDocTypeTag(node) {
- return node.kind === 292 /* JSDocTypeTag */;
+ return node.kind === 294 /* JSDocTypeTag */;
}
ts.isJSDocTypeTag = isJSDocTypeTag;
function isJSDocTemplateTag(node) {
- return node.kind === 293 /* JSDocTemplateTag */;
+ return node.kind === 295 /* JSDocTemplateTag */;
}
ts.isJSDocTemplateTag = isJSDocTemplateTag;
function isJSDocTypedefTag(node) {
- return node.kind === 294 /* JSDocTypedefTag */;
+ return node.kind === 296 /* JSDocTypedefTag */;
}
ts.isJSDocTypedefTag = isJSDocTypedefTag;
function isJSDocPropertyTag(node) {
- return node.kind === 295 /* JSDocPropertyTag */;
+ return node.kind === 297 /* JSDocPropertyTag */;
}
ts.isJSDocPropertyTag = isJSDocPropertyTag;
function isJSDocPropertyLikeTag(node) {
- return node.kind === 295 /* JSDocPropertyTag */ || node.kind === 290 /* JSDocParameterTag */;
+ return node.kind === 297 /* JSDocPropertyTag */ || node.kind === 292 /* JSDocParameterTag */;
}
ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
function isJSDocTypeLiteral(node) {
return node.kind === 286 /* JSDocTypeLiteral */;
}
ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
+ function isJSDocCallbackTag(node) {
+ return node.kind === 291 /* JSDocCallbackTag */;
+ }
+ ts.isJSDocCallbackTag = isJSDocCallbackTag;
+ function isJSDocSignature(node) {
+ return node.kind === 287 /* JSDocSignature */;
+ }
+ ts.isJSDocSignature = isJSDocSignature;
})(ts || (ts = {}));
// Node tests
//
@@ -13792,7 +13855,7 @@ var ts;
(function (ts) {
/* @internal */
function isSyntaxList(n) {
- return n.kind === 296 /* SyntaxList */;
+ return n.kind === 298 /* SyntaxList */;
}
ts.isSyntaxList = isSyntaxList;
/* @internal */
@@ -13937,6 +14000,7 @@ var ts;
switch (kind) {
case 152 /* MethodSignature */:
case 157 /* CallSignature */:
+ case 287 /* JSDocSignature */:
case 158 /* ConstructSignature */:
case 159 /* IndexSignature */:
case 162 /* FunctionType */:
@@ -14252,8 +14316,8 @@ var ts;
case 203 /* SpreadElement */:
case 207 /* AsExpression */:
case 205 /* OmittedExpression */:
- case 299 /* CommaListExpression */:
- case 298 /* PartiallyEmittedExpression */:
+ case 301 /* CommaListExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return true;
default:
return isUnaryExpressionKind(kind);
@@ -14267,12 +14331,12 @@ var ts;
ts.isAssertionExpression = isAssertionExpression;
/* @internal */
function isPartiallyEmittedExpression(node) {
- return node.kind === 298 /* PartiallyEmittedExpression */;
+ return node.kind === 300 /* PartiallyEmittedExpression */;
}
ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
/* @internal */
function isNotEmittedStatement(node) {
- return node.kind === 297 /* NotEmittedStatement */;
+ return node.kind === 299 /* NotEmittedStatement */;
}
ts.isNotEmittedStatement = isNotEmittedStatement;
/* @internal */
@@ -14383,8 +14447,9 @@ var ts;
|| kind === 236 /* TypeAliasDeclaration */
|| kind === 147 /* TypeParameter */
|| kind === 231 /* VariableDeclaration */
- || kind === 294 /* JSDocTypedefTag */
- || kind === 295 /* JSDocPropertyTag */;
+ || kind === 296 /* JSDocTypedefTag */
+ || kind === 291 /* JSDocCallbackTag */
+ || kind === 297 /* JSDocPropertyTag */;
}
function isDeclarationStatementKind(kind) {
return kind === 233 /* FunctionDeclaration */
@@ -14419,14 +14484,14 @@ var ts;
|| kind === 213 /* VariableStatement */
|| kind === 218 /* WhileStatement */
|| kind === 225 /* WithStatement */
- || kind === 297 /* NotEmittedStatement */
- || kind === 301 /* EndOfDeclarationMarker */
- || kind === 300 /* MergeDeclarationMarker */;
+ || kind === 299 /* NotEmittedStatement */
+ || kind === 303 /* EndOfDeclarationMarker */
+ || kind === 302 /* MergeDeclarationMarker */;
}
/* @internal */
function isDeclaration(node) {
if (node.kind === 147 /* TypeParameter */) {
- return node.parent.kind !== 293 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node);
+ return node.parent.kind !== 295 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node);
}
return isDeclarationKind(node.kind);
}
@@ -14521,18 +14586,18 @@ var ts;
/** True if node is of some JSDoc syntax kind. */
/* @internal */
function isJSDocNode(node) {
- return node.kind >= 277 /* FirstJSDocNode */ && node.kind <= 295 /* LastJSDocNode */;
+ return node.kind >= 277 /* FirstJSDocNode */ && node.kind <= 297 /* LastJSDocNode */;
}
ts.isJSDocNode = isJSDocNode;
/** True if node is of a kind that may contain comment text. */
function isJSDocCommentContainingNode(node) {
- return node.kind === 285 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node);
+ return node.kind === 285 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node);
}
ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
// TODO: determine what this does before making it public.
/* @internal */
function isJSDocTag(node) {
- return node.kind >= 287 /* FirstJSDocTagNode */ && node.kind <= 295 /* LastJSDocTagNode */;
+ return node.kind >= 288 /* FirstJSDocTagNode */ && node.kind <= 297 /* LastJSDocTagNode */;
}
ts.isJSDocTag = isJSDocTag;
function isSetAccessor(node) {
@@ -15078,7 +15143,7 @@ var ts;
return visitNode(cbNode, node.expression);
case 252 /* MissingDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators);
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return visitNodes(cbNode, cbNodes, node.elements);
case 254 /* JsxElement */:
return visitNode(cbNode, node.openingElement) ||
@@ -15120,8 +15185,8 @@ var ts;
return visitNode(cbNode, node.type);
case 285 /* JSDocComment */:
return visitNodes(cbNode, cbNodes, node.tags);
- case 290 /* JSDocParameterTag */:
- case 295 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */:
+ case 297 /* JSDocPropertyTag */:
if (node.isNameFirst) {
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.typeExpression);
@@ -15130,15 +15195,15 @@ var ts;
return visitNode(cbNode, node.typeExpression) ||
visitNode(cbNode, node.name);
}
- case 291 /* JSDocReturnTag */:
+ case 293 /* JSDocReturnTag */:
return visitNode(cbNode, node.typeExpression);
- case 292 /* JSDocTypeTag */:
+ case 294 /* JSDocTypeTag */:
return visitNode(cbNode, node.typeExpression);
- case 288 /* JSDocAugmentsTag */:
+ case 289 /* JSDocAugmentsTag */:
return visitNode(cbNode, node.class);
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
return visitNodes(cbNode, cbNodes, node.typeParameters);
- case 294 /* JSDocTypedefTag */:
+ case 296 /* JSDocTypedefTag */:
if (node.typeExpression &&
node.typeExpression.kind === 277 /* JSDocTypeExpression */) {
return visitNode(cbNode, node.typeExpression) ||
@@ -15148,6 +15213,15 @@ var ts;
return visitNode(cbNode, node.fullName) ||
visitNode(cbNode, node.typeExpression);
}
+ case 291 /* JSDocCallbackTag */:
+ return visitNode(cbNode, node.fullName) ||
+ visitNode(cbNode, node.typeExpression);
+ case 287 /* JSDocSignature */:
+ return visitNodes(cbNode, cbNodes, node.decorators) ||
+ visitNodes(cbNode, cbNodes, node.modifiers) ||
+ visitNodes(cbNode, cbNodes, node.typeParameters) ||
+ visitNodes(cbNode, cbNodes, node.parameters) ||
+ visitNode(cbNode, node.type);
case 286 /* JSDocTypeLiteral */:
if (node.jsDocPropertyTags) {
for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
@@ -15156,7 +15230,7 @@ var ts;
}
}
return;
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return visitNode(cbNode, node.expression);
}
}
@@ -20305,8 +20379,9 @@ var ts;
})(JSDocState || (JSDocState = {}));
var PropertyLikeParse;
(function (PropertyLikeParse) {
- PropertyLikeParse[PropertyLikeParse["Property"] = 0] = "Property";
- PropertyLikeParse[PropertyLikeParse["Parameter"] = 1] = "Parameter";
+ PropertyLikeParse[PropertyLikeParse["Property"] = 1] = "Property";
+ PropertyLikeParse[PropertyLikeParse["Parameter"] = 2] = "Parameter";
+ PropertyLikeParse[PropertyLikeParse["CallbackParameter"] = 4] = "CallbackParameter";
})(PropertyLikeParse || (PropertyLikeParse = {}));
function parseJSDocCommentWorker(start, length) {
var content = sourceText;
@@ -20354,7 +20429,7 @@ var ts;
case 57 /* AtToken */:
if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) {
removeTrailingNewlines(comments);
- parseTag(indent);
+ addTag(parseTag(indent));
// NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag.
// Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning
// for malformed examples like `/** @param {string} x @returns {number} the length */`
@@ -20433,7 +20508,24 @@ var ts;
result.comment = comments.length ? comments.join("") : undefined;
return finishNode(result, end);
}
+ function isNextNonwhitespaceTokenEndOfFile() {
+ // We must use infinite lookahead, as there could be any number of newlines :(
+ while (true) {
+ nextJSDocToken();
+ if (token() === 1 /* EndOfFileToken */) {
+ return true;
+ }
+ if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) {
+ return false;
+ }
+ }
+ }
function skipWhitespace() {
+ if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
+ if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
+ return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range
+ }
+ }
while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
nextJSDocToken();
}
@@ -20462,8 +20554,7 @@ var ts;
case "arg":
case "argument":
case "param":
- addTag(parseParameterOrPropertyTag(atToken, tagName, 1 /* Parameter */, indent));
- return;
+ return parseParameterOrPropertyTag(atToken, tagName, 2 /* Parameter */, indent);
case "return":
case "returns":
tag = parseReturnTag(atToken, tagName);
@@ -20475,7 +20566,10 @@ var ts;
tag = parseTypeTag(atToken, tagName);
break;
case "typedef":
- tag = parseTypedefTag(atToken, tagName);
+ tag = parseTypedefTag(atToken, tagName, indent);
+ break;
+ case "callback":
+ tag = parseCallbackTag(atToken, tagName, indent);
break;
default:
tag = parseUnknownTag(atToken, tagName);
@@ -20489,8 +20583,11 @@ var ts;
// a badly malformed tag should not be added to the list of tags
return;
}
- tag.comment = parseTagComments(indent + tag.end - tag.pos);
- addTag(tag);
+ if (!tag.comment) {
+ // some tags, like typedef and callback, have already parsed their comments earlier
+ tag.comment = parseTagComments(indent + tag.end - tag.pos);
+ }
+ return tag;
}
function parseTagComments(indent) {
var comments = [];
@@ -20553,12 +20650,15 @@ var ts;
return comments.length === 0 ? undefined : comments.join("");
}
function parseUnknownTag(atToken, tagName) {
- var result = createNode(287 /* JSDocTag */, atToken.pos);
+ var result = createNode(288 /* JSDocTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
return finishNode(result);
}
function addTag(tag) {
+ if (!tag) {
+ return;
+ }
if (!tags) {
tags = [tag];
tagsPos = tag.pos;
@@ -20609,9 +20709,9 @@ var ts;
if (isNameFirst) {
typeExpression = tryParseTypeExpression();
}
- var result = target === 1 /* Parameter */ ?
- createNode(290 /* JSDocParameterTag */, atToken.pos) :
- createNode(295 /* JSDocPropertyTag */, atToken.pos);
+ var result = target === 1 /* Property */ ?
+ createNode(297 /* JSDocPropertyTag */, atToken.pos) :
+ createNode(292 /* JSDocParameterTag */, atToken.pos);
var comment;
if (indent !== undefined)
comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
@@ -20637,7 +20737,7 @@ var ts;
var start_2 = scanner.getStartPos();
var children = void 0;
while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) {
- if (child.kind === 290 /* JSDocParameterTag */ || child.kind === 295 /* JSDocPropertyTag */) {
+ if (child.kind === 292 /* JSDocParameterTag */ || child.kind === 297 /* JSDocPropertyTag */) {
children = ts.append(children, child);
}
}
@@ -20653,27 +20753,27 @@ var ts;
}
}
function parseReturnTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 291 /* JSDocReturnTag */; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 293 /* JSDocReturnTag */; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(291 /* JSDocReturnTag */, atToken.pos);
+ var result = createNode(293 /* JSDocReturnTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result);
}
function parseTypeTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 292 /* JSDocTypeTag */; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocTypeTag */; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(292 /* JSDocTypeTag */, atToken.pos);
+ var result = createNode(294 /* JSDocTypeTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
return finishNode(result);
}
function parseAugmentsTag(atToken, tagName) {
- var result = createNode(288 /* JSDocAugmentsTag */, atToken.pos);
+ var result = createNode(289 /* JSDocAugmentsTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.class = parseExpressionWithTypeArgumentsForAugments();
@@ -20701,32 +20801,23 @@ var ts;
return node;
}
function parseClassTag(atToken, tagName) {
- var tag = createNode(289 /* JSDocClassTag */, atToken.pos);
+ var tag = createNode(290 /* JSDocClassTag */, atToken.pos);
tag.atToken = atToken;
tag.tagName = tagName;
return finishNode(tag);
}
- function parseTypedefTag(atToken, tagName) {
+ function parseTypedefTag(atToken, tagName, indent) {
var typeExpression = tryParseTypeExpression();
skipWhitespace();
- var typedefTag = createNode(294 /* JSDocTypedefTag */, atToken.pos);
+ var typedefTag = createNode(296 /* JSDocTypedefTag */, atToken.pos);
typedefTag.atToken = atToken;
typedefTag.tagName = tagName;
- typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0);
- if (typedefTag.fullName) {
- var rightNode = typedefTag.fullName;
- while (true) {
- if (rightNode.kind === 71 /* Identifier */ || !rightNode.body) {
- // if node is identifier - use it as name
- // otherwise use name of the rightmost part that we were able to parse
- typedefTag.name = rightNode.kind === 71 /* Identifier */ ? rightNode : rightNode.name;
- break;
- }
- rightNode = rightNode.body;
- }
- }
+ typedefTag.fullName = parseJSDocTypeNameWithNamespace();
+ typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
skipWhitespace();
+ typedefTag.comment = parseTagComments(indent);
typedefTag.typeExpression = typeExpression;
+ var end;
if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
var child = void 0;
var jsdocTypeLiteral = void 0;
@@ -20736,7 +20827,7 @@ var ts;
if (!jsdocTypeLiteral) {
jsdocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, start_3);
}
- if (child.kind === 292 /* JSDocTypeTag */) {
+ if (child.kind === 294 /* JSDocTypeTag */) {
if (childTypeTag) {
break;
}
@@ -20755,23 +20846,68 @@ var ts;
typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
childTypeTag.typeExpression :
finishNode(jsdocTypeLiteral);
+ end = typedefTag.typeExpression.end;
}
}
- return finishNode(typedefTag);
- function parseJSDocTypeNameWithNamespace(flags) {
- var pos = scanner.getTokenPos();
- var typeNameOrNamespaceName = parseJSDocIdentifierName();
- if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) {
- var jsDocNamespaceNode = createNode(238 /* ModuleDeclaration */, pos);
- jsDocNamespaceNode.flags |= flags;
- jsDocNamespaceNode.name = typeNameOrNamespaceName;
- jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */);
- return finishNode(jsDocNamespaceNode);
+ // Only include the characters between the name end and the next token if a comment was actually parsed out - otherwise it's just whitespace
+ return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
+ }
+ function parseJSDocTypeNameWithNamespace(nested) {
+ var pos = scanner.getTokenPos();
+ var typeNameOrNamespaceName = parseJSDocIdentifierName();
+ if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) {
+ var jsDocNamespaceNode = createNode(238 /* ModuleDeclaration */, pos);
+ if (nested) {
+ jsDocNamespaceNode.flags |= 4 /* NestedNamespace */;
}
- if (typeNameOrNamespaceName && flags & 4 /* NestedNamespace */) {
- typeNameOrNamespaceName.isInJSDocNamespace = true;
+ jsDocNamespaceNode.name = typeNameOrNamespaceName;
+ jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(/*nested*/ true);
+ return finishNode(jsDocNamespaceNode);
+ }
+ if (typeNameOrNamespaceName && nested) {
+ typeNameOrNamespaceName.isInJSDocNamespace = true;
+ }
+ return typeNameOrNamespaceName;
+ }
+ function parseCallbackTag(atToken, tagName, indent) {
+ var callbackTag = createNode(291 /* JSDocCallbackTag */, atToken.pos);
+ callbackTag.atToken = atToken;
+ callbackTag.tagName = tagName;
+ callbackTag.fullName = parseJSDocTypeNameWithNamespace();
+ callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
+ skipWhitespace();
+ callbackTag.comment = parseTagComments(indent);
+ var child;
+ var start = scanner.getStartPos();
+ var jsdocSignature = createNode(287 /* JSDocSignature */, start);
+ jsdocSignature.parameters = [];
+ while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) {
+ jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
+ }
+ var returnTag = tryParse(function () {
+ if (token() === 57 /* AtToken */) {
+ nextJSDocToken();
+ var tag = parseTag(indent);
+ if (tag && tag.kind === 293 /* JSDocReturnTag */) {
+ return tag;
+ }
+ }
+ });
+ if (returnTag) {
+ jsdocSignature.type = returnTag;
+ }
+ callbackTag.typeExpression = finishNode(jsdocSignature);
+ return finishNode(callbackTag);
+ }
+ function getJSDocTypeAliasName(fullName) {
+ if (fullName) {
+ var rightNode = fullName;
+ while (true) {
+ if (ts.isIdentifier(rightNode) || !rightNode.body) {
+ return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
+ }
+ rightNode = rightNode.body;
}
- return typeNameOrNamespaceName;
}
}
function escapedTextsEqual(a, b) {
@@ -20787,7 +20923,7 @@ var ts;
return a.escapedText === b.escapedText;
}
function parseChildPropertyTag() {
- return parseChildParameterOrPropertyTag(0 /* Property */);
+ return parseChildParameterOrPropertyTag(1 /* Property */);
}
function parseChildParameterOrPropertyTag(target, name) {
var canParseTag = true;
@@ -20797,7 +20933,8 @@ var ts;
case 57 /* AtToken */:
if (canParseTag) {
var child = tryParseChildTag(target);
- if (child && child.kind === 290 /* JSDocParameterTag */ &&
+ if (child && child.kind === 292 /* JSDocParameterTag */ &&
+ target !== 4 /* CallbackParameter */ &&
(ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
return false;
}
@@ -20836,20 +20973,20 @@ var ts;
var t;
switch (tagName.escapedText) {
case "type":
- return target === 0 /* Property */ && parseTypeTag(atToken, tagName);
+ return target === 1 /* Property */ && parseTypeTag(atToken, tagName);
case "prop":
case "property":
- t = 0 /* Property */;
+ t = 1 /* Property */;
break;
case "arg":
case "argument":
case "param":
- t = 1 /* Parameter */;
+ t = 2 /* Parameter */ | 4 /* CallbackParameter */;
break;
default:
return false;
}
- if (target !== t) {
+ if (!(target & t)) {
return false;
}
var tag = parseParameterOrPropertyTag(atToken, tagName, target, /*indent*/ undefined);
@@ -20882,7 +21019,7 @@ var ts;
break;
}
}
- var result = createNode(293 /* JSDocTemplateTag */, atToken.pos);
+ var result = createNode(295 /* JSDocTemplateTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
@@ -20931,7 +21068,7 @@ var ts;
var pos = scanner.getTokenPos();
var end = scanner.getTextPos();
var result = createNode(71 /* Identifier */, pos);
- result.escapedText = ts.escapeLeadingUnderscores(content.substring(pos, end));
+ result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText());
finishNode(result, end);
nextJSDocToken();
return result;
@@ -21735,7 +21872,7 @@ var ts;
var thisParentContainer; // Container one level up
var blockScopeContainer;
var lastContainer;
- var delayedTypedefs;
+ var delayedTypeAliases;
var seenThisKeyword;
// state used by control flow analysis
var currentFlow;
@@ -21793,7 +21930,7 @@ var ts;
thisParentContainer = undefined;
blockScopeContainer = undefined;
lastContainer = undefined;
- delayedTypedefs = undefined;
+ delayedTypeAliases = undefined;
seenThisKeyword = false;
currentFlow = undefined;
currentBreakTarget = undefined;
@@ -21867,6 +22004,7 @@ var ts;
return "__constructor" /* Constructor */;
case 162 /* FunctionType */:
case 157 /* CallSignature */:
+ case 287 /* JSDocSignature */:
return "__call" /* Call */;
case 163 /* ConstructorType */:
case 158 /* ConstructSignature */:
@@ -21895,9 +22033,6 @@ var ts;
var functionType = node.parent;
var index = functionType.parameters.indexOf(node);
return "arg" + index;
- case 294 /* JSDocTypedefTag */:
- var name_2 = ts.getNameOfJSDocTypedef(node);
- return typeof name_2 !== "undefined" ? name_2.escapedText : undefined;
}
}
function getDisplayName(node) {
@@ -22035,9 +22170,9 @@ var ts;
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
// and this case is specially handled. Module augmentations should only be merged with original module definition
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
- if (node.kind === 294 /* JSDocTypedefTag */)
+ if (ts.isJSDocTypeAlias(node))
ts.Debug.assert(ts.isInJavaScriptFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
- if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypedefTag(node)) {
+ if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) {
if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) {
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
}
@@ -22202,23 +22337,6 @@ var ts;
ts.forEachChild(node, bind, bindEach);
}
function bindChildrenWorker(node) {
- // Binding of JsDocComment should be done before the current block scope container changes.
- // because the scope of JsDocComment should not be affected by whether the current node is a
- // container or not.
- if (ts.hasJSDocNodes(node)) {
- if (ts.isInJavaScriptFile(node)) {
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var j = _a[_i];
- bind(j);
- }
- }
- else {
- for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
- var j = _c[_b];
- setParentPointers(node, j);
- }
- }
- }
if (checkUnreachable(node)) {
bindEachChild(node);
return;
@@ -22284,11 +22402,9 @@ var ts;
case 186 /* CallExpression */:
bindCallExpressionFlow(node);
break;
- case 285 /* JSDocComment */:
- bindJSDocComment(node);
- break;
- case 294 /* JSDocTypedefTag */:
- bindJSDocTypedefTag(node);
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ bindJSDocTypeAlias(node);
break;
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
case 273 /* SourceFile */:
@@ -22303,6 +22419,7 @@ var ts;
bindEachChild(node);
break;
}
+ bindJSDoc(node);
}
function isNarrowingExpression(expr) {
switch (expr.kind) {
@@ -22904,23 +23021,10 @@ var ts;
bindInitializedVariableFlow(node);
}
}
- function bindJSDocComment(node) {
- ts.forEachChild(node, function (n) {
- if (n.kind !== 294 /* JSDocTypedefTag */) {
- bind(n);
- }
- });
- }
- function bindJSDocTypedefTag(node) {
- ts.forEachChild(node, function (n) {
- // if the node has a fullName "A.B.C", that means symbol "C" was already bound
- // when we visit "fullName"; so when we visit the name "C" as the next child of
- // the jsDocTypedefTag, we should skip binding it.
- if (node.fullName && n === node.name && node.fullName.kind !== 71 /* Identifier */) {
- return;
- }
- bind(n);
- });
+ function bindJSDocTypeAlias(node) {
+ if (node.fullName) {
+ setParentPointers(node, node.fullName);
+ }
}
function bindCallExpressionFlow(node) {
// If the target of the call expression is a function expression or arrow function we have
@@ -22974,6 +23078,7 @@ var ts;
case 155 /* GetAccessor */:
case 156 /* SetAccessor */:
case 157 /* CallSignature */:
+ case 287 /* JSDocSignature */:
case 283 /* JSDocFunctionType */:
case 162 /* FunctionType */:
case 158 /* ConstructSignature */:
@@ -23050,6 +23155,7 @@ var ts;
case 163 /* ConstructorType */:
case 157 /* CallSignature */:
case 158 /* ConstructSignature */:
+ case 287 /* JSDocSignature */:
case 159 /* IndexSignature */:
case 153 /* MethodDeclaration */:
case 152 /* MethodSignature */:
@@ -23060,6 +23166,8 @@ var ts;
case 191 /* FunctionExpression */:
case 192 /* ArrowFunction */:
case 283 /* JSDocFunctionType */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
case 236 /* TypeAliasDeclaration */:
case 176 /* MappedType */:
// All the children of these container types are never visible through another
@@ -23234,22 +23342,35 @@ var ts;
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 67216319 /* BlockScopedVariableExcludes */);
}
function delayedBindJSDocTypedefTag() {
- if (!delayedTypedefs) {
+ if (!delayedTypeAliases) {
return;
}
var saveContainer = container;
var saveLastContainer = lastContainer;
var saveBlockScopeContainer = blockScopeContainer;
var saveParent = parent;
- for (var _i = 0, delayedTypedefs_1 = delayedTypedefs; _i < delayedTypedefs_1.length; _i++) {
- var delay = delayedTypedefs_1[_i];
- (container = delay.container, lastContainer = delay.lastContainer, blockScopeContainer = delay.blockScopeContainer, parent = delay.parent);
- bindBlockScopedDeclaration(delay.typedef, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */);
+ var saveCurrentFlow = currentFlow;
+ for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
+ var typeAlias = delayedTypeAliases_1[_i];
+ var host = ts.getJSDocHost(typeAlias);
+ container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file;
+ blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
+ currentFlow = { flags: 2 /* Start */ };
+ parent = typeAlias;
+ bind(typeAlias.typeExpression);
+ if (!typeAlias.fullName || typeAlias.fullName.kind === 71 /* Identifier */) {
+ parent = typeAlias.parent;
+ bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */);
+ }
+ else {
+ bind(typeAlias.fullName);
+ }
}
container = saveContainer;
lastContainer = saveLastContainer;
blockScopeContainer = saveBlockScopeContainer;
parent = saveParent;
+ currentFlow = saveCurrentFlow;
}
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
// check for reserved words used as identifiers in strict mode code.
@@ -23401,8 +23522,6 @@ var ts;
// Here the current node is "foo", which is a container, but the scope of "MyType" should
// not be inside "foo". Therefore we always bind @typedef before bind the parent node,
// and skip binding this tag later when binding all the other jsdoc tags.
- if (ts.isInJavaScriptFile(node))
- bindJSDocTypedefTagIfAny(node);
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
// and then potentially add the symbol to an appropriate symbol table. Possible
// destination symbol tables are:
@@ -23433,25 +23552,22 @@ var ts;
}
else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) {
subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
+ bindJSDoc(node);
}
inStrictMode = saveInStrictMode;
}
- function bindJSDocTypedefTagIfAny(node) {
- if (!ts.hasJSDocNodes(node)) {
- return;
- }
- for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
- var jsDoc = _a[_i];
- if (!jsDoc.tags) {
- continue;
+ function bindJSDoc(node) {
+ if (ts.hasJSDocNodes(node)) {
+ if (ts.isInJavaScriptFile(node)) {
+ for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
+ var j = _a[_i];
+ bind(j);
+ }
}
- for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) {
- var tag = _c[_b];
- if (tag.kind === 294 /* JSDocTypedefTag */) {
- var savedParent = parent;
- parent = jsDoc;
- bind(tag);
- parent = savedParent;
+ else {
+ for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
+ var j = _c[_b];
+ setParentPointers(node, j);
}
}
}
@@ -23486,7 +23602,7 @@ var ts;
// current "blockScopeContainer" needs to be set to its immediate namespace parent.
if (node.isInJSDocNamespace) {
var parentNode = node.parent;
- while (parentNode && parentNode.kind !== 294 /* JSDocTypedefTag */) {
+ while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
parentNode = parentNode.parent;
}
bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */);
@@ -23589,6 +23705,7 @@ var ts;
return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */);
case 162 /* FunctionType */:
case 283 /* JSDocFunctionType */:
+ case 287 /* JSDocSignature */:
case 163 /* ConstructorType */:
return bindFunctionOrConstructorType(node);
case 165 /* TypeLiteral */:
@@ -23648,24 +23765,23 @@ var ts;
// falls through
case 239 /* ModuleBlock */:
return updateStrictModeStatementList(node.statements);
- case 290 /* JSDocParameterTag */:
+ case 292 /* JSDocParameterTag */:
+ if (node.parent.kind === 287 /* JSDocSignature */) {
+ return bindParameter(node);
+ }
if (node.parent.kind !== 286 /* JSDocTypeLiteral */) {
break;
}
// falls through
- case 295 /* JSDocPropertyTag */:
+ case 297 /* JSDocPropertyTag */:
var propTag = node;
var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 /* JSDocOptionalType */ ?
4 /* Property */ | 16777216 /* Optional */ :
4 /* Property */;
return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */);
- case 294 /* JSDocTypedefTag */: {
- var fullName = node.fullName;
- if (!fullName || fullName.kind === 71 /* Identifier */) {
- (delayedTypedefs || (delayedTypedefs = [])).push({ typedef: node, container: container, lastContainer: lastContainer, blockScopeContainer: blockScopeContainer, parent: parent });
- }
- break;
- }
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
}
}
function bindPropertyWorker(node) {
@@ -24025,6 +24141,9 @@ var ts;
}
}
function bindParameter(node) {
+ if (node.kind === 292 /* JSDocParameterTag */ && container.kind !== 287 /* JSDocSignature */) {
+ return;
+ }
if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) {
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
@@ -24083,24 +24202,30 @@ var ts;
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
function getInferTypeContainer(node) {
- while (node) {
- var parent_2 = node.parent;
- if (parent_2 && parent_2.kind === 170 /* ConditionalType */ && parent_2.extendsType === node) {
- return parent_2;
- }
- node = parent_2;
- }
- return undefined;
+ var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
+ return extendsType && extendsType.parent;
}
function bindTypeParameter(node) {
- if (node.parent.kind === 171 /* InferType */) {
- var container_1 = getInferTypeContainer(node.parent);
+ if (ts.isJSDocTemplateTag(node.parent)) {
+ var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
if (container_1) {
if (!container_1.locals) {
container_1.locals = ts.createSymbolTable();
}
declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */);
}
+ else {
+ declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */);
+ }
+ }
+ else if (node.parent.kind === 171 /* InferType */) {
+ var container_2 = getInferTypeContainer(node.parent);
+ if (container_2) {
+ if (!container_2.locals) {
+ container_2.locals = ts.createSymbolTable();
+ }
+ declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */);
+ }
else {
bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node));
}
@@ -24725,7 +24850,7 @@ var ts;
break;
case 189 /* TypeAssertionExpression */:
case 207 /* AsExpression */:
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
// These nodes are TypeScript syntax.
transformFlags |= 3 /* AssertTypeScript */;
excludeFlags = 536872257 /* OuterExpressionExcludes */;
@@ -24997,7 +25122,7 @@ var ts;
return 940049729 /* BindingPatternExcludes */;
case 189 /* TypeAssertionExpression */:
case 207 /* AsExpression */:
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
case 190 /* ParenthesizedExpression */:
case 97 /* SuperKeyword */:
return 536872257 /* OuterExpressionExcludes */;
@@ -25015,7 +25140,7 @@ var ts;
*/
function setParentPointers(parent, child) {
child.parent = parent;
- ts.forEachChild(child, function (childsChild) { return setParentPointers(child, childsChild); });
+ ts.forEachChild(child, function (grandchild) { return setParentPointers(child, grandchild); });
}
})(ts || (ts = {}));
/** @internal */
@@ -27671,6 +27796,12 @@ var ts;
location = location.parent;
}
break;
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ // js type aliases do not resolve names from their host, so skip past it
+ lastLocation = location;
+ location = ts.getJSDocHost(location).parent;
+ continue;
}
if (isSelfReferenceLocation(location)) {
lastSelfReferenceLocation = location;
@@ -27786,9 +27917,11 @@ var ts;
function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
- if (decl.kind === 147 /* TypeParameter */ && parent === container) {
- return true;
+ if (decl.kind === 147 /* TypeParameter */) {
+ var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
+ if (parent === container) {
+ return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
+ }
}
}
return false;
@@ -28252,7 +28385,7 @@ var ts;
var symbol;
if (name.kind === 71 /* Identifier */) {
var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0;
- var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSPrototype(name, meaning) : undefined;
+ var symbolFromJSPrototype = ts.isInJavaScriptFile(name) ? resolveEntityNameFromJSSpecialAssignment(name, meaning) : undefined;
symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true);
if (!symbol) {
return symbolFromJSPrototype;
@@ -28306,24 +28439,38 @@ var ts;
return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
}
/**
- * For prototype-property methods like `A.prototype.m = function () ...`, try to resolve names in the scope of `A` too.
+ * 1. For prototype-property methods like `A.prototype.m = function () ...`, try to resolve names in the scope of `A` too.
* Note that prototype-property assignment to locations outside the current file (eg globals) doesn't work, so
* name resolution won't work either.
+ * 2. For property assignments like `{ x: function f () { } }`, try to resolve names in the scope of `f` too.
*/
- function resolveEntityNameFromJSPrototype(name, meaning) {
- if (isJSDocTypeReference(name.parent) && ts.isJSDocTag(name.parent.parent.parent)) {
- var host_1 = ts.getJSDocHost(name.parent.parent.parent);
- if (ts.isExpressionStatement(host_1) &&
- ts.isBinaryExpression(host_1.expression) &&
- ts.getSpecialPropertyAssignmentKind(host_1.expression) === 3 /* PrototypeProperty */) {
- var symbol = getSymbolOfNode(host_1.expression.left);
- if (symbol) {
- var secondaryLocation = symbol.parent.valueDeclaration;
- return resolveName(secondaryLocation, name.escapedText, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ true);
- }
+ function resolveEntityNameFromJSSpecialAssignment(name, meaning) {
+ if (isJSDocTypeReference(name.parent)) {
+ var secondaryLocation = getJSSpecialAssignmentLocation(name.parent);
+ if (secondaryLocation) {
+ return resolveName(secondaryLocation, name.escapedText, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ true);
}
}
}
+ function getJSSpecialAssignmentLocation(node) {
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
+ if (typeAlias) {
+ return;
+ }
+ var host = ts.getJSDocHost(node);
+ if (host &&
+ ts.isExpressionStatement(host) &&
+ ts.isBinaryExpression(host.expression) &&
+ ts.getSpecialPropertyAssignmentKind(host.expression) === 3 /* PrototypeProperty */) {
+ var symbol = getSymbolOfNode(host.expression.left);
+ return symbol && symbol.parent.valueDeclaration;
+ }
+ var sig = ts.getHostSignatureFromJSDocHost(host);
+ if (sig) {
+ var symbol = getSymbolOfNode(sig);
+ return symbol && symbol.valueDeclaration;
+ }
+ }
function resolveExternalModuleName(location, moduleReferenceExpression) {
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0);
}
@@ -28863,6 +29010,14 @@ var ts;
}
return hasAccessibleDeclarations;
}
+ else {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol)) {
+ // Any meaning of a module symbol is always accessible via an `import` type
+ return {
+ accessibility: 0 /* Accessible */
+ };
+ }
+ }
// If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible.
// It could be a qualified symbol and hence verify the path
// e.g.:
@@ -29100,7 +29255,7 @@ var ts;
flags: flags,
tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop },
encounteredError: false,
- symbolStack: undefined,
+ visitedSymbols: undefined,
inferTypeParameters: undefined
};
}
@@ -29207,9 +29362,10 @@ var ts;
return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined);
}
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
- var name = symbolToTypeReferenceName(type.aliasSymbol);
var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
- return ts.createTypeReferenceNode(name, typeArgumentNodes);
+ if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
+ return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes);
+ return symbolToTypeNode(type.aliasSymbol, context, 67901928 /* Type */, typeArgumentNodes);
}
if (type.flags & (131072 /* Union */ | 262144 /* Intersection */)) {
var types = type.flags & 131072 /* Union */ ? formatUnionTypes(type.types) : type.types;
@@ -29274,7 +29430,10 @@ var ts;
}
function createAnonymousTypeNode(type) {
var symbol = type.symbol;
+ var id;
if (symbol) {
+ var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */;
+ id = (isConstructorObject ? "+" : "") + getSymbolId(symbol);
if (isJavaScriptConstructor(symbol.valueDeclaration)) {
// Instance and static types share the same symbol; only add 'typeof' for the static side.
var isInstanceType = type === getInferredClassType(symbol) ? 67901928 /* Type */ : 67216319 /* Value */;
@@ -29286,7 +29445,7 @@ var ts;
shouldWriteTypeOfFunctionSymbol()) {
return symbolToTypeNode(symbol, context, 67216319 /* Value */);
}
- else if (ts.contains(context.symbolStack, symbol)) {
+ else if (context.visitedSymbols && context.visitedSymbols.has(id)) {
// If type is an anonymous type literal in a type alias declaration, use type alias name
var typeAlias = getTypeAliasForTypeLiteral(type);
if (typeAlias) {
@@ -29300,19 +29459,13 @@ var ts;
else {
// Since instantiations of the same anonymous type have the same symbol, tracking symbols instead
// of types allows us to catch circular references to instantiations of the same anonymous type
- if (!context.symbolStack) {
- context.symbolStack = [];
- }
- var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */;
- if (isConstructorObject) {
- return createTypeNodeFromObjectType(type);
- }
- else {
- context.symbolStack.push(symbol);
- var result = createTypeNodeFromObjectType(type);
- context.symbolStack.pop();
- return result;
+ if (!context.visitedSymbols) {
+ context.visitedSymbols = ts.createMap();
}
+ context.visitedSymbols.set(id, true);
+ var result = createTypeNodeFromObjectType(type);
+ context.visitedSymbols.delete(id);
+ return result;
}
}
else {
@@ -29329,7 +29482,7 @@ var ts;
}));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
// typeof is allowed only for static/non local functions
- return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ts.contains(context.symbolStack, symbol)) && // it is type of the symbol uses itself recursively
+ return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively
(!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed
}
}
@@ -29361,11 +29514,6 @@ var ts;
var typeLiteralNode = ts.createTypeLiteralNode(members);
return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */);
}
- function symbolToTypeReferenceName(symbol) {
- // Unnamed function expressions and arrow functions have reserved names that we don't want to display
- var entityName = symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.escapedName) ? symbolToName(symbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false) : ts.createIdentifier("");
- return entityName;
- }
function typeReferenceToTypeNode(type) {
var typeArguments = type.typeArguments || ts.emptyArray;
if (type.target === globalArrayType) {
@@ -29398,7 +29546,7 @@ var ts;
else {
var outerTypeParameters = type.target.outerTypeParameters;
var i = 0;
- var qualifiedName = void 0;
+ var resultType = void 0;
if (outerTypeParameters) {
var length_1 = outerTypeParameters.length;
while (i < length_1) {
@@ -29412,55 +29560,65 @@ var ts;
// the default outer type arguments), we don't show the group.
if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
- var typeArgumentNodes_1 = typeArgumentSlice && ts.createNodeArray(typeArgumentSlice);
- var namePart = symbolToTypeReferenceName(parent);
- (namePart.kind === 71 /* Identifier */ ? namePart : namePart.right).typeArguments = typeArgumentNodes_1;
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, namePart);
- qualifiedName = ts.createQualifiedName(qualifiedName, /*right*/ undefined);
- }
- else {
- qualifiedName = ts.createQualifiedName(namePart, /*right*/ undefined);
- }
+ var flags_2 = context.flags;
+ context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */;
+ var ref = symbolToTypeNode(parent, context, 67901928 /* Type */, typeArgumentSlice);
+ context.flags = flags_2;
+ resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
}
}
}
- var entityName = void 0;
- var nameIdentifier = symbolToTypeReferenceName(type.symbol);
- if (qualifiedName) {
- ts.Debug.assert(!qualifiedName.right);
- qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, nameIdentifier);
- entityName = qualifiedName;
- }
- else {
- entityName = nameIdentifier;
- }
var typeArgumentNodes = void 0;
if (typeArguments.length > 0) {
var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
}
- if (typeArgumentNodes) {
- var lastIdentifier = entityName.kind === 71 /* Identifier */ ? entityName : entityName.right;
- lastIdentifier.typeArguments = undefined;
- }
- return ts.createTypeReferenceNode(entityName, typeArgumentNodes);
+ var flags = context.flags;
+ context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */;
+ var finalRef = symbolToTypeNode(type.symbol, context, 67901928 /* Type */, typeArgumentNodes);
+ context.flags = flags;
+ return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
}
}
- function addToQualifiedNameMissingRightIdentifier(left, right) {
- ts.Debug.assert(left.right === undefined);
- if (right.kind === 71 /* Identifier */) {
- left.right = right;
- return left;
+ function appendReferenceToType(root, ref) {
+ if (ts.isImportTypeNode(root)) {
+ // first shift type arguments
+ var innerParams = root.typeArguments;
+ if (root.qualifier) {
+ (ts.isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams;
+ }
+ root.typeArguments = ref.typeArguments;
+ // then move qualifiers
+ var ids = getAccessStack(ref);
+ for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
+ var id = ids_1[_i];
+ root.qualifier = root.qualifier ? ts.createQualifiedName(root.qualifier, id) : id;
+ }
+ return root;
}
- var rightPart = right;
- while (rightPart.left.kind !== 71 /* Identifier */) {
- rightPart = rightPart.left;
+ else {
+ // first shift type arguments
+ var innerParams = root.typeArguments;
+ (ts.isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams;
+ root.typeArguments = ref.typeArguments;
+ // then move qualifiers
+ var ids = getAccessStack(ref);
+ for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
+ var id = ids_2[_a];
+ root.typeName = ts.createQualifiedName(root.typeName, id);
+ }
+ return root;
}
- left.right = rightPart.left;
- rightPart.left = left;
- return right;
+ }
+ function getAccessStack(ref) {
+ var state = ref.typeName;
+ var ids = [];
+ while (!ts.isIdentifier(state)) {
+ ids.unshift(state.right);
+ state = state.left;
+ }
+ ids.unshift(state);
+ return ids;
}
function createTypeNodesFromResolvedType(resolvedType) {
var typeElements = [];
@@ -29632,7 +29790,9 @@ var ts;
}
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) {
var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148 /* Parameter */);
- ts.Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol));
+ if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) {
+ parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292 /* JSDocParameterTag */);
+ }
var parameterType = getTypeOfSymbol(parameterSymbol);
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
parameterType = getOptionalType(parameterType);
@@ -29643,9 +29803,9 @@ var ts;
var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined;
var name = parameterDeclaration
? parameterDeclaration.name ?
- parameterDeclaration.name.kind === 71 /* Identifier */ ?
- ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) :
- cloneBindingName(parameterDeclaration.name) :
+ parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) :
+ parameterDeclaration.name.kind === 145 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) :
+ cloneBindingName(parameterDeclaration.name) :
ts.symbolName(parameterSymbol)
: ts.symbolName(parameterSymbol);
var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined;
@@ -29665,7 +29825,7 @@ var ts;
}
}
}
- function lookupSymbolChain(symbol, context, meaning) {
+ function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
// Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration.
var chain;
@@ -29701,7 +29861,7 @@ var ts;
// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
endOfChain ||
// If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
- !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) &&
+ (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) &&
// If a parent symbol is an anonymous type, don't write it.
!(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
return [symbol];
@@ -29742,8 +29902,8 @@ var ts;
}
return top;
}
- function symbolToTypeNode(symbol, context, meaning) {
- var chain = lookupSymbolChain(symbol, context, meaning);
+ function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
+ var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
context.flags |= 16777216 /* InInitialEntityName */;
var rootName = getNameOfSymbolAsWritten(chain[0], context);
context.flags ^= 16777216 /* InInitialEntityName */;
@@ -29751,9 +29911,13 @@ var ts;
if (ambientModuleSymbolRegex.test(rootName)) {
// module is root, must use `ImportTypeNode`
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
- var typeParameterNodes = lookupTypeParameterNodes(chain, 0, context);
+ var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1)));
if (!nonRootParts || ts.isEntityName(nonRootParts)) {
+ if (nonRootParts) {
+ var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
+ lastId.typeArguments = undefined;
+ }
return ts.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
}
else {
@@ -29766,9 +29930,17 @@ var ts;
if (ts.isIndexedAccessTypeNode(entityName)) {
return entityName; // Indexed accesses can never be `typeof`
}
- return isTypeOf ? ts.createTypeQueryNode(entityName) : ts.createTypeReferenceNode(entityName, /*typeArguments*/ undefined);
+ if (isTypeOf) {
+ return ts.createTypeQueryNode(entityName);
+ }
+ else {
+ var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
+ var lastTypeArgs = lastId.typeArguments;
+ lastId.typeArguments = undefined;
+ return ts.createTypeReferenceNode(entityName, lastTypeArgs);
+ }
function createAccessFromSymbolChain(chain, index, stopper) {
- var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
+ var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
var symbol = chain[index];
if (index === 0) {
context.flags |= 16777216 /* InInitialEntityName */;
@@ -29778,7 +29950,7 @@ var ts;
context.flags ^= 16777216 /* InInitialEntityName */;
}
var parent = chain[index - 1];
- if (parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
+ if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) {
// Should use an indexed access
var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
if (ts.isIndexedAccessTypeNode(LHS)) {
@@ -29946,6 +30118,24 @@ var ts;
return "default";
}
if (symbol.declarations && symbol.declarations.length) {
+ if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) {
+ var file_3 = ts.getDeclarationOfKind(symbol, 273 /* SourceFile */);
+ if (!file_3 || !context.tracker.moduleResolverHost) {
+ if (context.tracker.trackReferencedAmbientModule) {
+ var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
+ if (ts.length(ambientDecls)) {
+ for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
+ var decl = ambientDecls_1[_i];
+ context.tracker.trackReferencedAmbientModule(decl);
+ }
+ }
+ }
+ // ambient module, just use declaration/symbol name (fallthrough)
+ }
+ else {
+ return "\"" + ts.getResolvedExternalModuleName(context.tracker.moduleResolverHost, file_3, ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration))) + "\"";
+ }
+ }
var declaration = symbol.declarations[0];
var name = ts.getNameOfDeclaration(declaration);
if (name) {
@@ -29987,8 +30177,9 @@ var ts;
return false;
function determineIfDeclarationIsVisible() {
switch (node.kind) {
- case 294 /* JSDocTypedefTag */:
- // Top-level jsdoc typedefs are considered exported
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ // Top-level jsdoc type aliases are considered exported
// First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file
return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
case 181 /* BindingElement */:
@@ -30703,7 +30894,7 @@ var ts;
if (symbol.flags & 4194304 /* Prototype */) {
return links.type = getTypeOfPrototypeProperty(symbol);
}
- // CommonsJS require/module/exports all have type any.
+ // CommonsJS require and module both have type any.
if (symbol === requireSymbol || symbol === moduleSymbol) {
return links.type = anyType;
}
@@ -30737,7 +30928,7 @@ var ts;
declaration.kind === 184 /* PropertyAccessExpression */ && declaration.parent.kind === 199 /* BinaryExpression */) {
type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol);
}
- else if (ts.isJSDocPropertyTag(declaration)
+ else if (ts.isJSDocPropertyLikeTag(declaration)
|| ts.isPropertyAccessExpression(declaration)
|| ts.isIdentifier(declaration)
|| (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
@@ -31014,7 +31205,9 @@ var ts;
case 191 /* FunctionExpression */:
case 192 /* ArrowFunction */:
case 236 /* TypeAliasDeclaration */:
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
case 176 /* MappedType */:
case 170 /* ConditionalType */:
var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
@@ -31024,7 +31217,7 @@ var ts;
else if (node.kind === 170 /* ConditionalType */) {
return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
}
- var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray);
+ var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
var thisType = includeThisTypes &&
(node.kind === 234 /* ClassDeclaration */ || node.kind === 204 /* ClassExpression */ || node.kind === 235 /* InterfaceDeclaration */) &&
getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
@@ -31043,13 +31236,12 @@ var ts;
var result;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var node = _a[_i];
- if (node.kind === 235 /* InterfaceDeclaration */ || node.kind === 234 /* ClassDeclaration */ ||
- node.kind === 204 /* ClassExpression */ || node.kind === 236 /* TypeAliasDeclaration */ || node.kind === 294 /* JSDocTypedefTag */) {
+ if (node.kind === 235 /* InterfaceDeclaration */ ||
+ node.kind === 234 /* ClassDeclaration */ ||
+ node.kind === 204 /* ClassExpression */ ||
+ ts.isTypeAlias(node)) {
var declaration = node;
- var typeParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- if (typeParameters) {
- result = appendTypeParameters(result, typeParameters);
- }
+ result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
}
}
return result;
@@ -31326,9 +31518,9 @@ var ts;
return unknownType;
}
var declaration = ts.find(symbol.declarations, function (d) {
- return d.kind === 294 /* JSDocTypedefTag */ || d.kind === 236 /* TypeAliasDeclaration */;
+ return ts.isJSDocTypeAlias(d) || d.kind === 236 /* TypeAliasDeclaration */;
});
- var typeNode = declaration.kind === 294 /* JSDocTypedefTag */ ? declaration.typeExpression : declaration.type;
+ var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
// If typeNode is missing, we will error in checkJSDocTypedefTag.
var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType;
if (popTypeResolution()) {
@@ -31533,7 +31725,7 @@ var ts;
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
return (node.kind === 154 /* Constructor */ || (returnType && isThislessType(returnType))) &&
node.parameters.every(isThislessVariableLikeDeclaration) &&
- (!typeParameters || typeParameters.every(isThislessTypeParameter));
+ typeParameters.every(isThislessTypeParameter);
}
/**
* Returns true if the class or interface member given by the symbol is free of "this" references. The
@@ -31714,9 +31906,9 @@ var ts;
// If we have an existing early-bound member, combine its declarations so that we can
// report an error at each declaration.
var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
- var name_3 = ts.declarationNameToString(decl.name);
- ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_3); });
- error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_3);
+ var name_2 = ts.declarationNameToString(decl.name);
+ ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_declaration_0, name_2); });
+ error(decl.name || decl, ts.Diagnostics.Duplicate_declaration_0, name_2);
lateSymbol = createSymbol(0 /* None */, memberName, 1024 /* Late */);
}
lateSymbol.nameType = type;
@@ -32783,9 +32975,10 @@ var ts;
// type checking functions).
function getTypeParametersFromDeclaration(declaration) {
var result;
- ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) {
+ for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
+ var node = _a[_i];
result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
- });
+ }
return result;
}
function symbolsToArray(symbols) {
@@ -32815,7 +33008,7 @@ var ts;
return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
}
function isOptionalParameter(node) {
- if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) {
+ if (ts.hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) {
return true;
}
if (node.initializer) {
@@ -32832,6 +33025,13 @@ var ts;
}
return false;
}
+ function isOptionalJSDocParameterTag(node) {
+ if (!ts.isJSDocParameterTag(node)) {
+ return false;
+ }
+ var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
+ return isBracketed || !!typeExpression && typeExpression.type.kind === 282 /* JSDocOptionalType */;
+ }
function createTypePredicateFromTypePredicateNode(node) {
var parameterName = node.parameterName;
var type = getTypeFromTypeNode(node.type);
@@ -32920,6 +33120,7 @@ var ts;
for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
var param = declaration.parameters[i];
var paramSymbol = param.symbol;
+ var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
// Include parameter symbol instead of property symbol in the signature
if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) {
var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67216319 /* Value */, undefined, undefined, /*isUse*/ false);
@@ -32932,12 +33133,13 @@ var ts;
else {
parameters.push(paramSymbol);
}
- if (param.type && param.type.kind === 177 /* LiteralType */) {
+ if (type && type.kind === 177 /* LiteralType */) {
hasLiteralTypes = true;
}
// Record a new minimum argument count if this is not an optional parameter
- var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken ||
- iife && parameters.length > iife.arguments.length && !param.type ||
+ var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) ||
+ param.initializer || param.questionToken || param.dotDotDotToken ||
+ iife && parameters.length > iife.arguments.length && !type ||
isUntypedSignatureInJSFile ||
isJSDocOptionalParameter(param);
if (!isOptionalParameter_1) {
@@ -32971,7 +33173,7 @@ var ts;
* 2. It has at least one parameter, and the last parameter has a matching `@param` with a type that starts with `...`
*/
function maybeAddJsSyntheticRestParameter(declaration, parameters) {
- if (!containsArgumentsReference(declaration)) {
+ if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
return false;
}
var lastParam = ts.lastOrUndefined(declaration.parameters);
@@ -33364,7 +33566,7 @@ var ts;
var isJs = ts.isInJavaScriptFile(node);
var isJsImplicitAny = !noImplicitAny && isJs;
if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
- var missingAugmentsTag = isJs && node.parent.kind !== 288 /* JSDocAugmentsTag */;
+ var missingAugmentsTag = isJs && node.parent.kind !== 289 /* JSDocAugmentsTag */;
var diag = minTypeArgumentCount === typeParameters.length
? missingAugmentsTag
? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag
@@ -33515,7 +33717,7 @@ var ts;
}
function getConstrainedTypeVariable(typeVariable, node) {
var constraints;
- while (node && !ts.isStatement(node)) {
+ while (node && !ts.isStatement(node) && node.kind !== 285 /* JSDocComment */) {
var parent = node.parent;
if (parent.kind === 170 /* ConditionalType */ && node === parent.trueType) {
var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType);
@@ -33965,7 +34167,7 @@ var ts;
includes & 4096 /* Undefined */ ? includes & 16777216 /* NonWideningType */ ? undefinedType : undefinedWideningType :
neverType;
}
- return getUnionTypeFromSortedList(typeSet, aliasSymbol, aliasTypeArguments);
+ return getUnionTypeFromSortedList(typeSet, includes & 8374815 /* NotUnit */ ? 0 : 268435456 /* UnionOfUnitTypes */, aliasSymbol, aliasTypeArguments);
}
function getUnionTypePredicate(signatures) {
var first;
@@ -34002,7 +34204,7 @@ var ts;
: !ts.isIdentifierTypePredicate(b);
}
// This function assumes the constituent type list is sorted and deduplicated.
- function getUnionTypeFromSortedList(types, aliasSymbol, aliasTypeArguments) {
+ function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) {
if (types.length === 0) {
return neverType;
}
@@ -34013,7 +34215,7 @@ var ts;
var type = unionTypes.get(id);
if (!type) {
var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 12288 /* Nullable */);
- type = createType(131072 /* Union */ | propagatedFlags);
+ type = createType(131072 /* Union */ | propagatedFlags | unionOfUnitTypes);
unionTypes.set(id, type);
type.types = types;
/*
@@ -34030,7 +34232,8 @@ var ts;
function getTypeFromUnionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -34079,6 +34282,31 @@ var ts;
}
}
}
+ // When intersecting unions of unit types we can simply intersect based on type identity.
+ // Here we remove all unions of unit types from the given list and replace them with a
+ // a single union containing an intersection of the unit types.
+ function intersectUnionsOfUnitTypes(types) {
+ var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456 /* UnionOfUnitTypes */) !== 0; });
+ var unionType = types[unionIndex];
+ var intersection = unionType.types;
+ var i = types.length - 1;
+ var _loop_5 = function () {
+ var t = types[i];
+ if (t.flags & 268435456 /* UnionOfUnitTypes */) {
+ intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); });
+ ts.orderedRemoveItemAt(types, i);
+ }
+ i--;
+ };
+ while (i > unionIndex) {
+ _loop_5();
+ }
+ if (intersection === unionType.types) {
+ return false;
+ }
+ types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456 /* UnionOfUnitTypes */);
+ return true;
+ }
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
@@ -34113,6 +34341,12 @@ var ts;
return typeSet[0];
}
if (includes & 131072 /* Union */) {
+ if (includes & 268435456 /* UnionOfUnitTypes */ && intersectUnionsOfUnitTypes(typeSet)) {
+ // When the intersection creates a reduced set (which might mean that *all* union types have
+ // disappeared), we restart the operation to get a new set of combined flags. Once we have
+ // reduced we'll never reduce again, so this occurs at most once.
+ return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
+ }
// We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
// the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072 /* Union */) !== 0; });
@@ -34134,7 +34368,8 @@ var ts;
function getTypeFromIntersectionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node));
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
@@ -34425,7 +34660,7 @@ var ts;
var type = createObjectType(32 /* Mapped */, node.symbol);
type.declaration = node;
type.aliasSymbol = getAliasSymbolForTypeNode(node);
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
links.resolvedType = type;
// Eagerly resolve the constraint type which forces an error if the constraint type circularly
// references itself through one or more type aliases.
@@ -34526,7 +34761,8 @@ var ts;
var links = getNodeLinks(node);
if (!links.resolvedType) {
var checkType = getTypeFromTypeNode(node.checkType);
- var aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ var aliasSymbol = getAliasSymbolForTypeNode(node);
+ var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
var allOuterTypeParameters = getOuterTypeParameters(node, /*includeThisTypes*/ true);
var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isPossiblyReferencedInConditionalType(tp, node); });
var root = {
@@ -34539,7 +34775,7 @@ var ts;
inferTypeParameters: getInferTypeParameters(node),
outerTypeParameters: outerTypeParameters,
instantiations: undefined,
- aliasSymbol: getAliasSymbolForTypeNode(node),
+ aliasSymbol: aliasSymbol,
aliasTypeArguments: aliasTypeArguments
};
links.resolvedType = getConditionalType(root, /*mapper*/ undefined);
@@ -34638,7 +34874,7 @@ var ts;
else {
var type = createObjectType(16 /* Anonymous */, node.symbol);
type.aliasSymbol = aliasSymbol;
- type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
+ type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
type = createArrayType(type);
}
@@ -34648,10 +34884,9 @@ var ts;
return links.resolvedType;
}
function getAliasSymbolForTypeNode(node) {
- return (node.parent.kind === 236 /* TypeAliasDeclaration */ || node.parent.kind === 294 /* JSDocTypedefTag */) ? getSymbolOfNode(node.parent) : undefined;
+ return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined;
}
- function getAliasTypeArgumentsForTypeNode(node) {
- var symbol = getAliasSymbolForTypeNode(node);
+ function getTypeArgumentsForAliasSymbol(symbol) {
return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
}
/**
@@ -34887,6 +35122,7 @@ var ts;
case 165 /* TypeLiteral */:
case 286 /* JSDocTypeLiteral */:
case 283 /* JSDocFunctionType */:
+ case 287 /* JSDocSignature */:
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
case 174 /* TypeOperator */:
return getTypeFromTypeOperatorNode(node);
@@ -35076,6 +35312,15 @@ var ts;
// aren't the right hand side of a generic type alias declaration we optimize by reducing the
// set of type parameters to those that are possibly referenced in the literal.
var declaration_1 = symbol.declarations[0];
+ if (ts.isInJavaScriptFile(declaration_1)) {
+ var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag);
+ if (paramTag) {
+ var paramSymbol = ts.getParameterSymbolFromJSDoc(paramTag);
+ if (paramSymbol) {
+ declaration_1 = paramSymbol.valueDeclaration;
+ }
+ }
+ }
var outerTypeParameters = getOuterTypeParameters(declaration_1, /*includeThisTypes*/ true);
if (isJavaScriptConstructor(declaration_1)) {
var templateTagParameters = getTypeParametersFromDeclaration(declaration_1);
@@ -35117,8 +35362,8 @@ var ts;
// between the node and the type parameter declaration, if the node contains actual references to the
// type parameter, or if the node contains type queries, we consider the type parameter possibly referenced.
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
- var container_2 = tp.symbol.declarations[0].parent;
- if (ts.findAncestor(node, function (n) { return n.kind === 212 /* Block */ ? "quit" : n === container_2; })) {
+ var container_3 = tp.symbol.declarations[0].parent;
+ if (ts.findAncestor(node, function (n) { return n.kind === 212 /* Block */ ? "quit" : n === container_3; })) {
return ts.forEachChild(node, containsReference);
}
}
@@ -35968,7 +36213,7 @@ var ts;
// check excess properties against discriminant type only, not the entire union
return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors);
}
- var _loop_5 = function (prop) {
+ var _loop_6 = function (prop) {
if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
if (reportErrors) {
// We know *exactly* where things went wrong when comparing the types.
@@ -36005,7 +36250,7 @@ var ts;
};
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
var prop = _a[_i];
- var state_3 = _loop_5(prop);
+ var state_3 = _loop_6(prop);
if (typeof state_3 === "object")
return state_3.value;
}
@@ -38558,7 +38803,7 @@ var ts;
if (type.flags & 131072 /* Union */) {
var types = type.types;
var filtered = ts.filter(types, f);
- return filtered === types ? type : getUnionTypeFromSortedList(filtered);
+ return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456 /* UnionOfUnitTypes */);
}
return f(type) ? type : neverType;
}
@@ -40514,10 +40759,11 @@ var ts;
links.resolvedSignatures = ts.createMap();
}
var cacheKey = "" + getTypeId(valueType);
- if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) !== resolvingSignaturesArray) {
- signatures = links.resolvedSignatures.get(cacheKey);
+ var cachedResolved = links.resolvedSignatures.get(cacheKey);
+ if (cachedResolved && cachedResolved !== resolvingSignaturesArray) {
+ signatures = cachedResolved;
}
- else if (!links.resolvedSignatures.get(cacheKey)) {
+ else if (!cachedResolved) {
links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray);
links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures));
}
@@ -41739,7 +41985,7 @@ var ts;
// Assignability failure - check each prop individually, and if that fails, fall back on the bad error span
if (ts.length(openingLikeElement.attributes.properties)) {
var reportedError = false;
- var _loop_6 = function (prop) {
+ var _loop_7 = function (prop) {
if (ts.isJsxSpreadAttribute(prop))
return "continue";
var name = ts.idText(prop.name);
@@ -41753,7 +41999,7 @@ var ts;
};
for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) {
var prop = _c[_b];
- _loop_6(prop);
+ _loop_7(prop);
}
if (reportedError) {
return;
@@ -43780,8 +44026,8 @@ var ts;
if (allowSyntheticDefaultImports && type && type !== unknownType) {
var synthType = type;
if (!synthType.syntheticType) {
- var file_3 = ts.find(originalSymbol.declarations, ts.isSourceFile);
- var hasSyntheticDefault = canHaveSyntheticDefault(file_3, originalSymbol, /*dontResolveAlias*/ false);
+ var file_4 = ts.find(originalSymbol.declarations, ts.isSourceFile);
+ var hasSyntheticDefault = canHaveSyntheticDefault(file_4, originalSymbol, /*dontResolveAlias*/ false);
if (hasSyntheticDefault) {
var memberTable = ts.createSymbolTable();
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
@@ -46298,8 +46544,9 @@ var ts;
switch (d.kind) {
case 235 /* InterfaceDeclaration */:
case 236 /* TypeAliasDeclaration */:
- // A jsdoc typedef is, by definition, a type alias
- case 294 /* JSDocTypedefTag */:
+ // A jsdoc typedef and callback are, by definition, type aliases
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
return 2 /* ExportType */;
case 238 /* ModuleDeclaration */:
return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */
@@ -46768,7 +47015,7 @@ var ts;
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
}
}
- function checkJSDocTypedefTag(node) {
+ function checkJSDocTypeAliasTag(node) {
if (!node.typeExpression) {
// If the node had `@property` tags, `typeExpression` would have been set to the first property tag.
error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
@@ -47002,7 +47249,7 @@ var ts;
// Only report errors on the last declaration for the type parameter container;
// this ensures that all uses have been accounted for.
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (!(node.flags & 4194304 /* Ambient */) && typeParameters && ts.last(getSymbolOfNode(node).declarations) === node) {
+ if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) {
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
var typeParameter = typeParameters_2[_i];
if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) {
@@ -48270,7 +48517,7 @@ var ts;
var declaration = declarations_6[_i];
// If this declaration has too few or too many type parameters, we report an error
var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
- var numTypeParameters = ts.length(sourceParameters);
+ var numTypeParameters = sourceParameters.length;
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
return false;
}
@@ -48418,7 +48665,7 @@ var ts;
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
var issuedMemberError = false;
- var _loop_7 = function (member) {
+ var _loop_8 = function (member) {
if (ts.hasStaticModifier(member)) {
return "continue";
}
@@ -48437,7 +48684,7 @@ var ts;
};
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- _loop_7(member);
+ _loop_8(member);
}
if (!issuedMemberError) {
// check again with diagnostics to generate a less-specific error
@@ -49394,11 +49641,12 @@ var ts;
return checkInferType(node);
case 178 /* ImportType */:
return checkImportType(node);
- case 288 /* JSDocAugmentsTag */:
+ case 289 /* JSDocAugmentsTag */:
return checkJSDocAugmentsTag(node);
- case 294 /* JSDocTypedefTag */:
- return checkJSDocTypedefTag(node);
- case 290 /* JSDocParameterTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ return checkJSDocTypeAliasTag(node);
+ case 292 /* JSDocParameterTag */:
return checkJSDocParameterTag(node);
case 283 /* JSDocFunctionType */:
checkSignatureDeclaration(node);
@@ -49526,8 +49774,8 @@ var ts;
var paramTag = parent.parent;
if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) {
// Else we will add a diagnostic, see `checkJSDocVariadicType`.
- var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
- if (host_2) {
+ var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
+ if (host_1) {
/*
Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters.
So in the following situation we will not create an array type:
@@ -49535,7 +49783,7 @@ var ts;
function f(a) {}
Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type.
*/
- var lastParamDeclaration = ts.lastOrUndefined(host_2.parameters);
+ var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
if (!lastParamDeclaration ||
symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
@@ -49927,10 +50175,10 @@ var ts;
return entityNameSymbol;
}
}
- if (entityName.parent.kind === 290 /* JSDocParameterTag */) {
+ if (entityName.parent.kind === 292 /* JSDocParameterTag */) {
return ts.getParameterSymbolFromJSDoc(entityName.parent);
}
- if (entityName.parent.kind === 147 /* TypeParameter */ && entityName.parent.parent.kind === 293 /* JSDocTemplateTag */) {
+ if (entityName.parent.kind === 147 /* TypeParameter */ && entityName.parent.parent.kind === 295 /* JSDocTemplateTag */) {
ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true.
var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent);
return typeParameter && typeParameter.symbol;
@@ -50470,6 +50718,7 @@ var ts;
function isRequiredInitializedParameter(parameter) {
return strictNullChecks &&
!isOptionalParameter(parameter) &&
+ !ts.isJSDocParameterTag(parameter) &&
parameter.initializer &&
!ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */);
}
@@ -50771,8 +51020,8 @@ var ts;
var decl = _a[_i];
// check meaning of the local symbol to see if declaration needs to be analyzed further
if (decl.symbol && decl.symbol.flags & meaning) {
- var file_4 = ts.getSourceFileOfNode(decl);
- var typeReferenceDirective = fileToDirective.get(file_4.path);
+ var file_5 = ts.getSourceFileOfNode(decl);
+ var typeReferenceDirective = fileToDirective.get(file_5.path);
if (typeReferenceDirective) {
(typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
}
@@ -50807,8 +51056,8 @@ var ts;
// check that at least one declaration of top level symbol originates from type declaration file
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var file_5 = ts.getSourceFileOfNode(decl);
- if (fileToDirective.has(file_5.path)) {
+ var file_6 = ts.getSourceFileOfNode(decl);
+ if (fileToDirective.has(file_6.path)) {
return true;
}
}
@@ -50826,25 +51075,25 @@ var ts;
function initializeTypeChecker() {
// Bind all source files and propagate errors
for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
- var file_6 = _a[_i];
- ts.bindSourceFile(file_6, compilerOptions);
+ var file_7 = _a[_i];
+ ts.bindSourceFile(file_7, compilerOptions);
}
// Initialize global symbol table
var augmentations;
for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
- var file_7 = _c[_b];
- if (!ts.isExternalOrCommonJsModule(file_7)) {
- mergeSymbolTable(globals, file_7.locals);
+ var file_8 = _c[_b];
+ if (!ts.isExternalOrCommonJsModule(file_8)) {
+ mergeSymbolTable(globals, file_8.locals);
}
- if (file_7.patternAmbientModules && file_7.patternAmbientModules.length) {
- patternAmbientModules = ts.concatenate(patternAmbientModules, file_7.patternAmbientModules);
+ if (file_8.patternAmbientModules && file_8.patternAmbientModules.length) {
+ patternAmbientModules = ts.concatenate(patternAmbientModules, file_8.patternAmbientModules);
}
- if (file_7.moduleAugmentations.length) {
- (augmentations || (augmentations = [])).push(file_7.moduleAugmentations);
+ if (file_8.moduleAugmentations.length) {
+ (augmentations || (augmentations = [])).push(file_8.moduleAugmentations);
}
- if (file_7.symbol && file_7.symbol.globalExports) {
+ if (file_8.symbol && file_8.symbol.globalExports) {
// Merge in UMD exports with first-in-wins semantics (see #9771)
- var source = file_7.symbol.globalExports;
+ var source = file_8.symbol.globalExports;
source.forEach(function (sourceSymbol, id) {
if (!globals.has(id)) {
globals.set(id, sourceSymbol);
@@ -51296,7 +51545,7 @@ var ts;
}
function checkGrammarClassLikeDeclaration(node) {
var file = ts.getSourceFileOfNode(node);
- return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(ts.getEffectiveTypeParameterDeclarations(node), file);
+ return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
}
function checkGrammarArrowFunction(node, file) {
if (!ts.isArrowFunction(node)) {
@@ -51981,8 +52230,8 @@ var ts;
}
function checkGrammarConstructorTypeParameters(node) {
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- if (typeParameters) {
- var _a = ts.isNodeArray(typeParameters) ? typeParameters : ts.first(typeParameters), pos = _a.pos, end = _a.end;
+ if (ts.isNodeArray(typeParameters)) {
+ var pos = typeParameters.pos, end = typeParameters.end;
return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
}
}
@@ -52446,7 +52695,7 @@ var ts;
ts.updateQualifiedName = updateQualifiedName;
function parenthesizeForComputedName(expression) {
return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) ||
- expression.kind === 299 /* CommaListExpression */ ?
+ expression.kind === 301 /* CommaListExpression */ ?
createParen(expression) :
expression;
}
@@ -54425,7 +54674,7 @@ var ts;
* @param original The original statement.
*/
function createNotEmittedStatement(original) {
- var node = createSynthesizedNode(297 /* NotEmittedStatement */);
+ var node = createSynthesizedNode(299 /* NotEmittedStatement */);
node.original = original;
setTextRange(node, original);
return node;
@@ -54437,7 +54686,7 @@ var ts;
*/
/* @internal */
function createEndOfDeclarationMarker(original) {
- var node = createSynthesizedNode(301 /* EndOfDeclarationMarker */);
+ var node = createSynthesizedNode(303 /* EndOfDeclarationMarker */);
node.emitNode = {};
node.original = original;
return node;
@@ -54449,7 +54698,7 @@ var ts;
*/
/* @internal */
function createMergeDeclarationMarker(original) {
- var node = createSynthesizedNode(300 /* MergeDeclarationMarker */);
+ var node = createSynthesizedNode(302 /* MergeDeclarationMarker */);
node.emitNode = {};
node.original = original;
return node;
@@ -54464,7 +54713,7 @@ var ts;
* @param location The location for the expression. Defaults to the positions from "original" if provided.
*/
function createPartiallyEmittedExpression(expression, original) {
- var node = createSynthesizedNode(298 /* PartiallyEmittedExpression */);
+ var node = createSynthesizedNode(300 /* PartiallyEmittedExpression */);
node.expression = expression;
node.original = original;
setTextRange(node, original);
@@ -54480,7 +54729,7 @@ var ts;
ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression;
function flattenCommaElements(node) {
if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
- if (node.kind === 299 /* CommaListExpression */) {
+ if (node.kind === 301 /* CommaListExpression */) {
return node.elements;
}
if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) {
@@ -54490,7 +54739,7 @@ var ts;
return node;
}
function createCommaList(elements) {
- var node = createSynthesizedNode(299 /* CommaListExpression */);
+ var node = createSynthesizedNode(301 /* CommaListExpression */);
node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
return node;
}
@@ -55778,7 +56027,7 @@ var ts;
// if should be wrapped in parens since comma operator has the lowest precedence
var emittedExpression = ts.skipPartiallyEmittedExpressions(e);
return emittedExpression.kind === 199 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ ||
- emittedExpression.kind === 299 /* CommaListExpression */
+ emittedExpression.kind === 301 /* CommaListExpression */
? ts.createParen(e)
: e;
}
@@ -55798,7 +56047,7 @@ var ts;
var check = ts.skipPartiallyEmittedExpressions(e);
return (check.kind === 204 /* ClassExpression */ ||
check.kind === 191 /* FunctionExpression */ ||
- check.kind === 299 /* CommaListExpression */ ||
+ check.kind === 301 /* CommaListExpression */ ||
ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */)
? ts.createParen(e)
: e;
@@ -55963,7 +56212,7 @@ var ts;
case 184 /* PropertyAccessExpression */:
node = node.expression;
continue;
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
node = node.expression;
continue;
}
@@ -55993,7 +56242,7 @@ var ts;
case 207 /* AsExpression */:
case 208 /* NonNullExpression */:
return (kinds & 2 /* Assertions */) !== 0;
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0;
}
return false;
@@ -56030,7 +56279,7 @@ var ts;
case 189 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression);
case 207 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type);
case 208 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression);
- case 298 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
+ case 300 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
}
}
/**
@@ -56815,9 +57064,9 @@ var ts;
case 273 /* SourceFile */:
return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context));
// Transformation nodes
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression));
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression));
default:
// No need to visit nodes with no children.
@@ -56873,7 +57122,7 @@ var ts;
case 214 /* EmptyStatement */:
case 205 /* OmittedExpression */:
case 230 /* DebuggerStatement */:
- case 297 /* NotEmittedStatement */:
+ case 299 /* NotEmittedStatement */:
// No need to visit nodes with no children.
break;
// Names
@@ -57252,10 +57501,10 @@ var ts;
result = reduceNodes(node.statements, cbNodes, result);
break;
// Transformation nodes
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
result = reduceNode(node.expression, cbNode, result);
break;
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
result = reduceNodes(node.elements, cbNodes, result);
break;
default:
@@ -68885,9 +69134,9 @@ var ts;
return visitFunctionDeclaration(node);
case 234 /* ClassDeclaration */:
return visitClassDeclaration(node);
- case 300 /* MergeDeclarationMarker */:
+ case 302 /* MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 301 /* EndOfDeclarationMarker */:
+ case 303 /* EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
@@ -70819,9 +71068,9 @@ var ts;
return visitCatchClause(node);
case 212 /* Block */:
return visitBlock(node);
- case 300 /* MergeDeclarationMarker */:
+ case 302 /* MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 301 /* EndOfDeclarationMarker */:
+ case 303 /* EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return destructuringAndImportCallVisitor(node);
@@ -71888,19 +72137,22 @@ var ts;
var lateMarkedStatements;
var lateStatementReplacementMap;
var suppressNewDiagnosticContexts;
+ var host = context.getEmitHost();
var symbolTracker = {
trackSymbol: trackSymbol,
reportInaccessibleThisError: reportInaccessibleThisError,
reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
- reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression
+ reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
+ moduleResolverHost: host,
+ trackReferencedAmbientModule: trackReferencedAmbientModule,
};
var errorNameNode;
var currentSourceFile;
+ var refs;
var resolver = context.getEmitResolver();
var options = context.getCompilerOptions();
var newLine = ts.getNewLineCharacter(options);
var noResolve = options.noResolve, stripInternal = options.stripInternal;
- var host = context.getEmitHost();
return transformRoot;
function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
if (!typeReferenceDirectives) {
@@ -71912,6 +72164,10 @@ var ts;
necessaryTypeRefernces.set(ref, true);
}
}
+ function trackReferencedAmbientModule(node) {
+ var container = ts.getSourceFileOfNode(node);
+ refs.set("" + ts.getOriginalNodeId(container), container);
+ }
function handleSymbolAccessibilityError(symbolAccessibilityResult) {
if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
// Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info
@@ -72019,13 +72275,13 @@ var ts;
lateMarkedStatements = undefined;
lateStatementReplacementMap = ts.createMap();
necessaryTypeRefernces = undefined;
- var refs = collectReferences(currentSourceFile, ts.createMap());
+ refs = collectReferences(currentSourceFile, ts.createMap());
var references = [];
var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath));
var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
- refs.forEach(referenceVisitor);
var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
+ refs.forEach(referenceVisitor);
var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined)])), combinedStatements);
@@ -72037,17 +72293,19 @@ var ts;
}
function getFileReferenceForTypeName(typeName) {
// Elide type references for which we have imports
- for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
- var importStatement = emittedImports_1[_i];
- if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
- var expr = importStatement.moduleReference.expression;
- if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ if (emittedImports) {
+ for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
+ var importStatement = emittedImports_1[_i];
+ if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
+ var expr = importStatement.moduleReference.expression;
+ if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
+ return undefined;
+ }
+ }
+ else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
return undefined;
}
}
- else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
- return undefined;
- }
}
return { fileName: typeName, pos: -1, end: -1 };
}
@@ -72808,7 +73066,7 @@ var ts;
var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined);
var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile);
if (leadingsSyntheticCommentRanges) {
- var _loop_8 = function (range) {
+ var _loop_9 = function (range) {
if (range.kind === 3 /* MultiLineCommentTrivia */) {
var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2);
var lines = text.split(/\r\n?|\n/g);
@@ -72822,7 +73080,7 @@ var ts;
};
for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) {
var range = leadingsSyntheticCommentRanges_1[_i];
- _loop_8(range);
+ _loop_9(range);
}
}
return prop;
@@ -72984,7 +73242,7 @@ 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(302 /* Count */);
+ var enabledSyntaxKindFeatures = new Array(304 /* Count */);
var lexicalEnvironmentVariableDeclarations;
var lexicalEnvironmentFunctionDeclarations;
var lexicalEnvironmentVariableDeclarationsStack = [];
@@ -73479,7 +73737,7 @@ var ts;
source = undefined;
if (source)
setSourceFile(source);
- if (node.kind !== 297 /* NotEmittedStatement */
+ if (node.kind !== 299 /* NotEmittedStatement */
&& (emitFlags & 16 /* NoLeadingSourceMap */) === 0
&& pos >= 0) {
emitPos(skipSourceTrivia(pos));
@@ -73496,7 +73754,7 @@ var ts;
}
if (source)
setSourceFile(source);
- if (node.kind !== 297 /* NotEmittedStatement */
+ if (node.kind !== 299 /* NotEmittedStatement */
&& (emitFlags & 32 /* NoTrailingSourceMap */) === 0
&& end >= 0) {
emitPos(end);
@@ -73672,7 +73930,7 @@ var ts;
if (extendedDiagnostics) {
ts.performance.mark("preEmitNodeWithComment");
}
- var isEmittedNode = node.kind !== 297 /* NotEmittedStatement */;
+ var isEmittedNode = node.kind !== 299 /* 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 === 10 /* JsxText */;
@@ -74817,9 +75075,9 @@ var ts;
case 258 /* JsxFragment */:
return emitJsxFragment(node);
// Transformation nodes
- case 298 /* PartiallyEmittedExpression */:
+ case 300 /* PartiallyEmittedExpression */:
return emitPartiallyEmittedExpression(node);
- case 299 /* CommaListExpression */:
+ case 301 /* CommaListExpression */:
return emitCommaList(node);
}
}
@@ -77790,11 +78048,11 @@ var ts;
var diagnostic = diagnostics_2[_i];
var context_2 = "";
if (diagnostic.file) {
- var start = diagnostic.start, length_4 = diagnostic.length, file_8 = diagnostic.file;
- var _a = ts.getLineAndCharacterOfPosition(file_8, start), firstLine = _a.line, firstLineChar = _a.character;
- var _b = ts.getLineAndCharacterOfPosition(file_8, start + length_4), lastLine = _b.line, lastLineChar = _b.character;
- var lastLineInFile = ts.getLineAndCharacterOfPosition(file_8, file_8.text.length).line;
- var relativeFileName = host ? ts.convertToRelativePath(file_8.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_8.fileName;
+ var start = diagnostic.start, length_4 = diagnostic.length, file_9 = diagnostic.file;
+ var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character;
+ var _b = ts.getLineAndCharacterOfPosition(file_9, start + length_4), lastLine = _b.line, lastLineChar = _b.character;
+ var lastLineInFile = ts.getLineAndCharacterOfPosition(file_9, file_9.text.length).line;
+ var relativeFileName = host ? ts.convertToRelativePath(file_9.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_9.fileName;
var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
var gutterWidth = (lastLine + 1 + "").length;
if (hasMoreThanFiveLines) {
@@ -77808,9 +78066,9 @@ var ts;
context_2 += formatColorAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
i = lastLine - 1;
}
- var lineStart = ts.getPositionOfLineAndCharacter(file_8, i, 0);
- var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file_8, i + 1, 0) : file_8.text.length;
- var lineContent = file_8.text.slice(lineStart, lineEnd);
+ var lineStart = ts.getPositionOfLineAndCharacter(file_9, i, 0);
+ var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file_9, i + 1, 0) : file_9.text.length;
+ var lineContent = file_9.text.slice(lineStart, lineEnd);
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.
@@ -79180,31 +79438,31 @@ var ts;
// Get source file from normalized fileName
function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd, packageId) {
if (filesByName.has(path)) {
- var file_9 = filesByName.get(path);
+ var file_10 = filesByName.get(path);
// try to check if we've already seen this file but with a different casing in path
// NOTE: this only makes sense for case-insensitive file systems
- if (file_9 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_9.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
- reportFileNamesDifferOnlyInCasingError(fileName, file_9.fileName, refFile, refPos, refEnd);
+ if (file_10 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_10.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
+ reportFileNamesDifferOnlyInCasingError(fileName, file_10.fileName, refFile, refPos, refEnd);
}
// If the file was previously found via a node_modules search, but is now being processed as a root file,
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
- if (file_9 && sourceFilesFoundSearchingNodeModules.get(file_9.path) && currentNodeModulesDepth === 0) {
- sourceFilesFoundSearchingNodeModules.set(file_9.path, false);
+ if (file_10 && sourceFilesFoundSearchingNodeModules.get(file_10.path) && currentNodeModulesDepth === 0) {
+ sourceFilesFoundSearchingNodeModules.set(file_10.path, false);
if (!options.noResolve) {
- processReferencedFiles(file_9, isDefaultLib);
- processTypeReferenceDirectives(file_9);
+ processReferencedFiles(file_10, isDefaultLib);
+ processTypeReferenceDirectives(file_10);
}
- modulesWithElidedImports.set(file_9.path, false);
- processImportedModules(file_9);
+ modulesWithElidedImports.set(file_10.path, false);
+ processImportedModules(file_10);
}
// See if we need to reprocess the imports due to prior skipped imports
- else if (file_9 && modulesWithElidedImports.get(file_9.path)) {
+ else if (file_10 && modulesWithElidedImports.get(file_10.path)) {
if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
- modulesWithElidedImports.set(file_9.path, false);
- processImportedModules(file_9);
+ modulesWithElidedImports.set(file_10.path, false);
+ processImportedModules(file_10);
}
}
- return file_9;
+ return file_10;
}
var redirectedPath;
if (refFile) {
@@ -79431,9 +79689,9 @@ var ts;
function computeCommonSourceDirectory(sourceFiles) {
var fileNames = [];
for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
- var file_10 = sourceFiles_2[_i];
- if (!file_10.isDeclarationFile) {
- fileNames.push(file_10.fileName);
+ var file_11 = sourceFiles_2[_i];
+ if (!file_11.isDeclarationFile) {
+ fileNames.push(file_11.fileName);
}
}
return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
@@ -79537,14 +79795,14 @@ var ts;
if (options.composite && rootNames.length < files.length) {
var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); });
var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); });
- var _loop_9 = function (file_11) {
- if (normalizedRootNames.every(function (r) { return r !== file_11; })) {
- programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file_11));
+ var _loop_10 = function (file_12) {
+ if (normalizedRootNames.every(function (r) { return r !== file_12; })) {
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file_12));
}
};
for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
- var file_11 = sourceFiles_4[_i];
- _loop_9(file_11);
+ var file_12 = sourceFiles_4[_i];
+ _loop_10(file_12);
}
}
if (options.paths) {
@@ -83139,7 +83397,7 @@ var ts;
function serializeCompilerOptions(options) {
var result = ts.createMap();
var optionsNameMap = getOptionNameMap().optionNameMap;
- var _loop_10 = function (name) {
+ var _loop_11 = function (name) {
if (ts.hasProperty(options, name)) {
// tsconfig only options cannot be specified via command line,
// so we can assume that only types that can appear here string | number | boolean
@@ -83168,7 +83426,7 @@ var ts;
}
};
for (var name in options) {
- _loop_10(name);
+ _loop_11(name);
}
return result;
}
@@ -83814,30 +84072,30 @@ var ts;
if (filesSpecs) {
for (var _i = 0, filesSpecs_1 = filesSpecs; _i < filesSpecs_1.length; _i++) {
var fileName = filesSpecs_1[_i];
- var file_12 = ts.getNormalizedAbsolutePath(fileName, basePath);
- literalFileMap.set(keyMapper(file_12), file_12);
+ var file_13 = ts.getNormalizedAbsolutePath(fileName, basePath);
+ literalFileMap.set(keyMapper(file_13), file_13);
}
}
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
- var file_13 = _b[_a];
+ var file_14 = _b[_a];
// If we have already included a literal or wildcard path with a
// higher priority extension, we should skip this file.
//
// This handles cases where we may encounter both .ts and
// .d.ts (or .js if "allowJs" is enabled) in the same
// directory when they are compilation outputs.
- if (hasFileWithHigherPriorityExtension(file_13, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
+ if (hasFileWithHigherPriorityExtension(file_14, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
continue;
}
// We may have included a wildcard path with a lower priority
// extension due to the user-defined order of entries in the
// "include" array. If there is a lower priority extension in the
// same directory, we should remove it.
- removeWildcardFilesWithLowerPriorityExtension(file_13, wildcardFileMap, supportedExtensions, keyMapper);
- var key = keyMapper(file_13);
+ removeWildcardFilesWithLowerPriorityExtension(file_14, wildcardFileMap, supportedExtensions, keyMapper);
+ var key = keyMapper(file_14);
if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
- wildcardFileMap.set(key, file_13);
+ wildcardFileMap.set(key, file_14);
}
}
}
@@ -83899,8 +84157,8 @@ var ts;
if (include !== undefined) {
var recursiveKeys = [];
for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
- var file_14 = include_1[_i];
- var spec = ts.normalizePath(ts.combinePaths(path, file_14));
+ var file_15 = include_1[_i];
+ var spec = ts.normalizePath(ts.combinePaths(path, file_15));
if (excludeRegex && excludeRegex.test(spec)) {
continue;
}
@@ -84307,7 +84565,7 @@ var ts;
case 236 /* TypeAliasDeclaration */:
case 165 /* TypeLiteral */:
return 2 /* Type */;
- case 294 /* JSDocTypedefTag */:
+ case 296 /* 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 272 /* EnumMember */:
@@ -84516,7 +84774,7 @@ var ts;
}
ts.isExpressionOfExternalModuleImportEqualsDeclaration = isExpressionOfExternalModuleImportEqualsDeclaration;
function getContainerNode(node) {
- if (node.kind === 294 /* JSDocTypedefTag */) {
+ if (ts.isJSDocTypeAlias(node)) {
// This doesn't just apply to the node immediately under the comment, but to everything in its parent's scope.
// node.parent = the JSDoc comment, node.parent.parent = the node having the comment.
// Then we get parent again in the loop.
@@ -84554,7 +84812,10 @@ var ts;
case 204 /* ClassExpression */:
return "class" /* classElement */;
case 235 /* InterfaceDeclaration */: return "interface" /* interfaceElement */;
- case 236 /* TypeAliasDeclaration */: return "type" /* typeElement */;
+ case 236 /* TypeAliasDeclaration */:
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ return "type" /* typeElement */;
case 237 /* EnumDeclaration */: return "enum" /* enumElement */;
case 231 /* VariableDeclaration */:
return getKindOfVariableDeclaration(node);
@@ -84585,8 +84846,6 @@ var ts;
case 251 /* ExportSpecifier */:
case 245 /* NamespaceImport */:
return "alias" /* alias */;
- case 294 /* JSDocTypedefTag */:
- return "type" /* typeElement */;
case 199 /* BinaryExpression */:
var kind = ts.getSpecialPropertyAssignmentKind(node);
var right = node.right;
@@ -84648,6 +84907,10 @@ var ts;
return startEndContainsRange(r1.pos, r1.end, r2);
}
ts.rangeContainsRange = rangeContainsRange;
+ function rangeContainsPosition(r, pos) {
+ return r.pos <= pos && pos <= r.end;
+ }
+ ts.rangeContainsPosition = rangeContainsPosition;
function startEndContainsRange(start, end, range) {
return start <= range.pos && end >= range.end;
}
@@ -85429,6 +85692,25 @@ var ts;
return propSymbol;
}
ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement;
+ var NodeSet = /** @class */ (function () {
+ function NodeSet() {
+ this.map = ts.createMap();
+ }
+ NodeSet.prototype.add = function (node) {
+ this.map.set(String(ts.getNodeId(node)), node);
+ };
+ NodeSet.prototype.has = function (node) {
+ return this.map.has(String(ts.getNodeId(node)));
+ };
+ NodeSet.prototype.forEach = function (cb) {
+ this.map.forEach(cb);
+ };
+ NodeSet.prototype.some = function (pred) {
+ return ts.forEachEntry(this.map, pred) || false;
+ };
+ return NodeSet;
+ }());
+ ts.NodeSet = NodeSet;
})(ts || (ts = {}));
// Display-part writer helpers
/* @internal */
@@ -86430,20 +86712,22 @@ 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 290 /* JSDocParameterTag */:
+ case 292 /* JSDocParameterTag */:
processJSDocParameterTag(tag);
break;
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
processJSDocTemplateTag(tag);
+ pos = tag.end;
break;
- case 292 /* JSDocTypeTag */:
+ case 294 /* JSDocTypeTag */:
processElement(tag.typeExpression);
+ pos = tag.end;
break;
- case 291 /* JSDocReturnTag */:
+ case 293 /* JSDocReturnTag */:
processElement(tag.typeExpression);
+ pos = tag.end;
break;
}
- pos = tag.end;
}
}
if (pos !== docComment.end) {
@@ -86811,7 +87095,7 @@ var ts;
for (var path in paths) {
var patterns = paths[path];
if (paths.hasOwnProperty(path) && patterns) {
- var _loop_11 = function (name, kind) {
+ var _loop_12 = function (name, kind) {
// Path mappings may provide a duplicate way to get to something we've already added, so don't add again.
if (!result.some(function (entry) { return entry.name === name; })) {
result.push(nameAndKind(name, kind));
@@ -86819,7 +87103,7 @@ var ts;
};
for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host); _i < _a.length; _i++) {
var _b = _a[_i], name = _b.name, kind = _b.kind;
- _loop_11(name, kind);
+ _loop_12(name, kind);
}
}
}
@@ -86835,7 +87119,7 @@ var ts;
// (But do if we didn't find anything, e.g. 'package.json' missing.)
var foundGlobal = false;
if (fragmentDirectory === undefined) {
- var _loop_12 = function (moduleName) {
+ var _loop_13 = function (moduleName) {
if (!result.some(function (entry) { return entry.name === moduleName; })) {
foundGlobal = true;
result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */));
@@ -86843,7 +87127,7 @@ var ts;
};
for (var _e = 0, _f = enumerateNodeModulesVisibleToScript(host, scriptPath); _e < _f.length; _e++) {
var moduleName = _f[_e];
- _loop_12(moduleName);
+ _loop_13(moduleName);
}
}
if (!foundGlobal) {
@@ -87736,7 +88020,7 @@ var ts;
currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true);
if (!currentToken ||
(!ts.isDeclarationName(currentToken) &&
- (currentToken.parent.kind !== 295 /* JSDocPropertyTag */ ||
+ (currentToken.parent.kind !== 297 /* JSDocPropertyTag */ ||
currentToken.parent.name !== currentToken))) {
// Use as type location if inside tag's type expression
insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression);
@@ -87897,11 +88181,11 @@ var ts;
return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer };
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
- case 290 /* JSDocParameterTag */:
- case 295 /* JSDocPropertyTag */:
- case 291 /* JSDocReturnTag */:
- case 292 /* JSDocTypeTag */:
- case 294 /* JSDocTypedefTag */:
+ case 292 /* JSDocParameterTag */:
+ case 297 /* JSDocPropertyTag */:
+ case 293 /* JSDocReturnTag */:
+ case 294 /* JSDocTypeTag */:
+ case 296 /* JSDocTypedefTag */:
return true;
}
}
@@ -88939,7 +89223,7 @@ var ts;
function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) {
// class c { method() { } | method2() { } }
switch (location.kind) {
- case 296 /* SyntaxList */:
+ case 298 /* 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);
@@ -90189,8 +90473,8 @@ var ts;
case "symbol": {
var symbol = def.symbol;
var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind;
- var name_4 = displayParts_1.map(function (p) { return p.text; }).join("");
- return { node: symbol.declarations ? ts.getNameOfDeclaration(ts.first(symbol.declarations)) || ts.first(symbol.declarations) : originalNode, name: name_4, kind: kind_1, displayParts: displayParts_1 };
+ var name_3 = displayParts_1.map(function (p) { return p.text; }).join("");
+ return { node: symbol.declarations ? ts.getNameOfDeclaration(ts.first(symbol.declarations)) || ts.first(symbol.declarations) : originalNode, name: name_3, kind: kind_1, displayParts: displayParts_1 };
}
case "label": {
var node_3 = def.node;
@@ -90198,8 +90482,8 @@ var ts;
}
case "keyword": {
var node_4 = def.node;
- var name_5 = ts.tokenToString(node_4.kind);
- return { node: node_4, name: name_5, kind: "keyword" /* keyword */, displayParts: [{ text: name_5, kind: "keyword" /* keyword */ }] };
+ var name_4 = ts.tokenToString(node_4.kind);
+ return { node: node_4, name: name_4, kind: "keyword" /* keyword */, displayParts: [{ text: name_4, kind: "keyword" /* keyword */ }] };
}
case "this": {
var node_5 = def.node;
@@ -91568,14 +91852,14 @@ var ts;
function getReferenceAtPosition(sourceFile, position, program) {
var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position);
if (referencePath) {
- var file_15 = ts.tryResolveScriptReference(program, sourceFile, referencePath);
- return file_15 && { fileName: referencePath.fileName, file: file_15 };
+ var file_16 = ts.tryResolveScriptReference(program, sourceFile, referencePath);
+ return file_16 && { fileName: referencePath.fileName, file: file_16 };
}
var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
if (typeReferenceDirective) {
var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
- var file_16 = reference && program.getSourceFile(reference.resolvedFileName);
- return file_16 && { fileName: typeReferenceDirective.fileName, file: file_16 };
+ var file_17 = reference && program.getSourceFile(reference.resolvedFileName);
+ return file_17 && { fileName: typeReferenceDirective.fileName, file: file_17 };
}
return undefined;
}
@@ -91747,6 +92031,7 @@ var ts;
"author",
"argument",
"borrows",
+ "callback",
"class",
"constant",
"constructor",
@@ -91811,10 +92096,12 @@ var ts;
JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations;
function getCommentHavingNodes(declaration) {
switch (declaration.kind) {
- case 295 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */:
+ case 297 /* JSDocPropertyTag */:
return [declaration];
- case 294 /* JSDocTypedefTag */:
- return [declaration.parent];
+ case 291 /* JSDocCallbackTag */:
+ case 296 /* JSDocTypedefTag */:
+ return [declaration, declaration.parent];
default:
return ts.getJSDocCommentsAndTags(declaration);
}
@@ -91834,15 +92121,16 @@ var ts;
function getCommentText(tag) {
var comment = tag.comment;
switch (tag.kind) {
- case 288 /* JSDocAugmentsTag */:
+ case 289 /* JSDocAugmentsTag */:
return withNode(tag.class);
- case 293 /* JSDocTemplateTag */:
+ case 295 /* JSDocTemplateTag */:
return withList(tag.typeParameters);
- case 292 /* JSDocTypeTag */:
+ case 294 /* JSDocTypeTag */:
return withNode(tag.typeExpression);
- case 294 /* JSDocTypedefTag */:
- case 295 /* JSDocPropertyTag */:
- case 290 /* JSDocParameterTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
+ case 297 /* JSDocPropertyTag */:
+ case 292 /* JSDocParameterTag */:
var name = tag.name;
return name ? withNode(name) : comment;
default:
@@ -92460,7 +92748,7 @@ var ts;
if (!patternMatcher)
return ts.emptyArray;
var rawItems = [];
- var _loop_13 = function (sourceFile) {
+ var _loop_14 = function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) {
return "continue";
@@ -92472,7 +92760,7 @@ var ts;
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) {
var sourceFile = sourceFiles_7[_i];
- _loop_13(sourceFile);
+ _loop_14(sourceFile);
}
rawItems.sort(compareNavigateToItems);
if (maxResultCount !== undefined) {
@@ -92849,7 +93137,7 @@ var ts;
if (ts.hasJSDocNodes(node)) {
ts.forEach(node.jsDoc, function (jsDoc) {
ts.forEach(jsDoc.tags, function (tag) {
- if (tag.kind === 294 /* JSDocTypedefTag */) {
+ if (ts.isJSDocTypeAlias(tag)) {
addLeafNode(tag);
}
});
@@ -92962,8 +93250,6 @@ var ts;
case 192 /* ArrowFunction */:
case 204 /* ClassExpression */:
return getFunctionOrClassName(node);
- case 294 /* JSDocTypedefTag */:
- return getJSDocTypedefTagName(node);
default:
return undefined;
}
@@ -93005,29 +93291,10 @@ var ts;
return "()";
case 159 /* IndexSignature */:
return "[]";
- case 294 /* JSDocTypedefTag */:
- return getJSDocTypedefTagName(node);
default:
return "";
}
}
- function getJSDocTypedefTagName(node) {
- if (node.name) {
- return node.name.text;
- }
- else {
- var parentNode = node.parent && node.parent.parent;
- if (parentNode && parentNode.kind === 213 /* VariableStatement */) {
- if (parentNode.declarationList.declarations.length > 0) {
- var nameIdentifier = parentNode.declarationList.declarations[0].name;
- if (nameIdentifier.kind === 71 /* Identifier */) {
- return nameIdentifier.text;
- }
- }
- }
- return "";
- }
- }
/** Flattens the NavNode tree to a list, keeping only the top-level items. */
function topLevelItems(root) {
var topLevel = [];
@@ -93053,7 +93320,8 @@ var ts;
case 238 /* ModuleDeclaration */:
case 273 /* SourceFile */:
case 236 /* TypeAliasDeclaration */:
- case 294 /* JSDocTypedefTag */:
+ case 296 /* JSDocTypedefTag */:
+ case 291 /* JSDocCallbackTag */:
return true;
case 154 /* Constructor */:
case 153 /* MethodDeclaration */:
@@ -93979,13 +94247,13 @@ var ts;
// Assumes 'value' is already lowercase.
function indexOfIgnoringCase(str, value) {
var n = str.length - value.length;
- var _loop_14 = function (start) {
+ var _loop_15 = function (start) {
if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
return { value: start };
}
};
for (var start = 0; start <= n; start++) {
- var state_4 = _loop_14(start);
+ var state_4 = _loop_15(start);
if (typeof state_4 === "object")
return state_4.value;
}
@@ -94653,7 +94921,7 @@ var ts;
var nameToDeclarations = sourceFile.getNamedDeclarations();
var declarations = nameToDeclarations.get(name.text);
if (declarations) {
- var _loop_15 = function (declaration) {
+ var _loop_16 = function (declaration) {
var symbol = declaration.symbol;
if (symbol) {
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
@@ -94667,7 +94935,7 @@ var ts;
};
for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) {
var declaration = declarations_12[_b];
- var state_5 = _loop_15(declaration);
+ var state_5 = _loop_16(declaration);
if (typeof state_5 === "object")
return state_5.value;
}
@@ -95065,7 +95333,7 @@ var ts;
}
}
}
- return diags.concat(checker.getSuggestionDiagnostics(sourceFile));
+ return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort(function (d1, d2) { return d1.start - d2.start; });
}
ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics;
// convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
@@ -95821,7 +96089,7 @@ var ts;
return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; });
});
options = ts.cloneCompilerOptions(options);
- var _loop_16 = function (opt) {
+ var _loop_17 = function (opt) {
if (!ts.hasProperty(options, opt.name)) {
return "continue";
}
@@ -95840,7 +96108,7 @@ var ts;
};
for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
var opt = commandLineOptionsStringToEnum_1[_i];
- _loop_16(opt);
+ _loop_17(opt);
}
return options;
}
@@ -98584,7 +98852,7 @@ var ts;
this.formatContext = formatContext;
this.changes = [];
this.newFiles = [];
- this.deletedNodesInLists = []; // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
+ this.deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
this.classesWithNodesInsertedAtStart = ts.createMap(); // Set implemented as Map
}
ChangeTracker.fromContext = function (context) {
@@ -98628,35 +98896,14 @@ var ts;
this.deleteNode(sourceFile, node);
return this;
}
- var id = ts.getNodeId(node);
- ts.Debug.assert(!this.deletedNodesInLists[id], "Deleting a node twice");
- this.deletedNodesInLists[id] = true;
- if (index !== containingList.length - 1) {
- var nextToken = ts.getTokenAtPosition(sourceFile, node.end, /*includeJsDocComment*/ false);
- if (nextToken && isSeparator(node, nextToken)) {
- // find first non-whitespace position in the leading trivia of the node
- var startPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
- var nextElement = containingList[index + 1];
- /// find first non-whitespace position in the leading trivia of the next node
- var endPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
- // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node
- this.deleteRange(sourceFile, { pos: startPosition, end: endPosition });
- }
- }
- else {
- var prev = containingList[index - 1];
- if (this.deletedNodesInLists[ts.getNodeId(prev)]) {
- var pos = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
- var end = getAdjustedEndPosition(sourceFile, node, {});
- this.deleteRange(sourceFile, { pos: pos, end: end });
- }
- else {
- var previousToken = ts.getTokenAtPosition(sourceFile, containingList[index - 1].end, /*includeJsDocComment*/ false);
- if (previousToken && isSeparator(node, previousToken)) {
- this.deleteNodeRange(sourceFile, previousToken, node);
- }
- }
- }
+ // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node.
+ // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`.
+ ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice");
+ this.deletedNodesInLists.add(node);
+ this.deleteRange(sourceFile, {
+ pos: startPositionToDeleteNodeInList(sourceFile, node),
+ end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]),
+ });
return this;
};
ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) {
@@ -99017,6 +99264,19 @@ var ts;
}
});
};
+ ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () {
+ var _this = this;
+ this.deletedNodesInLists.forEach(function (node) {
+ var sourceFile = node.getSourceFile();
+ var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile);
+ if (node !== ts.last(list))
+ return;
+ var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2);
+ if (lastNonDeletedIndex !== -1) {
+ _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) });
+ }
+ });
+ };
/**
* Note: after calling this, the TextChanges object must be discarded!
* @param validate only for tests
@@ -99025,6 +99285,7 @@ var ts;
*/
ChangeTracker.prototype.getChanges = function (validate) {
this.finishClassesWithNodesInsertedAtStart();
+ this.finishTrailingCommaAfterDeletingNodesInList();
var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate);
for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) {
var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements;
@@ -99038,6 +99299,10 @@ var ts;
return ChangeTracker;
}());
textChanges_3.ChangeTracker = ChangeTracker;
+ // find first non-whitespace position in the leading trivia of the node
+ function startPositionToDeleteNodeInList(sourceFile, node) {
+ return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
+ }
function getClassBraceEnds(cls, sourceFile) {
return [ts.findChildOfKind(cls, 17 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile).end];
}
@@ -99049,14 +99314,14 @@ var ts;
// 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.
var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
- var _loop_17 = function (i) {
+ var _loop_18 = function (i) {
ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
});
};
// verify that change intervals do not overlap, except possibly at end points.
for (var i = 0; i < normalized.length - 1; i++) {
- _loop_17(i);
+ _loop_18(i);
}
var textChanges = normalized.map(function (c) {
return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate));
@@ -99491,7 +99756,7 @@ var ts;
if (ts.isFunctionLikeDeclaration(decl) && (ts.getJSDocReturnType(decl) || decl.parameters.some(function (p) { return !!ts.getJSDocType(p); }))) {
if (!decl.typeParameters) {
var typeParameters = ts.getJSDocTypeParameterDeclarations(decl);
- if (typeParameters)
+ if (typeParameters.length)
changes.insertTypeParameters(sourceFile, decl, typeParameters);
}
var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 19 /* OpenParenToken */, sourceFile);
@@ -101335,13 +101600,13 @@ var ts;
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); });
return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)];
}
- var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start); });
+ var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start, /*deleted*/ undefined); });
if (delDestructure.length) {
return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)];
}
var token = getToken(sourceFile, ts.textSpanEnd(context.span));
var result = [];
- var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token); });
+ var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined); });
if (deletion.length) {
result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations));
}
@@ -101352,49 +101617,60 @@ var ts;
return result;
},
fixIds: [fixIdPrefix, fixIdDelete],
- getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
- var sourceFile = context.sourceFile;
- var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file);
- switch (context.fixId) {
- case fixIdPrefix:
- if (ts.isIdentifier(token) && canPrefix(token)) {
- tryPrefixDeclaration(changes, diag.code, sourceFile, token);
- }
- break;
- case fixIdDelete:
- var importDecl = tryGetFullImport(diag.file, diag.start);
- if (importDecl) {
- changes.deleteNode(sourceFile, importDecl);
- }
- else {
- if (!tryDeleteFullDestructure(changes, sourceFile, diag.start)) {
- tryDeleteDeclaration(changes, sourceFile, token);
+ getAllCodeActions: function (context) {
+ // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors.
+ var deleted = new NodeSet();
+ return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ var sourceFile = context.sourceFile;
+ var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file);
+ switch (context.fixId) {
+ case fixIdPrefix:
+ if (ts.isIdentifier(token) && canPrefix(token)) {
+ tryPrefixDeclaration(changes, diag.code, sourceFile, token);
}
- }
- break;
- default:
- ts.Debug.fail(JSON.stringify(context.fixId));
- }
- }); },
+ break;
+ case fixIdDelete:
+ // Ignore if this range was already deleted.
+ if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); }))
+ break;
+ var importDecl = tryGetFullImport(diag.file, diag.start);
+ if (importDecl) {
+ changes.deleteNode(sourceFile, importDecl);
+ }
+ else {
+ if (!tryDeleteFullDestructure(changes, sourceFile, diag.start, deleted)) {
+ tryDeleteDeclaration(changes, sourceFile, token, deleted);
+ }
+ }
+ break;
+ default:
+ ts.Debug.fail(JSON.stringify(context.fixId));
+ }
+ });
+ },
});
// Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing.
function tryGetFullImport(sourceFile, pos) {
var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined;
}
- function tryDeleteFullDestructure(changes, sourceFile, pos) {
+ function tryDeleteFullDestructure(changes, sourceFile, pos, deletedAncestors) {
var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent))
return false;
var decl = startToken.parent.parent;
switch (decl.kind) {
case 231 /* VariableDeclaration */:
- tryDeleteVariableDeclaration(changes, sourceFile, decl);
+ tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors);
break;
case 148 /* Parameter */:
+ if (deletedAncestors)
+ deletedAncestors.add(decl);
changes.deleteNodeInList(sourceFile, decl);
break;
case 181 /* BindingElement */:
+ if (deletedAncestors)
+ deletedAncestors.add(decl);
changes.deleteNode(sourceFile, decl);
break;
default:
@@ -101403,7 +101679,7 @@ var ts;
return true;
}
function getToken(sourceFile, pos) {
- var token = ts.findPrecedingToken(pos, sourceFile);
+ var token = ts.findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true);
// this handles var ["computed"] = 12;
return token.kind === 22 /* CloseBracketToken */ ? ts.findPrecedingToken(pos - 1, sourceFile) : token;
}
@@ -101428,38 +101704,45 @@ var ts;
}
return false;
}
- function tryDeleteDeclaration(changes, sourceFile, token) {
+ function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors) {
switch (token.kind) {
case 71 /* Identifier */:
- tryDeleteIdentifier(changes, sourceFile, token);
+ tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors);
break;
case 151 /* PropertyDeclaration */:
case 245 /* NamespaceImport */:
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent);
changes.deleteNode(sourceFile, token.parent);
break;
default:
- tryDeleteDefault(changes, sourceFile, token);
+ tryDeleteDefault(changes, sourceFile, token, deletedAncestors);
}
}
- function tryDeleteDefault(changes, sourceFile, token) {
+ function tryDeleteDefault(changes, sourceFile, token, deletedAncestors) {
if (ts.isDeclarationName(token)) {
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent);
changes.deleteNode(sourceFile, token.parent);
}
else if (ts.isLiteralComputedPropertyDeclarationName(token)) {
+ if (deletedAncestors)
+ deletedAncestors.add(token.parent.parent);
changes.deleteNode(sourceFile, token.parent.parent);
}
}
- function tryDeleteIdentifier(changes, sourceFile, identifier) {
+ function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors) {
var parent = identifier.parent;
switch (parent.kind) {
case 231 /* VariableDeclaration */:
- tryDeleteVariableDeclaration(changes, sourceFile, parent);
+ tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors);
break;
case 147 /* TypeParameter */:
- var typeParameters = parent.parent.typeParameters;
+ var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent);
if (typeParameters.length === 1) {
- var previousToken = ts.getTokenAtPosition(sourceFile, typeParameters.pos - 1, /*includeJsDocComment*/ false);
- var nextToken = ts.getTokenAtPosition(sourceFile, typeParameters.end, /*includeJsDocComment*/ false);
+ var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end;
+ var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false);
+ var nextToken = ts.getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false);
ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */);
ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */);
changes.deleteNodeRange(sourceFile, previousToken, nextToken);
@@ -101542,7 +101825,7 @@ var ts;
tryDeleteNamedImportBinding(changes, sourceFile, parent);
break;
default:
- tryDeleteDefault(changes, sourceFile, identifier);
+ tryDeleteDefault(changes, sourceFile, identifier, deletedAncestors);
break;
}
}
@@ -101565,15 +101848,19 @@ var ts;
}
}
// token.parent is a variableDeclaration
- function tryDeleteVariableDeclaration(changes, sourceFile, varDecl) {
+ function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) {
switch (varDecl.parent.parent.kind) {
case 219 /* ForStatement */: {
var forStatement = varDecl.parent.parent;
var forInitializer = forStatement.initializer;
if (forInitializer.declarations.length === 1) {
+ if (deletedAncestors)
+ deletedAncestors.add(forInitializer);
changes.deleteNode(sourceFile, forInitializer);
}
else {
+ if (deletedAncestors)
+ deletedAncestors.add(varDecl);
changes.deleteNodeInList(sourceFile, varDecl);
}
break;
@@ -101582,6 +101869,8 @@ var ts;
var forOfStatement = varDecl.parent.parent;
ts.Debug.assert(forOfStatement.initializer.kind === 232 /* VariableDeclarationList */);
var forOfInitializer = forOfStatement.initializer;
+ if (deletedAncestors)
+ deletedAncestors.add(forOfInitializer.declarations[0]);
changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral());
break;
case 220 /* ForInStatement */:
@@ -101590,13 +101879,29 @@ var ts;
default:
var variableStatement = varDecl.parent.parent;
if (variableStatement.declarationList.declarations.length === 1) {
+ if (deletedAncestors)
+ deletedAncestors.add(variableStatement);
changes.deleteNode(sourceFile, variableStatement);
}
else {
+ if (deletedAncestors)
+ deletedAncestors.add(varDecl);
changes.deleteNodeInList(sourceFile, varDecl);
}
}
}
+ var NodeSet = /** @class */ (function () {
+ function NodeSet() {
+ this.map = ts.createMap();
+ }
+ NodeSet.prototype.add = function (node) {
+ this.map.set(String(ts.getNodeId(node)), node);
+ };
+ NodeSet.prototype.some = function (pred) {
+ return ts.forEachEntry(this.map, pred) || false;
+ };
+ return NodeSet;
+ }());
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
/* @internal */
@@ -101669,21 +101974,7 @@ var ts;
}
// Calls 'cb' with the start and end of each range where 'pred' is true.
function split(arr, pred, cb) {
- var start;
- for (var i = 0; i < arr.length; i++) {
- var value = arr[i];
- if (pred(value)) {
- start = start || value;
- }
- else {
- if (start) {
- cb(start, arr[i - 1]);
- start = undefined;
- }
- }
- }
- if (start)
- cb(start, arr[arr.length - 1]);
+ ts.getRangesWhere(arr, pred, function (start, afterEnd) { return cb(arr[start], arr[afterEnd - 1]); });
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -103169,6 +103460,39 @@ var ts;
})(ts || (ts = {}));
/* @internal */
var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
+ var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
+ var fixId = fixIdAddMissingTypeof;
+ var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var sourceFile = context.sourceFile, span = context.span;
+ var importType = getImportTypeNode(sourceFile, span.start);
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, importType); });
+ return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_missing_typeof, fixId, ts.Diagnostics.Add_missing_typeof)];
+ },
+ fixIds: [fixId],
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
+ return doChange(changes, context.sourceFile, getImportTypeNode(diag.file, diag.start));
+ }); },
+ });
+ function getImportTypeNode(sourceFile, pos) {
+ var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
+ ts.Debug.assert(token.kind === 91 /* ImportKeyword */);
+ ts.Debug.assert(token.parent.kind === 178 /* ImportType */);
+ return token.parent;
+ }
+ function doChange(changes, sourceFile, importType) {
+ var newTypeNode = ts.updateImportTypeNode(importType, importType.argument, importType.qualifier, importType.typeArguments, /* isTypeOf */ true);
+ changes.replaceNode(sourceFile, importType, newTypeNode);
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
(function (ts) {
var refactor;
(function (refactor) {
@@ -104362,8 +104686,8 @@ var ts;
i_1++;
}
// Note that we add the current node's type parameters *after* updating the corresponding scope.
- if (ts.isDeclarationWithTypeParameters(curr) && curr.typeParameters) {
- for (var _a = 0, _b = curr.typeParameters; _a < _b.length; _a++) {
+ if (ts.isDeclarationWithTypeParameters(curr)) {
+ for (var _a = 0, _b = ts.getEffectiveTypeParameterDeclarations(curr); _a < _b.length; _a++) {
var typeParameterDecl = _b[_a];
var typeParameter = checker.getTypeAtLocation(typeParameterDecl);
if (allTypeParameterUsages.has(typeParameter.id.toString())) {
@@ -104385,7 +104709,7 @@ var ts;
: ts.getEnclosingBlockScopeContainer(scopes[0]);
ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
}
- var _loop_18 = function (i) {
+ var _loop_19 = function (i) {
var scopeUsages = usagesPerScope[i];
// Special case: in the innermost scope, all usages are available.
// (The computed value reflects the value at the top-level of the scope, but the
@@ -104425,21 +104749,11 @@ var ts;
}
};
for (var i = 0; i < scopes.length; i++) {
- _loop_18(i);
+ _loop_19(i);
}
return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
- function hasTypeParameters(node) {
- return ts.isDeclarationWithTypeParameters(node) &&
- node.typeParameters !== undefined &&
- node.typeParameters.length > 0;
- }
function isInGenericContext(node) {
- for (; node; node = node.parent) {
- if (hasTypeParameters(node)) {
- return true;
- }
- }
- return false;
+ return !!ts.findAncestor(node, function (n) { return ts.isDeclarationWithTypeParameters(n) && ts.getEffectiveTypeParameterDeclarations(n).length !== 0; });
}
function recordTypeParameterUsages(type) {
// PERF: This is potentially very expensive. `type` could be a library type with
@@ -104704,8 +105018,8 @@ var ts;
var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message;
refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions });
function getAvailableActions(context) {
- var file = context.file, startPosition = context.startPosition;
- if (!getConvertibleFieldAtPosition(file, startPosition))
+ var file = context.file;
+ if (!getConvertibleFieldAtPosition(context, file))
return undefined;
return [{
name: actionName,
@@ -104719,8 +105033,8 @@ var ts;
}];
}
function getEditsForAction(context, _actionName) {
- var file = context.file, startPosition = context.startPosition;
- var fieldInfo = getConvertibleFieldAtPosition(file, startPosition);
+ var file = context.file;
+ var fieldInfo = getConvertibleFieldAtPosition(context, file);
if (!fieldInfo)
return undefined;
var isJS = ts.isSourceFileJavaScript(file);
@@ -104781,12 +105095,14 @@ var ts;
function startsWithUnderscore(name) {
return name.charCodeAt(0) === 95 /* _ */;
}
- function getConvertibleFieldAtPosition(file, startPosition) {
+ function getConvertibleFieldAtPosition(context, file) {
+ var startPosition = context.startPosition, endPosition = context.endPosition;
var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false);
var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration);
// make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier
var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */;
- if (!declaration || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning)
+ if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition)
+ || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning)
return undefined;
var name = declaration.name.text;
var startWithUnderscore = startsWithUnderscore(name);
@@ -104874,7 +105190,7 @@ var ts;
var refactorName = "Move to a new file";
refactor.registerRefactor(refactorName, {
getAvailableActions: function (context) {
- if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined)
+ if (!context.preferences.allowTextChangesInNewFiles || getFirstAndLastStatementToMove(context) === undefined)
return undefined;
var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file);
return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }];
@@ -104886,7 +105202,7 @@ var ts;
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
}
});
- function getStatementsToMove(context) {
+ function getFirstAndLastStatementToMove(context) {
var file = context.file;
var range = ts.createTextRangeFromSpan(ts.getRefactorContextSpan(context));
var statements = file.statements;
@@ -104900,11 +105216,11 @@ var ts;
// Can't be partially into the next node
if (afterEndNodeIndex !== -1 && (afterEndNodeIndex === 0 || statements[afterEndNodeIndex].getStart(file) < range.end))
return undefined;
- return statements.slice(startNodeIndex, afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex);
+ return { first: startNodeIndex, afterLast: afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex };
}
function doChange(oldFile, program, toMove, changes, host) {
var checker = program.getTypeChecker();
- var usage = getUsageInfo(oldFile, toMove, checker);
+ var usage = getUsageInfo(oldFile, toMove.all, checker);
var currentDirectory = ts.getDirectoryPath(oldFile.fileName);
var extension = ts.extensionFromPath(oldFile.fileName);
var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host);
@@ -104913,6 +105229,32 @@ var ts;
changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatements(oldFile, usage, changes, toMove, program, newModuleName));
addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host));
}
+ // Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file.
+ function getStatementsToMove(context) {
+ var statements = context.file.statements;
+ var _a = getFirstAndLastStatementToMove(context), first = _a.first, afterLast = _a.afterLast;
+ var all = [];
+ var ranges = [];
+ var rangeToMove = statements.slice(first, afterLast);
+ ts.getRangesWhere(rangeToMove, function (s) { return !isPureImport(s); }, function (start, afterEnd) {
+ for (var i = start; i < afterEnd; i++)
+ all.push(rangeToMove[i]);
+ ranges.push({ first: rangeToMove[start], last: rangeToMove[afterEnd - 1] });
+ });
+ return { all: all, ranges: ranges };
+ }
+ function isPureImport(node) {
+ switch (node.kind) {
+ case 243 /* ImportDeclaration */:
+ return true;
+ case 242 /* ImportEqualsDeclaration */:
+ return !ts.hasModifier(node, 1 /* Export */);
+ case 213 /* VariableStatement */:
+ return node.declarationList.declarations.every(function (d) { return ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); });
+ default:
+ return false;
+ }
+ }
function addNewFileToTsconfig(program, changes, oldFileName, newFileNameWithExtension, getCanonicalFileName) {
var cfg = program.getCompilerOptions().configFile;
if (!cfg)
@@ -104930,18 +105272,24 @@ var ts;
function getNewStatements(oldFile, usage, changes, toMove, program, newModuleName) {
var checker = program.getTypeChecker();
if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) {
- changes.deleteNodeRange(oldFile, ts.first(toMove), ts.last(toMove));
- return toMove;
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
+ return toMove.all;
}
var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator;
var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax);
if (importsFromNewFile) {
changes.insertNodeBefore(oldFile, oldFile.statements[0], importsFromNewFile, /*blankLineBetween*/ true);
}
- deleteUnusedOldImports(oldFile, toMove, changes, usage.unusedImportsFromOldFile, checker);
- changes.deleteNodeRange(oldFile, ts.first(toMove), ts.last(toMove));
+ deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
- return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax));
+ return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax));
+ }
+ function deleteMovedStatements(sourceFile, moved, changes) {
+ for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) {
+ var _a = moved_1[_i], first_1 = _a.first, last_3 = _a.last;
+ changes.deleteNodeRange(sourceFile, first_1, last_3);
+ }
}
function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) {
for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) {
@@ -104953,10 +105301,10 @@ var ts;
}
function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
var checker = program.getTypeChecker();
- var _loop_19 = function (sourceFile) {
+ var _loop_20 = function (sourceFile) {
if (sourceFile === oldFile)
return "continue";
- var _loop_20 = function (statement) {
+ var _loop_21 = function (statement) {
forEachImportInStatement(statement, function (importNode) {
var shouldMove = function (name) {
var symbol = ts.isBindingElement(name.parent)
@@ -104973,12 +105321,12 @@ var ts;
};
for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
var statement = _a[_i];
- _loop_20(statement);
+ _loop_21(statement);
}
};
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
- _loop_19(sourceFile);
+ _loop_20(sourceFile);
}
}
function moduleSpecifierFromImport(i) {
@@ -105225,12 +105573,14 @@ var ts;
}
function isVariableDeclarationInImport(decl) {
return ts.isSourceFile(decl.parent.parent.parent) &&
- ts.isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true);
+ decl.initializer && ts.isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true);
}
function filterImport(i, moduleSpecifier, keep) {
switch (i.kind) {
case 243 /* ImportDeclaration */: {
var clause = i.importClause;
+ if (!clause)
+ return undefined;
var defaultImport = clause.name && keep(clause.name) ? clause.name : undefined;
var namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep);
return defaultImport || namedBindings
@@ -105754,7 +106104,7 @@ var ts;
if (!children.length) {
return undefined;
}
- var child = ts.find(children, function (kid) { return kid.kind < 277 /* FirstJSDocNode */ || kid.kind > 295 /* LastJSDocNode */; });
+ var child = ts.find(children, function (kid) { return kid.kind < 277 /* FirstJSDocNode */ || kid.kind > 297 /* LastJSDocNode */; });
return child.kind < 145 /* FirstNode */ ?
child :
child.getFirstToken(sourceFile);
@@ -105824,7 +106174,7 @@ var ts;
}
}
function createSyntaxList(nodes, parent) {
- var list = createNode(296 /* SyntaxList */, nodes.pos, nodes.end, parent);
+ var list = createNode(298 /* SyntaxList */, nodes.pos, nodes.end, parent);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) {
@@ -106961,15 +107311,15 @@ var ts;
if (original === void 0) { original = input; }
var info = extract(input);
if (ts.endsWith(info.fileName, ".d.ts" /* Dts */)) {
- var file_17 = program.getSourceFile(info.fileName);
- if (!file_17) {
+ var file_18 = program.getSourceFile(info.fileName);
+ if (!file_18) {
var path = ts.toPath(info.fileName, currentDirectory, getCanonicalFileName);
- file_17 = sourcemappedFileCache.get(path);
+ file_18 = sourcemappedFileCache.get(path);
}
- if (!file_17) {
+ if (!file_18) {
return input;
}
- var mapper = getSourceMapper(info.fileName, file_17);
+ var mapper = getSourceMapper(info.fileName, file_18);
var newLoc = mapper.getOriginalPosition(info);
if (newLoc === info)
return input;
diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js
index 338f5ff7b8d..3aaf962cf0c 100644
--- a/lib/typingsInstaller.js
+++ b/lib/typingsInstaller.js
@@ -434,6 +434,15 @@ var ts;
return -1;
}
ts.findIndex = findIndex;
+ function findLastIndex(array, predicate, startIndex) {
+ for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
+ if (predicate(array[i], i)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+ ts.findLastIndex = findLastIndex;
function findMap(array, callback) {
for (var i = 0; i < array.length; i++) {
var result = callback(array[i], i);
@@ -764,6 +773,23 @@ var ts;
return false;
}
ts.some = some;
+ function getRangesWhere(arr, pred, cb) {
+ var start;
+ for (var i = 0; i < arr.length; i++) {
+ if (pred(arr[i])) {
+ start = start === undefined ? i : start;
+ }
+ else {
+ if (start !== undefined) {
+ cb(start, i);
+ start = undefined;
+ }
+ }
+ }
+ if (start !== undefined)
+ cb(start, arr.length);
+ }
+ ts.getRangesWhere = getRangesWhere;
function concatenate(array1, array2) {
if (!some(array2))
return array1;
@@ -4680,6 +4706,7 @@ var ts;
Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
+ Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing typeof"),
};
})(ts || (ts = {}));
var ts;
@@ -4913,7 +4940,7 @@ var ts;
if (includeJsDoc && ts.hasJSDocNodes(node)) {
return getTokenPosOfNode(node.jsDoc[0]);
}
- if (node.kind === 296 && node._children.length > 0) {
+ if (node.kind === 298 && node._children.length > 0) {
return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
}
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
@@ -5093,7 +5120,7 @@ var ts;
case 204:
case 235:
case 236:
- case 293:
+ case 295:
case 233:
case 153:
case 154:
@@ -5101,6 +5128,9 @@ var ts;
case 156:
case 191:
case 192:
+ case 291:
+ case 296:
+ case 287:
return true;
default:
ts.assertTypeIsNever(node);
@@ -5140,13 +5170,7 @@ var ts;
}
ts.isAnyImportOrReExport = isAnyImportOrReExport;
function getEnclosingBlockScopeContainer(node) {
- var current = node.parent;
- while (current) {
- if (isBlockScope(current, current.parent)) {
- return current;
- }
- current = current.parent;
- }
+ return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
}
ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
function declarationNameToString(name) {
@@ -6209,6 +6233,14 @@ var ts;
node.parameters[0].name.escapedText === "new";
}
ts.isJSDocConstructSignature = isJSDocConstructSignature;
+ function isJSDocTypeAlias(node) {
+ return node.kind === 296 || node.kind === 291;
+ }
+ ts.isJSDocTypeAlias = isJSDocTypeAlias;
+ function isTypeAlias(node) {
+ return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
+ }
+ ts.isTypeAlias = isTypeAlias;
function getSourceOfAssignment(node) {
return ts.isExpressionStatement(node) &&
node.expression && ts.isBinaryExpression(node.expression) &&
@@ -6230,6 +6262,8 @@ var ts;
return v && v.initializer;
case 151:
return node.initializer;
+ case 269:
+ return node.initializer;
}
}
function getSingleVariableOfVariableStatement(node) {
@@ -6254,8 +6288,7 @@ var ts;
if (parent.kind === 269 || parent.kind === 151 || getNestedModuleDeclaration(parent)) {
getJSDocCommentsAndTagsWorker(parent);
}
- if (parent.parent &&
- (getSingleVariableOfVariableStatement(parent.parent) === node)) {
+ if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) {
getJSDocCommentsAndTagsWorker(parent.parent);
}
if (parent.parent && parent.parent.parent &&
@@ -6298,7 +6331,10 @@ var ts;
}
ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
function getHostSignatureFromJSDoc(node) {
- var host = getJSDocHost(node);
+ return getHostSignatureFromJSDocHost(getJSDocHost(node));
+ }
+ ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ function getHostSignatureFromJSDocHost(host) {
var decl = getSourceOfDefaultedAssignment(host) ||
getSourceOfAssignment(host) ||
getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
@@ -6307,18 +6343,12 @@ var ts;
host;
return decl && ts.isFunctionLike(decl) ? decl : undefined;
}
- ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
+ ts.getHostSignatureFromJSDocHost = getHostSignatureFromJSDocHost;
function getJSDocHost(node) {
- while (node.parent.kind === 286) {
- if (node.parent.parent.kind === 294) {
- node = node.parent.parent;
- }
- else {
- node = node.parent.parent.parent;
- }
+ var comment = ts.findAncestor(node.parent, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152) ? "quit" : node.kind === 285; });
+ if (comment) {
+ return comment.parent;
}
- ts.Debug.assert(node.parent.kind === 285);
- return node.parent.parent;
}
ts.getJSDocHost = getJSDocHost;
function getTypeParameterFromJsDoc(node) {
@@ -6333,7 +6363,8 @@ var ts;
}
ts.hasRestParameter = hasRestParameter;
function isRestParameter(node) {
- return node.dotDotDotToken !== undefined || node.type && node.type.kind === 284;
+ var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
+ return node.dotDotDotToken !== undefined || type && type.kind === 284;
}
ts.isRestParameter = isRestParameter;
function getAssignmentTargetKind(node) {
@@ -6802,7 +6833,7 @@ var ts;
ts.getOperator = getOperator;
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
switch (nodeKind) {
- case 299:
+ case 301:
return 0;
case 203:
return 1;
@@ -7113,8 +7144,8 @@ var ts;
};
}
ts.createTextWriter = createTextWriter;
- function getResolvedExternalModuleName(host, file) {
- return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
+ function getResolvedExternalModuleName(host, file, referenceFile) {
+ return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
}
ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
@@ -7125,12 +7156,13 @@ var ts;
return getResolvedExternalModuleName(host, file);
}
ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
- function getExternalModuleNameFromPath(host, fileName) {
+ function getExternalModuleNameFromPath(host, fileName, referencePath) {
var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
- var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
+ var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false);
- return ts.removeFileExtension(relativePath);
+ var extensionless = ts.removeFileExtension(relativePath);
+ return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
}
ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
function getOwnEmitOutputFilePath(sourceFile, host, extension) {
@@ -7212,7 +7244,7 @@ var ts;
}
ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
function getThisParameter(signature) {
- if (signature.parameters.length) {
+ if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
var thisParameter = signature.parameters[0];
if (parameterIsThisKeyword(thisParameter)) {
return thisParameter;
@@ -7289,18 +7321,32 @@ var ts;
}
ts.getTypeAnnotationNode = getTypeAnnotationNode;
function getEffectiveReturnTypeNode(node) {
+ if (ts.isJSDocSignature(node)) {
+ return node.type && node.type.typeExpression && node.type.typeExpression.type;
+ }
return node.type || (isInJavaScriptFile(node) ? ts.getJSDocReturnType(node) : undefined);
}
ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
function getEffectiveTypeParameterDeclarations(node) {
- return ts.isJSDocTypedefTag(node)
- ? getJSDocTypeParameterDeclarations(node)
- : node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined);
+ if (ts.isJSDocSignature(node)) {
+ return ts.emptyArray;
+ }
+ if (isJSDocTypeAlias(node)) {
+ ts.Debug.assert(node.parent.kind === 285);
+ var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; });
+ var templateTagNodes = templateTags;
+ templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos;
+ templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end;
+ templateTagNodes.hasTrailingComma = false;
+ return templateTagNodes;
+ }
+ return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray);
}
ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
function getJSDocTypeParameterDeclarations(node) {
- var templateTag = ts.getJSDocTemplateTag(node);
- return templateTag && templateTag.typeParameters;
+ var tags = ts.filter(ts.getJSDocTags(node), ts.isJSDocTemplateTag);
+ var tag = ts.find(tags, function (tag) { return !(tag.parent.kind === 285 && ts.find(tag.parent.tags, isJSDocTypeAlias)); });
+ return (tag && tag.typeParameters) || ts.emptyArray;
}
ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
function getEffectiveSetAccessorTypeAnnotationNode(node) {
@@ -8419,8 +8465,8 @@ var ts;
break;
case 71:
return declaration;
- case 295:
- case 290: {
+ case 297:
+ case 292: {
var name = declaration.name;
if (name.kind === 145) {
return name.right;
@@ -8439,7 +8485,9 @@ var ts;
return undefined;
}
}
- case 294:
+ case 291:
+ return declaration.name;
+ case 296:
return getNameOfJSDocTypedef(declaration);
case 248: {
var expression = declaration.expression;
@@ -8768,7 +8816,7 @@ var ts;
}
ts.isParenthesizedExpression = isParenthesizedExpression;
function skipPartiallyEmittedExpressions(node) {
- while (node.kind === 298) {
+ while (node.kind === 300) {
node = node.expression;
}
return node;
@@ -9151,49 +9199,57 @@ var ts;
}
ts.isJSDoc = isJSDoc;
function isJSDocAugmentsTag(node) {
- return node.kind === 288;
+ return node.kind === 289;
}
ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
function isJSDocClassTag(node) {
- return node.kind === 289;
+ return node.kind === 290;
}
ts.isJSDocClassTag = isJSDocClassTag;
function isJSDocParameterTag(node) {
- return node.kind === 290;
+ return node.kind === 292;
}
ts.isJSDocParameterTag = isJSDocParameterTag;
function isJSDocReturnTag(node) {
- return node.kind === 291;
+ return node.kind === 293;
}
ts.isJSDocReturnTag = isJSDocReturnTag;
function isJSDocTypeTag(node) {
- return node.kind === 292;
+ return node.kind === 294;
}
ts.isJSDocTypeTag = isJSDocTypeTag;
function isJSDocTemplateTag(node) {
- return node.kind === 293;
+ return node.kind === 295;
}
ts.isJSDocTemplateTag = isJSDocTemplateTag;
function isJSDocTypedefTag(node) {
- return node.kind === 294;
+ return node.kind === 296;
}
ts.isJSDocTypedefTag = isJSDocTypedefTag;
function isJSDocPropertyTag(node) {
- return node.kind === 295;
+ return node.kind === 297;
}
ts.isJSDocPropertyTag = isJSDocPropertyTag;
function isJSDocPropertyLikeTag(node) {
- return node.kind === 295 || node.kind === 290;
+ return node.kind === 297 || node.kind === 292;
}
ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
function isJSDocTypeLiteral(node) {
return node.kind === 286;
}
ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
+ function isJSDocCallbackTag(node) {
+ return node.kind === 291;
+ }
+ ts.isJSDocCallbackTag = isJSDocCallbackTag;
+ function isJSDocSignature(node) {
+ return node.kind === 287;
+ }
+ ts.isJSDocSignature = isJSDocSignature;
})(ts || (ts = {}));
(function (ts) {
function isSyntaxList(n) {
- return n.kind === 296;
+ return n.kind === 298;
}
ts.isSyntaxList = isSyntaxList;
function isNode(node) {
@@ -9315,6 +9371,7 @@ var ts;
switch (kind) {
case 152:
case 157:
+ case 287:
case 158:
case 159:
case 162:
@@ -9590,8 +9647,8 @@ var ts;
case 203:
case 207:
case 205:
- case 299:
- case 298:
+ case 301:
+ case 300:
return true;
default:
return isUnaryExpressionKind(kind);
@@ -9604,11 +9661,11 @@ var ts;
}
ts.isAssertionExpression = isAssertionExpression;
function isPartiallyEmittedExpression(node) {
- return node.kind === 298;
+ return node.kind === 300;
}
ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
function isNotEmittedStatement(node) {
- return node.kind === 297;
+ return node.kind === 299;
}
ts.isNotEmittedStatement = isNotEmittedStatement;
function isNotEmittedOrPartiallyEmittedNode(node) {
@@ -9708,8 +9765,9 @@ var ts;
|| kind === 236
|| kind === 147
|| kind === 231
- || kind === 294
- || kind === 295;
+ || kind === 296
+ || kind === 291
+ || kind === 297;
}
function isDeclarationStatementKind(kind) {
return kind === 233
@@ -9744,13 +9802,13 @@ var ts;
|| kind === 213
|| kind === 218
|| kind === 225
- || kind === 297
- || kind === 301
- || kind === 300;
+ || kind === 299
+ || kind === 303
+ || kind === 302;
}
function isDeclaration(node) {
if (node.kind === 147) {
- return node.parent.kind !== 293 || ts.isInJavaScriptFile(node);
+ return node.parent.kind !== 295 || ts.isInJavaScriptFile(node);
}
return isDeclarationKind(node.kind);
}
@@ -9828,15 +9886,15 @@ var ts;
}
ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
function isJSDocNode(node) {
- return node.kind >= 277 && node.kind <= 295;
+ return node.kind >= 277 && node.kind <= 297;
}
ts.isJSDocNode = isJSDocNode;
function isJSDocCommentContainingNode(node) {
- return node.kind === 285 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node);
+ return node.kind === 285 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node);
}
ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
function isJSDocTag(node) {
- return node.kind >= 287 && node.kind <= 295;
+ return node.kind >= 288 && node.kind <= 297;
}
ts.isJSDocTag = isJSDocTag;
function isSetAccessor(node) {
@@ -11516,11 +11574,10 @@ var ts;
}
}
function scanJSDocToken() {
+ startPos = tokenPos = pos;
if (pos >= end) {
return token = 1;
}
- startPos = pos;
- tokenPos = pos;
var ch = text.charCodeAt(pos);
pos++;
switch (ch) {
@@ -12037,7 +12094,7 @@ var ts;
return visitNode(cbNode, node.expression);
case 252:
return visitNodes(cbNode, cbNodes, node.decorators);
- case 299:
+ case 301:
return visitNodes(cbNode, cbNodes, node.elements);
case 254:
return visitNode(cbNode, node.openingElement) ||
@@ -12079,8 +12136,8 @@ var ts;
return visitNode(cbNode, node.type);
case 285:
return visitNodes(cbNode, cbNodes, node.tags);
- case 290:
- case 295:
+ case 292:
+ case 297:
if (node.isNameFirst) {
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.typeExpression);
@@ -12089,15 +12146,15 @@ var ts;
return visitNode(cbNode, node.typeExpression) ||
visitNode(cbNode, node.name);
}
- case 291:
- return visitNode(cbNode, node.typeExpression);
- case 292:
- return visitNode(cbNode, node.typeExpression);
- case 288:
- return visitNode(cbNode, node.class);
case 293:
- return visitNodes(cbNode, cbNodes, node.typeParameters);
+ return visitNode(cbNode, node.typeExpression);
case 294:
+ return visitNode(cbNode, node.typeExpression);
+ case 289:
+ return visitNode(cbNode, node.class);
+ case 295:
+ return visitNodes(cbNode, cbNodes, node.typeParameters);
+ case 296:
if (node.typeExpression &&
node.typeExpression.kind === 277) {
return visitNode(cbNode, node.typeExpression) ||
@@ -12107,6 +12164,15 @@ var ts;
return visitNode(cbNode, node.fullName) ||
visitNode(cbNode, node.typeExpression);
}
+ case 291:
+ return visitNode(cbNode, node.fullName) ||
+ visitNode(cbNode, node.typeExpression);
+ case 287:
+ return visitNodes(cbNode, cbNodes, node.decorators) ||
+ visitNodes(cbNode, cbNodes, node.modifiers) ||
+ visitNodes(cbNode, cbNodes, node.typeParameters) ||
+ visitNodes(cbNode, cbNodes, node.parameters) ||
+ visitNode(cbNode, node.type);
case 286:
if (node.jsDocPropertyTags) {
for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
@@ -12115,7 +12181,7 @@ var ts;
}
}
return;
- case 298:
+ case 300:
return visitNode(cbNode, node.expression);
}
}
@@ -16227,7 +16293,7 @@ var ts;
case 57:
if (state === 0 || state === 1) {
removeTrailingNewlines(comments);
- parseTag(indent);
+ addTag(parseTag(indent));
state = 0;
margin = undefined;
indent++;
@@ -16296,7 +16362,23 @@ var ts;
result.comment = comments.length ? comments.join("") : undefined;
return finishNode(result, end);
}
+ function isNextNonwhitespaceTokenEndOfFile() {
+ while (true) {
+ nextJSDocToken();
+ if (token() === 1) {
+ return true;
+ }
+ if (!(token() === 5 || token() === 4)) {
+ return false;
+ }
+ }
+ }
function skipWhitespace() {
+ if (token() === 5 || token() === 4) {
+ if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
+ return;
+ }
+ }
while (token() === 5 || token() === 4) {
nextJSDocToken();
}
@@ -16325,8 +16407,7 @@ var ts;
case "arg":
case "argument":
case "param":
- addTag(parseParameterOrPropertyTag(atToken, tagName, 1, indent));
- return;
+ return parseParameterOrPropertyTag(atToken, tagName, 2, indent);
case "return":
case "returns":
tag = parseReturnTag(atToken, tagName);
@@ -16338,7 +16419,10 @@ var ts;
tag = parseTypeTag(atToken, tagName);
break;
case "typedef":
- tag = parseTypedefTag(atToken, tagName);
+ tag = parseTypedefTag(atToken, tagName, indent);
+ break;
+ case "callback":
+ tag = parseCallbackTag(atToken, tagName, indent);
break;
default:
tag = parseUnknownTag(atToken, tagName);
@@ -16351,8 +16435,10 @@ var ts;
if (!tag) {
return;
}
- tag.comment = parseTagComments(indent + tag.end - tag.pos);
- addTag(tag);
+ if (!tag.comment) {
+ tag.comment = parseTagComments(indent + tag.end - tag.pos);
+ }
+ return tag;
}
function parseTagComments(indent) {
var comments = [];
@@ -16409,12 +16495,15 @@ var ts;
return comments.length === 0 ? undefined : comments.join("");
}
function parseUnknownTag(atToken, tagName) {
- var result = createNode(287, atToken.pos);
+ var result = createNode(288, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
return finishNode(result);
}
function addTag(tag) {
+ if (!tag) {
+ return;
+ }
if (!tags) {
tags = [tag];
tagsPos = tag.pos;
@@ -16463,8 +16552,8 @@ var ts;
typeExpression = tryParseTypeExpression();
}
var result = target === 1 ?
- createNode(290, atToken.pos) :
- createNode(295, atToken.pos);
+ createNode(297, atToken.pos) :
+ createNode(292, atToken.pos);
var comment;
if (indent !== undefined)
comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
@@ -16490,7 +16579,7 @@ var ts;
var start_2 = scanner.getStartPos();
var children = void 0;
while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) {
- if (child.kind === 290 || child.kind === 295) {
+ if (child.kind === 292 || child.kind === 297) {
children = ts.append(children, child);
}
}
@@ -16506,27 +16595,27 @@ var ts;
}
}
function parseReturnTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 291; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 293; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(291, atToken.pos);
+ var result = createNode(293, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result);
}
function parseTypeTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 292; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 294; })) {
parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
}
- var result = createNode(292, atToken.pos);
+ var result = createNode(294, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = parseJSDocTypeExpression(true);
return finishNode(result);
}
function parseAugmentsTag(atToken, tagName) {
- var result = createNode(288, atToken.pos);
+ var result = createNode(289, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.class = parseExpressionWithTypeArgumentsForAugments();
@@ -16554,30 +16643,23 @@ var ts;
return node;
}
function parseClassTag(atToken, tagName) {
- var tag = createNode(289, atToken.pos);
+ var tag = createNode(290, atToken.pos);
tag.atToken = atToken;
tag.tagName = tagName;
return finishNode(tag);
}
- function parseTypedefTag(atToken, tagName) {
+ function parseTypedefTag(atToken, tagName, indent) {
var typeExpression = tryParseTypeExpression();
skipWhitespace();
- var typedefTag = createNode(294, atToken.pos);
+ var typedefTag = createNode(296, atToken.pos);
typedefTag.atToken = atToken;
typedefTag.tagName = tagName;
- typedefTag.fullName = parseJSDocTypeNameWithNamespace(0);
- if (typedefTag.fullName) {
- var rightNode = typedefTag.fullName;
- while (true) {
- if (rightNode.kind === 71 || !rightNode.body) {
- typedefTag.name = rightNode.kind === 71 ? rightNode : rightNode.name;
- break;
- }
- rightNode = rightNode.body;
- }
- }
+ typedefTag.fullName = parseJSDocTypeNameWithNamespace();
+ typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
skipWhitespace();
+ typedefTag.comment = parseTagComments(indent);
typedefTag.typeExpression = typeExpression;
+ var end;
if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
var child = void 0;
var jsdocTypeLiteral = void 0;
@@ -16587,7 +16669,7 @@ var ts;
if (!jsdocTypeLiteral) {
jsdocTypeLiteral = createNode(286, start_3);
}
- if (child.kind === 292) {
+ if (child.kind === 294) {
if (childTypeTag) {
break;
}
@@ -16606,23 +16688,67 @@ var ts;
typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
childTypeTag.typeExpression :
finishNode(jsdocTypeLiteral);
+ end = typedefTag.typeExpression.end;
}
}
- return finishNode(typedefTag);
- function parseJSDocTypeNameWithNamespace(flags) {
- var pos = scanner.getTokenPos();
- var typeNameOrNamespaceName = parseJSDocIdentifierName();
- if (typeNameOrNamespaceName && parseOptional(23)) {
- var jsDocNamespaceNode = createNode(238, pos);
- jsDocNamespaceNode.flags |= flags;
- jsDocNamespaceNode.name = typeNameOrNamespaceName;
- jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4);
- return finishNode(jsDocNamespaceNode);
+ return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
+ }
+ function parseJSDocTypeNameWithNamespace(nested) {
+ var pos = scanner.getTokenPos();
+ var typeNameOrNamespaceName = parseJSDocIdentifierName();
+ if (typeNameOrNamespaceName && parseOptional(23)) {
+ var jsDocNamespaceNode = createNode(238, pos);
+ if (nested) {
+ jsDocNamespaceNode.flags |= 4;
}
- if (typeNameOrNamespaceName && flags & 4) {
- typeNameOrNamespaceName.isInJSDocNamespace = true;
+ jsDocNamespaceNode.name = typeNameOrNamespaceName;
+ jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(true);
+ return finishNode(jsDocNamespaceNode);
+ }
+ if (typeNameOrNamespaceName && nested) {
+ typeNameOrNamespaceName.isInJSDocNamespace = true;
+ }
+ return typeNameOrNamespaceName;
+ }
+ function parseCallbackTag(atToken, tagName, indent) {
+ var callbackTag = createNode(291, atToken.pos);
+ callbackTag.atToken = atToken;
+ callbackTag.tagName = tagName;
+ callbackTag.fullName = parseJSDocTypeNameWithNamespace();
+ callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
+ skipWhitespace();
+ callbackTag.comment = parseTagComments(indent);
+ var child;
+ var start = scanner.getStartPos();
+ var jsdocSignature = createNode(287, start);
+ jsdocSignature.parameters = [];
+ while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4); })) {
+ jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
+ }
+ var returnTag = tryParse(function () {
+ if (token() === 57) {
+ nextJSDocToken();
+ var tag = parseTag(indent);
+ if (tag && tag.kind === 293) {
+ return tag;
+ }
+ }
+ });
+ if (returnTag) {
+ jsdocSignature.type = returnTag;
+ }
+ callbackTag.typeExpression = finishNode(jsdocSignature);
+ return finishNode(callbackTag);
+ }
+ function getJSDocTypeAliasName(fullName) {
+ if (fullName) {
+ var rightNode = fullName;
+ while (true) {
+ if (ts.isIdentifier(rightNode) || !rightNode.body) {
+ return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
+ }
+ rightNode = rightNode.body;
}
- return typeNameOrNamespaceName;
}
}
function escapedTextsEqual(a, b) {
@@ -16638,7 +16764,7 @@ var ts;
return a.escapedText === b.escapedText;
}
function parseChildPropertyTag() {
- return parseChildParameterOrPropertyTag(0);
+ return parseChildParameterOrPropertyTag(1);
}
function parseChildParameterOrPropertyTag(target, name) {
var canParseTag = true;
@@ -16648,7 +16774,8 @@ var ts;
case 57:
if (canParseTag) {
var child = tryParseChildTag(target);
- if (child && child.kind === 290 &&
+ if (child && child.kind === 292 &&
+ target !== 4 &&
(ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
return false;
}
@@ -16687,20 +16814,20 @@ var ts;
var t;
switch (tagName.escapedText) {
case "type":
- return target === 0 && parseTypeTag(atToken, tagName);
+ return target === 1 && parseTypeTag(atToken, tagName);
case "prop":
case "property":
- t = 0;
+ t = 1;
break;
case "arg":
case "argument":
case "param":
- t = 1;
+ t = 2 | 4;
break;
default:
return false;
}
- if (target !== t) {
+ if (!(target & t)) {
return false;
}
var tag = parseParameterOrPropertyTag(atToken, tagName, target, undefined);
@@ -16732,7 +16859,7 @@ var ts;
break;
}
}
- var result = createNode(293, atToken.pos);
+ var result = createNode(295, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
@@ -16778,7 +16905,7 @@ var ts;
var pos = scanner.getTokenPos();
var end = scanner.getTextPos();
var result = createNode(71, pos);
- result.escapedText = ts.escapeLeadingUnderscores(content.substring(pos, end));
+ result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText());
finishNode(result, end);
nextJSDocToken();
return result;