Skip to content

Commit

Permalink
Update LKG.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRosenwasser committed May 15, 2019
1 parent ff74180 commit c0bbb9b
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 77 deletions.
32 changes: 24 additions & 8 deletions lib/tsc.js
Expand Up @@ -33758,8 +33758,7 @@ var ts;
function getSimplifiedType(type, writing) {
return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type, writing) :
type.flags & 16777216 ? getSimplifiedConditionalType(type, writing) :
type.flags & 33554432 ? writing ? type.typeVariable : type.substitute :
type;
type;
}
function distributeIndexOverObjectType(objectType, indexType, writing) {
if (objectType.flags & 3145728) {
Expand Down Expand Up @@ -35512,7 +35511,7 @@ var ts;
var depth = 0;
var expandingFlags = 0;
var overflow = false;
var suppressNextError = false;
var overrideNextErrorInfo;
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
var result = isRelatedTo(source, target, !!errorNode, headMessage);
if (overflow) {
Expand Down Expand Up @@ -35618,10 +35617,16 @@ var ts;
if (isFreshLiteralType(target)) {
target = target.regularType;
}
if (source.flags & 58720256) {
if (source.flags & 33554432) {
source = source.substitute;
}
if (target.flags & 33554432) {
target = target.typeVariable;
}
if (source.flags & 25165824) {
source = getSimplifiedType(source, false);
}
if (target.flags & 58720256) {
if (target.flags & 25165824) {
target = getSimplifiedType(target, true);
}
if (target.flags & 1048576 && source.flags & 524288 &&
Expand Down Expand Up @@ -35713,10 +35718,14 @@ var ts;
}
}
if (!result && reportErrors) {
var maybeSuppress = suppressNextError;
suppressNextError = false;
var maybeSuppress = overrideNextErrorInfo;
overrideNextErrorInfo = undefined;
if (source.flags & 524288 && target.flags & 524288) {
var currentError = errorInfo;
tryElaborateArrayLikeErrors(source, target, reportErrors);
if (errorInfo !== currentError) {
maybeSuppress = errorInfo;
}
}
if (source.flags & 524288 && target.flags & 131068) {
tryElaborateErrorsForPrimitivesAndObjects(source, target);
Expand Down Expand Up @@ -36501,16 +36510,20 @@ var ts;
if (unmatchedProperty) {
if (reportErrors) {
var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, false));
var shouldSkipElaboration = false;
if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
suppressNextError = true;
shouldSkipElaboration = true;
}
if (props.length === 1) {
var propName = symbolToString(unmatchedProperty);
reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target)));
if (ts.length(unmatchedProperty.declarations)) {
associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
}
if (shouldSkipElaboration) {
overrideNextErrorInfo = errorInfo;
}
}
else if (tryElaborateArrayLikeErrors(source, target, false)) {
if (props.length > 5) {
Expand All @@ -36519,6 +36532,9 @@ var ts;
else {
reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", "));
}
if (shouldSkipElaboration) {
overrideNextErrorInfo = errorInfo;
}
}
}
return 0;
Expand Down
54 changes: 39 additions & 15 deletions lib/tsserver.js
Expand Up @@ -3500,7 +3500,7 @@ var ts;
/* @internal */
TypeFlags[TypeFlags["ObjectFlagsType"] = 3899392] = "ObjectFlagsType";
/* @internal */
TypeFlags[TypeFlags["Simplifiable"] = 58720256] = "Simplifiable";
TypeFlags[TypeFlags["Simplifiable"] = 25165824] = "Simplifiable";
// 'Narrowable' types are types where narrowing actually narrows.
// This *should* be every type other than null, undefined, void, and never
TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable";
Expand Down Expand Up @@ -40634,8 +40634,7 @@ var ts;
function getSimplifiedType(type, writing) {
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
type.flags & 33554432 /* Substitution */ ? writing ? type.typeVariable : type.substitute :
type;
type;
}
function distributeIndexOverObjectType(objectType, indexType, writing) {
// (T | U)[K] -> T[K] | U[K] (reading)
Expand Down Expand Up @@ -42612,7 +42611,7 @@ var ts;
var depth = 0;
var expandingFlags = 0 /* None */;
var overflow = false;
var suppressNextError = false;
var overrideNextErrorInfo;
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage);
if (overflow) {
Expand Down Expand Up @@ -42736,10 +42735,16 @@ var ts;
if (isFreshLiteralType(target)) {
target = target.regularType;
}
if (source.flags & 58720256 /* Simplifiable */) {
if (source.flags & 33554432 /* Substitution */) {
source = source.substitute;
}
if (target.flags & 33554432 /* Substitution */) {
target = target.typeVariable;
}
if (source.flags & 25165824 /* Simplifiable */) {
source = getSimplifiedType(source, /*writing*/ false);
}
if (target.flags & 58720256 /* Simplifiable */) {
if (target.flags & 25165824 /* Simplifiable */) {
target = getSimplifiedType(target, /*writing*/ true);
}
// Try to see if we're relating something like `Foo` -> `Bar | null | undefined`.
Expand Down Expand Up @@ -42868,10 +42873,14 @@ var ts;
}
}
if (!result && reportErrors) {
var maybeSuppress = suppressNextError;
suppressNextError = false;
var maybeSuppress = overrideNextErrorInfo;
overrideNextErrorInfo = undefined;
if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
var currentError = errorInfo;
tryElaborateArrayLikeErrors(source, target, reportErrors);
if (errorInfo !== currentError) {
maybeSuppress = errorInfo;
}
}
if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
tryElaborateErrorsForPrimitivesAndObjects(source, target);
Expand Down Expand Up @@ -43793,16 +43802,20 @@ var ts;
if (unmatchedProperty) {
if (reportErrors) {
var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false));
var shouldSkipElaboration = false;
if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
suppressNextError = true; // Retain top-level error for interface implementing issues, otherwise omit it
shouldSkipElaboration = true; // Retain top-level error for interface implementing issues, otherwise omit it
}
if (props.length === 1) {
var propName = symbolToString(unmatchedProperty);
reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target)));
if (ts.length(unmatchedProperty.declarations)) {
associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
}
if (shouldSkipElaboration) {
overrideNextErrorInfo = errorInfo;
}
}
else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) {
if (props.length > 5) { // arbitrary cutoff for too-long list form
Expand All @@ -43811,7 +43824,11 @@ var ts;
else {
reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", "));
}
if (shouldSkipElaboration) {
overrideNextErrorInfo = errorInfo;
}
}
// ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined)
}
return 0 /* False */;
}
Expand Down Expand Up @@ -121633,30 +121650,37 @@ var ts;
return undefined;
}
var typeChecker = program.getTypeChecker();
var symbol = getSymbolAtLocationForQuickInfo(node, typeChecker);
var nodeForQuickInfo = getNodeForQuickInfo(node);
var symbol = getSymbolAtLocationForQuickInfo(nodeForQuickInfo, typeChecker);
if (!symbol || typeChecker.isUnknownSymbol(symbol)) {
var type_2 = shouldGetType(sourceFile, node, position) ? typeChecker.getTypeAtLocation(node) : undefined;
var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined;
return type_2 && {
kind: "" /* unknown */,
kindModifiers: "" /* none */,
textSpan: ts.createTextSpanFromNode(node, sourceFile),
displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(node)); }),
textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile),
displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }),
documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined,
tags: type_2.symbol ? type_2.symbol.getJsDocTags() : undefined
};
}
var _a = typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) {
return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, ts.getContainerNode(node), node);
return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, ts.getContainerNode(nodeForQuickInfo), nodeForQuickInfo);
}), symbolKind = _a.symbolKind, displayParts = _a.displayParts, documentation = _a.documentation, tags = _a.tags;
return {
kind: symbolKind,
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol),
textSpan: ts.createTextSpanFromNode(node, sourceFile),
textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile),
displayParts: displayParts,
documentation: documentation,
tags: tags,
};
}
function getNodeForQuickInfo(node) {
if (ts.isNewExpression(node.parent) && node.pos === node.parent.pos) {
return node.parent.expression;
}
return node;
}
function shouldGetType(sourceFile, node, position) {
switch (node.kind) {
case 73 /* Identifier */:
Expand Down

0 comments on commit c0bbb9b

Please sign in to comment.