From fc7d1c39482d9af525a773e5d4a18a176184fcf8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 20 Jan 2018 15:32:26 -0800 Subject: [PATCH] Revise comments --- src/compiler/checker.ts | 16 ++++++++-------- src/compiler/types.ts | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d0fe701760d..2ecdefbf7f2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6965,7 +6965,7 @@ namespace ts { } // This function replaces substitution types with their underlying type parameters. We erase when creating - // type references and type alias instantiations because subsitution types are no longer necessary once + // type references and type alias instantiations because substitution types are no longer necessary once // the type arguments have been validated against their corresponding type parameter constraints. function eraseSubstitutionType(type: Type) { return type.flags & TypeFlags.Substitution ? (type).typeParameter : type; @@ -14621,7 +14621,7 @@ namespace ts { checkExternalEmitHelpers(memberDecl, ExternalEmitHelpers.Assign); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); propertiesArray = []; propertiesTable = createSymbolTable(); hasComputedStringProperty = false; @@ -14633,7 +14633,7 @@ namespace ts { error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } - spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 0); + spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); offset = i + 1; continue; } @@ -14678,7 +14678,7 @@ namespace ts { if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); } return spread; } @@ -14811,7 +14811,7 @@ namespace ts { else { Debug.assert(attributeDecl.kind === SyntaxKind.JsxSpreadAttribute); if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, ObjectFlags.JsxAttributes); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, ObjectFlags.JsxAttributes); attributesTable = createSymbolTable(); } const exprType = checkExpressionCached(attributeDecl.expression, checkMode); @@ -14819,7 +14819,7 @@ namespace ts { hasSpreadAnyType = true; } if (isValidSpreadType(exprType)) { - spread = getSpreadType(spread, exprType, openingLikeElement.symbol, 0, ObjectFlags.JsxAttributes); + spread = getSpreadType(spread, exprType, openingLikeElement.symbol, /*typeFlags*/ 0, ObjectFlags.JsxAttributes); } else { typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; @@ -14829,7 +14829,7 @@ namespace ts { if (!hasSpreadAnyType) { if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, ObjectFlags.JsxAttributes); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, ObjectFlags.JsxAttributes); } } @@ -14855,7 +14855,7 @@ namespace ts { const childPropMap = createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), - attributes.symbol, 0, ObjectFlags.JsxAttributes); + attributes.symbol, /*typeFlags*/ 0, ObjectFlags.JsxAttributes); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b9f36387243..13c9f151fec 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3804,7 +3804,8 @@ namespace ts { // Substitution types are created for type parameter references that occur in the true branch // of a conditional type. For example, in 'T extends string ? Foo : Bar', the reference to // T in Foo is resolved as a substitution type that substitutes 'string & T' for T. Thus, if - // Foo has a 'string' constraint on its type parameter, T will satisfy it. + // Foo has a 'string' constraint on its type parameter, T will satisfy it. Substitution types + // disappear upon instantiation (just like type parameters). export interface SubstitutionType extends InstantiableType { typeParameter: TypeParameter; // Target type parameter substitute: Type; // Type to substitute for type parameter