From e416c7046e1c64846fbdde1180ccee38eb733856 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 3 Apr 2017 10:56:35 -0700 Subject: [PATCH 01/14] Property tracking of recursive non-object types in checkTypeRelatedTo --- src/compiler/checker.ts | 329 +++++++++++++++++++++------------------- 1 file changed, 169 insertions(+), 160 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f9ef54cd362..6b902c5ad89 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8468,137 +8468,38 @@ namespace ts { return result; } } - else if (target.flags & TypeFlags.Union) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive))) { - return result; - } - } - else if (target.flags & TypeFlags.Intersection) { - if (result = typeRelatedToEachType(source, target as IntersectionType, reportErrors)) { - return result; - } - } - else if (source.flags & TypeFlags.Intersection) { - // Check to see if any constituents of the intersection are immediately related to the target. - // - // Don't report errors though. Checking whether a constituent is related to the source is not actually - // useful and leads to some confusing error messages. Instead it is better to let the below checks - // take care of this, or to not elaborate at all. For instance, - // - // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. - // - // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection - // than to report that 'D' is not assignable to 'A' or 'B'. - // - // - For a primitive type or type parameter (such as 'number = A & B') there is no point in - // breaking the intersection apart. - if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { - return result; - } - } - else if (target.flags & TypeFlags.TypeParameter) { - // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. - if (getObjectFlags(source) & ObjectFlags.Mapped && getConstraintTypeFromMappedType(source) === getIndexType(target)) { - if (!(source).declaration.questionToken) { - const templateType = getTemplateTypeFromMappedType(source); - const indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { - return result; - } - } - } - } - else if (target.flags & TypeFlags.Index) { - // A keyof S is related to a keyof T if T is related to S. - if (source.flags & TypeFlags.Index) { - if (result = isRelatedTo((target).type, (source).type, /*reportErrors*/ false)) { - return result; - } - } - // A type S is assignable to keyof T if S is assignable to keyof C, where C is the - // constraint of T. - const constraint = getConstraintOfType((target).type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } - } - } - else if (target.flags & TypeFlags.IndexedAccess) { - // A type S is related to a type T[K] if S is related to A[K], where K is string-like and - // A is the apparent type of S. - const constraint = getConstraintOfType(target); - if (constraint) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - - if (source.flags & TypeFlags.TypeParameter) { - // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. - if (getObjectFlags(target) & ObjectFlags.Mapped && getConstraintTypeFromMappedType(target) === getIndexType(source)) { - const indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); - const templateType = getTemplateTypeFromMappedType(target); - if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - let constraint = getConstraintOfTypeParameter(source); - // A type parameter with no constraint is not related to the non-primitive object type. - if (constraint || !(target.flags & TypeFlags.NonPrimitive)) { - if (!constraint || constraint.flags & TypeFlags.Any) { - constraint = emptyObjectType; - } - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - // Report constraint errors only if the constraint is not the empty object type - const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - } - else if (source.flags & TypeFlags.IndexedAccess) { - // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and - // A is the apparent type of S. - const constraint = getConstraintOfType(source); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else if (target.flags & TypeFlags.IndexedAccess && (source).indexType === (target).indexType) { - // if we have indexed access types with identical index types, see if relationship holds for - // the two object types. - if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { - return result; - } - } - } else { - if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + if (target.flags & TypeFlags.Union) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive))) { return result; } } - // Even if relationship doesn't hold for unions, intersections, or generic type references, - // it may hold in a structural comparison. - const apparentSource = getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (apparentSource.flags & (TypeFlags.Object | TypeFlags.Intersection) && target.flags & TypeFlags.Object) { - // Report structural errors only if we haven't reported any errors yet - const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & TypeFlags.Primitive); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + else if (target.flags & TypeFlags.Intersection) { + if (result = typeRelatedToEachType(source, target as IntersectionType, reportErrors)) { + return result; + } + } + else if (source.flags & TypeFlags.Intersection) { + // Check to see if any constituents of the intersection are immediately related to the target. + // + // Don't report errors though. Checking whether a constituent is related to the source is not actually + // useful and leads to some confusing error messages. Instead it is better to let the below checks + // take care of this, or to not elaborate at all. For instance, + // + // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. + // + // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection + // than to report that 'D' is not assignable to 'A' or 'B'. + // + // - For a primitive type or type parameter (such as 'number = A & B') there is no point in + // breaking the intersection apart. + if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { + return result; + } + } + + if (source.flags & TypeFlags.StructuredOrTypeVariable || target.flags & TypeFlags.StructuredOrTypeVariable) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -8620,13 +8521,7 @@ namespace ts { function isIdenticalTo(source: Type, target: Type): Ternary { let result: Ternary; if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { - if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { - // We have type references to same target type, see if all type arguments are identical - if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); } if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { @@ -8815,12 +8710,12 @@ namespace ts { return result; } - // Determine if two object types are related by structure. First, check if the result is already available in the global cache. + // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function objectTypeRelatedTo(source: Type, originalSource: Type, target: Type, reportErrors: boolean): Ternary { + function recursiveTypeRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { if (overflow) { return Ternary.False; } @@ -8862,28 +8757,7 @@ namespace ts { const saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; - let result: Ternary; - if (expandingFlags === 3) { - result = Ternary.Maybe; - } - else if (isGenericMappedType(source) || isGenericMappedType(target)) { - result = mappedTypeRelatedTo(source, target, reportErrors); - } - else { - result = propertiesRelatedTo(source, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, SignatureKind.Call, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, SignatureKind.Construct, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, IndexKind.String, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, IndexKind.Number, reportErrors); - } - } - } - } - } + let result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : Ternary.Maybe; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -8900,6 +8774,141 @@ namespace ts { return result; } + function structuredTypeRelatedTo(source: Type, target: Type, reportErrors: boolean): Ternary { + let result: Ternary; + const saveErrorInfo = errorInfo; + if (target.flags & TypeFlags.TypeParameter) { + // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. + if (getObjectFlags(source) & ObjectFlags.Mapped && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + if (!(source).declaration.questionToken) { + const templateType = getTemplateTypeFromMappedType(source); + const indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); + if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { + return result; + } + } + } + } + else if (target.flags & TypeFlags.Index) { + // A keyof S is related to a keyof T if T is related to S. + if (source.flags & TypeFlags.Index) { + if (result = isRelatedTo((target).type, (source).type, /*reportErrors*/ false)) { + return result; + } + } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + const constraint = getConstraintOfType((target).type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } + else if (target.flags & TypeFlags.IndexedAccess) { + // A type S is related to a type T[K] if S is related to A[K], where K is string-like and + // A is the apparent type of S. + const constraint = getConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + + if (source.flags & TypeFlags.TypeParameter) { + // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. + if (getObjectFlags(target) & ObjectFlags.Mapped && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + const indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); + const templateType = getTemplateTypeFromMappedType(target); + if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + let constraint = getConstraintOfTypeParameter(source); + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & TypeFlags.NonPrimitive)) { + if (!constraint || constraint.flags & TypeFlags.Any) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // Report constraint errors only if the constraint is not the empty object type + const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + } + else if (source.flags & TypeFlags.IndexedAccess) { + // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and + // A is the apparent type of S. + const constraint = getConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else if (target.flags & TypeFlags.IndexedAccess && (source).indexType === (target).indexType) { + // if we have indexed access types with identical index types, see if relationship holds for + // the two object types. + if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { + return result; + } + } + } + else { + if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + const sourceIsPrimitive = !!(source.flags & TypeFlags.Primitive); + if (relation !== identityRelation) { + source = getApparentType(source); + } + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (source.flags & (TypeFlags.Object | TypeFlags.Intersection) && target.flags & TypeFlags.Object) { + // Report structural errors only if we haven't reported any errors yet + const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + if (isGenericMappedType(source) || isGenericMappedType(target)) { + result = mappedTypeRelatedTo(source, target, reportStructuralErrors); + } + else { + result = propertiesRelatedTo(source, target, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, SignatureKind.Call, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, SignatureKind.Construct, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, IndexKind.String, sourceIsPrimitive, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, IndexKind.Number, sourceIsPrimitive, reportStructuralErrors); + } + } + } + } + } + if (result) { + errorInfo = saveErrorInfo; + return result; + } + } + } + return Ternary.False; + } + // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice // that S and T are contra-variant whereas X and Y are co-variant. @@ -9148,12 +9157,12 @@ namespace ts { return related; } - function indexTypesRelatedTo(source: Type, originalSource: Type, target: Type, kind: IndexKind, reportErrors: boolean) { + function indexTypesRelatedTo(source: Type, target: Type, kind: IndexKind, sourceIsPrimitive: boolean, reportErrors: boolean) { if (relation === identityRelation) { return indexTypesIdenticalTo(source, target, kind); } const targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || ((targetInfo.type.flags & TypeFlags.Any) && !(originalSource.flags & TypeFlags.Primitive))) { + if (!targetInfo || targetInfo.type.flags & TypeFlags.Any && !sourceIsPrimitive) { // Index signature of type any permits assignment from everything but primitives return Ternary.True; } From 2632ac280c82a7c2ab3a70e52be12a155430720e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 3 Apr 2017 11:47:49 -0700 Subject: [PATCH 02/14] Accept new baselines --- ...typeIsAssignableToReadonlyArray.errors.txt | 2 - .../mappedTypeRelationships.errors.txt | 128 +++++++----------- .../reference/promisePermutations.errors.txt | 6 - .../reference/promisePermutations2.errors.txt | 6 - .../reference/promisePermutations3.errors.txt | 6 - ...ommaInHeterogenousArrayLiteral1.errors.txt | 4 - .../baselines/reference/typeMatch2.errors.txt | 2 - .../typeParameterAssignability2.errors.txt | 4 - .../types.asyncGenerators.esnext.2.errors.txt | 2 - 9 files changed, 52 insertions(+), 108 deletions(-) diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt index 6f4a0ef9d6d..90dc909b11a 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt @@ -8,7 +8,6 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T Types of property 'concat' are incompatible. Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. Type 'A[]' is not assignable to type 'B[]'. - Type 'A' is not assignable to type 'B'. ==== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts (2 errors) ==== @@ -42,5 +41,4 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T !!! error TS2322: Types of property 'concat' are incompatible. !!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. !!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index ec2bacbe663..8b09da4aad1 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -1,34 +1,30 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(12,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. Type 'T[string]' is not assignable to type 'U[keyof T]'. Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. - Type 'T[keyof T]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(17,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T[string]' is not assignable to type 'U[K]'. Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. - Type 'T[K]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,5): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,5): error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. Type 'T[string]' is not assignable to type 'U[keyof U]'. Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. - Type 'T[keyof U]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. + Type 'T[keyof U]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,12): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T[string]' is not assignable to type 'U[K]'. Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. - Type 'T[K]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,12): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(31,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. @@ -42,30 +38,24 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(42,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. Type 'T[string]' is not assignable to type 'U[keyof T]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. - Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. - Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T[keyof T]' is not assignable to type 'U[string]'. Type 'T[string]' is not assignable to type 'U[string]'. Type 'T' is not assignable to type 'U'. - Type 'T[keyof T]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[string]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(47,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. Type 'T[string]' is not assignable to type 'U[K] | undefined'. Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. - Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T[K]' is not assignable to type 'U[K]'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T[K]' is not assignable to type 'U[string]'. Type 'T[string]' is not assignable to type 'U[string]'. Type 'T' is not assignable to type 'U'. - Type 'T[K]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(52,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(57,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(62,5): error TS2542: Index signature in type 'Readonly' only permits reading. @@ -77,10 +67,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(142,5): error TS Type 'T[P]' is not assignable to type 'U[P]'. Type 'T[string]' is not assignable to type 'U[P]'. Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. - Type 'T[P]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. + Type 'T[P]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(147,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. Type 'keyof U' is not assignable to type 'keyof T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(152,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. @@ -93,10 +82,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS Type 'T[P]' is not assignable to type 'U[P]'. Type 'T[string]' is not assignable to type 'U[P]'. Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. - Type 'T[P]' is not assignable to type 'U[string]'. - Type 'T[string]' is not assignable to type 'U[string]'. - Type 'T' is not assignable to type 'U'. + Type 'T[P]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. ==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (27 errors) ==== @@ -116,10 +104,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f4(x: T, y: U, k: K) { @@ -129,10 +116,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f5(x: T, y: U, k: keyof U) { @@ -144,10 +130,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof U]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. } @@ -161,10 +146,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'K' cannot be used to index type 'T'. } @@ -198,15 +182,12 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f13(x: T, y: Partial, k: K) { @@ -220,15 +201,12 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f20(x: T, y: Readonly, k: keyof T) { @@ -343,10 +321,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[P]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { @@ -389,9 +366,8 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. -!!! error TS2322: Type 'T[P]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } \ No newline at end of file diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index 69bd8c1e629..e5e7f2109a9 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -44,10 +44,8 @@ tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of t tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations.ts(137,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. - Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations.ts(144,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. - Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations.ts(152,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Types of property 'then' are incompatible. @@ -61,7 +59,6 @@ tests/cases/compiler/promisePermutations.ts(156,21): error TS2345: Argument of t Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. - Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. Type 'Promise' is not assignable to type 'Promise'. Type 'number' is not assignable to type 'string'. @@ -286,7 +283,6 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t ~~~~~~~ !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. -!!! error TS2453: Type 'string' is not assignable to type 'number'. var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); @@ -297,7 +293,6 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t ~~~~~~~~ !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. -!!! error TS2453: Type 'string' is not assignable to type 'number'. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -328,7 +323,6 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'IPromise'. -!!! error TS2345: Type 'number' is not assignable to type 'string'. var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index cbbd9cc7736..26fec6b2fd1 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -44,10 +44,8 @@ tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(136,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. - Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations2.ts(143,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. - Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations2.ts(151,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Types of property 'then' are incompatible. @@ -61,7 +59,6 @@ tests/cases/compiler/promisePermutations2.ts(155,21): error TS2345: Argument of Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations2.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. - Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations2.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. Type 'Promise' is not assignable to type 'Promise'. Type 'number' is not assignable to type 'string'. @@ -285,7 +282,6 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of ~~~~~~~ !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. -!!! error TS2453: Type 'string' is not assignable to type 'number'. var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); @@ -296,7 +292,6 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of ~~~~~~~~ !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. -!!! error TS2453: Type 'string' is not assignable to type 'number'. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -327,7 +322,6 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'IPromise'. -!!! error TS2345: Type 'number' is not assignable to type 'string'. var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index fd0ce0d643e..1354f486fcb 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -47,10 +47,8 @@ tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(136,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. - Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations3.ts(143,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. - Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations3.ts(151,12): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Types of property 'then' are incompatible. @@ -64,7 +62,6 @@ tests/cases/compiler/promisePermutations3.ts(155,21): error TS2345: Argument of Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations3.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. - Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations3.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. Type 'Promise' is not assignable to type 'Promise'. Type 'number' is not assignable to type 'string'. @@ -297,7 +294,6 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~ !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. -!!! error TS2453: Type 'string' is not assignable to type 'number'. var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var r10 = testFunction10(x => x); @@ -308,7 +304,6 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~ !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. -!!! error TS2453: Type 'string' is not assignable to type 'number'. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok @@ -339,7 +334,6 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'IPromise'. -!!! error TS2345: Type 'number' is not assignable to type 'string'. var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. diff --git a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt index b502eaad7e5..32c1a470bc3 100644 --- a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt +++ b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt @@ -2,8 +2,6 @@ tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS Type 'string | number' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. ==== tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts (2 errors) ==== @@ -19,8 +17,6 @@ tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS this.test([1, 2, "hi", 5]); ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'. -!!! error TS2345: Type 'string | number' is not assignable to type 'number'. -!!! error TS2345: Type 'string' is not assignable to type 'number'. } } \ No newline at end of file diff --git a/tests/baselines/reference/typeMatch2.errors.txt b/tests/baselines/reference/typeMatch2.errors.txt index e82439c0ad5..19ac6def2a9 100644 --- a/tests/baselines/reference/typeMatch2.errors.txt +++ b/tests/baselines/reference/typeMatch2.errors.txt @@ -12,7 +12,6 @@ tests/cases/compiler/typeMatch2.ts(18,5): error TS2322: Type 'Animal[]' is not a tests/cases/compiler/typeMatch2.ts(22,5): error TS2322: Type '{ f1: number; f2: Animal[]; }' is not assignable to type '{ f1: number; f2: Giraffe[]; }'. Types of property 'f2' are incompatible. Type 'Animal[]' is not assignable to type 'Giraffe[]'. - Type 'Animal' is not assignable to type 'Giraffe'. tests/cases/compiler/typeMatch2.ts(34,26): error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. @@ -62,7 +61,6 @@ tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is !!! error TS2322: Type '{ f1: number; f2: Animal[]; }' is not assignable to type '{ f1: number; f2: Giraffe[]; }'. !!! error TS2322: Types of property 'f2' are incompatible. !!! error TS2322: Type 'Animal[]' is not assignable to type 'Giraffe[]'. -!!! error TS2322: Type 'Animal' is not assignable to type 'Giraffe'. } function f4() { diff --git a/tests/baselines/reference/typeParameterAssignability2.errors.txt b/tests/baselines/reference/typeParameterAssignability2.errors.txt index e6159fd7135..9d32aed1232 100644 --- a/tests/baselines/reference/typeParameterAssignability2.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability2.errors.txt @@ -8,7 +8,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara Type 'V' is not assignable to type 'T'. Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(26,5): error TS2322: Type 'V' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(27,5): error TS2322: Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(30,5): error TS2322: Type 'V' is not assignable to type 'U'. Type 'Date' is not assignable to type 'U'. @@ -18,7 +17,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara Type 'V' is not assignable to type 'T'. Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(46,5): error TS2322: Type 'V' is not assignable to type 'T'. - Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(47,5): error TS2322: Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(50,5): error TS2322: Type 'V' is not assignable to type 'U'. Type 'Date' is not assignable to type 'U'. @@ -76,7 +74,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. t = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. @@ -112,7 +109,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. t = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'T'. diff --git a/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt b/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt index c13620a7f9e..92733c18640 100644 --- a/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt +++ b/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt @@ -7,7 +7,6 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(13,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator'. Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. - Type '"a"' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(16,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable'. Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable'. Types of property '[Symbol.asyncIterator]' are incompatible. @@ -84,7 +83,6 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator'. !!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. -!!! error TS2322: Type '"a"' is not assignable to type 'number'. yield* (async function * () { yield "a"; })(); }; const assignability4: () => AsyncIterable = async function * () { From 0f0a8a17dce675de87a7985dc274446af759b4cb Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 3 Apr 2017 12:32:54 -0700 Subject: [PATCH 03/14] Add regression tests --- .../recursiveTypeRelations.errors.txt | 48 +++++++++++++ .../reference/recursiveTypeRelations.js | 70 +++++++++++++++++++ .../cases/compiler/recursiveTypeRelations.ts | 35 ++++++++++ 3 files changed, 153 insertions(+) create mode 100644 tests/baselines/reference/recursiveTypeRelations.errors.txt create mode 100644 tests/baselines/reference/recursiveTypeRelations.js create mode 100644 tests/cases/compiler/recursiveTypeRelations.ts diff --git a/tests/baselines/reference/recursiveTypeRelations.errors.txt b/tests/baselines/reference/recursiveTypeRelations.errors.txt new file mode 100644 index 00000000000..f29d5742185 --- /dev/null +++ b/tests/baselines/reference/recursiveTypeRelations.errors.txt @@ -0,0 +1,48 @@ +tests/cases/compiler/recursiveTypeRelations.ts(8,5): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/compiler/recursiveTypeRelations.ts(27,38): error TS2304: Cannot find name 'ClassNameObject'. +tests/cases/compiler/recursiveTypeRelations.ts(27,61): error TS2304: Cannot find name 'ClassNameObject'. + + +==== tests/cases/compiler/recursiveTypeRelations.ts (3 errors) ==== + // Repro from #14896 + + type Attributes = { + [Key in Keys]: string; + } + + class Query> { + multiply>(x: B): Query; + ~~~~~~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + } + + // Repro from #14940 + + type ClassName = keyof S; + type ClassNameMap = { [K in keyof S]?: boolean } + type ClassNameObjectMap = object & ClassNameMap; + type ClassNameArg = ClassName | ClassNameObjectMap; + + export function css(styles: S, ...classNames: ClassNameArg[]): string { + const args = classNames.map(arg => { + if (arg == null) { + return null; + } + if (typeof arg == "string") { + return styles[arg]; + } + if (typeof arg == "object") { + return Object.keys(arg).reduce((obj: ClassNameObject, key: keyof S) => { + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'ClassNameObject'. + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'ClassNameObject'. + const exportedClassName = styles[key]; + obj[exportedClassName] = (arg as ClassNameMap)[key]; + return obj; + }, {}); + } + }); + return ""; + } + \ No newline at end of file diff --git a/tests/baselines/reference/recursiveTypeRelations.js b/tests/baselines/reference/recursiveTypeRelations.js new file mode 100644 index 00000000000..eccf5bac8f5 --- /dev/null +++ b/tests/baselines/reference/recursiveTypeRelations.js @@ -0,0 +1,70 @@ +//// [recursiveTypeRelations.ts] +// Repro from #14896 + +type Attributes = { + [Key in Keys]: string; +} + +class Query> { + multiply>(x: B): Query; +} + +// Repro from #14940 + +type ClassName = keyof S; +type ClassNameMap = { [K in keyof S]?: boolean } +type ClassNameObjectMap = object & ClassNameMap; +type ClassNameArg = ClassName | ClassNameObjectMap; + +export function css(styles: S, ...classNames: ClassNameArg[]): string { + const args = classNames.map(arg => { + if (arg == null) { + return null; + } + if (typeof arg == "string") { + return styles[arg]; + } + if (typeof arg == "object") { + return Object.keys(arg).reduce((obj: ClassNameObject, key: keyof S) => { + const exportedClassName = styles[key]; + obj[exportedClassName] = (arg as ClassNameMap)[key]; + return obj; + }, {}); + } + }); + return ""; +} + + +//// [recursiveTypeRelations.js] +// Repro from #14896 +"use strict"; +exports.__esModule = true; +var Query = (function () { + function Query() { + } + return Query; +}()); +function css(styles) { + var classNames = []; + for (var _i = 1; _i < arguments.length; _i++) { + classNames[_i - 1] = arguments[_i]; + } + var args = classNames.map(function (arg) { + if (arg == null) { + return null; + } + if (typeof arg == "string") { + return styles[arg]; + } + if (typeof arg == "object") { + return Object.keys(arg).reduce(function (obj, key) { + var exportedClassName = styles[key]; + obj[exportedClassName] = arg[key]; + return obj; + }, {}); + } + }); + return ""; +} +exports.css = css; diff --git a/tests/cases/compiler/recursiveTypeRelations.ts b/tests/cases/compiler/recursiveTypeRelations.ts new file mode 100644 index 00000000000..18545300f77 --- /dev/null +++ b/tests/cases/compiler/recursiveTypeRelations.ts @@ -0,0 +1,35 @@ +// Repro from #14896 + +type Attributes = { + [Key in Keys]: string; +} + +class Query> { + multiply>(x: B): Query; +} + +// Repro from #14940 + +type ClassName = keyof S; +type ClassNameMap = { [K in keyof S]?: boolean } +type ClassNameObjectMap = object & ClassNameMap; +type ClassNameArg = ClassName | ClassNameObjectMap; + +export function css(styles: S, ...classNames: ClassNameArg[]): string { + const args = classNames.map(arg => { + if (arg == null) { + return null; + } + if (typeof arg == "string") { + return styles[arg]; + } + if (typeof arg == "object") { + return Object.keys(arg).reduce((obj: ClassNameObject, key: keyof S) => { + const exportedClassName = styles[key]; + obj[exportedClassName] = (arg as ClassNameMap)[key]; + return obj; + }, {}); + } + }); + return ""; +} From 2f73e397f5638481cda24414ccab492bba151160 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 3 Apr 2017 12:46:58 -0700 Subject: [PATCH 04/14] Accept new baselines --- tests/baselines/reference/recursiveTypeRelations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/recursiveTypeRelations.js b/tests/baselines/reference/recursiveTypeRelations.js index eccf5bac8f5..d006c9482d8 100644 --- a/tests/baselines/reference/recursiveTypeRelations.js +++ b/tests/baselines/reference/recursiveTypeRelations.js @@ -37,8 +37,8 @@ export function css(styles: S, ...classNam //// [recursiveTypeRelations.js] -// Repro from #14896 "use strict"; +// Repro from #14896 exports.__esModule = true; var Query = (function () { function Query() { From 854731ad9b58b55f00a0d637180c1b43425b06aa Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 3 Apr 2017 13:51:13 -0700 Subject: [PATCH 05/14] Fix linting error --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 42c5b518c2a..3a893c640de 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8818,7 +8818,7 @@ namespace ts { const saveExpandingFlags = expandingFlags; if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; - let result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : Ternary.Maybe; + const result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : Ternary.Maybe; expandingFlags = saveExpandingFlags; depth--; if (result) { From fd081f40a8f29b3bad60ba71796b99a053795ee6 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 3 Apr 2017 14:02:14 -0700 Subject: [PATCH 06/14] Clean up literal emit --- src/compiler/binder.ts | 14 +++- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 2 +- src/compiler/emitter.ts | 11 ++- src/compiler/factory.ts | 7 +- src/compiler/parser.ts | 14 ++-- src/compiler/scanner.ts | 10 +++ src/compiler/transformers/es2015.ts | 30 +++++++++ src/compiler/types.ts | 16 ++++- src/compiler/utilities.ts | 67 ++----------------- src/harness/unittests/printer.ts | 3 + .../reference/castExpressionParentheses.js | 18 ++--- .../castExpressionParentheses.symbols | 23 ++++--- .../reference/castExpressionParentheses.types | 8 +-- .../destructuringInVariableDeclarations1.js | 2 +- .../destructuringInVariableDeclarations3.js | 2 +- .../destructuringInVariableDeclarations5.js | 2 +- .../destructuringInVariableDeclarations7.js | 2 +- .../destructuringInVariableDeclarations8.js | 2 +- .../destructuringTypeAssertionsES5_5.js | 2 +- .../destructuringWithNumberLiteral.js | 2 +- .../duplicateIdentifierDifferentSpelling.js | 2 +- .../printsFileCorrectly.templateLiteral.js | 1 + .../compiler/castExpressionParentheses.ts | 8 +-- 24 files changed, 127 insertions(+), 123 deletions(-) create mode 100644 tests/baselines/reference/printerApi/printsFileCorrectly.templateLiteral.js diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 45e8efdf512..dff33970426 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1854,7 +1854,7 @@ namespace ts { } function checkStrictModeNumericLiteral(node: NumericLiteral) { - if (inStrictMode && node.isOctalLiteral) { + if (inStrictMode && node.numericLiteralFlags & NumericLiteralFlags.Octal) { file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -3327,6 +3327,18 @@ namespace ts { transformFlags |= TransformFlags.AssertES2015; break; + case SyntaxKind.StringLiteral: + if ((node).hasExtendedUnicodeEscape) { + transformFlags |= TransformFlags.AssertES2015; + } + break; + + case SyntaxKind.NumericLiteral: + if ((node).numericLiteralFlags & NumericLiteralFlags.BinaryOrOctalSpecifier) { + transformFlags |= TransformFlags.AssertES2015; + } + break; + case SyntaxKind.ForOfStatement: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if ((node).awaitModifier) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5cb07f2d736..c8b36a7bbf5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23986,7 +23986,7 @@ namespace ts { function checkGrammarNumericLiteral(node: NumericLiteral): boolean { // Grammar checking - if (node.isOctalLiteral) { + if (node.numericLiteralFlags & NumericLiteralFlags.Octal) { let diagnosticMessage: DiagnosticMessage | undefined; if (languageVersion >= ScriptTarget.ES5) { diagnosticMessage = Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index a56f1004d28..fa7cd9c55ba 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1455,7 +1455,7 @@ namespace ts { return /^\.\.?($|[\\/])/.test(moduleName); } - export function getEmitScriptTarget(compilerOptions: CompilerOptions | PrinterOptions) { + export function getEmitScriptTarget(compilerOptions: CompilerOptions) { return compilerOptions.target || ScriptTarget.ES3; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 948a0ee44a2..69b5188878f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -204,7 +204,6 @@ namespace ts { } = handlers; const newLine = getNewLineCharacter(printerOptions); - const languageVersion = getEmitScriptTarget(printerOptions); const comments = createCommentWriter(printerOptions, onEmitSourceMapOfPosition); const { emitNodeWithComments, @@ -1084,7 +1083,7 @@ namespace ts { } const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; - const allowTrailingComma = languageVersion >= ScriptTarget.ES5 ? ListFormat.AllowTrailingComma : ListFormat.None; + const allowTrailingComma = currentSourceFile.languageVersion >= ScriptTarget.ES5 ? ListFormat.AllowTrailingComma : ListFormat.None; emitList(node, properties, ListFormat.ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine); if (indentedFlag) { @@ -1118,11 +1117,11 @@ namespace ts { // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal function needsDotDotForPropertyAccess(expression: Expression) { - if (expression.kind === SyntaxKind.NumericLiteral) { + expression = skipPartiallyEmittedExpressions(expression); + if (isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot const text = getLiteralTextOfNode(expression); - return getNumericLiteralFlags(text, /*hint*/ NumericLiteralFlags.All) === NumericLiteralFlags.None - && !(expression).isOctalLiteral + return !expression.numericLiteralFlags && text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0; } else if (isPropertyAccessExpression(expression) || isElementAccessExpression(expression)) { @@ -2638,7 +2637,7 @@ namespace ts { } } - return getLiteralText(node, currentSourceFile, languageVersion); + return getLiteralText(node, currentSourceFile); } /** diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 66b3eb713e5..3ed1c3bb9d5 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3365,17 +3365,14 @@ namespace ts { */ export function parenthesizeForAccess(expression: Expression): LeftHandSideExpression { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. The known exceptions are: + // to parenthesize the expression before a dot. The known exception is: // // NewExpression: // new C.x -> not the same as (new C).x - // NumericLiteral - // 1.x -> not the same as (1).x // const emittedExpression = skipPartiallyEmittedExpressions(expression); if (isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== SyntaxKind.NewExpression || (emittedExpression).arguments) - && emittedExpression.kind !== SyntaxKind.NumericLiteral) { + && (emittedExpression.kind !== SyntaxKind.NewExpression || (emittedExpression).arguments)) { return expression; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index fcb85f4fbdc..5f9140f7e18 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2031,23 +2031,19 @@ namespace ts { node.isUnterminated = true; } - const tokenPos = scanner.getTokenPos(); - nextToken(); - finishNode(node); - // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal.But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - if (node.kind === SyntaxKind.NumericLiteral - && sourceText.charCodeAt(tokenPos) === CharacterCodes._0 - && isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - - node.isOctalLiteral = true; + if (node.kind === SyntaxKind.NumericLiteral) { + (node).numericLiteralFlags = scanner.getNumericLiteralFlags(); } + nextToken(); + finishNode(node); + return node; } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 466074bdbcc..7b6e0c09db4 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -23,6 +23,8 @@ namespace ts { isIdentifier(): boolean; isReservedWord(): boolean; isUnterminated(): boolean; + /* @internal */ + getNumericLiteralFlags(): NumericLiteralFlags; reScanGreaterToken(): SyntaxKind; reScanSlashToken(): SyntaxKind; reScanTemplateToken(): SyntaxKind; @@ -799,6 +801,7 @@ namespace ts { let precedingLineBreak: boolean; let hasExtendedUnicodeEscape: boolean; let tokenIsUnterminated: boolean; + let numericLiteralFlags: NumericLiteralFlags; setText(text, start, length); @@ -814,6 +817,7 @@ namespace ts { isIdentifier: () => token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord, isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord, isUnterminated: () => tokenIsUnterminated, + getNumericLiteralFlags: () => numericLiteralFlags, reScanGreaterToken, reScanSlashToken, reScanTemplateToken, @@ -850,6 +854,7 @@ namespace ts { let end = pos; if (text.charCodeAt(pos) === CharacterCodes.E || text.charCodeAt(pos) === CharacterCodes.e) { pos++; + numericLiteralFlags = NumericLiteralFlags.Scientific; if (text.charCodeAt(pos) === CharacterCodes.plus || text.charCodeAt(pos) === CharacterCodes.minus) pos++; if (isDigit(text.charCodeAt(pos))) { pos++; @@ -1221,6 +1226,7 @@ namespace ts { hasExtendedUnicodeEscape = false; precedingLineBreak = false; tokenIsUnterminated = false; + numericLiteralFlags = 0; while (true) { tokenPos = pos; if (pos >= end) { @@ -1419,6 +1425,7 @@ namespace ts { value = 0; } tokenValue = "" + value; + numericLiteralFlags = NumericLiteralFlags.HexSpecifier; return token = SyntaxKind.NumericLiteral; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === CharacterCodes.B || text.charCodeAt(pos + 1) === CharacterCodes.b)) { @@ -1429,6 +1436,7 @@ namespace ts { value = 0; } tokenValue = "" + value; + numericLiteralFlags = NumericLiteralFlags.BinarySpecifier; return token = SyntaxKind.NumericLiteral; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === CharacterCodes.O || text.charCodeAt(pos + 1) === CharacterCodes.o)) { @@ -1439,11 +1447,13 @@ namespace ts { value = 0; } tokenValue = "" + value; + numericLiteralFlags = NumericLiteralFlags.OctalSpecifier; return token = SyntaxKind.NumericLiteral; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); + numericLiteralFlags = NumericLiteralFlags.Octal; return token = SyntaxKind.NumericLiteral; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index fd2c287d0e0..74f7d96633c 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -466,6 +466,12 @@ namespace ts { case SyntaxKind.TemplateTail: return visitTemplateLiteral(node); + case SyntaxKind.StringLiteral: + return visitStringLiteral(node); + + case SyntaxKind.NumericLiteral: + return visitNumericLiteral(node); + case SyntaxKind.TaggedTemplateExpression: return visitTaggedTemplateExpression(node); @@ -3414,6 +3420,30 @@ namespace ts { return setTextRange(createLiteral(node.text), node); } + /** + * Visits a string literal with an extended unicode escape. + * + * @param node A string literal. + */ + function visitStringLiteral(node: StringLiteral) { + if (node.hasExtendedUnicodeEscape) { + return setTextRange(createLiteral(node.text), node); + } + return node; + } + + /** + * Visits a binary or octal (ES6) numeric literal. + * + * @param node A string literal. + */ + function visitNumericLiteral(node: NumericLiteral) { + if (node.numericLiteralFlags & NumericLiteralFlags.BinaryOrOctalSpecifier) { + return setTextRange(createNumericLiteral(node.text), node); + } + return node; + } + /** * Visits a TaggedTemplateExpression node. * diff --git a/src/compiler/types.ts b/src/compiler/types.ts index dcad61a3177..064c78fd767 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1313,8 +1313,6 @@ namespace ts { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; - /* @internal */ - isOctalLiteral?: boolean; } // The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral, @@ -1332,8 +1330,21 @@ namespace ts { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } + /* @internal */ + export const enum NumericLiteralFlags { + None = 0, + Scientific = 1 << 1, // e.g. `10e2` + Octal = 1 << 2, // e.g. `0777` + HexSpecifier = 1 << 3, // e.g. `0x00000000` + BinarySpecifier = 1 << 4, // e.g. `0b0110010000000000` + OctalSpecifier = 1 << 5, // e.g. `0o777` + BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier, + } + export interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; + /* @internal */ + numericLiteralFlags?: NumericLiteralFlags; } export interface TemplateHead extends LiteralLikeNode { @@ -4189,7 +4200,6 @@ namespace ts { } export interface PrinterOptions { - target?: ScriptTarget; removeComments?: boolean; newLine?: NewLineKind; /*@internal*/ sourceMap?: boolean; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5c6e519519b..39caa561ba3 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -322,21 +322,11 @@ namespace ts { return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } - export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, languageVersion: ScriptTarget) { - // Any template literal or string literal with an extended escape - // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < ScriptTarget.ES2015 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } - + export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile) { // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. if (!nodeIsSynthesized(node) && node.parent) { - const text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < ScriptTarget.ES2015 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; + return getSourceTextOfNodeFromSourceFile(sourceFile, node); } // If we can't reach the original source text, use the canonical form if it's a number, @@ -359,55 +349,6 @@ namespace ts { Debug.fail(`Literal kind '${node.kind}' not accounted for.`); } - export function isBinaryOrOctalIntegerLiteral(node: LiteralLikeNode, text: string) { - return node.kind === SyntaxKind.NumericLiteral - && (getNumericLiteralFlags(text, /*hint*/ NumericLiteralFlags.BinaryOrOctal) & NumericLiteralFlags.BinaryOrOctal) !== 0; - } - - export const enum NumericLiteralFlags { - None = 0, - Hexadecimal = 1 << 0, - Binary = 1 << 1, - Octal = 1 << 2, - Scientific = 1 << 3, - - BinaryOrOctal = Binary | Octal, - BinaryOrOctalOrHexadecimal = BinaryOrOctal | Hexadecimal, - All = Hexadecimal | Binary | Octal | Scientific, - } - - /** - * Scans a numeric literal string to determine the form of the number. - * @param text Numeric literal text - * @param hint If `Scientific` or `All` is specified, performs a more expensive check to scan for scientific notation. - */ - export function getNumericLiteralFlags(text: string, hint?: NumericLiteralFlags) { - if (text.length > 1) { - switch (text.charCodeAt(1)) { - case CharacterCodes.b: - case CharacterCodes.B: - return NumericLiteralFlags.Binary; - case CharacterCodes.o: - case CharacterCodes.O: - return NumericLiteralFlags.Octal; - case CharacterCodes.x: - case CharacterCodes.X: - return NumericLiteralFlags.Hexadecimal; - } - - if (hint & NumericLiteralFlags.Scientific) { - for (let i = text.length - 1; i >= 0; i--) { - switch (text.charCodeAt(i)) { - case CharacterCodes.e: - case CharacterCodes.E: - return NumericLiteralFlags.Scientific; - } - } - } - } - return NumericLiteralFlags.None; - } - function getQuotedEscapedLiteralText(leftQuote: string, text: string, rightQuote: string) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -2027,6 +1968,10 @@ namespace ts { return false; } + export function isNumericLiteral(node: Node): node is NumericLiteral { + return node.kind === SyntaxKind.NumericLiteral; + } + export function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral { const kind = node.kind; return kind === SyntaxKind.StringLiteral diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index e5167b592c2..894ffcf0ea2 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -52,6 +52,9 @@ namespace ts { printsCorrectly("default", {}, printer => printer.printFile(sourceFile)); printsCorrectly("removeComments", { removeComments: true }, printer => printer.printFile(sourceFile)); + + // github #14948 + printsCorrectly("templateLiteral", {}, printer => printer.printFile(createSourceFile("source.ts", "let greeting = `Hi ${name}, how are you?`;", ScriptTarget.ES2017))); }); describe("printBundle", () => { diff --git a/tests/baselines/reference/castExpressionParentheses.js b/tests/baselines/reference/castExpressionParentheses.js index 94d5daafb0a..b1f4507f982 100644 --- a/tests/baselines/reference/castExpressionParentheses.js +++ b/tests/baselines/reference/castExpressionParentheses.js @@ -24,15 +24,15 @@ declare var a; (a[0]); (a.b["0"]); (a()).x; - -declare var A; - -// should keep the parentheses in emit (1).foo; (1.).foo; (1.0).foo; (12e+34).foo; (0xff).foo; + +declare var A; + +// should keep the parentheses in emit ((1.0)); (new A).foo; (typeof A).x; @@ -74,12 +74,12 @@ a; a[0]; a.b["0"]; a().x; +1..foo; +1..foo; +1.0.foo; +12e+34.foo; +0xff.foo; // should keep the parentheses in emit -(1).foo; -(1.).foo; -(1.0).foo; -(12e+34).foo; -(0xff).foo; (1.0); (new A).foo; (typeof A).x; diff --git a/tests/baselines/reference/castExpressionParentheses.symbols b/tests/baselines/reference/castExpressionParentheses.symbols index ef31ee0f226..df7ef6a1f2f 100644 --- a/tests/baselines/reference/castExpressionParentheses.symbols +++ b/tests/baselines/reference/castExpressionParentheses.symbols @@ -37,27 +37,28 @@ declare var a; (a()).x; >a : Symbol(a, Decl(castExpressionParentheses.ts, 0, 11)) -declare var A; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) - -// should keep the parentheses in emit (1).foo; (1.).foo; (1.0).foo; (12e+34).foo; (0xff).foo; + +declare var A; +>A : Symbol(A, Decl(castExpressionParentheses.ts, 31, 11)) + +// should keep the parentheses in emit ((1.0)); (new A).foo; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 31, 11)) (typeof A).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 31, 11)) (-A).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 31, 11)) new (A()); ->A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 31, 11)) (()=> {})(); >Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 39, 2)) @@ -66,14 +67,14 @@ new (A()); >foo : Symbol(foo, Decl(castExpressionParentheses.ts, 40, 6)) (-A).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 31, 11)) // nested cast, should keep one pair of parenthese ((-A)).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 31, 11)) // nested parenthesized expression, should keep one pair of parenthese ((A)) ->A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 31, 11)) diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index aa633825eec..5971b55f103 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -125,10 +125,6 @@ declare var a; >a : any >x : any -declare var A; ->A : any - -// should keep the parentheses in emit (1).foo; >(1).foo : any >(1) : any @@ -164,6 +160,10 @@ declare var A; >0xff : 255 >foo : any +declare var A; +>A : any + +// should keep the parentheses in emit ((1.0)); >((1.0)) : any >(1.0) : any diff --git a/tests/baselines/reference/destructuringInVariableDeclarations1.js b/tests/baselines/reference/destructuringInVariableDeclarations1.js index a7645ceabe9..0cad8e5b990 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations1.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations1.js @@ -8,7 +8,7 @@ export let { toString } = 1; //// [destructuringInVariableDeclarations1.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.toString = (1).toString; +exports.toString = 1..toString; { let { toFixed } = 1; } diff --git a/tests/baselines/reference/destructuringInVariableDeclarations3.js b/tests/baselines/reference/destructuringInVariableDeclarations3.js index 2522a704e18..18708c92a7d 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations3.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations3.js @@ -9,7 +9,7 @@ export let { toString } = 1; define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.toString = (1).toString; + exports.toString = 1..toString; { let { toFixed } = 1; } diff --git a/tests/baselines/reference/destructuringInVariableDeclarations5.js b/tests/baselines/reference/destructuringInVariableDeclarations5.js index 20a094a0375..5aa76cc3a92 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations5.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations5.js @@ -17,7 +17,7 @@ export let { toString } = 1; })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.toString = (1).toString; + exports.toString = 1..toString; { let { toFixed } = 1; } diff --git a/tests/baselines/reference/destructuringInVariableDeclarations7.js b/tests/baselines/reference/destructuringInVariableDeclarations7.js index e7e4f803b77..82f28b09672 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations7.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations7.js @@ -13,7 +13,7 @@ System.register([], function (exports_1, context_1) { return { setters: [], execute: function () { - exports_1("toString", toString = (1).toString); + exports_1("toString", toString = 1..toString); { let { toFixed } = 1; } diff --git a/tests/baselines/reference/destructuringInVariableDeclarations8.js b/tests/baselines/reference/destructuringInVariableDeclarations8.js index 12340433bf4..bf4be279e78 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations8.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations8.js @@ -14,7 +14,7 @@ System.register([], function (exports_1, context_1) { return { setters: [], execute: function () { - toString = (1).toString; + toString = 1..toString; { let { toFixed } = 1; } diff --git a/tests/baselines/reference/destructuringTypeAssertionsES5_5.js b/tests/baselines/reference/destructuringTypeAssertionsES5_5.js index a51ac02af77..dddfaee8527 100644 --- a/tests/baselines/reference/destructuringTypeAssertionsES5_5.js +++ b/tests/baselines/reference/destructuringTypeAssertionsES5_5.js @@ -2,4 +2,4 @@ var { x } = 0; //// [destructuringTypeAssertionsES5_5.js] -var x = (0).x; +var x = 0..x; diff --git a/tests/baselines/reference/destructuringWithNumberLiteral.js b/tests/baselines/reference/destructuringWithNumberLiteral.js index 8804b850cc3..e8a5ee7d45e 100644 --- a/tests/baselines/reference/destructuringWithNumberLiteral.js +++ b/tests/baselines/reference/destructuringWithNumberLiteral.js @@ -2,4 +2,4 @@ var { toExponential } = 0; //// [destructuringWithNumberLiteral.js] -var toExponential = (0).toExponential; +var toExponential = 0..toExponential; diff --git a/tests/baselines/reference/duplicateIdentifierDifferentSpelling.js b/tests/baselines/reference/duplicateIdentifierDifferentSpelling.js index 96e5781919d..0bd30fe2fca 100644 --- a/tests/baselines/reference/duplicateIdentifierDifferentSpelling.js +++ b/tests/baselines/reference/duplicateIdentifierDifferentSpelling.js @@ -10,7 +10,7 @@ var X = { 0b11: '', 3: '' }; //// [duplicateIdentifierDifferentSpelling.js] var A = (function () { function A() { - this[3] = ''; + this[0b11] = ''; this[3] = ''; } return A; diff --git a/tests/baselines/reference/printerApi/printsFileCorrectly.templateLiteral.js b/tests/baselines/reference/printerApi/printsFileCorrectly.templateLiteral.js new file mode 100644 index 00000000000..fdfca9b218e --- /dev/null +++ b/tests/baselines/reference/printerApi/printsFileCorrectly.templateLiteral.js @@ -0,0 +1 @@ +let greeting = `Hi ${name}, how are you?`; diff --git a/tests/cases/compiler/castExpressionParentheses.ts b/tests/cases/compiler/castExpressionParentheses.ts index 06908f39936..4d70b9a7777 100644 --- a/tests/cases/compiler/castExpressionParentheses.ts +++ b/tests/cases/compiler/castExpressionParentheses.ts @@ -23,15 +23,15 @@ declare var a; (a[0]); (a.b["0"]); (a()).x; - -declare var A; - -// should keep the parentheses in emit (1).foo; (1.).foo; (1.0).foo; (12e+34).foo; (0xff).foo; + +declare var A; + +// should keep the parentheses in emit ((1.0)); (new A).foo; (typeof A).x; From 73cab096088f824aa62550ad98f250823a6b2b26 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 3 Apr 2017 09:32:39 -0700 Subject: [PATCH 07/14] Enable jsdoc-format lint rule --- src/compiler/checker.ts | 169 ++-- src/compiler/commandLineParser.ts | 26 +- src/compiler/comments.ts | 2 +- src/compiler/core.ts | 2 +- src/compiler/moduleNameResolver.ts | 14 +- src/compiler/transformers/destructuring.ts | 3 +- src/compiler/transformers/es2015.ts | 4 +- src/compiler/types.ts | 21 +- src/compiler/utilities.ts | 20 +- src/harness/fourslash.ts | 2 +- src/harness/harnessLanguageService.ts | 6 +- .../unittests/tsserverProjectSystem.ts | 10 +- src/lib/dom.iterable.d.ts | 40 +- src/lib/es2015.core.d.ts | 560 +++++------ src/lib/es2015.generator.d.ts | 28 +- src/lib/es2015.iterable.d.ts | 298 +++--- src/lib/es2015.promise.d.ts | 12 +- src/lib/es2015.symbol.d.ts | 26 +- src/lib/es2015.symbol.wellknown.d.ts | 224 ++--- src/lib/es2016.array.include.d.ts | 88 +- src/lib/es2017.object.d.ts | 24 +- src/lib/es2017.sharedmemory.d.ts | 8 +- src/lib/es2017.string.d.ts | 40 +- src/lib/scripthost.d.ts | 6 +- src/server/editorServices.ts | 14 +- src/server/protocol.ts | 934 +++++++++--------- src/server/utilities.ts | 4 +- src/services/codefixes/helpers.ts | 2 +- src/services/documentRegistry.ts | 92 +- src/services/findAllReferences.ts | 6 +- src/services/formatting/formatting.ts | 68 +- src/services/jsTyping.ts | 1 - src/services/services.ts | 8 +- src/services/shims.ts | 2 +- src/services/types.ts | 16 +- src/services/utilities.ts | 14 +- tslint.json | 3 +- 37 files changed, 1399 insertions(+), 1398 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5cb07f2d736..78ddce79f27 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -255,7 +255,7 @@ namespace ts { * List of every ambient module with a "*" wildcard. * Unlike other ambient modules, these can't be stored in `globals` because symbol tables only deal with exact matches. * This is only used if there is no exact match. - */ + */ let patternAmbientModules: PatternAmbientModule[]; let globalObjectType: ObjectType; @@ -5569,7 +5569,8 @@ namespace ts { } /** If the given type is an object type and that type has a property by the given name, - * return the symbol for that property. Otherwise return undefined. */ + * return the symbol for that property. Otherwise return undefined. + */ function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); @@ -13265,11 +13266,11 @@ namespace ts { } /** - * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic - * property (in which case nodeLinks.jsxFlags will be IntrinsicNamedElement) or an intrinsic - * string index signature (in which case nodeLinks.jsxFlags will be IntrinsicIndexedElement). - * May also return unknownSymbol if both of these lookups fail. - */ + * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic + * property (in which case nodeLinks.jsxFlags will be IntrinsicNamedElement) or an intrinsic + * string index signature (in which case nodeLinks.jsxFlags will be IntrinsicIndexedElement). + * May also return unknownSymbol if both of these lookups fail. + */ function getIntrinsicTagSymbol(node: JsxOpeningLikeElement | JsxClosingElement): Symbol { const links = getNodeLinks(node); if (!links.resolvedSymbol) { @@ -13473,7 +13474,7 @@ namespace ts { * @return attributes type if able to resolve the type of node * anyType if there is no type ElementAttributesProperty or there is an error * emptyObjectType if there is no "prop" in the element instance type - **/ + */ function resolveCustomJsxElementAttributesType(openingLikeElement: JsxOpeningLikeElement, shouldIncludeAllStatelessAttributesType: boolean, elementType?: Type, @@ -13730,11 +13731,11 @@ namespace ts { } /** - * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. - * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" - * Check assignablity between given attributes property, "source attributes", and the "target attributes" - * @param openingLikeElement an opening-like JSX element to check its JSXAttributes - */ + * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. + * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" + * Check assignablity between given attributes property, "source attributes", and the "target attributes" + * @param openingLikeElement an opening-like JSX element to check its JSXAttributes + */ function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement: JsxOpeningLikeElement) { // The function involves following steps: // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. @@ -14601,18 +14602,18 @@ namespace ts { /** - * Returns the effective argument count for a node that works like a function invocation. - * If 'node' is a Decorator, the number of arguments is derived from the decoration - * target and the signature: - * If 'node.target' is a class declaration or class expression, the effective argument - * count is 1. - * If 'node.target' is a parameter declaration, the effective argument count is 3. - * If 'node.target' is a property declaration, the effective argument count is 2. - * If 'node.target' is a method or accessor declaration, the effective argument count - * is 3, although it can be 2 if the signature only accepts two arguments, allowing - * us to match a property decorator. - * Otherwise, the argument count is the length of the 'args' array. - */ + * Returns the effective argument count for a node that works like a function invocation. + * If 'node' is a Decorator, the number of arguments is derived from the decoration + * target and the signature: + * If 'node.target' is a class declaration or class expression, the effective argument + * count is 1. + * If 'node.target' is a parameter declaration, the effective argument count is 3. + * If 'node.target' is a property declaration, the effective argument count is 2. + * If 'node.target' is a method or accessor declaration, the effective argument count + * is 3, although it can be 2 if the signature only accepts two arguments, allowing + * us to match a property decorator. + * Otherwise, the argument count is the length of the 'args' array. + */ function getEffectiveArgumentCount(node: CallLikeExpression, args: Expression[], signature: Signature) { if (node.kind === SyntaxKind.Decorator) { switch (node.parent.kind) { @@ -14654,17 +14655,17 @@ namespace ts { } /** - * Returns the effective type of the first argument to a decorator. - * If 'node' is a class declaration or class expression, the effective argument type - * is the type of the static side of the class. - * If 'node' is a parameter declaration, the effective argument type is either the type - * of the static or instance side of the class for the parameter's parent method, - * depending on whether the method is declared static. - * For a constructor, the type is always the type of the static side of the class. - * If 'node' is a property, method, or accessor declaration, the effective argument - * type is the type of the static or instance side of the parent class for class - * element, depending on whether the element is declared static. - */ + * Returns the effective type of the first argument to a decorator. + * If 'node' is a class declaration or class expression, the effective argument type + * is the type of the static side of the class. + * If 'node' is a parameter declaration, the effective argument type is either the type + * of the static or instance side of the class for the parameter's parent method, + * depending on whether the method is declared static. + * For a constructor, the type is always the type of the static side of the class. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. + */ function getEffectiveDecoratorFirstArgumentType(node: Node): Type { // The first argument to a decorator is its `target`. if (node.kind === SyntaxKind.ClassDeclaration) { @@ -14700,20 +14701,20 @@ namespace ts { } /** - * Returns the effective type for the second argument to a decorator. - * If 'node' is a parameter, its effective argument type is one of the following: - * If 'node.parent' is a constructor, the effective argument type is 'any', as we - * will emit `undefined`. - * If 'node.parent' is a member with an identifier, numeric, or string literal name, - * the effective argument type will be a string literal type for the member name. - * If 'node.parent' is a computed property name, the effective argument type will - * either be a symbol type or the string type. - * If 'node' is a member with an identifier, numeric, or string literal name, the - * effective argument type will be a string literal type for the member name. - * If 'node' is a computed property name, the effective argument type will either - * be a symbol type or the string type. - * A class decorator does not have a second argument type. - */ + * Returns the effective type for the second argument to a decorator. + * If 'node' is a parameter, its effective argument type is one of the following: + * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * will emit `undefined`. + * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * the effective argument type will be a string literal type for the member name. + * If 'node.parent' is a computed property name, the effective argument type will + * either be a symbol type or the string type. + * If 'node' is a member with an identifier, numeric, or string literal name, the + * effective argument type will be a string literal type for the member name. + * If 'node' is a computed property name, the effective argument type will either + * be a symbol type or the string type. + * A class decorator does not have a second argument type. + */ function getEffectiveDecoratorSecondArgumentType(node: Node) { // The second argument to a decorator is its `propertyKey` if (node.kind === SyntaxKind.ClassDeclaration) { @@ -14767,12 +14768,12 @@ namespace ts { } /** - * Returns the effective argument type for the third argument to a decorator. - * If 'node' is a parameter, the effective argument type is the number type. - * If 'node' is a method or accessor, the effective argument type is a - * `TypedPropertyDescriptor` instantiated with the type of the member. - * Class and property decorators do not have a third effective argument. - */ + * Returns the effective argument type for the third argument to a decorator. + * If 'node' is a parameter, the effective argument type is the number type. + * If 'node' is a method or accessor, the effective argument type is a + * `TypedPropertyDescriptor` instantiated with the type of the member. + * Class and property decorators do not have a third effective argument. + */ function getEffectiveDecoratorThirdArgumentType(node: Node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator @@ -14805,8 +14806,8 @@ namespace ts { } /** - * Returns the effective argument type for the provided argument to a decorator. - */ + * Returns the effective argument type for the provided argument to a decorator. + */ function getEffectiveDecoratorArgumentType(node: Decorator, argIndex: number): Type { if (argIndex === 0) { return getEffectiveDecoratorFirstArgumentType(node.parent); @@ -14823,8 +14824,8 @@ namespace ts { } /** - * Gets the effective argument type for an argument in a call expression. - */ + * Gets the effective argument type for an argument in a call expression. + */ function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number): Type { // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types @@ -14842,8 +14843,8 @@ namespace ts { } /** - * Gets the effective argument expression for an argument in a call expression. - */ + * Gets the effective argument expression for an argument in a call expression. + */ function getEffectiveArgument(node: CallLikeExpression, args: Expression[], argIndex: number) { // For a decorator or the first argument of a tagged template expression we return undefined. if (node.kind === SyntaxKind.Decorator || @@ -14855,8 +14856,8 @@ namespace ts { } /** - * Gets the error node to use when reporting errors for an effective argument. - */ + * Gets the error node to use when reporting errors for an effective argument. + */ function getEffectiveArgumentErrorNode(node: CallLikeExpression, argIndex: number, arg: Expression) { if (node.kind === SyntaxKind.Decorator) { // For a decorator, we use the expression of the decorator for error reporting. @@ -15358,8 +15359,8 @@ namespace ts { } /** - * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. - */ + * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. + */ function getDiagnosticHeadMessageForDecoratorResolution(node: Decorator) { switch (node.parent.kind) { case SyntaxKind.ClassDeclaration: @@ -15380,8 +15381,8 @@ namespace ts { } /** - * Resolves a decorator as if it were a call expression. - */ + * Resolves a decorator as if it were a call expression. + */ function resolveDecorator(node: Decorator, candidatesOutArray: Signature[]): Signature { const funcType = checkExpression(node.expression); const apparentType = getApparentType(funcType); @@ -18189,10 +18190,10 @@ namespace ts { } /** - * Gets the "promised type" of a promise. - * @param type The type of the promise. - * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. - */ + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. + */ function getPromisedTypeOfPromise(promise: Type, errorNode?: Node): Type { // // { // promise @@ -18247,12 +18248,12 @@ namespace ts { } /** - * Gets the "awaited type" of a type. - * @param type The type to await. - * @remarks The "awaited type" of an expression is its "promised type" if the expression is a - * Promise-like type; otherwise, it is the type of the expression. This is used to reflect - * The runtime behavior of the `await` keyword. - */ + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ function checkAwaitedType(type: Type, errorNode: Node): Type { return getAwaitedType(type, errorNode) || unknownType; } @@ -22055,9 +22056,9 @@ namespace ts { } /** - * Gets either the static or instance type of a class element, based on - * whether the element is declared as "static". - */ + * Gets either the static or instance type of a class element, based on + * whether the element is declared as "static". + */ function getParentTypeOfClassElement(node: ClassElement) { const classSymbol = getSymbolOfNode(node.parent); return getModifierFlags(node) & ModifierFlags.Static @@ -23579,9 +23580,9 @@ namespace ts { } /** Does the accessor have the right number of parameters? - - A get accessor has no parameters or a single `this` parameter. - A set accessor has one parameter or a `this` parameter and one more parameter */ + * A get accessor has no parameters or a single `this` parameter. + * A set accessor has one parameter or a `this` parameter and one more parameter. + */ function doesAccessorHaveCorrectParameterCount(accessor: AccessorDeclaration) { return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === SyntaxKind.GetAccessor ? 0 : 1); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 24abac1e298..d38d9be4e76 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -860,9 +860,9 @@ namespace ts { } /** - * Read tsconfig.json file - * @param fileName The path to the config file - */ + * Read tsconfig.json file + * @param fileName The path to the config file + */ export function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic } { let text = ""; try { @@ -875,10 +875,10 @@ namespace ts { } /** - * Parse the text of the tsconfig.json file - * @param fileName The path to the config file - * @param jsonText The text of the config file - */ + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ export function parseConfigFileTextToJson(fileName: string, jsonText: string, stripComments = true): { config?: any; error?: Diagnostic } { try { const jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; @@ -1083,12 +1083,12 @@ namespace ts { } /** - * Parse the contents of a config file (tsconfig.json). - * @param json The contents of the config file to parse - * @param host Instance of ParseConfigHost used to enumerate files in folder. - * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir - */ + * Parse the contents of a config file (tsconfig.json). + * @param json The contents of the config file to parse + * @param host Instance of ParseConfigHost used to enumerate files in folder. + * @param basePath A root directory to resolve relative path entries in the config + * file to. e.g. outDir + */ export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: JsFileExtensionInfo[] = []): ParsedCommandLine { const errors: Diagnostic[] = []; basePath = normalizeSlashes(basePath); diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index 9e077ebfaa8..c50cacc2ccb 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -411,7 +411,7 @@ namespace ts { * Determine if the given comment is a triple-slash * * @return true if the comment is a triple-slash comment else false - **/ + */ function isTripleSlashComment(commentPos: number, commentEnd: number) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments diff --git a/src/compiler/core.ts b/src/compiler/core.ts index a56f1004d28..1039325fe56 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1358,7 +1358,7 @@ namespace ts { /** * Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files") - */ + */ export function getRootLength(path: string): number { if (path.charCodeAt(0) === CharacterCodes.slash) { if (path.charCodeAt(1) !== CharacterCodes.slash) return 1; diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 699919e0566..5280c794725 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -249,13 +249,13 @@ namespace ts { } /** - * Given a set of options, returns the set of type directive names - * that should be included for this program automatically. - * This list could either come from the config file, - * or from enumerating the types root + initial secondary types lookup location. - * More type directives might appear in the program later as a result of loading actual source files; - * this list is only the set of defaults that are implicitly included. - */ + * Given a set of options, returns the set of type directive names + * that should be included for this program automatically. + * This list could either come from the config file, + * or from enumerating the types root + initial secondary types lookup location. + * More type directives might appear in the program later as a result of loading actual source files; + * this list is only the set of defaults that are implicitly included. + */ export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] { // Use explicit type list from tsconfig.json if (options.types) { diff --git a/src/compiler/transformers/destructuring.ts b/src/compiler/transformers/destructuring.ts index df372fd9a2c..bbc79270c77 100644 --- a/src/compiler/transformers/destructuring.ts +++ b/src/compiler/transformers/destructuring.ts @@ -490,7 +490,8 @@ namespace ts { }; /** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement - * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`*/ + * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);` + */ function createRestCall(context: TransformationContext, value: Expression, elements: BindingOrAssignmentElement[], computedTempVariables: Expression[], location: TextRange): Expression { context.requestEmitHelper(restHelper); const propertyNames: Expression[] = []; diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index fd2c287d0e0..2b9e3598b4a 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -315,7 +315,7 @@ namespace ts { * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. - **/ + */ function enterSubtree(excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) { const ancestorFacts = hierarchyFacts; hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & HierarchyFacts.AncestorFactsMask; @@ -328,7 +328,7 @@ namespace ts { * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. - **/ + */ function exitSubtree(ancestorFacts: HierarchyFacts, excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) { hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & HierarchyFacts.SubtreeFactsMask | ancestorFacts; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index dcad61a3177..90d11607911 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -819,7 +819,7 @@ namespace ts { body?: FunctionBody; } - /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements.*/ + /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; parent?: ClassDeclaration | ClassExpression; @@ -1386,11 +1386,11 @@ namespace ts { } /** - * This interface is a base interface for ObjectLiteralExpression and JSXAttributes to extend from. JSXAttributes is similar to - * ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be - * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type - * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) - **/ + * This interface is a base interface for ObjectLiteralExpression and JSXAttributes to extend from. JSXAttributes is similar to + * ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be + * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type + * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) + */ export interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } @@ -2319,9 +2319,9 @@ namespace ts { readDirectory(rootDir: string, extensions: string[], excludes: string[], includes: string[]): string[]; /** - * Gets a value indicating whether the specified path exists and is a file. - * @param path The path to test. - */ + * Gets a value indicating whether the specified path exists and is a file. + * @param path The path to test. + */ fileExists(path: string): boolean; readFile(path: string): string; @@ -2669,8 +2669,7 @@ namespace ts { errorModuleName?: string; // If the symbol is not visible from module, module's name } - /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator - * metadata */ + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ export enum TypeReferenceSerializationKind { Unknown, // The TypeReferenceNode could not be resolved. The type name diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5c6e519519b..7c0664a0637 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1095,13 +1095,13 @@ namespace ts { } /** - * Given an super call/property node, returns the closest node where - * - a super call/property access is legal in the node and not legal in the parent node the node. - * i.e. super call is legal in constructor but not legal in the class body. - * - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher) - * - a super call/property is definitely illegal in the container (but might be legal in some subnode) - * i.e. super property access is illegal in function declaration but can be legal in the statement list - */ + * Given an super call/property node, returns the closest node where + * - a super call/property access is legal in the node and not legal in the parent node the node. + * i.e. super call is legal in constructor but not legal in the class body. + * - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher) + * - a super call/property is definitely illegal in the container (but might be legal in some subnode) + * i.e. super property access is illegal in function declaration but can be legal in the statement list + */ export function getSuperContainer(node: Node, stopOnFunctions: boolean): Node { while (true) { node = node.parent; @@ -4554,9 +4554,9 @@ namespace ts { } /** - * Checks to see if the locale is in the appropriate format, - * and if it is, attempts to set the appropriate language. - */ + * Checks to see if the locale is in the appropriate format, + * and if it is, attempts to set the appropriate language. + */ export function validateLocaleAndSetLanguage( locale: string, sys: { getExecutingFilePath(): string, resolvePath(path: string): string, fileExists(fileName: string): boolean, readFile(fileName: string): string }, diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 499c854b091..18b458c60d3 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2205,7 +2205,7 @@ namespace FourSlash { /** * Applies fixes for the errors in fileName and compares the results to * expectedContents after all fixes have been applied. - + * * Note: applying one codefix may generate another (eg: remove duplicate implements * may generate an extends -> interface conversion fix). * @param expectedContents The contents of the file after the fixes are applied. diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index e7f32748570..14508640faf 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -169,9 +169,9 @@ namespace Harness.LanguageService { } /** - * @param line 0 based index - * @param col 0 based index - */ + * @param line 0 based index + * @param col 0 based index + */ public positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { const script: ScriptInfo = this.getScriptInfo(fileName); assert.isOk(script); diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index b78fa094571..35939861704 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -548,11 +548,11 @@ namespace ts.projectSystem { } /** - * Test server cancellation token used to mock host token cancellation requests. - * The cancelAfterRequest constructor param specifies how many isCancellationRequested() calls - * should be made before canceling the token. The id of the request to cancel should be set with - * setRequestToCancel(); - */ + * Test server cancellation token used to mock host token cancellation requests. + * The cancelAfterRequest constructor param specifies how many isCancellationRequested() calls + * should be made before canceling the token. The id of the request to cancel should be set with + * setRequestToCancel(); + */ export class TestServerCancellationToken implements server.ServerCancellationToken { private currentId = -1; private requestToCancel = -1; diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index c79e0079962..b5e0404c17b 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -23,23 +23,23 @@ interface FormData { interface NodeList { /** - * Returns an array of key, value pairs for every entry in the list - */ + * Returns an array of key, value pairs for every entry in the list + */ entries(): IterableIterator<[number, Node]>; /** - * Performs the specified action for each node in an list. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; /** - * Returns an list of keys in the list - */ + * Returns an list of keys in the list + */ keys(): IterableIterator; /** - * Returns an list of values in the list - */ + * Returns an list of values in the list + */ values(): IterableIterator; @@ -49,23 +49,23 @@ interface NodeList { interface NodeListOf { /** - * Returns an array of key, value pairs for every entry in the list - */ + * Returns an array of key, value pairs for every entry in the list + */ entries(): IterableIterator<[number, TNode]>; /** - * Performs the specified action for each node in an list. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; /** - * Returns an list of keys in the list - */ + * Returns an list of keys in the list + */ keys(): IterableIterator; /** - * Returns an list of values in the list - */ + * Returns an list of values in the list + */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 2e56221fe9a..341fd80872c 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -2,75 +2,75 @@ declare type PropertyKey = string | number | symbol; interface Array { /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): T | undefined; find(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): number; findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: T, start?: number, end?: number): this; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; } interface ArrayConstructor { /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): Array; from(arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): Array; from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ from(arrayLike: ArrayLike): Array; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: T[]): Array; } @@ -80,332 +80,332 @@ interface DateConstructor { interface Function { /** - * Returns the name of the function. Function names are read-only and can not be changed. - */ + * Returns the name of the function. Function names are read-only and can not be changed. + */ readonly name: string; } interface Math { /** - * Returns the number of leading zero bits in the 32-bit binary representation of a number. - * @param x A numeric expression. - */ + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ clz32(x: number): number; /** - * Returns the result of 32-bit multiplication of two numbers. - * @param x First number - * @param y Second number - */ + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ imul(x: number, y: number): number; /** - * Returns the sign of the x, indicating whether x is positive, negative or zero. - * @param x The numeric expression to test - */ + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ sign(x: number): number; /** - * Returns the base 10 logarithm of a number. - * @param x A numeric expression. - */ + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ log10(x: number): number; /** - * Returns the base 2 logarithm of a number. - * @param x A numeric expression. - */ + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ log2(x: number): number; /** - * Returns the natural logarithm of 1 + x. - * @param x A numeric expression. - */ + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ log1p(x: number): number; /** - * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of - * the natural logarithms). - * @param x A numeric expression. - */ + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ expm1(x: number): number; /** - * Returns the hyperbolic cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ cosh(x: number): number; /** - * Returns the hyperbolic sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ sinh(x: number): number; /** - * Returns the hyperbolic tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ tanh(x: number): number; /** - * Returns the inverse hyperbolic cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ acosh(x: number): number; /** - * Returns the inverse hyperbolic sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ asinh(x: number): number; /** - * Returns the inverse hyperbolic tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ atanh(x: number): number; /** - * Returns the square root of the sum of squares of its arguments. - * @param values Values to compute the square root for. - * If no arguments are passed, the result is +0. - * If there is only one argument, the result is the absolute value. - * If any argument is +Infinity or -Infinity, the result is +Infinity. - * If any argument is NaN, the result is NaN. - * If all arguments are either +0 or −0, the result is +0. - */ + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ hypot(...values: number[] ): number; /** - * Returns the integral part of the a numeric expression, x, removing any fractional digits. - * If x is already an integer, the result is x. - * @param x A numeric expression. - */ + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ trunc(x: number): number; /** - * Returns the nearest single precision float representation of a number. - * @param x A numeric expression. - */ + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ fround(x: number): number; /** - * Returns an implementation-dependent approximation to the cube root of number. - * @param x A numeric expression. - */ + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ cbrt(x: number): number; } interface NumberConstructor { /** - * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 - * that is representable as a Number value, which is approximately: - * 2.2204460492503130808472633361816 x 10‍−‍16. - */ + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ readonly EPSILON: number; /** - * Returns true if passed value is finite. - * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a - * number. Only finite values of the type number, result in true. - * @param number A numeric value. - */ + * Returns true if passed value is finite. + * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ isFinite(number: number): boolean; /** - * Returns true if the value passed is an integer, false otherwise. - * @param number A numeric value. - */ + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ isInteger(number: number): boolean; /** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a - * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter - * to a number. Only values of the type number, that are also NaN, result in true. - * @param number A numeric value. - */ + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ isNaN(number: number): boolean; /** - * Returns true if the value passed is a safe integer. - * @param number A numeric value. - */ + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ isSafeInteger(number: number): boolean; /** - * The value of the largest integer n such that n and n + 1 are both exactly representable as - * a Number value. - * The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1. - */ + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ readonly MAX_SAFE_INTEGER: number; /** - * The value of the smallest integer n such that n and n − 1 are both exactly representable as - * a Number value. - * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). - */ + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ readonly MIN_SAFE_INTEGER: number; /** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ parseFloat(string: string): number; /** - * Converts A string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ parseInt(string: string, radix?: number): number; } interface Object { /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ hasOwnProperty(v: PropertyKey): boolean; /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ + * Determines whether a specified property is enumerable. + * @param v A property name. + */ propertyIsEnumerable(v: PropertyKey): boolean; } interface ObjectConstructor { /** - * Copy the values of all of the enumerable own properties from one or more source objects to a - * target object. Returns the target object. - * @param target The target object to copy to. - * @param source The source object from which to copy properties. - */ + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source The source object from which to copy properties. + */ assign(target: T, source: U): T & U; /** - * Copy the values of all of the enumerable own properties from one or more source objects to a - * target object. Returns the target object. - * @param target The target object to copy to. - * @param source1 The first source object from which to copy properties. - * @param source2 The second source object from which to copy properties. - */ + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ assign(target: T, source1: U, source2: V): T & U & V; /** - * Copy the values of all of the enumerable own properties from one or more source objects to a - * target object. Returns the target object. - * @param target The target object to copy to. - * @param source1 The first source object from which to copy properties. - * @param source2 The second source object from which to copy properties. - * @param source3 The third source object from which to copy properties. - */ + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; /** - * Copy the values of all of the enumerable own properties from one or more source objects to a - * target object. Returns the target object. - * @param target The target object to copy to. - * @param sources One or more source objects from which to copy properties - */ + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties + */ assign(target: any, ...sources: any[]): any; /** - * Returns an array of all symbol properties found directly on object o. - * @param o Object to retrieve the symbols from. - */ + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ getOwnPropertySymbols(o: any): symbol[]; /** - * Returns true if the values are the same value, false otherwise. - * @param value1 The first value. - * @param value2 The second value. - */ + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ is(value1: any, value2: any): boolean; /** - * Sets the prototype of a specified object o to object proto or null. Returns the object o. - * @param o The object to change its prototype. - * @param proto The value of the new prototype or null. - */ + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ setPrototypeOf(o: any, proto: object | null): any; /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not - * inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript - * object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor - * property. - */ + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; } interface ReadonlyArray { - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (this: undefined, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; - find(predicate: (this: undefined, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (this: undefined, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; + find(predicate: (this: undefined, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; } interface RegExp { /** - * Returns a string indicating the flags of the regular expression in question. This field is read-only. - * The characters in this string are sequenced and concatenated in the following order: - * - * - "g" for global - * - "i" for ignoreCase - * - "m" for multiline - * - "u" for unicode - * - "y" for sticky - * - * If no flags are set, the value is the empty string. - */ + * Returns a string indicating the flags of the regular expression in question. This field is read-only. + * The characters in this string are sequenced and concatenated in the following order: + * + * - "g" for global + * - "i" for ignoreCase + * - "m" for multiline + * - "u" for unicode + * - "y" for sticky + * + * If no flags are set, the value is the empty string. + */ readonly flags: string; /** - * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular - * expression. Default is false. Read-only. - */ + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ readonly sticky: boolean; /** - * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular - * expression. Default is false. Read-only. - */ + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ readonly unicode: boolean; } @@ -416,64 +416,64 @@ interface RegExpConstructor { interface String { /** - * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point - * value of the UTF-16 encoded code point starting at the string element at position pos in - * the String resulting from converting this object to a String. - * If there is no element at that position, the result is undefined. - * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. - */ + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ codePointAt(pos: number): number | undefined; /** - * Returns true if searchString appears as a substring of the result of converting this - * object to a String, at one or more positions that are - * greater than or equal to position; otherwise, returns false. - * @param searchString search string - * @param position If position is undefined, 0 is assumed, so as to search all of the String. - */ + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ includes(searchString: string, position?: number): boolean; /** - * Returns true if the sequence of elements of searchString converted to a String is the - * same as the corresponding elements of this object (converted to a String) starting at - * endPosition – length(this). Otherwise returns false. - */ + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ endsWith(searchString: string, endPosition?: number): boolean; /** - * Returns the String value result of normalizing the string into the normalization form - * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. - * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default - * is "NFC" - */ + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; /** - * Returns the String value result of normalizing the string into the normalization form - * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. - * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default - * is "NFC" - */ + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ normalize(form?: string): string; /** - * Returns a String value that is made from count copies appended together. If count is 0, - * T is the empty String is returned. - * @param count number of copies to append - */ + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ repeat(count: number): string; /** - * Returns true if the sequence of elements of searchString converted to a String is the - * same as the corresponding elements of this object (converted to a String) starting at - * position. Otherwise returns false. - */ + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ startsWith(searchString: string, position?: number): boolean; /** - * Returns an HTML anchor element and sets the name attribute to the text value - * @param name - */ + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ anchor(name: string): string; /** Returns a HTML element */ @@ -518,17 +518,17 @@ interface String { interface StringConstructor { /** - * Return the String value whose elements are, in order, the elements in the List elements. - * If length is 0, the empty string is returned. - */ + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ fromCodePoint(...codePoints: number[]): string; /** - * String.raw is intended for use as a tag function of a Tagged Template String. When called - * as such the first argument will be a well formed template call site object and the rest - * parameter will contain the substitution values. - * @param template A well-formed template string call site representation. - * @param substitutions A set of substitution values. - */ + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ raw(template: TemplateStringsArray, ...substitutions: any[]): string; } diff --git a/src/lib/es2015.generator.d.ts b/src/lib/es2015.generator.d.ts index 5637ef816de..8ea4f2f9630 100644 --- a/src/lib/es2015.generator.d.ts +++ b/src/lib/es2015.generator.d.ts @@ -16,37 +16,37 @@ interface GeneratorFunction { */ readonly length: number; /** - * Returns the name of the function. - */ + * Returns the name of the function. + */ readonly name: string; /** - * A reference to the prototype. - */ + * A reference to the prototype. + */ readonly prototype: Generator; } interface GeneratorFunctionConstructor { /** - * Creates a new Generator function. - * @param args A list of arguments the function accepts. - */ + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ new (...args: string[]): GeneratorFunction; /** - * Creates a new Generator function. - * @param args A list of arguments the function accepts. - */ + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ (...args: string[]): GeneratorFunction; /** * The length of the arguments. */ readonly length: number; /** - * Returns the name of the function. - */ + * Returns the name of the function. + */ readonly name: string; /** - * A reference to the prototype. - */ + * A reference to the prototype. + */ readonly prototype: GeneratorFunction; } declare var GeneratorFunction: GeneratorFunctionConstructor; diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 73f0d45cda7..03c583dc155 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -2,9 +2,9 @@ interface SymbolConstructor { /** - * A method that returns the default iterator for an object. Called by the semantics of the - * for-of statement. - */ + * A method that returns the default iterator for an object. Called by the semantics of the + * for-of statement. + */ readonly iterator: symbol; } @@ -32,36 +32,36 @@ interface Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, T]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } interface ArrayConstructor { /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): Array; from(iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): Array; from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ from(iterable: Iterable): Array; } @@ -70,18 +70,18 @@ interface ReadonlyArray { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, T]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -154,22 +154,22 @@ interface String { } /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Int8Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, number]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -177,11 +177,11 @@ interface Int8ArrayConstructor { new (elements: Iterable): Int8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; @@ -190,22 +190,22 @@ interface Int8ArrayConstructor { } /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint8Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, number]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -213,11 +213,11 @@ interface Uint8ArrayConstructor { new (elements: Iterable): Uint8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; @@ -226,24 +226,24 @@ interface Uint8ArrayConstructor { } /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, number]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -252,11 +252,11 @@ interface Uint8ClampedArrayConstructor { /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; @@ -265,24 +265,24 @@ interface Uint8ClampedArrayConstructor { } /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Int16Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, number]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -290,11 +290,11 @@ interface Int16ArrayConstructor { new (elements: Iterable): Int16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; @@ -303,22 +303,22 @@ interface Int16ArrayConstructor { } /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint16Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, number]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -326,11 +326,11 @@ interface Uint16ArrayConstructor { new (elements: Iterable): Uint16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; @@ -339,22 +339,22 @@ interface Uint16ArrayConstructor { } /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Int32Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, number]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -362,11 +362,11 @@ interface Int32ArrayConstructor { new (elements: Iterable): Int32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; @@ -375,22 +375,22 @@ interface Int32ArrayConstructor { } /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint32Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, number]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -398,11 +398,11 @@ interface Uint32ArrayConstructor { new (elements: Iterable): Uint32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; @@ -411,22 +411,22 @@ interface Uint32ArrayConstructor { } /** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ interface Float32Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, number]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -434,11 +434,11 @@ interface Float32ArrayConstructor { new (elements: Iterable): Float32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; @@ -447,22 +447,22 @@ interface Float32ArrayConstructor { } /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Float64Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array - */ + * Returns an array of key, value pairs for every entry in the array + */ entries(): IterableIterator<[number, number]>; /** - * Returns an list of keys in the array - */ + * Returns an list of keys in the array + */ keys(): IterableIterator; /** - * Returns an list of values in the array - */ + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -470,11 +470,11 @@ interface Float64ArrayConstructor { new (elements: Iterable): Float64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; diff --git a/src/lib/es2015.promise.d.ts b/src/lib/es2015.promise.d.ts index 208e5c1cdc2..ab33531191f 100644 --- a/src/lib/es2015.promise.d.ts +++ b/src/lib/es2015.promise.d.ts @@ -1,7 +1,7 @@ interface PromiseConstructor { /** - * A reference to the prototype. - */ + * A reference to the prototype. + */ readonly prototype: Promise; /** @@ -187,10 +187,10 @@ interface PromiseConstructor { reject(reason: any): Promise; /** - * Creates a new resolved promise for the provided value. - * @param value A promise. - * @returns A promise whose internal state matches the provided promise. - */ + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ resolve(value: T | PromiseLike): Promise; /** diff --git a/src/lib/es2015.symbol.d.ts b/src/lib/es2015.symbol.d.ts index 44a5f17d742..8444ef24618 100644 --- a/src/lib/es2015.symbol.d.ts +++ b/src/lib/es2015.symbol.d.ts @@ -8,28 +8,28 @@ interface Symbol { interface SymbolConstructor { /** - * A reference to the prototype. - */ + * A reference to the prototype. + */ readonly prototype: Symbol; /** - * Returns a new unique Symbol value. - * @param description Description of the new Symbol object. - */ + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ (description?: string | number): symbol; /** - * Returns a Symbol object from the global symbol registry matching the given key if found. - * Otherwise, returns a new symbol with this key. - * @param key key to search for. - */ + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ for(key: string): symbol; /** - * Returns a key from the global symbol registry matching the given Symbol if found. - * Otherwise, returns a undefined. - * @param sym Symbol to find the key for. - */ + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ keyFor(sym: symbol): string | undefined; } diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 5334dae9e01..578cf0acbc2 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -2,63 +2,63 @@ interface SymbolConstructor { /** - * A method that determines if a constructor object recognizes an object as one of the - * constructor’s instances. Called by the semantics of the instanceof operator. - */ + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ readonly hasInstance: symbol; /** - * A Boolean value that if true indicates that an object should flatten to its array elements - * by Array.prototype.concat. - */ + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ readonly isConcatSpreadable: symbol; /** - * A regular expression method that matches the regular expression against a string. Called - * by the String.prototype.match method. - */ + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. + */ readonly match: symbol; /** - * A regular expression method that replaces matched substrings of a string. Called by the - * String.prototype.replace method. - */ + * A regular expression method that replaces matched substrings of a string. Called by the + * String.prototype.replace method. + */ readonly replace: symbol; /** - * A regular expression method that returns the index within a string that matches the - * regular expression. Called by the String.prototype.search method. - */ + * A regular expression method that returns the index within a string that matches the + * regular expression. Called by the String.prototype.search method. + */ readonly search: symbol; /** - * A function valued property that is the constructor function that is used to create - * derived objects. - */ + * A function valued property that is the constructor function that is used to create + * derived objects. + */ readonly species: symbol; /** - * A regular expression method that splits a string at the indices that match the regular - * expression. Called by the String.prototype.split method. - */ + * A regular expression method that splits a string at the indices that match the regular + * expression. Called by the String.prototype.split method. + */ readonly split: symbol; /** - * A method that converts an object to a corresponding primitive value. - * Called by the ToPrimitive abstract operation. - */ + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. + */ readonly toPrimitive: symbol; /** - * A String value that is used in the creation of the default string description of an object. - * Called by the built-in method Object.prototype.toString. - */ + * A String value that is used in the creation of the default string description of an object. + * Called by the built-in method Object.prototype.toString. + */ readonly toStringTag: symbol; /** - * An Object whose own property names are property names that are excluded from the 'with' - * environment bindings of the associated objects. - */ + * An Object whose own property names are property names that are excluded from the 'with' + * environment bindings of the associated objects. + */ readonly unscopables: symbol; } @@ -154,50 +154,50 @@ interface PromiseConstructor { } interface RegExp { - /** - * Matches a string with this regular expression, and returns an array containing the results of - * that search. - * @param string A string to search within. - */ + /** + * Matches a string with this regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ [Symbol.match](string: string): RegExpMatchArray | null; /** - * Replaces text in a string, using this regular expression. - * @param string A String object or string literal whose contents matching against - * this regular expression will be replaced - * @param replaceValue A String object or string literal containing the text to replace for every - * successful match of this regular expression. - */ + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of this regular expression. + */ [Symbol.replace](string: string, replaceValue: string): string; /** - * Replaces text in a string, using this regular expression. - * @param string A String object or string literal whose contents matching against - * this regular expression will be replaced - * @param replacer A function that returns the replacement text. - */ + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. + */ [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; /** - * Finds the position beginning first substring match in a regular expression search - * using this regular expression. - * - * @param string The string to search within. - */ + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ [Symbol.search](string: string): number; /** - * Returns an array of substrings that were delimited by strings in the original input that - * match against this regular expression. - * - * If the regular expression contains capturing parentheses, then each time this - * regular expression matches, the results (including any undefined results) of the - * capturing parentheses are spliced. - * - * @param string string value to split - * @param limit if not undefined, the output array is truncated so that it contains no more - * than 'limit' elements. - */ + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ [Symbol.split](string: string, limit?: number): string[]; } @@ -207,45 +207,45 @@ interface RegExpConstructor { interface String { /** - * Matches a string an object that supports being matched against, and returns an array containing the results of that search. - * @param matcher An object that supports being matched against. - */ + * Matches a string an object that supports being matched against, and returns an array containing the results of that search. + * @param matcher An object that supports being matched against. + */ match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; /** - * Replaces text in a string, using an object that supports replacement within a string. - * @param searchValue A object can search for and replace matches within a string. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. - */ + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; /** - * Replaces text in a string, using an object that supports replacement within a string. - * @param searchValue A object can search for and replace matches within a string. - * @param replacer A function that returns the replacement text. - */ + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; /** - * Finds the first substring match in a regular expression search. - * @param searcher An object which supports searching within a string. - */ + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ search(searcher: { [Symbol.search](string: string): number; }): number; /** - * Split a string into substrings using the specified separator and return them as an array. - * @param splitter An object that can split a string. - * @param limit A value used to limit the number of elements returned in the array. - */ + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; } /** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; } @@ -255,73 +255,73 @@ interface DataView { } /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Int8Array { readonly [Symbol.toStringTag]: "Int8Array"; } /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint8Array { readonly [Symbol.toStringTag]: "UInt8Array"; } /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ interface Uint8ClampedArray { readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Int16Array { readonly [Symbol.toStringTag]: "Int16Array"; } /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint16Array { readonly [Symbol.toStringTag]: "Uint16Array"; } /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Int32Array { readonly [Symbol.toStringTag]: "Int32Array"; } /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint32Array { readonly [Symbol.toStringTag]: "Uint32Array"; } /** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ interface Float32Array { readonly [Symbol.toStringTag]: "Float32Array"; } /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } diff --git a/src/lib/es2016.array.include.d.ts b/src/lib/es2016.array.include.d.ts index fdd9ed4639f..1012c18407b 100644 --- a/src/lib/es2016.array.include.d.ts +++ b/src/lib/es2016.array.include.d.ts @@ -1,98 +1,98 @@ interface Array { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: T, fromIndex?: number): boolean; } interface ReadonlyArray { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: T, fromIndex?: number): boolean; } interface Int8Array { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: number, fromIndex?: number): boolean; } interface Uint8Array { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: number, fromIndex?: number): boolean; } interface Uint8ClampedArray { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: number, fromIndex?: number): boolean; } interface Int16Array { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: number, fromIndex?: number): boolean; } interface Uint16Array { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: number, fromIndex?: number): boolean; } interface Int32Array { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: number, fromIndex?: number): boolean; } interface Uint32Array { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: number, fromIndex?: number): boolean; } interface Float32Array { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: number, fromIndex?: number): boolean; } interface Float64Array { /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: number, fromIndex?: number): boolean; } \ No newline at end of file diff --git a/src/lib/es2017.object.d.ts b/src/lib/es2017.object.d.ts index 80c2161506a..1f090a8fef2 100644 --- a/src/lib/es2017.object.d.ts +++ b/src/lib/es2017.object.d.ts @@ -1,25 +1,25 @@ interface ObjectConstructor { /** - * Returns an array of values of the enumerable properties of an object - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ + * Returns an array of values of the enumerable properties of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ values(o: { [s: string]: T }): T[]; /** - * Returns an array of values of the enumerable properties of an object - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ + * Returns an array of values of the enumerable properties of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ values(o: any): any[]; /** - * Returns an array of key/values of the enumerable properties of an object - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ + * Returns an array of key/values of the enumerable properties of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ entries(o: { [s: string]: T }): [string, T][]; /** - * Returns an array of key/values of the enumerable properties of an object - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ + * Returns an array of key/values of the enumerable properties of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ entries(o: any): [string, any][]; } diff --git a/src/lib/es2017.sharedmemory.d.ts b/src/lib/es2017.sharedmemory.d.ts index d9f986627ca..e18390a5591 100644 --- a/src/lib/es2017.sharedmemory.d.ts +++ b/src/lib/es2017.sharedmemory.d.ts @@ -3,8 +3,8 @@ interface SharedArrayBuffer { /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ + * Read-only. The length of the ArrayBuffer (in bytes). + */ readonly byteLength: number; /* @@ -12,8 +12,8 @@ interface SharedArrayBuffer { */ length: number; /** - * Returns a section of an SharedArrayBuffer. - */ + * Returns a section of an SharedArrayBuffer. + */ slice(begin: number, end?: number): SharedArrayBuffer; readonly [Symbol.species]: SharedArrayBuffer; readonly [Symbol.toStringTag]: "SharedArrayBuffer"; diff --git a/src/lib/es2017.string.d.ts b/src/lib/es2017.string.d.ts index 3a440f887e9..80139e3712e 100644 --- a/src/lib/es2017.string.d.ts +++ b/src/lib/es2017.string.d.ts @@ -1,27 +1,27 @@ interface String { /** - * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. - * The padding is applied from the start (left) of the current string. - * - * @param maxLength The length of the resulting string once the current string has been padded. - * If this parameter is smaller than the current string's length, the current string will be returned as it is. - * - * @param fillString The string to pad the current string with. - * If this string is too long, it will be truncated and the left-most part will be applied. - * The default value for this parameter is " " (U+0020). - */ + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the start (left) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ padStart(maxLength: number, fillString?: string): string; /** - * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. - * The padding is applied from the end (right) of the current string. - * - * @param maxLength The length of the resulting string once the current string has been padded. - * If this parameter is smaller than the current string's length, the current string will be returned as it is. - * - * @param fillString The string to pad the current string with. - * If this string is too long, it will be truncated and the left-most part will be applied. - * The default value for this parameter is " " (U+0020). - */ + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the end (right) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ padEnd(maxLength: number, fillString?: string): string; } diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index 8f10c631ec7..bec8be31735 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -99,9 +99,9 @@ interface TextStreamReader extends TextStreamBase { declare var WScript: { /** - * Outputs text to either a message box (under WScript.exe) or the command console window followed by - * a newline (under CScript.exe). - */ + * Outputs text to either a message box (under WScript.exe) or the command console window followed by + * a newline (under CScript.exe). + */ Echo(s: any): void; /** diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 30c7a87dc74..a1fd61e8fef 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -179,12 +179,12 @@ namespace ts.server { class DirectoryWatchers { /** * a path to directory watcher map that detects added tsconfig files - **/ + */ private readonly directoryWatchersForTsconfig: Map = createMap(); /** * count of how many projects are using the directory watcher. * If the number becomes 0 for a watcher, then we should close it. - **/ + */ private readonly directoryWatchersRefCount: Map = createMap(); constructor(private readonly projectService: ProjectService) { @@ -241,11 +241,11 @@ namespace ts.server { readonly externalProjects: ExternalProject[] = []; /** * projects built from openFileRoots - **/ + */ readonly inferredProjects: InferredProject[] = []; /** * projects specified by a tsconfig.json file - **/ + */ readonly configuredProjects: ConfiguredProject[] = []; /** * list of open files @@ -637,9 +637,9 @@ namespace ts.server { } /** - * Remove this file from the set of open, non-configured files. - * @param info The file that has been closed or newly configured - */ + * Remove this file from the set of open, non-configured files. + * @param info The file that has been closed or newly configured + */ private closeOpenFile(info: ScriptInfo): void { // Closing file should trigger re-reading the file content from disk. This is // because the user may chose to discard the buffer content before saving diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 0bf13df7f4b..71998666fed 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -1,6 +1,6 @@ /** - * Declaration module describing the TypeScript Server protocol - */ + * Declaration module describing the TypeScript Server protocol + */ namespace ts.server.protocol { export namespace CommandTypes { export type Brace = "brace"; @@ -98,99 +98,99 @@ namespace ts.server.protocol { } /** - * A TypeScript Server message - */ + * A TypeScript Server message + */ export interface Message { /** - * Sequence number of the message - */ + * Sequence number of the message + */ seq: number; /** - * One of "request", "response", or "event" - */ + * One of "request", "response", or "event" + */ type: "request" | "response" | "event"; } /** - * Client-initiated request message - */ + * Client-initiated request message + */ export interface Request extends Message { /** - * The command to execute - */ + * The command to execute + */ command: string; /** - * Object containing arguments for the command - */ + * Object containing arguments for the command + */ arguments?: any; } /** - * Request to reload the project structure for all the opened files - */ + * Request to reload the project structure for all the opened files + */ export interface ReloadProjectsRequest extends Message { command: CommandTypes.ReloadProjects; } /** - * Server-initiated event message - */ + * Server-initiated event message + */ export interface Event extends Message { /** - * Name of event - */ + * Name of event + */ event: string; /** - * Event-specific information - */ + * Event-specific information + */ body?: any; } /** - * Response by server to client request message. - */ + * Response by server to client request message. + */ export interface Response extends Message { /** - * Sequence number of the request message. - */ + * Sequence number of the request message. + */ request_seq: number; /** - * Outcome of the request. - */ + * Outcome of the request. + */ success: boolean; /** - * The command requested. - */ + * The command requested. + */ command: string; /** - * Contains error message if success === false. - */ + * Contains error message if success === false. + */ message?: string; /** - * Contains message body if success === true. - */ + * Contains message body if success === true. + */ body?: any; } /** - * Arguments for FileRequest messages. - */ + * Arguments for FileRequest messages. + */ export interface FileRequestArgs { /** - * The file for the request (absolute pathname required). - */ + * The file for the request (absolute pathname required). + */ file: string; /* - * Optional name of project that contains file - */ + * Optional name of project that contains file + */ projectFileName?: string; } @@ -290,18 +290,18 @@ namespace ts.server.protocol { } /** - * Arguments for ProjectInfoRequest request. - */ + * Arguments for ProjectInfoRequest request. + */ export interface ProjectInfoRequestArgs extends FileRequestArgs { /** - * Indicate if the file name list of the project is needed - */ + * Indicate if the file name list of the project is needed + */ needFileNameList: boolean; } /** - * A request to get the project information of the current file. - */ + * A request to get the project information of the current file. + */ export interface ProjectInfoRequest extends Request { command: CommandTypes.ProjectInfo; arguments: ProjectInfoRequestArgs; @@ -325,21 +325,21 @@ namespace ts.server.protocol { } /** - * Response message body for "projectInfo" request - */ + * Response message body for "projectInfo" request + */ export interface ProjectInfo { /** - * For configured project, this is the normalized path of the 'tsconfig.json' file - * For inferred project, this is undefined - */ + * For configured project, this is the normalized path of the 'tsconfig.json' file + * For inferred project, this is undefined + */ configFileName: string; /** - * The list of normalized file name in the project, including 'lib.d.ts' - */ + * The list of normalized file name in the project, including 'lib.d.ts' + */ fileNames?: string[]; /** - * Indicates if the project has a active language service instance - */ + * Indicates if the project has a active language service instance + */ languageServiceDisabled?: boolean; } @@ -359,32 +359,32 @@ namespace ts.server.protocol { } /** - * Response message for "projectInfo" request - */ + * Response message for "projectInfo" request + */ export interface ProjectInfoResponse extends Response { body?: ProjectInfo; } /** - * Request whose sole parameter is a file name. - */ + * Request whose sole parameter is a file name. + */ export interface FileRequest extends Request { arguments: FileRequestArgs; } /** - * Instances of this interface specify a location in a source file: - * (file, line, character offset), where line and character offset are 1-based. - */ + * Instances of this interface specify a location in a source file: + * (file, line, character offset), where line and character offset are 1-based. + */ export interface FileLocationRequestArgs extends FileRequestArgs { /** - * The line number for the request (1-based). - */ + * The line number for the request (1-based). + */ line: number; /** - * The character offset (on the line) for the request (1-based). - */ + * The character offset (on the line) for the request (1-based). + */ offset: number; /** @@ -395,25 +395,25 @@ namespace ts.server.protocol { } /** - * Request for the available codefixes at a specific position. - */ + * Request for the available codefixes at a specific position. + */ export interface CodeFixRequest extends Request { command: CommandTypes.GetCodeFixes; arguments: CodeFixRequestArgs; } /** - * Instances of this interface specify errorcodes on a specific location in a sourcefile. - */ + * Instances of this interface specify errorcodes on a specific location in a sourcefile. + */ export interface CodeFixRequestArgs extends FileRequestArgs { /** - * The line number for the request (1-based). - */ + * The line number for the request (1-based). + */ startLine: number; /** - * The character offset (on the line) for the request (1-based). - */ + * The character offset (on the line) for the request (1-based). + */ startOffset: number; /** @@ -423,13 +423,13 @@ namespace ts.server.protocol { startPosition?: number; /** - * The line number for the request (1-based). - */ + * The line number for the request (1-based). + */ endLine: number; /** - * The character offset (on the line) for the request (1-based). - */ + * The character offset (on the line) for the request (1-based). + */ endOffset: number; /** @@ -439,8 +439,8 @@ namespace ts.server.protocol { endPosition?: number; /** - * Errorcodes we want to get the fixes for. - */ + * Errorcodes we want to get the fixes for. + */ errorCodes?: number[]; } @@ -452,8 +452,8 @@ namespace ts.server.protocol { } /** - * A request whose arguments specify a file location (file, line, col). - */ + * A request whose arguments specify a file location (file, line, col). + */ export interface FileLocationRequest extends FileRequest { arguments: FileLocationRequestArgs; } @@ -498,9 +498,9 @@ namespace ts.server.protocol { } /** - * Arguments in document highlight request; include: filesToSearch, file, - * line, offset. - */ + * Arguments in document highlight request; include: filesToSearch, file, + * line, offset. + */ export interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { /** * List of files to search for document highlights. @@ -509,82 +509,82 @@ namespace ts.server.protocol { } /** - * Go to definition request; value of command field is - * "definition". Return response giving the file locations that - * define the symbol found in file at location line, col. - */ + * Go to definition request; value of command field is + * "definition". Return response giving the file locations that + * define the symbol found in file at location line, col. + */ export interface DefinitionRequest extends FileLocationRequest { command: CommandTypes.Definition; } /** - * Go to type request; value of command field is - * "typeDefinition". Return response giving the file locations that - * define the type for the symbol found in file at location line, col. - */ + * Go to type request; value of command field is + * "typeDefinition". Return response giving the file locations that + * define the type for the symbol found in file at location line, col. + */ export interface TypeDefinitionRequest extends FileLocationRequest { command: CommandTypes.TypeDefinition; } /** - * Go to implementation request; value of command field is - * "implementation". Return response giving the file locations that - * implement the symbol found in file at location line, col. - */ + * Go to implementation request; value of command field is + * "implementation". Return response giving the file locations that + * implement the symbol found in file at location line, col. + */ export interface ImplementationRequest extends FileLocationRequest { command: CommandTypes.Implementation; } /** - * Location in source code expressed as (one-based) line and character offset. - */ + * Location in source code expressed as (one-based) line and character offset. + */ export interface Location { line: number; offset: number; } /** - * Object found in response messages defining a span of text in source code. - */ + * Object found in response messages defining a span of text in source code. + */ export interface TextSpan { /** - * First character of the definition. - */ + * First character of the definition. + */ start: Location; /** - * One character past last character of the definition. - */ + * One character past last character of the definition. + */ end: Location; } /** - * Object found in response messages defining a span of text in a specific source file. - */ + * Object found in response messages defining a span of text in a specific source file. + */ export interface FileSpan extends TextSpan { /** - * File containing text span. - */ + * File containing text span. + */ file: string; } /** - * Definition response message. Gives text range for definition. - */ + * Definition response message. Gives text range for definition. + */ export interface DefinitionResponse extends Response { body?: FileSpan[]; } /** - * Definition response message. Gives text range for definition. - */ + * Definition response message. Gives text range for definition. + */ export interface TypeDefinitionResponse extends Response { body?: FileSpan[]; } /** - * Implementation response message. Gives text range for implementations. - */ + * Implementation response message. Gives text range for implementations. + */ export interface ImplementationResponse extends Response { body?: FileSpan[]; } @@ -608,18 +608,18 @@ namespace ts.server.protocol { } /** - * Get occurrences request; value of command field is - * "occurrences". Return response giving spans that are relevant - * in the file at a given line and column. - */ + * Get occurrences request; value of command field is + * "occurrences". Return response giving spans that are relevant + * in the file at a given line and column. + */ export interface OccurrencesRequest extends FileLocationRequest { command: CommandTypes.Occurrences; } export interface OccurrencesResponseItem extends FileSpan { /** - * True if the occurrence is a write location, false otherwise. - */ + * True if the occurrence is a write location, false otherwise. + */ isWriteAccess: boolean; /** @@ -633,10 +633,10 @@ namespace ts.server.protocol { } /** - * Get document highlights request; value of command field is - * "documentHighlights". Return response giving spans that are relevant - * in the file at a given line and column. - */ + * Get document highlights request; value of command field is + * "documentHighlights". Return response giving spans that are relevant + * in the file at a given line and column. + */ export interface DocumentHighlightsRequest extends FileLocationRequest { command: CommandTypes.DocumentHighlights; arguments: DocumentHighlightsRequestArgs; @@ -655,13 +655,13 @@ namespace ts.server.protocol { */ export interface DocumentHighlightsItem { /** - * File containing highlight spans. - */ + * File containing highlight spans. + */ file: string; /** - * Spans to highlight in file. - */ + * Spans to highlight in file. + */ highlightSpans: HighlightSpan[]; } @@ -673,25 +673,25 @@ namespace ts.server.protocol { } /** - * Find references request; value of command field is - * "references". Return response giving the file locations that - * reference the symbol found in file at location line, col. - */ + * Find references request; value of command field is + * "references". Return response giving the file locations that + * reference the symbol found in file at location line, col. + */ export interface ReferencesRequest extends FileLocationRequest { command: CommandTypes.References; } export interface ReferencesResponseItem extends FileSpan { /** Text of line containing the reference. Including this - * with the response avoids latency of editor loading files - * to show text of reference line (the server already has - * loaded the referencing files). - */ + * with the response avoids latency of editor loading files + * to show text of reference line (the server already has + * loaded the referencing files). + */ lineText: string; /** - * True if reference is a write location, false otherwise. - */ + * True if reference is a write location, false otherwise. + */ isWriteAccess: boolean; /** @@ -701,33 +701,33 @@ namespace ts.server.protocol { } /** - * The body of a "references" response message. - */ + * The body of a "references" response message. + */ export interface ReferencesResponseBody { /** - * The file locations referencing the symbol. - */ + * The file locations referencing the symbol. + */ refs: ReferencesResponseItem[]; /** - * The name of the symbol. - */ + * The name of the symbol. + */ symbolName: string; /** - * The start character offset of the symbol (on the line provided by the references request). - */ + * The start character offset of the symbol (on the line provided by the references request). + */ symbolStartOffset: number; /** - * The full display name of the symbol. - */ + * The full display name of the symbol. + */ symbolDisplayString: string; } /** - * Response to "references" request. - */ + * Response to "references" request. + */ export interface ReferencesResponse extends Response { body?: ReferencesResponseBody; } @@ -747,48 +747,48 @@ namespace ts.server.protocol { } /** - * Rename request; value of command field is "rename". Return - * response giving the file locations that reference the symbol - * found in file at location line, col. Also return full display - * name of the symbol so that client can print it unambiguously. - */ + * Rename request; value of command field is "rename". Return + * response giving the file locations that reference the symbol + * found in file at location line, col. Also return full display + * name of the symbol so that client can print it unambiguously. + */ export interface RenameRequest extends FileLocationRequest { command: CommandTypes.Rename; arguments: RenameRequestArgs; } /** - * Information about the item to be renamed. - */ + * Information about the item to be renamed. + */ export interface RenameInfo { /** - * True if item can be renamed. - */ + * True if item can be renamed. + */ canRename: boolean; /** - * Error message if item can not be renamed. - */ + * Error message if item can not be renamed. + */ localizedErrorMessage?: string; /** - * Display name of the item to be renamed. - */ + * Display name of the item to be renamed. + */ displayName: string; /** - * Full display name of item to be renamed. - */ + * Full display name of item to be renamed. + */ fullDisplayName: string; /** - * The items's kind (such as 'className' or 'parameterName' or plain 'text'). - */ + * The items's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; } @@ -815,8 +815,8 @@ namespace ts.server.protocol { } /** - * Rename response message. - */ + * Rename response message. + */ export interface RenameResponse extends Response { body?: RenameResponseBody; } @@ -985,19 +985,19 @@ namespace ts.server.protocol { /** - * Information found in a configure request. - */ + * Information found in a configure request. + */ export interface ConfigureRequestArguments { /** - * Information about the host, for example 'Emacs 24.4' or - * 'Sublime Text version 3075' - */ + * Information about the host, for example 'Emacs 24.4' or + * 'Sublime Text version 3075' + */ hostInfo?: string; /** - * If present, tab settings apply only to this file. - */ + * If present, tab settings apply only to this file. + */ file?: string; /** @@ -1012,24 +1012,24 @@ namespace ts.server.protocol { } /** - * Configure request; value of command field is "configure". Specifies - * host information, such as host type, tab size, and indent size. - */ + * Configure request; value of command field is "configure". Specifies + * host information, such as host type, tab size, and indent size. + */ export interface ConfigureRequest extends Request { command: CommandTypes.Configure; arguments: ConfigureRequestArguments; } /** - * Response to "configure" request. This is just an acknowledgement, so - * no body field is required. - */ + * Response to "configure" request. This is just an acknowledgement, so + * no body field is required. + */ export interface ConfigureResponse extends Response { } /** - * Information found in an "open" request. - */ + * Information found in an "open" request. + */ export interface OpenRequestArgs extends FileRequestArgs { /** * Used when a version of the file content is known to be more up to date than the one on disk. @@ -1046,13 +1046,13 @@ namespace ts.server.protocol { export type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; /** - * Open request; value of command field is "open". Notify the - * server that the client has file open. The server will not - * monitor the filesystem for changes in this file and will assume - * that the client is updating the server (using the change and/or - * reload messages) when the file changes. Server does not currently - * send a response to an open request. - */ + * Open request; value of command field is "open". Notify the + * server that the client has file open. The server will not + * monitor the filesystem for changes in this file and will assume + * that the client is updating the server (using the change and/or + * reload messages) when the file changes. Server does not currently + * send a response to an open request. + */ export interface OpenRequest extends Request { command: CommandTypes.Open; arguments: OpenRequestArgs; @@ -1199,27 +1199,27 @@ namespace ts.server.protocol { } /** - * Response to SetCompilerOptionsForInferredProjectsResponse request. This is just an acknowledgement, so - * no body field is required. - */ + * Response to SetCompilerOptionsForInferredProjectsResponse request. This is just an acknowledgement, so + * no body field is required. + */ export interface SetCompilerOptionsForInferredProjectsResponse extends Response { } /** - * Exit request; value of command field is "exit". Ask the server process - * to exit. - */ + * Exit request; value of command field is "exit". Ask the server process + * to exit. + */ export interface ExitRequest extends Request { command: CommandTypes.Exit; } /** - * Close request; value of command field is "close". Notify the - * server that the client has closed a previously open file. If - * file is still referenced by open files, the server will resume - * monitoring the filesystem for changes to file. Server does not - * currently send a response to a close request. - */ + * Close request; value of command field is "close". Notify the + * server that the client has closed a previously open file. If + * file is still referenced by open files, the server will resume + * monitoring the filesystem for changes to file. Server does not + * currently send a response to a close request. + */ export interface CloseRequest extends FileRequest { command: CommandTypes.Close; } @@ -1277,47 +1277,47 @@ namespace ts.server.protocol { } /** - * Quickinfo request; value of command field is - * "quickinfo". Return response giving a quick type and - * documentation string for the symbol found in file at location - * line, col. - */ + * Quickinfo request; value of command field is + * "quickinfo". Return response giving a quick type and + * documentation string for the symbol found in file at location + * line, col. + */ export interface QuickInfoRequest extends FileLocationRequest { command: CommandTypes.Quickinfo; } /** - * Body of QuickInfoResponse. - */ + * Body of QuickInfoResponse. + */ export interface QuickInfoResponseBody { /** - * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). - */ + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; /** - * Starting file location of symbol. - */ + * Starting file location of symbol. + */ start: Location; /** - * One past last character of symbol. - */ + * One past last character of symbol. + */ end: Location; /** - * Type and kind of symbol. - */ + * Type and kind of symbol. + */ displayString: string; /** - * Documentation associated with symbol. - */ + * Documentation associated with symbol. + */ documentation: string; /** @@ -1327,24 +1327,24 @@ namespace ts.server.protocol { } /** - * Quickinfo response message. - */ + * Quickinfo response message. + */ export interface QuickInfoResponse extends Response { body?: QuickInfoResponseBody; } /** - * Arguments for format messages. - */ + * Arguments for format messages. + */ export interface FormatRequestArgs extends FileLocationRequestArgs { /** - * Last line of range for which to format text in file. - */ + * Last line of range for which to format text in file. + */ endLine: number; /** - * Character offset on last line of range for which to format text in file. - */ + * Character offset on last line of range for which to format text in file. + */ endOffset: number; /** @@ -1359,39 +1359,39 @@ namespace ts.server.protocol { } /** - * Format request; value of command field is "format". Return - * response giving zero or more edit instructions. The edit - * instructions will be sorted in file order. Applying the edit - * instructions in reverse to file will result in correctly - * reformatted text. - */ + * Format request; value of command field is "format". Return + * response giving zero or more edit instructions. The edit + * instructions will be sorted in file order. Applying the edit + * instructions in reverse to file will result in correctly + * reformatted text. + */ export interface FormatRequest extends FileLocationRequest { command: CommandTypes.Format; arguments: FormatRequestArgs; } /** - * Object found in response messages defining an editing - * instruction for a span of text in source code. The effect of - * this instruction is to replace the text starting at start and - * ending one character before end with newText. For an insertion, - * the text span is empty. For a deletion, newText is empty. - */ + * Object found in response messages defining an editing + * instruction for a span of text in source code. The effect of + * this instruction is to replace the text starting at start and + * ending one character before end with newText. For an insertion, + * the text span is empty. For a deletion, newText is empty. + */ export interface CodeEdit { /** - * First character of the text span to edit. - */ + * First character of the text span to edit. + */ start: Location; /** - * One character past last character of the text span to edit. - */ + * One character past last character of the text span to edit. + */ end: Location; /** - * Replace the span defined above with this string (may be - * the empty string). - */ + * Replace the span defined above with this string (may be + * the empty string). + */ newText: string; } @@ -1413,109 +1413,109 @@ namespace ts.server.protocol { } /** - * Format and format on key response message. - */ + * Format and format on key response message. + */ export interface FormatResponse extends Response { body?: CodeEdit[]; } /** - * Arguments for format on key messages. - */ + * Arguments for format on key messages. + */ export interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { /** - * Key pressed (';', '\n', or '}'). - */ + * Key pressed (';', '\n', or '}'). + */ key: string; options?: FormatCodeSettings; } /** - * Format on key request; value of command field is - * "formatonkey". Given file location and key typed (as string), - * return response giving zero or more edit instructions. The - * edit instructions will be sorted in file order. Applying the - * edit instructions in reverse to file will result in correctly - * reformatted text. - */ + * Format on key request; value of command field is + * "formatonkey". Given file location and key typed (as string), + * return response giving zero or more edit instructions. The + * edit instructions will be sorted in file order. Applying the + * edit instructions in reverse to file will result in correctly + * reformatted text. + */ export interface FormatOnKeyRequest extends FileLocationRequest { command: CommandTypes.Formatonkey; arguments: FormatOnKeyRequestArgs; } /** - * Arguments for completions messages. - */ + * Arguments for completions messages. + */ export interface CompletionsRequestArgs extends FileLocationRequestArgs { /** - * Optional prefix to apply to possible completions. - */ + * Optional prefix to apply to possible completions. + */ prefix?: string; } /** - * Completions request; value of command field is "completions". - * Given a file location (file, line, col) and a prefix (which may - * be the empty string), return the possible completions that - * begin with prefix. - */ + * Completions request; value of command field is "completions". + * Given a file location (file, line, col) and a prefix (which may + * be the empty string), return the possible completions that + * begin with prefix. + */ export interface CompletionsRequest extends FileLocationRequest { command: CommandTypes.Completions; arguments: CompletionsRequestArgs; } /** - * Arguments for completion details request. - */ + * Arguments for completion details request. + */ export interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { /** - * Names of one or more entries for which to obtain details. - */ + * Names of one or more entries for which to obtain details. + */ entryNames: string[]; } /** - * Completion entry details request; value of command field is - * "completionEntryDetails". Given a file location (file, line, - * col) and an array of completion entry names return more - * detailed information for each completion entry. - */ + * Completion entry details request; value of command field is + * "completionEntryDetails". Given a file location (file, line, + * col) and an array of completion entry names return more + * detailed information for each completion entry. + */ export interface CompletionDetailsRequest extends FileLocationRequest { command: CommandTypes.CompletionDetails; arguments: CompletionDetailsRequestArgs; } /** - * Part of a symbol description. - */ + * Part of a symbol description. + */ export interface SymbolDisplayPart { /** - * Text of an item describing the symbol. - */ + * Text of an item describing the symbol. + */ text: string; /** - * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). - */ + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; } /** - * An item found in a completion response. - */ + * An item found in a completion response. + */ export interface CompletionEntry { /** - * The symbol's name. - */ + * The symbol's name. + */ name: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; /** * A string that is used for comparing completion items so that they can be ordered. This @@ -1530,34 +1530,34 @@ namespace ts.server.protocol { } /** - * Additional completion entry details, available on demand - */ + * Additional completion entry details, available on demand + */ export interface CompletionEntryDetails { /** - * The symbol's name. - */ + * The symbol's name. + */ name: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; /** - * Display parts of the symbol (similar to quick info). - */ + * Display parts of the symbol (similar to quick info). + */ displayParts: SymbolDisplayPart[]; /** - * Documentation strings for the symbol. - */ + * Documentation strings for the symbol. + */ documentation: SymbolDisplayPart[]; /** - * JSDoc tags for the symbol. - */ + * JSDoc tags for the symbol. + */ tags: JSDocTagInfo[]; } @@ -1580,13 +1580,13 @@ namespace ts.server.protocol { name: string; /** - * Documentation of the parameter. - */ + * Documentation of the parameter. + */ documentation: SymbolDisplayPart[]; /** - * Display parts of the parameter. - */ + * Display parts of the parameter. + */ displayParts: SymbolDisplayPart[]; /** @@ -1674,10 +1674,10 @@ namespace ts.server.protocol { } /** - * Signature help request; value of command field is "signatureHelp". - * Given a file location (file, line, col), return the signature - * help. - */ + * Signature help request; value of command field is "signatureHelp". + * Given a file location (file, line, col), return the signature + * help. + */ export interface SignatureHelpRequest extends FileLocationRequest { command: CommandTypes.SignatureHelp; arguments: SignatureHelpRequestArgs; @@ -1691,8 +1691,8 @@ namespace ts.server.protocol { } /** - * Synchronous request for semantic diagnostics of one file. - */ + * Synchronous request for semantic diagnostics of one file. + */ export interface SemanticDiagnosticsSyncRequest extends FileRequest { command: CommandTypes.SemanticDiagnosticsSync; arguments: SemanticDiagnosticsSyncRequestArgs; @@ -1703,15 +1703,15 @@ namespace ts.server.protocol { } /** - * Response object for synchronous sematic diagnostics request. - */ + * Response object for synchronous sematic diagnostics request. + */ export interface SemanticDiagnosticsSyncResponse extends Response { body?: Diagnostic[] | DiagnosticWithLinePosition[]; } /** - * Synchronous request for syntactic diagnostics of one file. - */ + * Synchronous request for syntactic diagnostics of one file. + */ export interface SyntacticDiagnosticsSyncRequest extends FileRequest { command: CommandTypes.SyntacticDiagnosticsSync; arguments: SyntacticDiagnosticsSyncRequestArgs; @@ -1722,65 +1722,65 @@ namespace ts.server.protocol { } /** - * Response object for synchronous syntactic diagnostics request. - */ + * Response object for synchronous syntactic diagnostics request. + */ export interface SyntacticDiagnosticsSyncResponse extends Response { body?: Diagnostic[] | DiagnosticWithLinePosition[]; } /** - * Arguments for GeterrForProject request. - */ + * Arguments for GeterrForProject request. + */ export interface GeterrForProjectRequestArgs { /** - * the file requesting project error list - */ + * the file requesting project error list + */ file: string; /** - * Delay in milliseconds to wait before starting to compute - * errors for the files in the file list - */ + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ delay: number; } /** - * GeterrForProjectRequest request; value of command field is - * "geterrForProject". It works similarly with 'Geterr', only - * it request for every file in this project. - */ + * GeterrForProjectRequest request; value of command field is + * "geterrForProject". It works similarly with 'Geterr', only + * it request for every file in this project. + */ export interface GeterrForProjectRequest extends Request { command: CommandTypes.GeterrForProject; arguments: GeterrForProjectRequestArgs; } /** - * Arguments for geterr messages. - */ + * Arguments for geterr messages. + */ export interface GeterrRequestArgs { /** - * List of file names for which to compute compiler errors. - * The files will be checked in list order. - */ + * List of file names for which to compute compiler errors. + * The files will be checked in list order. + */ files: string[]; /** - * Delay in milliseconds to wait before starting to compute - * errors for the files in the file list - */ + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ delay: number; } /** - * Geterr request; value of command field is "geterr". Wait for - * delay milliseconds and then, if during the wait no change or - * reload messages have arrived for the first file in the files - * list, get the syntactic errors for the file, field requests, - * and then get the semantic errors for the file. Repeat with a - * smaller delay for each subsequent file on the files list. Best - * practice for an editor is to send a file list containing each - * file that is currently visible, in most-recently-used order. - */ + * Geterr request; value of command field is "geterr". Wait for + * delay milliseconds and then, if during the wait no change or + * reload messages have arrived for the first file in the files + * list, get the syntactic errors for the file, field requests, + * and then get the semantic errors for the file. Repeat with a + * smaller delay for each subsequent file on the files list. Best + * practice for an editor is to send a file list containing each + * file that is currently visible, in most-recently-used order. + */ export interface GeterrRequest extends Request { command: CommandTypes.Geterr; arguments: GeterrRequestArgs; @@ -1801,46 +1801,46 @@ namespace ts.server.protocol { } /** - * Item of diagnostic information found in a DiagnosticEvent message. - */ + * Item of diagnostic information found in a DiagnosticEvent message. + */ export interface Diagnostic { /** - * Starting file location at which text applies. - */ + * Starting file location at which text applies. + */ start: Location; /** - * The last file location at which the text applies. - */ + * The last file location at which the text applies. + */ end: Location; /** - * Text of diagnostic message. - */ + * Text of diagnostic message. + */ text: string; /** - * The error code of the diagnostic message. - */ + * The error code of the diagnostic message. + */ code?: number; } export interface DiagnosticEventBody { /** - * The file for which diagnostic information is reported. - */ + * The file for which diagnostic information is reported. + */ file: string; /** - * An array of diagnostic information items. - */ + * An array of diagnostic information items. + */ diagnostics: Diagnostic[]; } /** - * Event message for "syntaxDiag" and "semanticDiag" event types. - * These events provide syntactic and semantic errors for a file. - */ + * Event message for "syntaxDiag" and "semanticDiag" event types. + * These events provide syntactic and semantic errors for a file. + */ export interface DiagnosticEvent extends Event { body?: DiagnosticEventBody; } @@ -1893,195 +1893,195 @@ namespace ts.server.protocol { } /** - * Arguments for reload request. - */ + * Arguments for reload request. + */ export interface ReloadRequestArgs extends FileRequestArgs { /** - * Name of temporary file from which to reload file - * contents. May be same as file. - */ + * Name of temporary file from which to reload file + * contents. May be same as file. + */ tmpfile: string; } /** - * Reload request message; value of command field is "reload". - * Reload contents of file with name given by the 'file' argument - * from temporary file with name given by the 'tmpfile' argument. - * The two names can be identical. - */ + * Reload request message; value of command field is "reload". + * Reload contents of file with name given by the 'file' argument + * from temporary file with name given by the 'tmpfile' argument. + * The two names can be identical. + */ export interface ReloadRequest extends FileRequest { command: CommandTypes.Reload; arguments: ReloadRequestArgs; } /** - * Response to "reload" request. This is just an acknowledgement, so - * no body field is required. - */ + * Response to "reload" request. This is just an acknowledgement, so + * no body field is required. + */ export interface ReloadResponse extends Response { } /** - * Arguments for saveto request. - */ + * Arguments for saveto request. + */ export interface SavetoRequestArgs extends FileRequestArgs { /** - * Name of temporary file into which to save server's view of - * file contents. - */ + * Name of temporary file into which to save server's view of + * file contents. + */ tmpfile: string; } /** - * Saveto request message; value of command field is "saveto". - * For debugging purposes, save to a temporaryfile (named by - * argument 'tmpfile') the contents of file named by argument - * 'file'. The server does not currently send a response to a - * "saveto" request. - */ + * Saveto request message; value of command field is "saveto". + * For debugging purposes, save to a temporaryfile (named by + * argument 'tmpfile') the contents of file named by argument + * 'file'. The server does not currently send a response to a + * "saveto" request. + */ export interface SavetoRequest extends FileRequest { command: CommandTypes.Saveto; arguments: SavetoRequestArgs; } /** - * Arguments for navto request message. - */ + * Arguments for navto request message. + */ export interface NavtoRequestArgs extends FileRequestArgs { /** - * Search term to navigate to from current location; term can - * be '.*' or an identifier prefix. - */ + * Search term to navigate to from current location; term can + * be '.*' or an identifier prefix. + */ searchValue: string; /** - * Optional limit on the number of items to return. - */ + * Optional limit on the number of items to return. + */ maxResultCount?: number; /** - * Optional flag to indicate we want results for just the current file - * or the entire project. - */ + * Optional flag to indicate we want results for just the current file + * or the entire project. + */ currentFileOnly?: boolean; projectFileName?: string; } /** - * Navto request message; value of command field is "navto". - * Return list of objects giving file locations and symbols that - * match the search term given in argument 'searchTerm'. The - * context for the search is given by the named file. - */ + * Navto request message; value of command field is "navto". + * Return list of objects giving file locations and symbols that + * match the search term given in argument 'searchTerm'. The + * context for the search is given by the named file. + */ export interface NavtoRequest extends FileRequest { command: CommandTypes.Navto; arguments: NavtoRequestArgs; } /** - * An item found in a navto response. - */ + * An item found in a navto response. + */ export interface NavtoItem { /** - * The symbol's name. - */ + * The symbol's name. + */ name: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * exact, substring, or prefix. - */ + * exact, substring, or prefix. + */ matchKind?: string; /** - * If this was a case sensitive or insensitive match. - */ + * If this was a case sensitive or insensitive match. + */ isCaseSensitive?: boolean; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers?: string; /** - * The file in which the symbol is found. - */ + * The file in which the symbol is found. + */ file: string; /** - * The location within file at which the symbol is found. - */ + * The location within file at which the symbol is found. + */ start: Location; /** - * One past the last character of the symbol. - */ + * One past the last character of the symbol. + */ end: Location; /** - * Name of symbol's container symbol (if any); for example, - * the class name if symbol is a class member. - */ + * Name of symbol's container symbol (if any); for example, + * the class name if symbol is a class member. + */ containerName?: string; /** - * Kind of symbol's container symbol (if any). - */ + * Kind of symbol's container symbol (if any). + */ containerKind?: string; } /** - * Navto response message. Body is an array of navto items. Each - * item gives a symbol that matched the search term. - */ + * Navto response message. Body is an array of navto items. Each + * item gives a symbol that matched the search term. + */ export interface NavtoResponse extends Response { body?: NavtoItem[]; } /** - * Arguments for change request message. - */ + * Arguments for change request message. + */ export interface ChangeRequestArgs extends FormatRequestArgs { /** - * Optional string to insert at location (file, line, offset). - */ + * Optional string to insert at location (file, line, offset). + */ insertString?: string; } /** - * Change request message; value of command field is "change". - * Update the server's view of the file named by argument 'file'. - * Server does not currently send a response to a change request. - */ + * Change request message; value of command field is "change". + * Update the server's view of the file named by argument 'file'. + * Server does not currently send a response to a change request. + */ export interface ChangeRequest extends FileLocationRequest { command: CommandTypes.Change; arguments: ChangeRequestArgs; } /** - * Response to "brace" request. - */ + * Response to "brace" request. + */ export interface BraceResponse extends Response { body?: TextSpan[]; } /** - * Brace matching request; value of command field is "brace". - * Return response giving the file locations of matching braces - * found in file at location line, offset. - */ + * Brace matching request; value of command field is "brace". + * Return response giving the file locations of matching braces + * found in file at location line, offset. + */ export interface BraceRequest extends FileLocationRequest { command: CommandTypes.Brace; } /** - * NavBar items request; value of command field is "navbar". - * Return response giving the list of navigation bar entries - * extracted from the requested file. - */ + * NavBar items request; value of command field is "navbar". + * Return response giving the list of navigation bar entries + * extracted from the requested file. + */ export interface NavBarRequest extends FileRequest { command: CommandTypes.NavBar; } @@ -2096,33 +2096,33 @@ namespace ts.server.protocol { export interface NavigationBarItem { /** - * The item's display text. - */ + * The item's display text. + */ text: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers?: string; /** - * The definition locations of the item. - */ + * The definition locations of the item. + */ spans: TextSpan[]; /** - * Optional children. - */ + * Optional children. + */ childItems?: NavigationBarItem[]; /** - * Number of levels deep this item should appear. - */ + * Number of levels deep this item should appear. + */ indent: number; } diff --git a/src/server/utilities.ts b/src/server/utilities.ts index af1f8e9826f..8784efff750 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -166,11 +166,11 @@ namespace ts.server { export interface ProjectOptions { /** * true if config file explicitly listed files - **/ + */ configHasFilesProperty?: boolean; /** * these fields can be present in the project file - **/ + */ files?: string[]; wildcardDirectories?: Map; compilerOptions?: CompilerOptions; diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index b836815fc27..d9e1387e029 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -146,7 +146,7 @@ namespace ts.codefix { /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, * this is one of them. - */ + */ let maxArgsSignature = signatures[0]; let minArgumentCount = signatures[0].minArgumentCount; let someSigHasRestParameter = false; diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index e2cd20a4463..891a25db76a 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -1,34 +1,34 @@ namespace ts { /** - * The document registry represents a store of SourceFile objects that can be shared between - * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) - * of files in the context. - * SourceFile objects account for most of the memory usage by the language service. Sharing - * the same DocumentRegistry instance between different instances of LanguageService allow - * for more efficient memory utilization since all projects will share at least the library - * file (lib.d.ts). - * - * A more advanced use of the document registry is to serialize sourceFile objects to disk - * and re-hydrate them when needed. - * - * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it - * to all subsequent createLanguageService calls. - */ + * The document registry represents a store of SourceFile objects that can be shared between + * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) + * of files in the context. + * SourceFile objects account for most of the memory usage by the language service. Sharing + * the same DocumentRegistry instance between different instances of LanguageService allow + * for more efficient memory utilization since all projects will share at least the library + * file (lib.d.ts). + * + * A more advanced use of the document registry is to serialize sourceFile objects to disk + * and re-hydrate them when needed. + * + * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it + * to all subsequent createLanguageService calls. + */ export interface DocumentRegistry { /** - * Request a stored SourceFile with a given fileName and compilationSettings. - * The first call to acquire will call createLanguageServiceSourceFile to generate - * the SourceFile if was not found in the registry. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - */ + * Request a stored SourceFile with a given fileName and compilationSettings. + * The first call to acquire will call createLanguageServiceSourceFile to generate + * the SourceFile if was not found in the registry. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @parm scriptSnapshot Text of the file. Only used if the file was not found + * in the registry and a new one was created. + * @parm version Current version of the file. Only used if the file was not found + * in the registry and a new one was created. + */ acquireDocument( fileName: string, compilationSettings: CompilerOptions, @@ -46,17 +46,17 @@ namespace ts { scriptKind?: ScriptKind): SourceFile; /** - * Request an updated version of an already existing SourceFile with a given fileName - * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile - * to get an updated SourceFile. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @param scriptSnapshot Text of the file. - * @param version Current version of the file. - */ + * Request an updated version of an already existing SourceFile with a given fileName + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile + * to get an updated SourceFile. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. + */ updateDocument( fileName: string, compilationSettings: CompilerOptions, @@ -75,14 +75,14 @@ namespace ts { getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey; /** - * Informs the DocumentRegistry that a file is not needed any longer. - * - * Note: It is not allowed to call release on a SourceFile that was not acquired from - * this registry originally. - * - * @param fileName The name of the file to be released - * @param compilationSettings The compilation settings used to acquire the file - */ + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @param fileName The name of the file to be released + * @param compilationSettings The compilation settings used to acquire the file + */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 5a471fb6f35..734f45203d6 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -496,9 +496,9 @@ namespace ts.FindAllReferences { } /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ function getReferencesInNode(container: Node, searchSymbol: Symbol, searchText: string, diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 4fa3b71a3a2..465c2a34487 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -34,31 +34,31 @@ namespace ts.formatting { getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind, container: Node): number; getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number, container: Node): number; /** - * Indentation for open and close tokens of the node if it is block or another node that needs special indentation - * ... { - * ......... - * ....} - * ____ - indentation - * ____ - delta - **/ + * Indentation for open and close tokens of the node if it is block or another node that needs special indentation + * ... { + * ......... + * ....} + * ____ - indentation + * ____ - delta + */ getIndentation(): number; /** - * Prefered relative indentation for child nodes. - * Delta is used to carry the indentation info - * foo(bar({ - * $ - * })) - * Both 'foo', 'bar' introduce new indentation with delta = 4, but total indentation in $ is not 8. - * foo: { indentation: 0, delta: 4 } - * bar: { indentation: foo.indentation + foo.delta = 4, delta: 4} however 'foo' and 'bar' are on the same line - * so bar inherits indentation from foo and bar.delta will be 4 - * - */ + * Prefered relative indentation for child nodes. + * Delta is used to carry the indentation info + * foo(bar({ + * $ + * })) + * Both 'foo', 'bar' introduce new indentation with delta = 4, but total indentation in $ is not 8. + * foo: { indentation: 0, delta: 4 } + * bar: { indentation: foo.indentation + foo.delta = 4, delta: 4} however 'foo' and 'bar' are on the same line + * so bar inherits indentation from foo and bar.delta will be 4 + * + */ getDelta(child: TextRangeWithKind): number; /** - * Formatter calls this function when rule adds or deletes new lines from the text - * so indentation scope can adjust values of indentation and delta. - */ + * Formatter calls this function when rule adds or deletes new lines from the text + * so indentation scope can adjust values of indentation and delta. + */ recomputeIndentation(lineAddedByFormatting: boolean): void; } @@ -205,9 +205,9 @@ namespace ts.formatting { } /** formatting is not applied to ranges that contain parse errors. - * This function will return a predicate that for a given text range will tell - * if there are any parse errors that overlap with the range. - */ + * This function will return a predicate that for a given text range will tell + * if there are any parse errors that overlap with the range. + */ function prepareRangeContainsErrorFunction(errors: Diagnostic[], originalRange: TextRange): (r: TextRange) => boolean { if (!errors.length) { return rangeHasNoErrors; @@ -254,10 +254,10 @@ namespace ts.formatting { } /** - * Start of the original range might fall inside the comment - scanner will not yield appropriate results - * This function will look for token that is located before the start of target range - * and return its end as start position for the scanner. - */ + * Start of the original range might fall inside the comment - scanner will not yield appropriate results + * This function will look for token that is located before the start of target range + * and return its end as start position for the scanner. + */ function getScanStartPosition(enclosingNode: Node, originalRange: TextRange, sourceFile: SourceFile): number { const start = enclosingNode.getStart(sourceFile); if (start === originalRange.pos && enclosingNode.end === originalRange.end) { @@ -400,12 +400,12 @@ namespace ts.formatting { // local functions /** Tries to compute the indentation for a list element. - * If list element is not in range then - * function will pick its actual indentation - * so it can be pushed downstream as inherited indentation. - * If list element is in the range - its indentation will be equal - * to inherited indentation from its predecessors. - */ + * If list element is not in range then + * function will pick its actual indentation + * so it can be pushed downstream as inherited indentation. + * If list element is in the range - its indentation will be equal + * to inherited indentation from its predecessors. + */ function tryComputeIndentationForListItem(startPos: number, endPos: number, parentStartLine: number, diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index c11f6e67a71..74be20f66a4 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -204,7 +204,6 @@ namespace ts.JsTyping { /** * Infer typing names from packages folder (ex: node_module, bower_components) * @param packagesFolderPath is the path to the packages folder - */ function getTypingNamesFromPackagesFolder(packagesFolderPath: string) { filesToWatch.push(packagesFolderPath); diff --git a/src/services/services.ts b/src/services/services.ts index 7086f4471a5..3d108ac7fab 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2131,10 +2131,10 @@ namespace ts { declare const __dirname: string; /** - * Get the path of the default library files (lib.d.ts) as distributed with the typescript - * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. - */ + * Get the path of the default library files (lib.d.ts) as distributed with the typescript + * node package. + * The functionality is not supported if the ts module is consumed outside of a node module. + */ export function getDefaultLibFilePath(options: CompilerOptions): string { // Check __dirname is defined and that we are on a node.js system. if (typeof __dirname !== "undefined") { diff --git a/src/services/shims.ts b/src/services/shims.ts index de2fd39b8a8..0f2d0a4aacb 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -49,7 +49,7 @@ namespace ts { error(s: string): void; } - /** Public interface of the host of a language service shim instance.*/ + /** Public interface of the host of a language service shim instance. */ export interface LanguageServiceShimHost extends Logger { getCompilationSettings(): string; diff --git a/src/services/types.ts b/src/services/types.ts index f31632ea822..62fbf18cddf 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -597,10 +597,10 @@ namespace ts { kindModifiers: string; // see ScriptElementKindModifier, comma separated sortText: string; /** - * An optional span that indicates the text to be replaced by this completion item. It will be - * set if the required span differs from the one generated by the default replacement behavior and should - * be used in that case - */ + * An optional span that indicates the text to be replaced by this completion item. It will be + * set if the required span differs from the one generated by the default replacement behavior and should + * be used in that case + */ replacementSpan?: TextSpan; } @@ -624,9 +624,9 @@ namespace ts { bannerText: string; /** - * Whether or not this region should be automatically collapsed when - * the 'Collapse to Definitions' command is invoked. - */ + * Whether or not this region should be automatically collapsed when + * the 'Collapse to Definitions' command is invoked. + */ autoCollapse: boolean; } @@ -798,7 +798,7 @@ namespace ts { /** * - **/ + */ export const jsxAttribute = "JSX attribute"; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 2c48cd79b9b..459d70bda6e 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -705,13 +705,13 @@ namespace ts { } /** - * The token on the left of the position is the token that strictly includes the position - * or sits to the left of the cursor if it is on a boundary. For example - * - * fo|o -> will return foo - * foo |bar -> will return foo - * - */ + * The token on the left of the position is the token that strictly includes the position + * or sits to the left of the cursor if it is on a boundary. For example + * + * fo|o -> will return foo + * foo |bar -> will return foo + * + */ export function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node { // Ideally, getTokenAtPosition should return a token. However, it is currently // broken, so we do a check to make sure the result was indeed a token. diff --git a/tslint.json b/tslint.json index be722309a24..a0a7339798f 100644 --- a/tslint.json +++ b/tslint.json @@ -59,6 +59,7 @@ "no-increment-decrement": true, "object-literal-surrounding-space": true, "no-type-assertion-whitespace": true, - "no-in-operator": true + "no-in-operator": true, + "jsdoc-format": true } } From 2d3dd8563284087874cc05ba0bcd6ca4f712b72f Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 4 Apr 2017 13:55:47 -0700 Subject: [PATCH 08/14] Simplify parseTypeReference Create the node first, rather than creating it later and setting its pos to another node that was created first. --- src/compiler/parser.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index fcb85f4fbdc..2ae72417426 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2054,9 +2054,8 @@ namespace ts { // TYPES function parseTypeReference(): TypeReferenceNode { - const typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected); - const node = createNode(SyntaxKind.TypeReference, typeName.pos); - node.typeName = typeName; + const node = createNode(SyntaxKind.TypeReference); + node.typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token() === SyntaxKind.LessThanToken) { node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); } From 6909574973f10fd6735161c5cc90c37ca1ac8902 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 4 Apr 2017 14:48:57 -0700 Subject: [PATCH 09/14] Limit symbol instantiations to a maximum depth of 100 --- src/compiler/checker.ts | 24 +++++++++++++++++------- src/compiler/diagnosticMessages.json | 4 ++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7bdde91f286..1f558c7e579 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -47,6 +47,7 @@ namespace ts { let typeCount = 0; let symbolCount = 0; + let symbolInstantiationDepth = 0; const emptyArray: any[] = []; const emptySymbols = createMap(); @@ -4440,14 +4441,22 @@ namespace ts { function getTypeOfInstantiatedSymbol(symbol: Symbol): Type { const links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { - return unknownType; + if (symbolInstantiationDepth === 100) { + error(symbol.valueDeclaration, Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); + links.type = unknownType; } - let type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - if (!popTypeResolution()) { - type = reportCircularityError(symbol); + else { + if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { + return unknownType; + } + symbolInstantiationDepth++; + let type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + symbolInstantiationDepth--; + if (!popTypeResolution()) { + type = reportCircularityError(symbol); + } + links.type = type; } - links.type = type; } return links.type; } @@ -7257,8 +7266,9 @@ namespace ts { else { error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } + return unknownType; } - return unknownType; + return anyType; } function getIndexedAccessForMappedType(type: MappedType, indexType: Type, accessNode?: ElementAccessExpression | IndexedAccessTypeNode) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 983e128ec7f..075d4247460 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1827,6 +1827,10 @@ "category": "Error", "code": 2549 }, + "Generic type instantiation is excessively deep and possibly infinite.": { + "category": "Error", + "code": 2550 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 From 833fd010d7537312de8dc6f0890f21f2a39f3e9d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 4 Apr 2017 14:49:06 -0700 Subject: [PATCH 10/14] Static prop. inits can refer to later static methods Static methods are created before static property initializers run, so static property initializers may refer to static methods. This was not allowed previously. --- src/compiler/checker.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7bdde91f286..1e309cdf488 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -751,6 +751,7 @@ namespace ts { // declaration is after usage, but it can still be legal if usage is deferred: // 1. inside a function // 2. inside an instance property initializer, a reference to a non-instance property + // 3. inside a static property initializer, a reference to a static method in the same class const container = getEnclosingBlockScopeContainer(declaration); return isUsedInFunctionOrInstanceProperty(usage, declaration, container); @@ -792,14 +793,22 @@ namespace ts { return true; } - const initializerOfInstanceProperty = current.parent && + const initializerOfProperty = current.parent && current.parent.kind === SyntaxKind.PropertyDeclaration && - (getModifierFlags(current.parent) & ModifierFlags.Static) === 0 && (current.parent).initializer === current; - if (initializerOfInstanceProperty) { - const isDeclarationInstanceProperty = declaration.kind === SyntaxKind.PropertyDeclaration && !(getModifierFlags(declaration) & ModifierFlags.Static); - return !isDeclarationInstanceProperty || getContainingClass(usage) !== getContainingClass(declaration); + if (initializerOfProperty) { + if (getModifierFlags(current.parent) & ModifierFlags.Static) { + if (declaration.kind === SyntaxKind.MethodDeclaration) { + return true; + } + } + else { + const isDeclarationInstanceProperty = declaration.kind === SyntaxKind.PropertyDeclaration && !(getModifierFlags(declaration) & ModifierFlags.Static); + if(!isDeclarationInstanceProperty || getContainingClass(usage) !== getContainingClass(declaration)) { + return true; + } + } } current = current.parent; From 4214aed37de464490128294fa425797096a7f644 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 4 Apr 2017 14:50:42 -0700 Subject: [PATCH 11/14] Test:static inits can refer to later static methods --- .../scopeCheckStaticInitializer.errors.txt | 30 +++++++++++++++ .../reference/scopeCheckStaticInitializer.js | 37 +++++++++++++++++++ .../compiler/scopeCheckStaticInitializer.ts | 14 +++++++ 3 files changed, 81 insertions(+) create mode 100644 tests/baselines/reference/scopeCheckStaticInitializer.errors.txt create mode 100644 tests/baselines/reference/scopeCheckStaticInitializer.js create mode 100644 tests/cases/compiler/scopeCheckStaticInitializer.ts diff --git a/tests/baselines/reference/scopeCheckStaticInitializer.errors.txt b/tests/baselines/reference/scopeCheckStaticInitializer.errors.txt new file mode 100644 index 00000000000..c023c356a2a --- /dev/null +++ b/tests/baselines/reference/scopeCheckStaticInitializer.errors.txt @@ -0,0 +1,30 @@ +tests/cases/compiler/scopeCheckStaticInitializer.ts(2,38): error TS2448: Block-scoped variable 'data' used before its declaration. +tests/cases/compiler/scopeCheckStaticInitializer.ts(5,23): error TS2449: Class 'After' used before its declaration. +tests/cases/compiler/scopeCheckStaticInitializer.ts(5,29): error TS2448: Block-scoped variable 'data' used before its declaration. +tests/cases/compiler/scopeCheckStaticInitializer.ts(6,23): error TS2449: Class 'After' used before its declaration. + + +==== tests/cases/compiler/scopeCheckStaticInitializer.ts (4 errors) ==== + class X { + static illegalBeforeProperty = X.data; + ~~~~ +!!! error TS2448: Block-scoped variable 'data' used before its declaration. + static okBeforeMethod = X.method; + + static illegal2 = After.data; + ~~~~~ +!!! error TS2449: Class 'After' used before its declaration. + ~~~~ +!!! error TS2448: Block-scoped variable 'data' used before its declaration. + static illegal3 = After.method; + ~~~~~ +!!! error TS2449: Class 'After' used before its declaration. + static data = 13; + static method() { } + } + class After { + static data = 12; + static method() { }; + } + + \ No newline at end of file diff --git a/tests/baselines/reference/scopeCheckStaticInitializer.js b/tests/baselines/reference/scopeCheckStaticInitializer.js new file mode 100644 index 00000000000..59711f07380 --- /dev/null +++ b/tests/baselines/reference/scopeCheckStaticInitializer.js @@ -0,0 +1,37 @@ +//// [scopeCheckStaticInitializer.ts] +class X { + static illegalBeforeProperty = X.data; + static okBeforeMethod = X.method; + + static illegal2 = After.data; + static illegal3 = After.method; + static data = 13; + static method() { } +} +class After { + static data = 12; + static method() { }; +} + + + +//// [scopeCheckStaticInitializer.js] +var X = (function () { + function X() { + } + X.method = function () { }; + return X; +}()); +X.illegalBeforeProperty = X.data; +X.okBeforeMethod = X.method; +X.illegal2 = After.data; +X.illegal3 = After.method; +X.data = 13; +var After = (function () { + function After() { + } + After.method = function () { }; + ; + return After; +}()); +After.data = 12; diff --git a/tests/cases/compiler/scopeCheckStaticInitializer.ts b/tests/cases/compiler/scopeCheckStaticInitializer.ts new file mode 100644 index 00000000000..a5c7b6ccd62 --- /dev/null +++ b/tests/cases/compiler/scopeCheckStaticInitializer.ts @@ -0,0 +1,14 @@ +class X { + static illegalBeforeProperty = X.data; + static okBeforeMethod = X.method; + + static illegal2 = After.data; + static illegal3 = After.method; + static data = 13; + static method() { } +} +class After { + static data = 12; + static method() { }; +} + From 68ab129fac529f1ed35bbb70edcc3093e88a4fcc Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 4 Apr 2017 14:53:48 -0700 Subject: [PATCH 12/14] Add regression test --- .../reference/limitDeepInstantiations.errors.txt | 15 +++++++++++++++ .../reference/limitDeepInstantiations.js | 12 ++++++++++++ tests/cases/compiler/limitDeepInstantiations.ts | 5 +++++ 3 files changed, 32 insertions(+) create mode 100644 tests/baselines/reference/limitDeepInstantiations.errors.txt create mode 100644 tests/baselines/reference/limitDeepInstantiations.js create mode 100644 tests/cases/compiler/limitDeepInstantiations.ts diff --git a/tests/baselines/reference/limitDeepInstantiations.errors.txt b/tests/baselines/reference/limitDeepInstantiations.errors.txt new file mode 100644 index 00000000000..330e5fbc8e4 --- /dev/null +++ b/tests/baselines/reference/limitDeepInstantiations.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/limitDeepInstantiations.ts(3,35): error TS2550: Generic type instantiation is excessively deep and possibly infinite. +tests/cases/compiler/limitDeepInstantiations.ts(5,13): error TS2344: Type '"false"' does not satisfy the constraint '"true"'. + + +==== tests/cases/compiler/limitDeepInstantiations.ts (2 errors) ==== + // Repro from #14837 + + type Foo = { "true": Foo> }[T]; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2550: Generic type instantiation is excessively deep and possibly infinite. + let f1: Foo<"true", {}>; + let f2: Foo<"false", {}>; + ~~~~~~~ +!!! error TS2344: Type '"false"' does not satisfy the constraint '"true"'. + \ No newline at end of file diff --git a/tests/baselines/reference/limitDeepInstantiations.js b/tests/baselines/reference/limitDeepInstantiations.js new file mode 100644 index 00000000000..7b70cbd5956 --- /dev/null +++ b/tests/baselines/reference/limitDeepInstantiations.js @@ -0,0 +1,12 @@ +//// [limitDeepInstantiations.ts] +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +let f1: Foo<"true", {}>; +let f2: Foo<"false", {}>; + + +//// [limitDeepInstantiations.js] +// Repro from #14837 +var f1; +var f2; diff --git a/tests/cases/compiler/limitDeepInstantiations.ts b/tests/cases/compiler/limitDeepInstantiations.ts new file mode 100644 index 00000000000..f478157ecc2 --- /dev/null +++ b/tests/cases/compiler/limitDeepInstantiations.ts @@ -0,0 +1,5 @@ +// Repro from #14837 + +type Foo = { "true": Foo> }[T]; +let f1: Foo<"true", {}>; +let f2: Foo<"false", {}>; From a5d320a83e3f295d6ffbafa219de7e8919ae16dd Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 4 Apr 2017 15:15:25 -0700 Subject: [PATCH 13/14] Fix whitespace lint --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1e309cdf488..2fe44641efd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -805,7 +805,7 @@ namespace ts { } else { const isDeclarationInstanceProperty = declaration.kind === SyntaxKind.PropertyDeclaration && !(getModifierFlags(declaration) & ModifierFlags.Static); - if(!isDeclarationInstanceProperty || getContainingClass(usage) !== getContainingClass(declaration)) { + if (!isDeclarationInstanceProperty || getContainingClass(usage) !== getContainingClass(declaration)) { return true; } } From d32231ebe3fd597ffa36bfce26e7506c91a9c20c Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 4 Apr 2017 16:49:03 -0700 Subject: [PATCH 14/14] Set numericLiteralFlags in factory to align with parser --- src/compiler/factory.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 3ed1c3bb9d5..718bf48389a 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -88,6 +88,7 @@ namespace ts { export function createNumericLiteral(value: string): NumericLiteral { const node = createSynthesizedNode(SyntaxKind.NumericLiteral); node.text = value; + node.numericLiteralFlags = 0; return node; }