From cf7b2d4ae91c4f27ba9ae7137ddf9a407815e590 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 28 May 2019 13:48:46 -0700 Subject: [PATCH] Bring #31486 and #31586 into `release-3.5` (#31634) * Defer union or intersection property type normalization (#31486) * Defer union or intersection property type normalization * Accept moved span * Update user baselines (#31615) * Cache widened types (#31586) * Cache widened types * Fix lint * Accept LKG --- lib/tsc.js | 107 ++++++++++++---- lib/tsserver.js | 115 ++++++++++++++---- lib/tsserverlibrary.js | 115 ++++++++++++++---- lib/typescript.js | 115 ++++++++++++++---- lib/typescriptServices.js | 115 ++++++++++++++---- lib/typingsInstaller.js | 115 ++++++++++++++---- src/compiler/checker.ts | 103 +++++++++++++--- src/compiler/types.ts | 5 + .../reference/intersectionTypeMembers.js | 34 ++++++ .../reference/intersectionTypeMembers.symbols | 55 +++++++++ .../reference/intersectionTypeMembers.types | 58 +++++++++ .../reference/noImplicitThisBigThis.js | 115 ++++++++++++++++++ .../reference/noImplicitThisBigThis.symbols | 99 +++++++++++++++ .../reference/noImplicitThisBigThis.types | 103 ++++++++++++++++ ...ormalizedIntersectionTooComplex.errors.txt | 6 +- .../reactTagNameComponentWithPropsNoOOM.js | 33 +++++ ...eactTagNameComponentWithPropsNoOOM.symbols | 32 +++++ .../reactTagNameComponentWithPropsNoOOM.types | 35 ++++++ .../reactTagNameComponentWithPropsNoOOM2.js | 33 +++++ ...actTagNameComponentWithPropsNoOOM2.symbols | 35 ++++++ ...reactTagNameComponentWithPropsNoOOM2.types | 36 ++++++ tests/baselines/reference/user/bluebird.log | 106 ++++++++-------- .../user/chrome-devtools-frontend.log | 9 +- tests/baselines/reference/user/webpack.log | 5 +- tests/cases/compiler/noImplicitThisBigThis.ts | 50 ++++++++ .../reactTagNameComponentWithPropsNoOOM.tsx | 13 ++ .../reactTagNameComponentWithPropsNoOOM2.tsx | 13 ++ .../intersection/intersectionTypeMembers.ts | 22 ++++ 28 files changed, 1460 insertions(+), 222 deletions(-) create mode 100644 tests/baselines/reference/noImplicitThisBigThis.js create mode 100644 tests/baselines/reference/noImplicitThisBigThis.symbols create mode 100644 tests/baselines/reference/noImplicitThisBigThis.types create mode 100644 tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.js create mode 100644 tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.symbols create mode 100644 tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.types create mode 100644 tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.js create mode 100644 tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.symbols create mode 100644 tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.types create mode 100644 tests/cases/compiler/noImplicitThisBigThis.ts create mode 100644 tests/cases/compiler/reactTagNameComponentWithPropsNoOOM.tsx create mode 100644 tests/cases/compiler/reactTagNameComponentWithPropsNoOOM2.tsx diff --git a/lib/tsc.js b/lib/tsc.js index 2cbf0416941d..fbb258864583 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -30321,7 +30321,19 @@ var ts; } return anyType; } + function getTypeOfSymbolWithDeferredType(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + } + return links.type; + } function getTypeOfSymbol(symbol) { + if (ts.getCheckFlags(symbol) & 65536) { + return getTypeOfSymbolWithDeferredType(symbol); + } if (ts.getCheckFlags(symbol) & 1) { return getTypeOfInstantiatedSymbol(symbol); } @@ -32062,7 +32074,14 @@ var ts; } result.declarations = declarations; result.nameType = nameType; - result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + if (propTypes.length > 2) { + result.checkFlags |= 65536; + result.deferralParent = containingType; + result.deferralConstituents = propTypes; + } + else { + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + } return result; } function getUnionOrIntersectionProperty(type, name) { @@ -35596,8 +35615,8 @@ var ts; } return false; } - function isIgnoredJsxProperty(source, sourceProp, targetMemberType) { - return ts.getObjectFlags(source) & 4096 && !(isUnhyphenatedJsxName(sourceProp.escapedName) || targetMemberType); + function isIgnoredJsxProperty(source, sourceProp) { + return ts.getObjectFlags(source) & 4096 && !isUnhyphenatedJsxName(sourceProp.escapedName); } function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; @@ -36546,6 +36565,43 @@ var ts; } return result || properties; } + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48); + var source = getTypeOfSourceProperty(sourceProp); + if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) { + var links = getSymbolLinks(targetProp); + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + var unionParent = !!(links.deferralParent.flags & 1048576); + var result_6 = unionParent ? 0 : -1; + var targetTypes = links.deferralConstituents; + for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { + var targetType = targetTypes_3[_i]; + var related = isRelatedTo(source, targetType, false, undefined, !unionParent); + if (!unionParent) { + if (!related) { + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + result_6 &= related; + } + else { + if (related) { + return related; + } + } + } + if (unionParent && !result_6 && targetIsOptional) { + result_6 = isRelatedTo(source, undefinedType); + } + if (unionParent && !result_6 && reportErrors) { + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + return result_6; + } + else { + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); @@ -36583,7 +36639,7 @@ var ts; } return 0; } - var related = isRelatedTo(getTypeOfSourceProperty(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(ts.getCheckFlags(targetProp) & 48)), reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -36684,9 +36740,6 @@ var ts; if (!(targetProp.flags & 4194304)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - if (isIgnoredJsxProperty(source, sourceProp, getTypeOfSymbol(targetProp))) { - continue; - } var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); if (!related) { return 0; @@ -36805,7 +36858,7 @@ var ts; var result = -1; for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (isIgnoredJsxProperty(source, prop, undefined)) { + if (isIgnoredJsxProperty(source, prop)) { continue; } if (prop.nameType && prop.nameType.flags & 8192) { @@ -37494,23 +37547,31 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (ts.getObjectFlags(type) & 393216) { + if (context === undefined && type.widened) { + return type.widened; + } + var result = void 0; if (type.flags & 98304) { - return anyType; + result = anyType; } - if (isObjectLiteralType(type)) { - return getWidenedTypeOfObjectLiteral(type, context); + else if (isObjectLiteralType(type)) { + result = getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 1048576) { + else if (type.flags & 1048576) { var unionContext_1 = context || createWideningContext(undefined, undefined, type.types); var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 ? t : getWidenedTypeWithContext(t, unionContext_1); }); - return getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1); + } + else if (type.flags & 2097152) { + result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - if (type.flags & 2097152) { - return getIntersectionType(ts.sameMap(type.types, getWidenedType)); + else if (isArrayType(type) || isTupleType(type)) { + result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } - if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + if (result && context === undefined) { + type.widened = result; } + return result || type; } return type; } @@ -45984,10 +46045,10 @@ var ts; case 249: case 252: case 251: - var result_6 = 0; + var result_7 = 0; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_6 |= getDeclarationSpaces(d); }); - return result_6; + ts.forEach(target.declarations, function (d) { result_7 |= getDeclarationSpaces(d); }); + return result_7; case 238: case 187: case 240: @@ -73263,13 +73324,13 @@ var ts; } var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile); if (oldSourceFile !== file && file.resolvedModules) { - var result_7 = []; + var result_8 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; var resolvedModule = file.resolvedModules.get(moduleName); - result_7.push(resolvedModule); + result_8.push(resolvedModule); } - return result_7; + return result_8; } var unknownModuleNames; var result; diff --git a/lib/tsserver.js b/lib/tsserver.js index 057eff6e2079..896699e5ad0f 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -3536,6 +3536,7 @@ var ts; CheckFlags[CheckFlags["ReverseMapped"] = 8192] = "ReverseMapped"; CheckFlags[CheckFlags["OptionalParameter"] = 16384] = "OptionalParameter"; CheckFlags[CheckFlags["RestParameter"] = 32768] = "RestParameter"; + CheckFlags[CheckFlags["DeferredType"] = 65536] = "DeferredType"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant"; CheckFlags[CheckFlags["Partial"] = 48] = "Partial"; @@ -36724,7 +36725,19 @@ var ts; // we have already reported an implicit any error so we don't report anything here. return anyType; } + function getTypeOfSymbolWithDeferredType(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + } + return links.type; + } function getTypeOfSymbol(symbol) { + if (ts.getCheckFlags(symbol) & 65536 /* DeferredType */) { + return getTypeOfSymbolWithDeferredType(symbol); + } if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } @@ -38744,7 +38757,15 @@ var ts; } result.declarations = declarations; result.nameType = nameType; - result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + if (propTypes.length > 2) { + // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed + result.checkFlags |= 65536 /* DeferredType */; + result.deferralParent = containingType; + result.deferralConstituents = propTypes; + } + else { + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + } return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -42690,8 +42711,8 @@ var ts; } return false; } - function isIgnoredJsxProperty(source, sourceProp, targetMemberType) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !(isUnhyphenatedJsxName(sourceProp.escapedName) || targetMemberType); + function isIgnoredJsxProperty(source, sourceProp) { + return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -43833,6 +43854,49 @@ var ts; } return result || properties; } + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var source = getTypeOfSourceProperty(sourceProp); + if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { + // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes + var links = getSymbolLinks(targetProp); + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); + var result_6 = unionParent ? 0 /* False */ : -1 /* True */; + var targetTypes = links.deferralConstituents; + for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { + var targetType = targetTypes_3[_i]; + var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, /*isIntersectionConstituent*/ !unionParent); + if (!unionParent) { + if (!related) { + // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + result_6 &= related; + } + else { + if (related) { + return related; + } + } + } + if (unionParent && !result_6 && targetIsOptional) { + result_6 = isRelatedTo(source, undefinedType); + } + if (unionParent && !result_6 && reportErrors) { + // The easiest way to get the right errors here is to un-defer (which may be costly) + // If it turns out this is too costly too often, we can replicate the error handling logic within + // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union + // type on which to hand discriminable properties, which we are expressly trying to avoid here) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + return result_6; + } + else { + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); @@ -43871,7 +43935,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isRelatedTo(getTypeOfSourceProperty(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(ts.getCheckFlags(targetProp) & 48 /* Partial */)), reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -43983,9 +44047,6 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - if (isIgnoredJsxProperty(source, sourceProp, getTypeOfSymbol(targetProp))) { - continue; - } var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); if (!related) { return 0 /* False */; @@ -44121,7 +44182,7 @@ var ts; var result = -1 /* True */; for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (isIgnoredJsxProperty(source, prop, /*targetMemberType*/ undefined)) { + if (isIgnoredJsxProperty(source, prop)) { continue; } // Skip over symbol-named members @@ -44933,26 +44994,34 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { + if (context === undefined && type.widened) { + return type.widened; + } + var result = void 0; if (type.flags & 98304 /* Nullable */) { - return anyType; + result = anyType; } - if (isObjectLiteralType(type)) { - return getWidenedTypeOfObjectLiteral(type, context); + else if (isObjectLiteralType(type)) { + result = getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - return getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + } + else if (type.flags & 2097152 /* Intersection */) { + result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - if (type.flags & 2097152 /* Intersection */) { - return getIntersectionType(ts.sameMap(type.types, getWidenedType)); + else if (isArrayType(type) || isTupleType(type)) { + result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } - if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + if (result && context === undefined) { + type.widened = result; } + return result || type; } return type; } @@ -54920,10 +54989,10 @@ var ts; case 249 /* ImportEqualsDeclaration */: case 252 /* NamespaceImport */: case 251 /* ImportClause */: - var result_6 = 0 /* None */; + var result_7 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_6 |= getDeclarationSpaces(d); }); - return result_6; + ts.forEach(target.declarations, function (d) { result_7 |= getDeclarationSpaces(d); }); + return result_7; case 238 /* VariableDeclaration */: case 187 /* BindingElement */: case 240 /* FunctionDeclaration */: @@ -89425,13 +89494,13 @@ var ts; // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - var result_7 = []; + var result_8 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; var resolvedModule = file.resolvedModules.get(moduleName); - result_7.push(resolvedModule); + result_8.push(resolvedModule); } - return result_7; + return result_8; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index aaf01702b969..3e0937a3bf6e 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -3535,6 +3535,7 @@ var ts; CheckFlags[CheckFlags["ReverseMapped"] = 8192] = "ReverseMapped"; CheckFlags[CheckFlags["OptionalParameter"] = 16384] = "OptionalParameter"; CheckFlags[CheckFlags["RestParameter"] = 32768] = "RestParameter"; + CheckFlags[CheckFlags["DeferredType"] = 65536] = "DeferredType"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant"; CheckFlags[CheckFlags["Partial"] = 48] = "Partial"; @@ -36723,7 +36724,19 @@ var ts; // we have already reported an implicit any error so we don't report anything here. return anyType; } + function getTypeOfSymbolWithDeferredType(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + } + return links.type; + } function getTypeOfSymbol(symbol) { + if (ts.getCheckFlags(symbol) & 65536 /* DeferredType */) { + return getTypeOfSymbolWithDeferredType(symbol); + } if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } @@ -38743,7 +38756,15 @@ var ts; } result.declarations = declarations; result.nameType = nameType; - result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + if (propTypes.length > 2) { + // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed + result.checkFlags |= 65536 /* DeferredType */; + result.deferralParent = containingType; + result.deferralConstituents = propTypes; + } + else { + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + } return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -42689,8 +42710,8 @@ var ts; } return false; } - function isIgnoredJsxProperty(source, sourceProp, targetMemberType) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !(isUnhyphenatedJsxName(sourceProp.escapedName) || targetMemberType); + function isIgnoredJsxProperty(source, sourceProp) { + return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -43832,6 +43853,49 @@ var ts; } return result || properties; } + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var source = getTypeOfSourceProperty(sourceProp); + if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { + // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes + var links = getSymbolLinks(targetProp); + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); + var result_6 = unionParent ? 0 /* False */ : -1 /* True */; + var targetTypes = links.deferralConstituents; + for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { + var targetType = targetTypes_3[_i]; + var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, /*isIntersectionConstituent*/ !unionParent); + if (!unionParent) { + if (!related) { + // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + result_6 &= related; + } + else { + if (related) { + return related; + } + } + } + if (unionParent && !result_6 && targetIsOptional) { + result_6 = isRelatedTo(source, undefinedType); + } + if (unionParent && !result_6 && reportErrors) { + // The easiest way to get the right errors here is to un-defer (which may be costly) + // If it turns out this is too costly too often, we can replicate the error handling logic within + // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union + // type on which to hand discriminable properties, which we are expressly trying to avoid here) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + return result_6; + } + else { + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); @@ -43870,7 +43934,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isRelatedTo(getTypeOfSourceProperty(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(ts.getCheckFlags(targetProp) & 48 /* Partial */)), reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -43982,9 +44046,6 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - if (isIgnoredJsxProperty(source, sourceProp, getTypeOfSymbol(targetProp))) { - continue; - } var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); if (!related) { return 0 /* False */; @@ -44120,7 +44181,7 @@ var ts; var result = -1 /* True */; for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (isIgnoredJsxProperty(source, prop, /*targetMemberType*/ undefined)) { + if (isIgnoredJsxProperty(source, prop)) { continue; } // Skip over symbol-named members @@ -44932,26 +44993,34 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { + if (context === undefined && type.widened) { + return type.widened; + } + var result = void 0; if (type.flags & 98304 /* Nullable */) { - return anyType; + result = anyType; } - if (isObjectLiteralType(type)) { - return getWidenedTypeOfObjectLiteral(type, context); + else if (isObjectLiteralType(type)) { + result = getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - return getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + } + else if (type.flags & 2097152 /* Intersection */) { + result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - if (type.flags & 2097152 /* Intersection */) { - return getIntersectionType(ts.sameMap(type.types, getWidenedType)); + else if (isArrayType(type) || isTupleType(type)) { + result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } - if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + if (result && context === undefined) { + type.widened = result; } + return result || type; } return type; } @@ -54919,10 +54988,10 @@ var ts; case 249 /* ImportEqualsDeclaration */: case 252 /* NamespaceImport */: case 251 /* ImportClause */: - var result_6 = 0 /* None */; + var result_7 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_6 |= getDeclarationSpaces(d); }); - return result_6; + ts.forEach(target.declarations, function (d) { result_7 |= getDeclarationSpaces(d); }); + return result_7; case 238 /* VariableDeclaration */: case 187 /* BindingElement */: case 240 /* FunctionDeclaration */: @@ -89424,13 +89493,13 @@ var ts; // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - var result_7 = []; + var result_8 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; var resolvedModule = file.resolvedModules.get(moduleName); - result_7.push(resolvedModule); + result_8.push(resolvedModule); } - return result_7; + return result_8; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules diff --git a/lib/typescript.js b/lib/typescript.js index 6ccbd71858bf..5b5ad499a823 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -3524,6 +3524,7 @@ var ts; CheckFlags[CheckFlags["ReverseMapped"] = 8192] = "ReverseMapped"; CheckFlags[CheckFlags["OptionalParameter"] = 16384] = "OptionalParameter"; CheckFlags[CheckFlags["RestParameter"] = 32768] = "RestParameter"; + CheckFlags[CheckFlags["DeferredType"] = 65536] = "DeferredType"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant"; CheckFlags[CheckFlags["Partial"] = 48] = "Partial"; @@ -36712,7 +36713,19 @@ var ts; // we have already reported an implicit any error so we don't report anything here. return anyType; } + function getTypeOfSymbolWithDeferredType(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + } + return links.type; + } function getTypeOfSymbol(symbol) { + if (ts.getCheckFlags(symbol) & 65536 /* DeferredType */) { + return getTypeOfSymbolWithDeferredType(symbol); + } if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } @@ -38732,7 +38745,15 @@ var ts; } result.declarations = declarations; result.nameType = nameType; - result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + if (propTypes.length > 2) { + // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed + result.checkFlags |= 65536 /* DeferredType */; + result.deferralParent = containingType; + result.deferralConstituents = propTypes; + } + else { + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + } return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -42678,8 +42699,8 @@ var ts; } return false; } - function isIgnoredJsxProperty(source, sourceProp, targetMemberType) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !(isUnhyphenatedJsxName(sourceProp.escapedName) || targetMemberType); + function isIgnoredJsxProperty(source, sourceProp) { + return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -43821,6 +43842,49 @@ var ts; } return result || properties; } + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var source = getTypeOfSourceProperty(sourceProp); + if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { + // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes + var links = getSymbolLinks(targetProp); + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); + var result_6 = unionParent ? 0 /* False */ : -1 /* True */; + var targetTypes = links.deferralConstituents; + for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { + var targetType = targetTypes_3[_i]; + var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, /*isIntersectionConstituent*/ !unionParent); + if (!unionParent) { + if (!related) { + // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + result_6 &= related; + } + else { + if (related) { + return related; + } + } + } + if (unionParent && !result_6 && targetIsOptional) { + result_6 = isRelatedTo(source, undefinedType); + } + if (unionParent && !result_6 && reportErrors) { + // The easiest way to get the right errors here is to un-defer (which may be costly) + // If it turns out this is too costly too often, we can replicate the error handling logic within + // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union + // type on which to hand discriminable properties, which we are expressly trying to avoid here) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + return result_6; + } + else { + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); @@ -43859,7 +43923,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isRelatedTo(getTypeOfSourceProperty(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(ts.getCheckFlags(targetProp) & 48 /* Partial */)), reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -43971,9 +44035,6 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - if (isIgnoredJsxProperty(source, sourceProp, getTypeOfSymbol(targetProp))) { - continue; - } var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); if (!related) { return 0 /* False */; @@ -44109,7 +44170,7 @@ var ts; var result = -1 /* True */; for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (isIgnoredJsxProperty(source, prop, /*targetMemberType*/ undefined)) { + if (isIgnoredJsxProperty(source, prop)) { continue; } // Skip over symbol-named members @@ -44921,26 +44982,34 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { + if (context === undefined && type.widened) { + return type.widened; + } + var result = void 0; if (type.flags & 98304 /* Nullable */) { - return anyType; + result = anyType; } - if (isObjectLiteralType(type)) { - return getWidenedTypeOfObjectLiteral(type, context); + else if (isObjectLiteralType(type)) { + result = getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - return getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + } + else if (type.flags & 2097152 /* Intersection */) { + result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - if (type.flags & 2097152 /* Intersection */) { - return getIntersectionType(ts.sameMap(type.types, getWidenedType)); + else if (isArrayType(type) || isTupleType(type)) { + result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } - if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + if (result && context === undefined) { + type.widened = result; } + return result || type; } return type; } @@ -54908,10 +54977,10 @@ var ts; case 249 /* ImportEqualsDeclaration */: case 252 /* NamespaceImport */: case 251 /* ImportClause */: - var result_6 = 0 /* None */; + var result_7 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_6 |= getDeclarationSpaces(d); }); - return result_6; + ts.forEach(target.declarations, function (d) { result_7 |= getDeclarationSpaces(d); }); + return result_7; case 238 /* VariableDeclaration */: case 187 /* BindingElement */: case 240 /* FunctionDeclaration */: @@ -89413,13 +89482,13 @@ var ts; // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - var result_7 = []; + var result_8 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; var resolvedModule = file.resolvedModules.get(moduleName); - result_7.push(resolvedModule); + result_8.push(resolvedModule); } - return result_7; + return result_8; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 10dfdc8afff2..01f0275f24b0 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -3524,6 +3524,7 @@ var ts; CheckFlags[CheckFlags["ReverseMapped"] = 8192] = "ReverseMapped"; CheckFlags[CheckFlags["OptionalParameter"] = 16384] = "OptionalParameter"; CheckFlags[CheckFlags["RestParameter"] = 32768] = "RestParameter"; + CheckFlags[CheckFlags["DeferredType"] = 65536] = "DeferredType"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant"; CheckFlags[CheckFlags["Partial"] = 48] = "Partial"; @@ -36712,7 +36713,19 @@ var ts; // we have already reported an implicit any error so we don't report anything here. return anyType; } + function getTypeOfSymbolWithDeferredType(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + } + return links.type; + } function getTypeOfSymbol(symbol) { + if (ts.getCheckFlags(symbol) & 65536 /* DeferredType */) { + return getTypeOfSymbolWithDeferredType(symbol); + } if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } @@ -38732,7 +38745,15 @@ var ts; } result.declarations = declarations; result.nameType = nameType; - result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + if (propTypes.length > 2) { + // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed + result.checkFlags |= 65536 /* DeferredType */; + result.deferralParent = containingType; + result.deferralConstituents = propTypes; + } + else { + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + } return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -42678,8 +42699,8 @@ var ts; } return false; } - function isIgnoredJsxProperty(source, sourceProp, targetMemberType) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !(isUnhyphenatedJsxName(sourceProp.escapedName) || targetMemberType); + function isIgnoredJsxProperty(source, sourceProp) { + return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -43821,6 +43842,49 @@ var ts; } return result || properties; } + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var source = getTypeOfSourceProperty(sourceProp); + if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { + // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes + var links = getSymbolLinks(targetProp); + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); + var result_6 = unionParent ? 0 /* False */ : -1 /* True */; + var targetTypes = links.deferralConstituents; + for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { + var targetType = targetTypes_3[_i]; + var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, /*isIntersectionConstituent*/ !unionParent); + if (!unionParent) { + if (!related) { + // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + result_6 &= related; + } + else { + if (related) { + return related; + } + } + } + if (unionParent && !result_6 && targetIsOptional) { + result_6 = isRelatedTo(source, undefinedType); + } + if (unionParent && !result_6 && reportErrors) { + // The easiest way to get the right errors here is to un-defer (which may be costly) + // If it turns out this is too costly too often, we can replicate the error handling logic within + // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union + // type on which to hand discriminable properties, which we are expressly trying to avoid here) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + return result_6; + } + else { + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); @@ -43859,7 +43923,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isRelatedTo(getTypeOfSourceProperty(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(ts.getCheckFlags(targetProp) & 48 /* Partial */)), reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -43971,9 +44035,6 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - if (isIgnoredJsxProperty(source, sourceProp, getTypeOfSymbol(targetProp))) { - continue; - } var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); if (!related) { return 0 /* False */; @@ -44109,7 +44170,7 @@ var ts; var result = -1 /* True */; for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (isIgnoredJsxProperty(source, prop, /*targetMemberType*/ undefined)) { + if (isIgnoredJsxProperty(source, prop)) { continue; } // Skip over symbol-named members @@ -44921,26 +44982,34 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { + if (context === undefined && type.widened) { + return type.widened; + } + var result = void 0; if (type.flags & 98304 /* Nullable */) { - return anyType; + result = anyType; } - if (isObjectLiteralType(type)) { - return getWidenedTypeOfObjectLiteral(type, context); + else if (isObjectLiteralType(type)) { + result = getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - return getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + } + else if (type.flags & 2097152 /* Intersection */) { + result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - if (type.flags & 2097152 /* Intersection */) { - return getIntersectionType(ts.sameMap(type.types, getWidenedType)); + else if (isArrayType(type) || isTupleType(type)) { + result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } - if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + if (result && context === undefined) { + type.widened = result; } + return result || type; } return type; } @@ -54908,10 +54977,10 @@ var ts; case 249 /* ImportEqualsDeclaration */: case 252 /* NamespaceImport */: case 251 /* ImportClause */: - var result_6 = 0 /* None */; + var result_7 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_6 |= getDeclarationSpaces(d); }); - return result_6; + ts.forEach(target.declarations, function (d) { result_7 |= getDeclarationSpaces(d); }); + return result_7; case 238 /* VariableDeclaration */: case 187 /* BindingElement */: case 240 /* FunctionDeclaration */: @@ -89413,13 +89482,13 @@ var ts; // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - var result_7 = []; + var result_8 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; var resolvedModule = file.resolvedModules.get(moduleName); - result_7.push(resolvedModule); + result_8.push(resolvedModule); } - return result_7; + return result_8; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 59e24f28256a..37631477ac80 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -3525,6 +3525,7 @@ var ts; CheckFlags[CheckFlags["ReverseMapped"] = 8192] = "ReverseMapped"; CheckFlags[CheckFlags["OptionalParameter"] = 16384] = "OptionalParameter"; CheckFlags[CheckFlags["RestParameter"] = 32768] = "RestParameter"; + CheckFlags[CheckFlags["DeferredType"] = 65536] = "DeferredType"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant"; CheckFlags[CheckFlags["Partial"] = 48] = "Partial"; @@ -36713,7 +36714,19 @@ var ts; // we have already reported an implicit any error so we don't report anything here. return anyType; } + function getTypeOfSymbolWithDeferredType(symbol) { + var links = getSymbolLinks(symbol); + if (!links.type) { + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + } + return links.type; + } function getTypeOfSymbol(symbol) { + if (ts.getCheckFlags(symbol) & 65536 /* DeferredType */) { + return getTypeOfSymbolWithDeferredType(symbol); + } if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } @@ -38733,7 +38746,15 @@ var ts; } result.declarations = declarations; result.nameType = nameType; - result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + if (propTypes.length > 2) { + // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed + result.checkFlags |= 65536 /* DeferredType */; + result.deferralParent = containingType; + result.deferralConstituents = propTypes; + } + else { + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + } return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -42679,8 +42700,8 @@ var ts; } return false; } - function isIgnoredJsxProperty(source, sourceProp, targetMemberType) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !(isUnhyphenatedJsxName(sourceProp.escapedName) || targetMemberType); + function isIgnoredJsxProperty(source, sourceProp) { + return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -43822,6 +43843,49 @@ var ts; } return result || properties; } + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var source = getTypeOfSourceProperty(sourceProp); + if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { + // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes + var links = getSymbolLinks(targetProp); + ts.Debug.assertDefined(links.deferralParent); + ts.Debug.assertDefined(links.deferralConstituents); + var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); + var result_6 = unionParent ? 0 /* False */ : -1 /* True */; + var targetTypes = links.deferralConstituents; + for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { + var targetType = targetTypes_3[_i]; + var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, /*isIntersectionConstituent*/ !unionParent); + if (!unionParent) { + if (!related) { + // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + result_6 &= related; + } + else { + if (related) { + return related; + } + } + } + if (unionParent && !result_6 && targetIsOptional) { + result_6 = isRelatedTo(source, undefinedType); + } + if (unionParent && !result_6 && reportErrors) { + // The easiest way to get the right errors here is to un-defer (which may be costly) + // If it turns out this is too costly too often, we can replicate the error handling logic within + // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union + // type on which to hand discriminable properties, which we are expressly trying to avoid here) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + return result_6; + } + else { + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); @@ -43860,7 +43924,7 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isRelatedTo(getTypeOfSourceProperty(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(ts.getCheckFlags(targetProp) & 48 /* Partial */)), reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -43972,9 +44036,6 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - if (isIgnoredJsxProperty(source, sourceProp, getTypeOfSymbol(targetProp))) { - continue; - } var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); if (!related) { return 0 /* False */; @@ -44110,7 +44171,7 @@ var ts; var result = -1 /* True */; for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; - if (isIgnoredJsxProperty(source, prop, /*targetMemberType*/ undefined)) { + if (isIgnoredJsxProperty(source, prop)) { continue; } // Skip over symbol-named members @@ -44922,26 +44983,34 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { + if (context === undefined && type.widened) { + return type.widened; + } + var result = void 0; if (type.flags & 98304 /* Nullable */) { - return anyType; + result = anyType; } - if (isObjectLiteralType(type)) { - return getWidenedTypeOfObjectLiteral(type, context); + else if (isObjectLiteralType(type)) { + result = getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - return getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + } + else if (type.flags & 2097152 /* Intersection */) { + result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } - if (type.flags & 2097152 /* Intersection */) { - return getIntersectionType(ts.sameMap(type.types, getWidenedType)); + else if (isArrayType(type) || isTupleType(type)) { + result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } - if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + if (result && context === undefined) { + type.widened = result; } + return result || type; } return type; } @@ -54909,10 +54978,10 @@ var ts; case 249 /* ImportEqualsDeclaration */: case 252 /* NamespaceImport */: case 251 /* ImportClause */: - var result_6 = 0 /* None */; + var result_7 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_6 |= getDeclarationSpaces(d); }); - return result_6; + ts.forEach(target.declarations, function (d) { result_7 |= getDeclarationSpaces(d); }); + return result_7; case 238 /* VariableDeclaration */: case 187 /* BindingElement */: case 240 /* FunctionDeclaration */: @@ -89414,13 +89483,13 @@ var ts; // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - var result_7 = []; + var result_8 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; var resolvedModule = file.resolvedModules.get(moduleName); - result_7.push(resolvedModule); + result_8.push(resolvedModule); } - return result_7; + return result_8; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5091f5f03063..85b3641f0041 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5921,7 +5921,20 @@ namespace ts { return anyType; } + function getTypeOfSymbolWithDeferredType(symbol: Symbol) { + const links = getSymbolLinks(symbol); + if (!links.type) { + Debug.assertDefined(links.deferralParent); + Debug.assertDefined(links.deferralConstituents); + links.type = links.deferralParent!.flags & TypeFlags.Union ? getUnionType(links.deferralConstituents!) : getIntersectionType(links.deferralConstituents!); + } + return links.type; + } + function getTypeOfSymbol(symbol: Symbol): Type { + if (getCheckFlags(symbol) & CheckFlags.DeferredType) { + return getTypeOfSymbolWithDeferredType(symbol); + } if (getCheckFlags(symbol) & CheckFlags.Instantiated) { return getTypeOfInstantiatedSymbol(symbol); } @@ -8061,7 +8074,15 @@ namespace ts { result.declarations = declarations!; result.nameType = nameType; - result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + if (propTypes.length > 2) { + // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed + result.checkFlags |= CheckFlags.DeferredType; + result.deferralParent = containingType; + result.deferralConstituents = propTypes; + } + else { + result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); + } return result; } @@ -12313,8 +12334,8 @@ namespace ts { return false; } - function isIgnoredJsxProperty(source: Type, sourceProp: Symbol, targetMemberType: Type | undefined) { - return getObjectFlags(source) & ObjectFlags.JsxAttributes && !(isUnhyphenatedJsxName(sourceProp.escapedName) || targetMemberType); + function isIgnoredJsxProperty(source: Type, sourceProp: Symbol) { + return getObjectFlags(source) & ObjectFlags.JsxAttributes && !isUnhyphenatedJsxName(sourceProp.escapedName); } /** @@ -13495,6 +13516,49 @@ namespace ts { return result || properties; } + function isPropertySymbolTypeRelated(sourceProp: Symbol, targetProp: Symbol, getTypeOfSourceProperty: (sym: Symbol) => Type, reportErrors: boolean): Ternary { + const targetIsOptional = strictNullChecks && !!(getCheckFlags(targetProp) & CheckFlags.Partial); + const source = getTypeOfSourceProperty(sourceProp); + if (getCheckFlags(targetProp) & CheckFlags.DeferredType && !getSymbolLinks(targetProp).type) { + // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes + const links = getSymbolLinks(targetProp); + Debug.assertDefined(links.deferralParent); + Debug.assertDefined(links.deferralConstituents); + const unionParent = !!(links.deferralParent!.flags & TypeFlags.Union); + let result = unionParent ? Ternary.False : Ternary.True; + const targetTypes = links.deferralConstituents!; + for (const targetType of targetTypes) { + const related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, /*isIntersectionConstituent*/ !unionParent); + if (!unionParent) { + if (!related) { + // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + result &= related; + } + else { + if (related) { + return related; + } + } + } + if (unionParent && !result && targetIsOptional) { + result = isRelatedTo(source, undefinedType); + } + if (unionParent && !result && reportErrors) { + // The easiest way to get the right errors here is to un-defer (which may be costly) + // If it turns out this is too costly too often, we can replicate the error handling logic within + // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union + // type on which to hand discriminable properties, which we are expressly trying to avoid here) + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + return result; + } + else { + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + } + } + function propertyRelatedTo(source: Type, target: Type, sourceProp: Symbol, targetProp: Symbol, getTypeOfSourceProperty: (sym: Symbol) => Type, reportErrors: boolean): Ternary { const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); @@ -13537,7 +13601,7 @@ namespace ts { return Ternary.False; } // If the target comes from a partial union prop, allow `undefined` in the target type - const related = isRelatedTo(getTypeOfSourceProperty(sourceProp), addOptionality(getTypeOfSymbol(targetProp), !!(getCheckFlags(targetProp) & CheckFlags.Partial)), reportErrors); + const related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); if (!related) { if (reportErrors) { reportError(Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); @@ -13649,9 +13713,6 @@ namespace ts { if (!(targetProp.flags & SymbolFlags.Prototype)) { const sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { - if (isIgnoredJsxProperty(source, sourceProp, getTypeOfSymbol(targetProp))) { - continue; - } const related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); if (!related) { return Ternary.False; @@ -13797,7 +13858,7 @@ namespace ts { function eachPropertyRelatedTo(source: Type, target: Type, kind: IndexKind, reportErrors: boolean): Ternary { let result = Ternary.True; for (const prop of getPropertiesOfObjectType(source)) { - if (isIgnoredJsxProperty(source, prop, /*targetMemberType*/ undefined)) { + if (isIgnoredJsxProperty(source, prop)) { continue; } // Skip over symbol-named members @@ -14679,26 +14740,34 @@ namespace ts { function getWidenedTypeWithContext(type: Type, context: WideningContext | undefined): Type { if (getObjectFlags(type) & ObjectFlags.RequiresWidening) { + if (context === undefined && type.widened) { + return type.widened; + } + let result: Type | undefined; if (type.flags & TypeFlags.Nullable) { - return anyType; + result = anyType; } - if (isObjectLiteralType(type)) { - return getWidenedTypeOfObjectLiteral(type, context); + else if (isObjectLiteralType(type)) { + result = getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & TypeFlags.Union) { + else if (type.flags & TypeFlags.Union) { const unionContext = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, (type).types); const widenedTypes = sameMap((type).types, t => t.flags & TypeFlags.Nullable ? t : getWidenedTypeWithContext(t, unionContext)); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - return getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType) ? UnionReduction.Subtype : UnionReduction.Literal); + result = getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType) ? UnionReduction.Subtype : UnionReduction.Literal); + } + else if (type.flags & TypeFlags.Intersection) { + result = getIntersectionType(sameMap((type).types, getWidenedType)); } - if (type.flags & TypeFlags.Intersection) { - return getIntersectionType(sameMap((type).types, getWidenedType)); + else if (isArrayType(type) || isTupleType(type)) { + result = createTypeReference((type).target, sameMap((type).typeArguments, getWidenedType)); } - if (isArrayType(type) || isTupleType(type)) { - return createTypeReference((type).target, sameMap((type).typeArguments, getWidenedType)); + if (result && context === undefined) { + type.widened = result; } + return result || type; } return type; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 03ca196a8608..cb646a0b6876 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3752,6 +3752,8 @@ namespace ts { extendedContainers?: Symbol[]; // Containers (other than the parent) which this symbol is aliased in extendedContainersByFile?: Map; // Containers (other than the parent) which this symbol is aliased in variances?: VarianceFlags[]; // Alias symbol type argument variance cache + deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type + deferralParent?: Type; // Source union/intersection of a deferred type } /* @internal */ @@ -3778,6 +3780,7 @@ namespace ts { ReverseMapped = 1 << 13, // Property of reverse-inferred homomorphic mapped type OptionalParameter = 1 << 14, // Optional parameter RestParameter = 1 << 15, // Rest parameter + DeferredType = 1 << 16, // Calculation of the type of this symbol is deferred due to processing costs, should be fetched with `getTypeOfSymbolWithDeferredType` Synthetic = SyntheticProperty | SyntheticMethod, Discriminant = HasNonUniformType | HasLiteralType, Partial = ReadPartial | WritePartial @@ -4010,6 +4013,8 @@ namespace ts { restrictiveInstantiation?: Type; // Instantiation with type parameters mapped to unconstrained form /* @internal */ immediateBaseConstraint?: Type; // Immediate base constraint cache + /* @internal */ + widened?: Type; // Cached widened form of the type } /* @internal */ diff --git a/tests/baselines/reference/intersectionTypeMembers.js b/tests/baselines/reference/intersectionTypeMembers.js index 59968b007db9..867a6f0fc66c 100644 --- a/tests/baselines/reference/intersectionTypeMembers.js +++ b/tests/baselines/reference/intersectionTypeMembers.js @@ -43,6 +43,28 @@ const de: D & E = { other: { g: 101 } } } + +// Additional test case with >2 doubly nested members so fix for #31441 is tested w/ excess props +interface F { + nested: { doublyNested: { g: string; } } +} + +interface G { + nested: { doublyNested: { h: string; } } +} + +const defg: D & E & F & G = { + nested: { + doublyNested: { + d: 'yes', + f: 'no', + g: 'ok', + h: 'affirmative' + }, + different: { e: 12 }, + other: { g: 101 } + } +} //// [intersectionTypeMembers.js] @@ -69,3 +91,15 @@ var de = { other: { g: 101 } } }; +var defg = { + nested: { + doublyNested: { + d: 'yes', + f: 'no', + g: 'ok', + h: 'affirmative' + }, + different: { e: 12 }, + other: { g: 101 } + } +}; diff --git a/tests/baselines/reference/intersectionTypeMembers.symbols b/tests/baselines/reference/intersectionTypeMembers.symbols index be47b2960db6..b4629d1659d9 100644 --- a/tests/baselines/reference/intersectionTypeMembers.symbols +++ b/tests/baselines/reference/intersectionTypeMembers.symbols @@ -146,3 +146,58 @@ const de: D & E = { } } +// Additional test case with >2 doubly nested members so fix for #31441 is tested w/ excess props +interface F { +>F : Symbol(F, Decl(intersectionTypeMembers.ts, 43, 1)) + + nested: { doublyNested: { g: string; } } +>nested : Symbol(F.nested, Decl(intersectionTypeMembers.ts, 46, 13)) +>doublyNested : Symbol(doublyNested, Decl(intersectionTypeMembers.ts, 47, 13)) +>g : Symbol(g, Decl(intersectionTypeMembers.ts, 47, 29)) +} + +interface G { +>G : Symbol(G, Decl(intersectionTypeMembers.ts, 48, 1)) + + nested: { doublyNested: { h: string; } } +>nested : Symbol(G.nested, Decl(intersectionTypeMembers.ts, 50, 13)) +>doublyNested : Symbol(doublyNested, Decl(intersectionTypeMembers.ts, 51, 13)) +>h : Symbol(h, Decl(intersectionTypeMembers.ts, 51, 29)) +} + +const defg: D & E & F & G = { +>defg : Symbol(defg, Decl(intersectionTypeMembers.ts, 54, 5)) +>D : Symbol(D, Decl(intersectionTypeMembers.ts, 26, 14)) +>E : Symbol(E, Decl(intersectionTypeMembers.ts, 30, 1)) +>F : Symbol(F, Decl(intersectionTypeMembers.ts, 43, 1)) +>G : Symbol(G, Decl(intersectionTypeMembers.ts, 48, 1)) + + nested: { +>nested : Symbol(nested, Decl(intersectionTypeMembers.ts, 54, 29)) + + doublyNested: { +>doublyNested : Symbol(doublyNested, Decl(intersectionTypeMembers.ts, 55, 13)) + + d: 'yes', +>d : Symbol(d, Decl(intersectionTypeMembers.ts, 56, 23)) + + f: 'no', +>f : Symbol(f, Decl(intersectionTypeMembers.ts, 57, 21)) + + g: 'ok', +>g : Symbol(g, Decl(intersectionTypeMembers.ts, 58, 20)) + + h: 'affirmative' +>h : Symbol(h, Decl(intersectionTypeMembers.ts, 59, 20)) + + }, + different: { e: 12 }, +>different : Symbol(different, Decl(intersectionTypeMembers.ts, 61, 10)) +>e : Symbol(e, Decl(intersectionTypeMembers.ts, 62, 20)) + + other: { g: 101 } +>other : Symbol(other, Decl(intersectionTypeMembers.ts, 62, 29)) +>g : Symbol(g, Decl(intersectionTypeMembers.ts, 63, 16)) + } +} + diff --git a/tests/baselines/reference/intersectionTypeMembers.types b/tests/baselines/reference/intersectionTypeMembers.types index eb9d5fa4eb85..817fa044624e 100644 --- a/tests/baselines/reference/intersectionTypeMembers.types +++ b/tests/baselines/reference/intersectionTypeMembers.types @@ -148,3 +148,61 @@ const de: D & E = { } } +// Additional test case with >2 doubly nested members so fix for #31441 is tested w/ excess props +interface F { + nested: { doublyNested: { g: string; } } +>nested : { doublyNested: { g: string; }; } +>doublyNested : { g: string; } +>g : string +} + +interface G { + nested: { doublyNested: { h: string; } } +>nested : { doublyNested: { h: string; }; } +>doublyNested : { h: string; } +>h : string +} + +const defg: D & E & F & G = { +>defg : D & E & F & G +>{ nested: { doublyNested: { d: 'yes', f: 'no', g: 'ok', h: 'affirmative' }, different: { e: 12 }, other: { g: 101 } }} : { nested: { doublyNested: { d: string; f: string; g: string; h: string; }; different: { e: number; }; other: { g: number; }; }; } + + nested: { +>nested : { doublyNested: { d: string; f: string; g: string; h: string; }; different: { e: number; }; other: { g: number; }; } +>{ doublyNested: { d: 'yes', f: 'no', g: 'ok', h: 'affirmative' }, different: { e: 12 }, other: { g: 101 } } : { doublyNested: { d: string; f: string; g: string; h: string; }; different: { e: number; }; other: { g: number; }; } + + doublyNested: { +>doublyNested : { d: string; f: string; g: string; h: string; } +>{ d: 'yes', f: 'no', g: 'ok', h: 'affirmative' } : { d: string; f: string; g: string; h: string; } + + d: 'yes', +>d : string +>'yes' : "yes" + + f: 'no', +>f : string +>'no' : "no" + + g: 'ok', +>g : string +>'ok' : "ok" + + h: 'affirmative' +>h : string +>'affirmative' : "affirmative" + + }, + different: { e: 12 }, +>different : { e: number; } +>{ e: 12 } : { e: number; } +>e : number +>12 : 12 + + other: { g: 101 } +>other : { g: number; } +>{ g: 101 } : { g: number; } +>g : number +>101 : 101 + } +} + diff --git a/tests/baselines/reference/noImplicitThisBigThis.js b/tests/baselines/reference/noImplicitThisBigThis.js new file mode 100644 index 000000000000..f2e633f2dcff --- /dev/null +++ b/tests/baselines/reference/noImplicitThisBigThis.js @@ -0,0 +1,115 @@ +//// [noImplicitThisBigThis.ts] +// https://github.com/microsoft/TypeScript/issues/29902 + +function createObj() { + return { + func1() { + return this; + }, + func2() { + return this; + }, + func3() { + return this; + } + }; +} + +function createObjNoCrash() { + return { + func1() { + return this; + }, + func2() { + return this; + }, + func3() { + return this; + }, + func4() { + return this; + }, + func5() { + return this; + }, + func6() { + return this; + }, + func7() { + return this; + }, + func8() { + return this; + }, + func9() { + return this; + } + }; +} + + +//// [noImplicitThisBigThis.js] +// https://github.com/microsoft/TypeScript/issues/29902 +function createObj() { + return { + func1: function () { + return this; + }, + func2: function () { + return this; + }, + func3: function () { + return this; + } + }; +} +function createObjNoCrash() { + return { + func1: function () { + return this; + }, + func2: function () { + return this; + }, + func3: function () { + return this; + }, + func4: function () { + return this; + }, + func5: function () { + return this; + }, + func6: function () { + return this; + }, + func7: function () { + return this; + }, + func8: function () { + return this; + }, + func9: function () { + return this; + } + }; +} + + +//// [noImplicitThisBigThis.d.ts] +declare function createObj(): { + func1(): any; + func2(): any; + func3(): any; +}; +declare function createObjNoCrash(): { + func1(): any; + func2(): any; + func3(): any; + func4(): any; + func5(): any; + func6(): any; + func7(): any; + func8(): any; + func9(): any; +}; diff --git a/tests/baselines/reference/noImplicitThisBigThis.symbols b/tests/baselines/reference/noImplicitThisBigThis.symbols new file mode 100644 index 000000000000..9f0c8c1bf243 --- /dev/null +++ b/tests/baselines/reference/noImplicitThisBigThis.symbols @@ -0,0 +1,99 @@ +=== tests/cases/compiler/noImplicitThisBigThis.ts === +// https://github.com/microsoft/TypeScript/issues/29902 + +function createObj() { +>createObj : Symbol(createObj, Decl(noImplicitThisBigThis.ts, 0, 0)) + + return { + func1() { +>func1 : Symbol(func1, Decl(noImplicitThisBigThis.ts, 3, 12)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 3, 10)) + + }, + func2() { +>func2 : Symbol(func2, Decl(noImplicitThisBigThis.ts, 6, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 3, 10)) + + }, + func3() { +>func3 : Symbol(func3, Decl(noImplicitThisBigThis.ts, 9, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 3, 10)) + } + }; +} + +function createObjNoCrash() { +>createObjNoCrash : Symbol(createObjNoCrash, Decl(noImplicitThisBigThis.ts, 14, 1)) + + return { + func1() { +>func1 : Symbol(func1, Decl(noImplicitThisBigThis.ts, 17, 12)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 17, 10)) + + }, + func2() { +>func2 : Symbol(func2, Decl(noImplicitThisBigThis.ts, 20, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 17, 10)) + + }, + func3() { +>func3 : Symbol(func3, Decl(noImplicitThisBigThis.ts, 23, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 17, 10)) + + }, + func4() { +>func4 : Symbol(func4, Decl(noImplicitThisBigThis.ts, 26, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 17, 10)) + + }, + func5() { +>func5 : Symbol(func5, Decl(noImplicitThisBigThis.ts, 29, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 17, 10)) + + }, + func6() { +>func6 : Symbol(func6, Decl(noImplicitThisBigThis.ts, 32, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 17, 10)) + + }, + func7() { +>func7 : Symbol(func7, Decl(noImplicitThisBigThis.ts, 35, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 17, 10)) + + }, + func8() { +>func8 : Symbol(func8, Decl(noImplicitThisBigThis.ts, 38, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 17, 10)) + + }, + func9() { +>func9 : Symbol(func9, Decl(noImplicitThisBigThis.ts, 41, 10)) + + return this; +>this : Symbol(__object, Decl(noImplicitThisBigThis.ts, 17, 10)) + } + }; +} + diff --git a/tests/baselines/reference/noImplicitThisBigThis.types b/tests/baselines/reference/noImplicitThisBigThis.types new file mode 100644 index 000000000000..4e1731aebc73 --- /dev/null +++ b/tests/baselines/reference/noImplicitThisBigThis.types @@ -0,0 +1,103 @@ +=== tests/cases/compiler/noImplicitThisBigThis.ts === +// https://github.com/microsoft/TypeScript/issues/29902 + +function createObj() { +>createObj : () => { func1(): any; func2(): any; func3(): any; } + + return { +>{ func1() { return this; }, func2() { return this; }, func3() { return this; } } : { func1(): { func1(): any; func2(): any; func3(): any; }; func2(): { func1(): any; func2(): any; func3(): any; }; func3(): { func1(): any; func2(): any; func3(): any; }; } + + func1() { +>func1 : () => { func1(): any; func2(): any; func3(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; }; func2(): { func1(): any; func2(): any; func3(): any; }; func3(): { func1(): any; func2(): any; func3(): any; }; } + + }, + func2() { +>func2 : () => { func1(): any; func2(): any; func3(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; }; func2(): { func1(): any; func2(): any; func3(): any; }; func3(): { func1(): any; func2(): any; func3(): any; }; } + + }, + func3() { +>func3 : () => { func1(): any; func2(): any; func3(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; }; func2(): { func1(): any; func2(): any; func3(): any; }; func3(): { func1(): any; func2(): any; func3(): any; }; } + } + }; +} + +function createObjNoCrash() { +>createObjNoCrash : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return { +>{ func1() { return this; }, func2() { return this; }, func3() { return this; }, func4() { return this; }, func5() { return this; }, func6() { return this; }, func7() { return this; }, func8() { return this; }, func9() { return this; } } : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + + func1() { +>func1 : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + + }, + func2() { +>func2 : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + + }, + func3() { +>func3 : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + + }, + func4() { +>func4 : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + + }, + func5() { +>func5 : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + + }, + func6() { +>func6 : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + + }, + func7() { +>func7 : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + + }, + func8() { +>func8 : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + + }, + func9() { +>func9 : () => { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; } + + return this; +>this : { func1(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func2(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func3(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func4(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func5(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func6(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func7(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func8(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; func9(): { func1(): any; func2(): any; func3(): any; func4(): any; func5(): any; func6(): any; func7(): any; func8(): any; func9(): any; }; } + } + }; +} + diff --git a/tests/baselines/reference/normalizedIntersectionTooComplex.errors.txt b/tests/baselines/reference/normalizedIntersectionTooComplex.errors.txt index 4e214eff5071..64e7d7f00c51 100644 --- a/tests/baselines/reference/normalizedIntersectionTooComplex.errors.txt +++ b/tests/baselines/reference/normalizedIntersectionTooComplex.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/normalizedIntersectionTooComplex.ts(36,14): error TS2590: Expression produces a union type that is too complex to represent. tests/cases/compiler/normalizedIntersectionTooComplex.ts(36,40): error TS7006: Parameter 'x' implicitly has an 'any' type. +tests/cases/compiler/normalizedIntersectionTooComplex.ts(36,40): error TS2590: Expression produces a union type that is too complex to represent. ==== tests/cases/compiler/normalizedIntersectionTooComplex.ts (2 errors) ==== @@ -39,8 +39,8 @@ tests/cases/compiler/normalizedIntersectionTooComplex.ts(36,40): error TS7006: P declare var all: keyof Big; const ctor = getCtor(all); const comp = ctor({ common: "ok", ref: x => console.log(x) }); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2590: Expression produces a union type that is too complex to represent. ~ !!! error TS7006: Parameter 'x' implicitly has an 'any' type. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2590: Expression produces a union type that is too complex to represent. \ No newline at end of file diff --git a/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.js b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.js new file mode 100644 index 000000000000..c85d07ec99b1 --- /dev/null +++ b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.js @@ -0,0 +1,33 @@ +//// [reactTagNameComponentWithPropsNoOOM.tsx] +/// + +import * as React from "react"; +declare const Tag: keyof React.ReactHTML; + +const classes = ""; +const rest: {} = {}; +const children: any[] = []; + +{children} + + +//// [reactTagNameComponentWithPropsNoOOM.js] +"use strict"; +/// +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +exports.__esModule = true; +var React = require("react"); +var classes = ""; +var rest = {}; +var children = []; +React.createElement(Tag, __assign({ className: classes }, rest), children); diff --git a/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.symbols b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.symbols new file mode 100644 index 000000000000..0b827bf7a0d8 --- /dev/null +++ b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/reactTagNameComponentWithPropsNoOOM.tsx === +/// + +import * as React from "react"; +>React : Symbol(React, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 2, 6)) + +declare const Tag: keyof React.ReactHTML; +>Tag : Symbol(Tag, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 3, 13)) +>React : Symbol(React, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 2, 6)) +>ReactHTML : Symbol(React.ReactHTML, Decl(react16.d.ts, 2089, 9)) + +const classes = ""; +>classes : Symbol(classes, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 5, 5)) + +const rest: {} = {}; +>rest : Symbol(rest, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 6, 5)) + +const children: any[] = []; +>children : Symbol(children, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 7, 5)) + + +>Tag : Symbol(Tag, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 3, 13)) +>className : Symbol(className, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 8, 4)) +>classes : Symbol(classes, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 5, 5)) +>rest : Symbol(rest, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 6, 5)) + +{children} +>children : Symbol(children, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 7, 5)) + + +>Tag : Symbol(Tag, Decl(reactTagNameComponentWithPropsNoOOM.tsx, 3, 13)) + diff --git a/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.types b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.types new file mode 100644 index 000000000000..f31716a55e4c --- /dev/null +++ b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM.types @@ -0,0 +1,35 @@ +=== tests/cases/compiler/reactTagNameComponentWithPropsNoOOM.tsx === +/// + +import * as React from "react"; +>React : typeof React + +declare const Tag: keyof React.ReactHTML; +>Tag : "object" | "time" | "link" | "menu" | "dialog" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "main" | "map" | "mark" | "menuitem" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" +>React : any + +const classes = ""; +>classes : "" +>"" : "" + +const rest: {} = {}; +>rest : {} +>{} : {} + +const children: any[] = []; +>children : any[] +>[] : never[] + + +>{children} : JSX.Element +>Tag : "object" | "time" | "link" | "menu" | "dialog" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "main" | "map" | "mark" | "menuitem" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" +>className : string +>classes : "" +>rest : {} + +{children} +>children : any[] + + +>Tag : "object" | "time" | "link" | "menu" | "dialog" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "main" | "map" | "mark" | "menuitem" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" + diff --git a/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.js b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.js new file mode 100644 index 000000000000..4b6e9d0c54a3 --- /dev/null +++ b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.js @@ -0,0 +1,33 @@ +//// [reactTagNameComponentWithPropsNoOOM2.tsx] +/// + +import * as React from "react"; +declare const Tag: keyof React.ReactHTML; + +const classes = ""; +const rest: React.HTMLAttributes = {}; +const children: any[] = []; + +{children} + + +//// [reactTagNameComponentWithPropsNoOOM2.js] +"use strict"; +/// +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +exports.__esModule = true; +var React = require("react"); +var classes = ""; +var rest = {}; +var children = []; +React.createElement(Tag, __assign({ className: classes }, rest), children); diff --git a/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.symbols b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.symbols new file mode 100644 index 000000000000..658f9fd5c439 --- /dev/null +++ b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/reactTagNameComponentWithPropsNoOOM2.tsx === +/// + +import * as React from "react"; +>React : Symbol(React, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 2, 6)) + +declare const Tag: keyof React.ReactHTML; +>Tag : Symbol(Tag, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 3, 13)) +>React : Symbol(React, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 2, 6)) +>ReactHTML : Symbol(React.ReactHTML, Decl(react16.d.ts, 2089, 9)) + +const classes = ""; +>classes : Symbol(classes, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 5, 5)) + +const rest: React.HTMLAttributes = {}; +>rest : Symbol(rest, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 6, 5)) +>React : Symbol(React, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 2, 6)) +>HTMLAttributes : Symbol(React.HTMLAttributes, Decl(react16.d.ts, 1048, 9), Decl(react16.d.ts, 1105, 9)) +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +const children: any[] = []; +>children : Symbol(children, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 7, 5)) + + +>Tag : Symbol(Tag, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 3, 13)) +>className : Symbol(className, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 8, 4)) +>classes : Symbol(classes, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 5, 5)) +>rest : Symbol(rest, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 6, 5)) + +{children} +>children : Symbol(children, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 7, 5)) + + +>Tag : Symbol(Tag, Decl(reactTagNameComponentWithPropsNoOOM2.tsx, 3, 13)) + diff --git a/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.types b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.types new file mode 100644 index 000000000000..fac8a844e032 --- /dev/null +++ b/tests/baselines/reference/reactTagNameComponentWithPropsNoOOM2.types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/reactTagNameComponentWithPropsNoOOM2.tsx === +/// + +import * as React from "react"; +>React : typeof React + +declare const Tag: keyof React.ReactHTML; +>Tag : "object" | "time" | "link" | "menu" | "dialog" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "main" | "map" | "mark" | "menuitem" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" +>React : any + +const classes = ""; +>classes : "" +>"" : "" + +const rest: React.HTMLAttributes = {}; +>rest : React.HTMLAttributes +>React : any +>{} : {} + +const children: any[] = []; +>children : any[] +>[] : never[] + + +>{children} : JSX.Element +>Tag : "object" | "time" | "link" | "menu" | "dialog" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "main" | "map" | "mark" | "menuitem" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" +>className : string +>classes : "" +>rest : React.HTMLAttributes + +{children} +>children : any[] + + +>Tag : "object" | "time" | "link" | "menu" | "dialog" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "main" | "map" | "mark" | "menuitem" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" + diff --git a/tests/baselines/reference/user/bluebird.log b/tests/baselines/reference/user/bluebird.log index 5c1689ff49b8..26d7270bcb66 100644 --- a/tests/baselines/reference/user/bluebird.log +++ b/tests/baselines/reference/user/bluebird.log @@ -131,60 +131,62 @@ node_modules/bluebird/js/release/promise.js(65,15): error TS2350: Only a void fu node_modules/bluebird/js/release/promise.js(65,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(95,22): error TS2339: Property 'isObject' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(99,59): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(119,22): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(121,32): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(123,14): error TS2339: Property '_warn' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(136,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(148,14): error TS2551: Property 'isFulfilled' does not exist on type 'Promise'. Did you mean '_setFulfilled'? -node_modules/bluebird/js/release/promise.js(149,37): error TS2339: Property 'value' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(151,21): error TS2551: Property 'isRejected' does not exist on type 'Promise'. Did you mean '_setRejected'? -node_modules/bluebird/js/release/promise.js(152,36): error TS2339: Property 'reason' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(160,14): error TS2339: Property '_warn' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(166,29): error TS2339: Property 'originatesFromRejection' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(177,9): error TS2339: Property '_captureStackTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(207,9): error TS2339: Property '_captureStackTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(214,15): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promise.js(214,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(238,63): error TS2339: Property '_boundTo' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(241,14): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(253,20): error TS2339: Property '_unsetRejectionIsUnhandled' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(257,20): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(264,26): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(295,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(106,19): error TS2350: Only a void function can be called with the 'new' keyword. +node_modules/bluebird/js/release/promise.js(107,60): error TS2554: Expected 0 arguments, but got 1. +node_modules/bluebird/js/release/promise.js(124,22): error TS2339: Property 'classString' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(126,32): error TS2339: Property 'classString' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(128,14): error TS2339: Property '_warn' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(141,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(153,14): error TS2551: Property 'isFulfilled' does not exist on type 'Promise'. Did you mean '_setFulfilled'? +node_modules/bluebird/js/release/promise.js(154,37): error TS2339: Property 'value' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(156,21): error TS2551: Property 'isRejected' does not exist on type 'Promise'. Did you mean '_setRejected'? +node_modules/bluebird/js/release/promise.js(157,36): error TS2339: Property 'reason' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(165,14): error TS2339: Property '_warn' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(171,29): error TS2339: Property 'originatesFromRejection' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(182,9): error TS2339: Property '_captureStackTrace' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(212,9): error TS2339: Property '_captureStackTrace' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(219,15): error TS2350: Only a void function can be called with the 'new' keyword. +node_modules/bluebird/js/release/promise.js(219,68): error TS2339: Property 'classString' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(243,63): error TS2339: Property '_boundTo' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(246,14): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(258,20): error TS2339: Property '_unsetRejectionIsUnhandled' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(262,20): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(269,26): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise.js(300,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. node_modules/bluebird/js/release/promise.js(305,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(322,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(339,42): error TS2339: Property '_isBound' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(400,50): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(404,49): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(412,50): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(416,49): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(434,26): error TS2339: Property '_propagateFrom' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(454,31): error TS2339: Property '_value' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(456,30): error TS2339: Property '_reason' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(459,17): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(466,22): error TS2339: Property 'ensureErrorObject' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(470,18): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(471,14): error TS2339: Property '_warn' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(473,10): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(480,10): error TS2339: Property '_captureStackTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(481,10): error TS2339: Property '_pushContext' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(483,18): error TS2339: Property '_execute' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(489,10): error TS2339: Property '_popContext' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(506,19): error TS2350: Only a void function can be called with the 'new' keyword. -node_modules/bluebird/js/release/promise.js(507,42): error TS2339: Property 'classString' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(558,22): error TS2339: Property '_promiseCancelled' does not exist on type '{}'. -node_modules/bluebird/js/release/promise.js(572,23): error TS2339: Property '_isResolved' does not exist on type '{}'. -node_modules/bluebird/js/release/promise.js(574,26): error TS2339: Property '_promiseFulfilled' does not exist on type '{}'. -node_modules/bluebird/js/release/promise.js(576,26): error TS2339: Property '_promiseRejected' does not exist on type '{}'. -node_modules/bluebird/js/release/promise.js(630,14): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(642,14): error TS2339: Property '_dereferenceTrace' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(653,46): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(659,14): error TS2339: Property '_ensurePossibleRejectionHandled' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(699,10): error TS2339: Property '_clearCancellationData' does not exist on type 'Promise'. -node_modules/bluebird/js/release/promise.js(724,6): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(754,10): error TS2339: Property 'toFastProperties' does not exist on type 'typeof ret'. -node_modules/bluebird/js/release/promise.js(755,10): error TS2339: Property 'toFastProperties' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(310,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(327,10): error TS2339: Property '_fireEvent' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(344,42): error TS2339: Property '_isBound' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(405,50): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(409,49): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(417,50): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(421,49): error TS2339: Property 'domainBind' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(439,26): error TS2339: Property '_propagateFrom' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(459,31): error TS2339: Property '_value' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(461,30): error TS2339: Property '_reason' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(464,17): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(471,22): error TS2339: Property 'ensureErrorObject' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(475,18): error TS2339: Property 'classString' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(476,14): error TS2339: Property '_warn' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(478,10): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(485,10): error TS2339: Property '_captureStackTrace' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(486,10): error TS2339: Property '_pushContext' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(488,18): error TS2339: Property '_execute' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(494,10): error TS2339: Property '_popContext' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(511,19): error TS2350: Only a void function can be called with the 'new' keyword. +node_modules/bluebird/js/release/promise.js(512,42): error TS2339: Property 'classString' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(563,22): error TS2339: Property '_promiseCancelled' does not exist on type '{}'. +node_modules/bluebird/js/release/promise.js(577,23): error TS2339: Property '_isResolved' does not exist on type '{}'. +node_modules/bluebird/js/release/promise.js(579,26): error TS2339: Property '_promiseFulfilled' does not exist on type '{}'. +node_modules/bluebird/js/release/promise.js(581,26): error TS2339: Property '_promiseRejected' does not exist on type '{}'. +node_modules/bluebird/js/release/promise.js(635,14): error TS2339: Property '_attachExtraTrace' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(647,14): error TS2339: Property '_dereferenceTrace' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(658,46): error TS2339: Property 'isNode' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(664,14): error TS2339: Property '_ensurePossibleRejectionHandled' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(704,10): error TS2339: Property '_clearCancellationData' does not exist on type 'Promise'. +node_modules/bluebird/js/release/promise.js(737,6): error TS2339: Property 'notEnumerableProp' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(767,10): error TS2339: Property 'toFastProperties' does not exist on type 'typeof ret'. +node_modules/bluebird/js/release/promise.js(768,10): error TS2339: Property 'toFastProperties' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise_array.js(5,20): error TS2339: Property 'isArray' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise_array.js(26,6): error TS2339: Property 'inherits' does not exist on type 'typeof ret'. node_modules/bluebird/js/release/promise_array.js(61,19): error TS2339: Property 'asArray' does not exist on type 'typeof ret'. diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index bdde6b918c09..d32422fb4169 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -698,13 +698,6 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10092,16): error TS2304: Cannot find name 'd41d8cd98f00b204e9800998ecf8427e_LibraryDetectorTests'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10513,19): error TS2488: Type 'NodeListOf' must have a '[Symbol.iterator]()' method that returns an iterator. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10811,19): error TS2304: Cannot find name 'getElementsInDocument'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11441,1): error TS2322: Type 'unknown' is not assignable to type 'number'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11444,1): error TS2322: Type 'unknown' is not assignable to type 'number'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11447,15): error TS2339: Property 'textLength' does not exist on type 'unknown'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11447,28): error TS2339: Property 'textLength' does not exist on type 'unknown'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11450,43): error TS2339: Property 'node' does not exist on type 'unknown'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11453,6): error TS2339: Property 'cssRule' does not exist on type 'unknown'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(11460,6): error TS2339: Property 'cssRule' does not exist on type 'unknown'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(12197,34): error TS2554: Expected 0 arguments, but got 2. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(12327,36): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(13607,7): error TS2339: Property 'protocolMethod' does not exist on type 'Error'. @@ -3389,7 +3382,7 @@ node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2765,22): error node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2785,91): error TS2339: Property 'xRel' does not exist on type 'Pos'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2855,32): error TS2339: Property 'left' does not exist on type 'never'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2855,49): error TS2339: Property 'right' does not exist on type 'never'. -node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2856,10): error TS2365: Operator '+' cannot be applied to types 'null' and '0 | 1'. +node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2856,10): error TS2365: Operator '+' cannot be applied to types 'null' and '1 | 0'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2858,32): error TS2339: Property 'left' does not exist on type 'never'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(2858,49): error TS2339: Property 'right' does not exist on type 'never'. node_modules/chrome-devtools-frontend/front_end/cm/codemirror.js(3034,25): error TS2339: Property 'xRel' does not exist on type 'Pos'. diff --git a/tests/baselines/reference/user/webpack.log b/tests/baselines/reference/user/webpack.log index 0cde6bb16231..ce91836eddf7 100644 --- a/tests/baselines/reference/user/webpack.log +++ b/tests/baselines/reference/user/webpack.log @@ -1,10 +1,7 @@ Exit Code: 1 Standard output: -../../../../../built/local/lib.dom.d.ts(17676,19): error TS2451: Cannot redeclare block-scoped variable 'WebAssembly'. +../../../../../built/local/lib.dom.d.ts(17677,19): error TS2451: Cannot redeclare block-scoped variable 'WebAssembly'. declarations.d.ts(258,15): error TS2451: Cannot redeclare block-scoped variable 'WebAssembly'. -lib/ContextModuleFactory.js(253,50): error TS2339: Property 'concat' does not exist on type 'unknown'. -lib/web/JsonpChunkTemplatePlugin.js(13,6): error TS2339: Property 'id' does not exist on type 'unknown'. -lib/web/JsonpMainTemplatePlugin.js(501,11): error TS2339: Property 'id' does not exist on type 'unknown'. diff --git a/tests/cases/compiler/noImplicitThisBigThis.ts b/tests/cases/compiler/noImplicitThisBigThis.ts new file mode 100644 index 000000000000..687f2f9355d1 --- /dev/null +++ b/tests/cases/compiler/noImplicitThisBigThis.ts @@ -0,0 +1,50 @@ +// @declaration: true +// @noImplicitThis: true + +// https://github.com/microsoft/TypeScript/issues/29902 + +function createObj() { + return { + func1() { + return this; + }, + func2() { + return this; + }, + func3() { + return this; + } + }; +} + +function createObjNoCrash() { + return { + func1() { + return this; + }, + func2() { + return this; + }, + func3() { + return this; + }, + func4() { + return this; + }, + func5() { + return this; + }, + func6() { + return this; + }, + func7() { + return this; + }, + func8() { + return this; + }, + func9() { + return this; + } + }; +} diff --git a/tests/cases/compiler/reactTagNameComponentWithPropsNoOOM.tsx b/tests/cases/compiler/reactTagNameComponentWithPropsNoOOM.tsx new file mode 100644 index 000000000000..e6011974230b --- /dev/null +++ b/tests/cases/compiler/reactTagNameComponentWithPropsNoOOM.tsx @@ -0,0 +1,13 @@ +// @jsx: react +// @strict: true +/// + +import * as React from "react"; +declare const Tag: keyof React.ReactHTML; + +const classes = ""; +const rest: {} = {}; +const children: any[] = []; + +{children} + \ No newline at end of file diff --git a/tests/cases/compiler/reactTagNameComponentWithPropsNoOOM2.tsx b/tests/cases/compiler/reactTagNameComponentWithPropsNoOOM2.tsx new file mode 100644 index 000000000000..64d46b5dd951 --- /dev/null +++ b/tests/cases/compiler/reactTagNameComponentWithPropsNoOOM2.tsx @@ -0,0 +1,13 @@ +// @jsx: react +// @strict: true +/// + +import * as React from "react"; +declare const Tag: keyof React.ReactHTML; + +const classes = ""; +const rest: React.HTMLAttributes = {}; +const children: any[] = []; + +{children} + \ No newline at end of file diff --git a/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts b/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts index a350c657f614..bfb257b8ac2e 100644 --- a/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts +++ b/tests/cases/conformance/types/intersection/intersectionTypeMembers.ts @@ -42,3 +42,25 @@ const de: D & E = { other: { g: 101 } } } + +// Additional test case with >2 doubly nested members so fix for #31441 is tested w/ excess props +interface F { + nested: { doublyNested: { g: string; } } +} + +interface G { + nested: { doublyNested: { h: string; } } +} + +const defg: D & E & F & G = { + nested: { + doublyNested: { + d: 'yes', + f: 'no', + g: 'ok', + h: 'affirmative' + }, + different: { e: 12 }, + other: { g: 101 } + } +}