Skip to content

Commit

Permalink
🤖 Pick PR #40005 (feat(40004): Missing Compiler API p...) into releas…
Browse files Browse the repository at this point in the history
…e-4.0 (#40015)

* Cherry-pick PR #40005 into release-4.0

Component commits:
fa1ed85 feat(40004): make isNamedTupleMember public

* Update LKG

Co-authored-by: Alexander T <[email protected]>
Co-authored-by: typescript-bot <[email protected]>
  • Loading branch information
3 people authored Aug 12, 2020
1 parent 7558de6 commit 6620b25
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 36 deletions.
37 changes: 31 additions & 6 deletions lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20363,6 +20363,10 @@ var ts;
return node.kind === 178;
}
ts.isTupleTypeNode = isTupleTypeNode;
function isNamedTupleMember(node) {
return node.kind === 191;
}
ts.isNamedTupleMember = isNamedTupleMember;
function isOptionalTypeNode(node) {
return node.kind === 179;
}
Expand Down Expand Up @@ -56083,7 +56087,31 @@ var ts;
}
function checkDeprecatedSignature(signature, node) {
if (signature.declaration && signature.declaration.flags & 134217728) {
errorOrSuggestion(false, node, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
var suggestionNode = getDeprecatedSuggestionNode(node);
errorOrSuggestion(false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
}
}
function getDeprecatedSuggestionNode(node) {
node = ts.skipParentheses(node);
switch (node.kind) {
case 200:
case 160:
case 201:
return getDeprecatedSuggestionNode(node.expression);
case 202:
return getDeprecatedSuggestionNode(node.tag);
case 272:
case 271:
return getDeprecatedSuggestionNode(node.tagName);
case 199:
return node.argumentExpression;
case 198:
return node.name;
case 172:
var typeReference = node;
return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference;
default:
return node;
}
}
function isSymbolOrSymbolForCall(node) {
Expand Down Expand Up @@ -58848,8 +58876,7 @@ var ts;
var symbol = getNodeLinks(node).resolvedSymbol;
if (symbol) {
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728); })) {
var diagLocation = ts.isTypeReferenceNode(node) && ts.isQualifiedName(node.typeName) ? node.typeName.right : node;
errorOrSuggestion(false, diagLocation, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
errorOrSuggestion(false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName);
}
if (type.flags & 32 && symbol.flags & 8) {
error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
Expand Down Expand Up @@ -62053,9 +62080,7 @@ var ts;
&& !(node.flags & 8388608)) {
error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
}
if (ts.isImportSpecifier(node) &&
(target.valueDeclaration && target.valueDeclaration.flags & 134217728
|| ts.every(target.declarations, function (d) { return !!(d.flags & 134217728); }))) {
if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728); })) {
errorOrSuggestion(false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
}
}
Expand Down
37 changes: 31 additions & 6 deletions lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -25446,6 +25446,10 @@ var ts;
return node.kind === 178 /* TupleType */;
}
ts.isTupleTypeNode = isTupleTypeNode;
function isNamedTupleMember(node) {
return node.kind === 191 /* NamedTupleMember */;
}
ts.isNamedTupleMember = isNamedTupleMember;
function isOptionalTypeNode(node) {
return node.kind === 179 /* OptionalType */;
}
Expand Down Expand Up @@ -67368,7 +67372,31 @@ var ts;
}
function checkDeprecatedSignature(signature, node) {
if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) {
errorOrSuggestion(/*isError*/ false, node, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
var suggestionNode = getDeprecatedSuggestionNode(node);
errorOrSuggestion(/*isError*/ false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
}
}
function getDeprecatedSuggestionNode(node) {
node = ts.skipParentheses(node);
switch (node.kind) {
case 200 /* CallExpression */:
case 160 /* Decorator */:
case 201 /* NewExpression */:
return getDeprecatedSuggestionNode(node.expression);
case 202 /* TaggedTemplateExpression */:
return getDeprecatedSuggestionNode(node.tag);
case 272 /* JsxOpeningElement */:
case 271 /* JsxSelfClosingElement */:
return getDeprecatedSuggestionNode(node.tagName);
case 199 /* ElementAccessExpression */:
return node.argumentExpression;
case 198 /* PropertyAccessExpression */:
return node.name;
case 172 /* TypeReference */:
var typeReference = node;
return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference;
default:
return node;
}
}
function isSymbolOrSymbolForCall(node) {
Expand Down Expand Up @@ -70474,8 +70502,7 @@ var ts;
var symbol = getNodeLinks(node).resolvedSymbol;
if (symbol) {
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) {
var diagLocation = ts.isTypeReferenceNode(node) && ts.isQualifiedName(node.typeName) ? node.typeName.right : node;
errorOrSuggestion(/* isError */ false, diagLocation, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
errorOrSuggestion(/* isError */ false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName);
}
if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
Expand Down Expand Up @@ -74372,9 +74399,7 @@ var ts;
&& !(node.flags & 8388608 /* Ambient */)) {
error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
}
if (ts.isImportSpecifier(node) &&
(target.valueDeclaration && target.valueDeclaration.flags & 134217728 /* Deprecated */
|| ts.every(target.declarations, function (d) { return !!(d.flags & 134217728 /* Deprecated */); }))) {
if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); })) {
errorOrSuggestion(/* isError */ false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4306,6 +4306,7 @@ declare namespace ts {
function isTypeLiteralNode(node: Node): node is TypeLiteralNode;
function isArrayTypeNode(node: Node): node is ArrayTypeNode;
function isTupleTypeNode(node: Node): node is TupleTypeNode;
function isNamedTupleMember(node: Node): node is NamedTupleMember;
function isOptionalTypeNode(node: Node): node is OptionalTypeNode;
function isRestTypeNode(node: Node): node is RestTypeNode;
function isUnionTypeNode(node: Node): node is UnionTypeNode;
Expand Down
37 changes: 31 additions & 6 deletions lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -25640,6 +25640,10 @@ var ts;
return node.kind === 178 /* TupleType */;
}
ts.isTupleTypeNode = isTupleTypeNode;
function isNamedTupleMember(node) {
return node.kind === 191 /* NamedTupleMember */;
}
ts.isNamedTupleMember = isNamedTupleMember;
function isOptionalTypeNode(node) {
return node.kind === 179 /* OptionalType */;
}
Expand Down Expand Up @@ -67562,7 +67566,31 @@ var ts;
}
function checkDeprecatedSignature(signature, node) {
if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) {
errorOrSuggestion(/*isError*/ false, node, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
var suggestionNode = getDeprecatedSuggestionNode(node);
errorOrSuggestion(/*isError*/ false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
}
}
function getDeprecatedSuggestionNode(node) {
node = ts.skipParentheses(node);
switch (node.kind) {
case 200 /* CallExpression */:
case 160 /* Decorator */:
case 201 /* NewExpression */:
return getDeprecatedSuggestionNode(node.expression);
case 202 /* TaggedTemplateExpression */:
return getDeprecatedSuggestionNode(node.tag);
case 272 /* JsxOpeningElement */:
case 271 /* JsxSelfClosingElement */:
return getDeprecatedSuggestionNode(node.tagName);
case 199 /* ElementAccessExpression */:
return node.argumentExpression;
case 198 /* PropertyAccessExpression */:
return node.name;
case 172 /* TypeReference */:
var typeReference = node;
return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference;
default:
return node;
}
}
function isSymbolOrSymbolForCall(node) {
Expand Down Expand Up @@ -70668,8 +70696,7 @@ var ts;
var symbol = getNodeLinks(node).resolvedSymbol;
if (symbol) {
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) {
var diagLocation = ts.isTypeReferenceNode(node) && ts.isQualifiedName(node.typeName) ? node.typeName.right : node;
errorOrSuggestion(/* isError */ false, diagLocation, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
errorOrSuggestion(/* isError */ false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName);
}
if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
Expand Down Expand Up @@ -74566,9 +74593,7 @@ var ts;
&& !(node.flags & 8388608 /* Ambient */)) {
error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
}
if (ts.isImportSpecifier(node) &&
(target.valueDeclaration && target.valueDeclaration.flags & 134217728 /* Deprecated */
|| ts.every(target.declarations, function (d) { return !!(d.flags & 134217728 /* Deprecated */); }))) {
if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); })) {
errorOrSuggestion(/* isError */ false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4306,6 +4306,7 @@ declare namespace ts {
function isTypeLiteralNode(node: Node): node is TypeLiteralNode;
function isArrayTypeNode(node: Node): node is ArrayTypeNode;
function isTupleTypeNode(node: Node): node is TupleTypeNode;
function isNamedTupleMember(node: Node): node is NamedTupleMember;
function isOptionalTypeNode(node: Node): node is OptionalTypeNode;
function isRestTypeNode(node: Node): node is RestTypeNode;
function isUnionTypeNode(node: Node): node is UnionTypeNode;
Expand Down
37 changes: 31 additions & 6 deletions lib/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -25640,6 +25640,10 @@ var ts;
return node.kind === 178 /* TupleType */;
}
ts.isTupleTypeNode = isTupleTypeNode;
function isNamedTupleMember(node) {
return node.kind === 191 /* NamedTupleMember */;
}
ts.isNamedTupleMember = isNamedTupleMember;
function isOptionalTypeNode(node) {
return node.kind === 179 /* OptionalType */;
}
Expand Down Expand Up @@ -67562,7 +67566,31 @@ var ts;
}
function checkDeprecatedSignature(signature, node) {
if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) {
errorOrSuggestion(/*isError*/ false, node, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
var suggestionNode = getDeprecatedSuggestionNode(node);
errorOrSuggestion(/*isError*/ false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
}
}
function getDeprecatedSuggestionNode(node) {
node = ts.skipParentheses(node);
switch (node.kind) {
case 200 /* CallExpression */:
case 160 /* Decorator */:
case 201 /* NewExpression */:
return getDeprecatedSuggestionNode(node.expression);
case 202 /* TaggedTemplateExpression */:
return getDeprecatedSuggestionNode(node.tag);
case 272 /* JsxOpeningElement */:
case 271 /* JsxSelfClosingElement */:
return getDeprecatedSuggestionNode(node.tagName);
case 199 /* ElementAccessExpression */:
return node.argumentExpression;
case 198 /* PropertyAccessExpression */:
return node.name;
case 172 /* TypeReference */:
var typeReference = node;
return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference;
default:
return node;
}
}
function isSymbolOrSymbolForCall(node) {
Expand Down Expand Up @@ -70668,8 +70696,7 @@ var ts;
var symbol = getNodeLinks(node).resolvedSymbol;
if (symbol) {
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) {
var diagLocation = ts.isTypeReferenceNode(node) && ts.isQualifiedName(node.typeName) ? node.typeName.right : node;
errorOrSuggestion(/* isError */ false, diagLocation, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
errorOrSuggestion(/* isError */ false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName);
}
if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
Expand Down Expand Up @@ -74566,9 +74593,7 @@ var ts;
&& !(node.flags & 8388608 /* Ambient */)) {
error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
}
if (ts.isImportSpecifier(node) &&
(target.valueDeclaration && target.valueDeclaration.flags & 134217728 /* Deprecated */
|| ts.every(target.declarations, function (d) { return !!(d.flags & 134217728 /* Deprecated */); }))) {
if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); })) {
errorOrSuggestion(/* isError */ false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/typescriptServices.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4306,6 +4306,7 @@ declare namespace ts {
function isTypeLiteralNode(node: Node): node is TypeLiteralNode;
function isArrayTypeNode(node: Node): node is ArrayTypeNode;
function isTupleTypeNode(node: Node): node is TupleTypeNode;
function isNamedTupleMember(node: Node): node is NamedTupleMember;
function isOptionalTypeNode(node: Node): node is OptionalTypeNode;
function isRestTypeNode(node: Node): node is RestTypeNode;
function isUnionTypeNode(node: Node): node is UnionTypeNode;
Expand Down
Loading

0 comments on commit 6620b25

Please sign in to comment.