From 975ba5d9774a3e88133e01538db15fb5416768c9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 24 Mar 2023 12:14:33 -0700 Subject: [PATCH] Add fallback logic for generating signatures for unions of array members --- src/compiler/checker.ts | 31 +- src/compiler/types.ts | 2 + .../completionEntryForUnionMethod.baseline | 3313 +++++------------ .../reference/unionOfArraysFilterCall.js | 36 + .../reference/unionOfArraysFilterCall.symbols | 104 + .../reference/unionOfArraysFilterCall.types | 126 + .../reference/unionOfClassCalls.errors.txt | 85 - .../reference/unionOfClassCalls.types | 2 +- .../cases/compiler/unionOfArraysFilterCall.ts | 26 + 9 files changed, 1217 insertions(+), 2508 deletions(-) create mode 100644 tests/baselines/reference/unionOfArraysFilterCall.js create mode 100644 tests/baselines/reference/unionOfArraysFilterCall.symbols create mode 100644 tests/baselines/reference/unionOfArraysFilterCall.types delete mode 100644 tests/baselines/reference/unionOfClassCalls.errors.txt create mode 100644 tests/cases/compiler/unionOfArraysFilterCall.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 53ba0a0a89434..5ee40cf1b526e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14265,7 +14265,36 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { * maps primitive types and type parameters are to their apparent types. */ function getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[] { - return getSignaturesOfStructuredType(getReducedApparentType(type), kind); + const result = getSignaturesOfStructuredType(getReducedApparentType(type), kind); + if (kind === SignatureKind.Call && !length(result) && type.flags & TypeFlags.Union) { + if ((type as UnionType).arrayFallbackSignatures) { + return (type as UnionType).arrayFallbackSignatures!; + } + // If the union is all different instantiations of a member of the global array type... + let memberName: __String; + if (everyType(type, t => !!t.symbol?.parent && isArrayOrTupleSymbol(t.symbol.parent) && (!memberName ? (memberName = t.symbol.escapedName, true) : memberName === t.symbol.escapedName))) { + // Transform the type from `(A[] | B[])["member"]` to `(A | B)[]["member"]` (since we pretend array is covariant anyway) + const arrayArg = mapType(type, t => getMappedType((isReadonlyArraySymbol(t.symbol.parent) ? globalReadonlyArrayType : globalArrayType).typeParameters![0], (t as AnonymousType).mapper!)); + const arrayType = createArrayType(arrayArg, someType(type, t => isReadonlyArraySymbol(t.symbol.parent))); + return (type as UnionType).arrayFallbackSignatures = getSignaturesOfType(getTypeOfPropertyOfType(arrayType, memberName!)!, kind); + } + (type as UnionType).arrayFallbackSignatures = result; + } + return result; + } + + function isArrayOrTupleSymbol(symbol: Symbol | undefined) { + if (!symbol || !globalArrayType.symbol || !globalReadonlyArrayType.symbol) { + return false; + } + return !!getSymbolIfSameReference(symbol, globalArrayType.symbol) || !!getSymbolIfSameReference(symbol, globalReadonlyArrayType.symbol); + } + + function isReadonlyArraySymbol(symbol: Symbol | undefined) { + if (!symbol || !globalReadonlyArrayType.symbol) { + return false; + } + return !!getSymbolIfSameReference(symbol, globalReadonlyArrayType.symbol); } function findIndexInfo(indexInfos: readonly IndexInfo[], keyType: Type) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 82cdb98a8d6b0..ad39e640f2877 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6438,6 +6438,8 @@ export interface UnionType extends UnionOrIntersectionType { keyPropertyName?: __String; // Property with unique unit type that exists in every object/intersection in union type /** @internal */ constituentMap?: Map; // Constituents keyed by unit type discriminants + /** @internal */ + arrayFallbackSignatures?: readonly Signature[]; // Special remapped signature list for unions of arrays } export interface IntersectionType extends UnionOrIntersectionType { diff --git a/tests/baselines/reference/completionEntryForUnionMethod.baseline b/tests/baselines/reference/completionEntryForUnionMethod.baseline index 738d7249b298b..8592e21eae698 100644 --- a/tests/baselines/reference/completionEntryForUnionMethod.baseline +++ b/tests/baselines/reference/completionEntryForUnionMethod.baseline @@ -3,25 +3,9 @@ // y.map( // ^^^ // | ---------------------------------------------------------------------- -// | (property) Array.concat: { -// | (...items: ConcatArray[]): string[]; -// | (...items: (string | ConcatArray)[]): string[]; -// | } | { -// | (...items: ConcatArray[]): number[]; -// | (...items: (number | ConcatArray<...>)[]): number[]; -// | } -// | (property) Array.every: { -// | (predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): this is S[]; -// | (predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean; -// | } | { -// | ...; -// | } -// | (property) Array.filter: { -// | (predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[]; -// | (predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[]; -// | } | { -// | ...; -// | } +// | (method) Array.concat(...items: ConcatArray[]): (string | number)[] (+1 overload) +// | (method) Array.every(predicate: (value: string | number, index: number, array: (string | number)[]) => value is S, thisArg?: any): this is S[] (+1 overload) +// | (method) Array.filter(predicate: (value: string | number, index: number, array: (string | number)[]) => value is S, thisArg?: any): S[] (+1 overload) // | (method) Array.forEach(callbackfn: ((value: string, index: number, array: string[]) => void) & ((value: number, index: number, array: number[]) => void), thisArg: any): void // | (method) Array.indexOf(searchElement: never, fromIndex: number): number // | (method) Array.join(separator?: string): string @@ -30,20 +14,8 @@ // | (method) Array.map(callbackfn: ((value: string, index: number, array: string[]) => unknown) & ((value: number, index: number, array: number[]) => unknown), thisArg: any): unknown[] // | (method) Array.pop(): string | number // | (method) Array.push(items: never[]): number -// | (property) Array.reduce: { -// | (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; -// | (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; -// | (callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; -// | } | { -// | ...; -// | } -// | (property) Array.reduceRight: { -// | (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; -// | (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; -// | (callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; -// | } | { -// | ...; -// | } +// | (method) Array.reduce(callbackfn: (previousValue: string | number, currentValue: string | number, currentIndex: number, array: (string | number)[]) => string | number): string | number (+2 overloads) +// | (method) Array.reduceRight(callbackfn: (previousValue: string | number, currentValue: string | number, currentIndex: number, array: (string | number)[]) => string | number): string | number (+2 overloads) // | (method) Array.reverse(): string[] | number[] // | (method) Array.shift(): string | number // | (method) Array.slice(start?: number, end?: number): string[] | number[] @@ -74,7 +46,7 @@ "entries": [ { "name": "concat", - "kind": "property", + "kind": "method", "kindModifiers": "declare", "sortText": "11", "displayParts": [ @@ -83,7 +55,7 @@ "kind": "punctuation" }, { - "text": "property", + "text": "method", "kind": "text" }, { @@ -118,26 +90,6 @@ "text": "concat", "kind": "propertyName" }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, { "text": "(", "kind": "punctuation" @@ -171,23 +123,11 @@ "kind": "keyword" }, { - "text": ">", - "kind": "punctuation" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ":", + "text": "|", "kind": "punctuation" }, { @@ -195,41 +135,25 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", + "text": ">", "kind": "punctuation" }, { - "text": ";", + "text": "[", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", + "text": "]", "kind": "punctuation" }, { - "text": "...", + "text": ")", "kind": "punctuation" }, - { - "text": "items", - "kind": "parameterName" - }, { "text": ":", "kind": "punctuation" @@ -259,21 +183,9 @@ "kind": "space" }, { - "text": "ConcatArray", - "kind": "interfaceName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", + "text": "number", "kind": "keyword" }, - { - "text": ">", - "kind": "punctuation" - }, { "text": ")", "kind": "punctuation" @@ -287,39 +199,76 @@ "kind": "punctuation" }, { - "text": ")", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ":", + "text": "(", "kind": "punctuation" }, + { + "text": "+", + "kind": "operator" + }, + { + "text": "1", + "kind": "numericLiteral" + }, { "text": " ", "kind": "space" }, { - "text": "string", - "kind": "keyword" + "text": "overload", + "kind": "text" }, { - "text": "[", + "text": ")", "kind": "punctuation" - }, + } + ], + "documentation": [ { - "text": "]", - "kind": "punctuation" - }, + "text": "Combines two or more arrays.\nThis method returns a new array without modifying any existing arrays.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "items", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Additional arrays and/or items to add to the end of the array.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "every", + "kind": "method", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ { - "text": ";", + "text": "(", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" + "text": "method", + "kind": "text" }, { - "text": "}", + "text": ")", "kind": "punctuation" }, { @@ -327,35 +276,47 @@ "kind": "space" }, { - "text": "|", + "text": "Array", + "kind": "localName" + }, + { + "text": "<", "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "T", + "kind": "typeParameterName" }, { - "text": "{", + "text": ">", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" + "text": ".", + "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "every", + "kind": "propertyName" }, { - "text": "(", + "text": "<", "kind": "punctuation" }, { - "text": "...", + "text": "S", + "kind": "typeParameterName" + }, + { + "text": ">", "kind": "punctuation" }, { - "text": "items", + "text": "(", + "kind": "punctuation" + }, + { + "text": "predicate", "kind": "parameterName" }, { @@ -367,35 +328,31 @@ "kind": "space" }, { - "text": "ConcatArray", - "kind": "interfaceName" - }, - { - "text": "<", + "text": "(", "kind": "punctuation" }, { - "text": "number", - "kind": "keyword" + "text": "value", + "kind": "parameterName" }, { - "text": ">", + "text": ":", "kind": "punctuation" }, { - "text": "[", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": "]", - "kind": "punctuation" + "text": "string", + "kind": "keyword" }, { - "text": ")", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ":", + "text": "|", "kind": "punctuation" }, { @@ -407,35 +364,39 @@ "kind": "keyword" }, { - "text": "[", + "text": ",", "kind": "punctuation" }, { - "text": "]", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ";", - "kind": "punctuation" + "text": "index", + "kind": "parameterName" }, { - "text": "\n", - "kind": "lineBreak" + "text": ":", + "kind": "punctuation" }, { - "text": " ", + "text": " ", "kind": "space" }, { - "text": "(", - "kind": "punctuation" + "text": "number", + "kind": "keyword" }, { - "text": "...", + "text": ",", "kind": "punctuation" }, { - "text": "items", + "text": " ", + "kind": "space" + }, + { + "text": "array", "kind": "parameterName" }, { @@ -451,7 +412,7 @@ "kind": "punctuation" }, { - "text": "number", + "text": "string", "kind": "keyword" }, { @@ -467,19 +428,19 @@ "kind": "space" }, { - "text": "ConcatArray", - "kind": "interfaceName" + "text": "number", + "kind": "keyword" }, { - "text": "<", + "text": ")", "kind": "punctuation" }, { - "text": "...", - "kind": "text" + "text": "[", + "kind": "punctuation" }, { - "text": ">", + "text": "]", "kind": "punctuation" }, { @@ -487,53 +448,137 @@ "kind": "punctuation" }, { - "text": "[", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": "]", + "text": "=>", "kind": "punctuation" }, { - "text": ")", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ":", - "kind": "punctuation" + "text": "value", + "kind": "text" }, { "text": " ", "kind": "space" }, { - "text": "number", + "text": "is", "kind": "keyword" }, { - "text": "[", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": "]", - "kind": "punctuation" + "text": "S", + "kind": "typeParameterName" }, { - "text": ";", + "text": ",", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" + "text": " ", + "kind": "space" }, { - "text": "}", - "kind": "punctuation" - } + "text": "thisArg", + "kind": "parameterName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "this", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "is", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "S", + "kind": "typeParameterName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "+", + "kind": "operator" + }, + { + "text": "1", + "kind": "numericLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "overload", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + } ], "documentation": [ { - "text": "Combines two or more arrays.\nThis method returns a new array without modifying any existing arrays.", + "text": "Determines whether all the members of an array satisfy the specified test.", "kind": "text" } ], @@ -542,7 +587,7 @@ "name": "param", "text": [ { - "text": "items", + "text": "predicate", "kind": "parameterName" }, { @@ -550,7 +595,7 @@ "kind": "space" }, { - "text": "Additional arrays and/or items to add to the end of the array.", + "text": "A function that accepts up to three arguments. The every method calls\nthe predicate function for each element in the array until the predicate returns a value\nwhich is coercible to the Boolean value false, or until the end of the array.", "kind": "text" } ] @@ -559,7 +604,7 @@ "name": "param", "text": [ { - "text": "items", + "text": "thisArg", "kind": "parameterName" }, { @@ -567,7 +612,7 @@ "kind": "space" }, { - "text": "Additional arrays and/or items to add to the end of the array.", + "text": "An object to which the this keyword can refer in the predicate function.\nIf thisArg is omitted, undefined is used as the this value.", "kind": "text" } ] @@ -575,8 +620,8 @@ ] }, { - "name": "every", - "kind": "property", + "name": "filter", + "kind": "method", "kindModifiers": "declare", "sortText": "11", "displayParts": [ @@ -585,7 +630,7 @@ "kind": "punctuation" }, { - "text": "property", + "text": "method", "kind": "text" }, { @@ -617,29 +662,9 @@ "kind": "punctuation" }, { - "text": "every", + "text": "filter", "kind": "propertyName" }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, { "text": "<", "kind": "punctuation" @@ -648,22 +673,6 @@ "text": "S", "kind": "typeParameterName" }, - { - "text": " ", - "kind": "space" - }, - { - "text": "extends", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, { "text": ">", "kind": "punctuation" @@ -704,6 +713,22 @@ "text": "string", "kind": "keyword" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, { "text": ",", "kind": "punctuation" @@ -748,10 +773,34 @@ "text": " ", "kind": "space" }, + { + "text": "(", + "kind": "punctuation" + }, { "text": "string", "kind": "keyword" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, { "text": "[", "kind": "punctuation" @@ -836,22 +885,6 @@ "text": " ", "kind": "space" }, - { - "text": "this", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "is", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, { "text": "S", "kind": "typeParameterName" @@ -864,30 +897,6 @@ "text": "]", "kind": "punctuation" }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "predicate", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, { "text": " ", "kind": "space" @@ -897,1466 +906,55 @@ "kind": "punctuation" }, { - "text": "value", - "kind": "parameterName" + "text": "+", + "kind": "operator" }, { - "text": ":", - "kind": "punctuation" + "text": "1", + "kind": "numericLiteral" }, { "text": " ", "kind": "space" }, { - "text": "string", - "kind": "keyword" + "text": "overload", + "kind": "text" }, { - "text": ",", + "text": ")", "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, + } + ], + "documentation": [ { - "text": "index", - "kind": "parameterName" - }, + "text": "Returns the elements of an array that meet the condition specified in a callback function.", + "kind": "text" + } + ], + "tags": [ { - "text": ":", - "kind": "punctuation" + "name": "param", + "text": [ + { + "text": "predicate", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.", + "kind": "text" + } + ] }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "array", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "unknown", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "thisArg", - "kind": "parameterName" - }, - { - "text": "?", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "boolean", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "|", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "...", - "kind": "propertyName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", - "kind": "punctuation" - } - ], - "documentation": [ - { - "text": "Determines whether all the members of an array satisfy the specified test.", - "kind": "text" - } - ], - "tags": [ - { - "name": "param", - "text": [ - { - "text": "predicate", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "A function that accepts up to three arguments. The every method calls\nthe predicate function for each element in the array until the predicate returns a value\nwhich is coercible to the Boolean value false, or until the end of the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "thisArg", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "An object to which the this keyword can refer in the predicate function.\nIf thisArg is omitted, undefined is used as the this value.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "predicate", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "A function that accepts up to three arguments. The every method calls\nthe predicate function for each element in the array until the predicate returns a value\nwhich is coercible to the Boolean value false, or until the end of the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "thisArg", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "An object to which the this keyword can refer in the predicate function.\nIf thisArg is omitted, undefined is used as the this value.", - "kind": "text" - } - ] - } - ] - }, - { - "name": "filter", - "kind": "property", - "kindModifiers": "declare", - "sortText": "11", - "displayParts": [ - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "property", - "kind": "text" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Array", - "kind": "localName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ".", - "kind": "punctuation" - }, - { - "text": "filter", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "S", - "kind": "typeParameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "extends", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "predicate", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "value", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "index", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "array", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "value", - "kind": "text" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "is", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "S", - "kind": "typeParameterName" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "thisArg", - "kind": "parameterName" - }, - { - "text": "?", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "S", - "kind": "typeParameterName" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "predicate", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "value", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "index", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "array", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "unknown", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "thisArg", - "kind": "parameterName" - }, - { - "text": "?", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "|", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "...", - "kind": "propertyName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", - "kind": "punctuation" - } - ], - "documentation": [ - { - "text": "Returns the elements of an array that meet the condition specified in a callback function.", - "kind": "text" - } - ], - "tags": [ - { - "name": "param", - "text": [ - { - "text": "predicate", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "thisArg", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "predicate", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "thisArg", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.", - "kind": "text" - } - ] - } - ] - }, - { - "name": "forEach", - "kind": "method", - "kindModifiers": "declare", - "sortText": "11", - "displayParts": [ - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "method", - "kind": "text" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Array", - "kind": "localName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ".", - "kind": "punctuation" - }, - { - "text": "forEach", - "kind": "propertyName" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "callbackfn", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "value", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "index", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "array", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "void", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "&", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "value", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "index", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "array", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "void", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "thisArg", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "void", - "kind": "keyword" - } - ], - "documentation": [ - { - "text": "Performs the specified action for each element in an array.", - "kind": "text" - } - ], - "tags": [ - { - "name": "param", - "text": [ - { - "text": "callbackfn", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "thisArg", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.", - "kind": "text" - } - ] - } - ] - }, - { - "name": "indexOf", - "kind": "method", - "kindModifiers": "declare", - "sortText": "11", - "displayParts": [ - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "method", - "kind": "text" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Array", - "kind": "localName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ".", - "kind": "punctuation" - }, - { - "text": "indexOf", - "kind": "propertyName" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "searchElement", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "never", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "fromIndex", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - } - ], - "documentation": [ - { - "text": "Returns the index of the first occurrence of a value in an array, or -1 if it is not present.", - "kind": "text" - } - ], - "tags": [ - { - "name": "param", - "text": [ - { - "text": "searchElement", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "The value to locate in the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "fromIndex", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.", - "kind": "text" - } - ] - } - ] - }, - { - "name": "join", - "kind": "method", - "kindModifiers": "declare", - "sortText": "11", - "displayParts": [ - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "method", - "kind": "text" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Array", - "kind": "localName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ".", - "kind": "punctuation" - }, - { - "text": "join", - "kind": "propertyName" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "separator", - "kind": "parameterName" - }, - { - "text": "?", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - } - ], - "documentation": [ - { - "text": "Adds all the elements of an array into a string, separated by the specified separator string.", - "kind": "text" - } - ], - "tags": [ { "name": "param", "text": [ { - "text": "separator", + "text": "thisArg", "kind": "parameterName" }, { @@ -2364,7 +962,7 @@ "kind": "space" }, { - "text": "A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.", + "text": "An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.", "kind": "text" } ] @@ -2372,7 +970,7 @@ ] }, { - "name": "lastIndexOf", + "name": "forEach", "kind": "method", "kindModifiers": "declare", "sortText": "11", @@ -2414,7 +1012,7 @@ "kind": "punctuation" }, { - "text": "lastIndexOf", + "text": "forEach", "kind": "propertyName" }, { @@ -2422,7 +1020,7 @@ "kind": "punctuation" }, { - "text": "searchElement", + "text": "callbackfn", "kind": "parameterName" }, { @@ -2434,19 +1032,15 @@ "kind": "space" }, { - "text": "never", - "kind": "keyword" - }, - { - "text": ",", + "text": "(", "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "(", + "kind": "punctuation" }, { - "text": "fromIndex", + "text": "value", "kind": "parameterName" }, { @@ -2458,15 +1052,11 @@ "kind": "space" }, { - "text": "number", + "text": "string", "kind": "keyword" }, { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", + "text": ",", "kind": "punctuation" }, { @@ -2474,69 +1064,11 @@ "kind": "space" }, { - "text": "number", - "kind": "keyword" - } - ], - "documentation": [ - { - "text": "Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.", - "kind": "text" - } - ], - "tags": [ - { - "name": "param", - "text": [ - { - "text": "searchElement", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "The value to locate in the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "fromIndex", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "The array index at which to begin searching backward. If fromIndex is omitted, the search starts at the last index in the array.", - "kind": "text" - } - ] - } - ] - }, - { - "name": "length", - "kind": "property", - "kindModifiers": "declare", - "sortText": "11", - "displayParts": [ - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "property", - "kind": "text" + "text": "index", + "kind": "parameterName" }, { - "text": ")", + "text": ":", "kind": "punctuation" }, { @@ -2544,28 +1076,20 @@ "kind": "space" }, { - "text": "Array", - "kind": "localName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "T", - "kind": "typeParameterName" + "text": "number", + "kind": "keyword" }, { - "text": ">", + "text": ",", "kind": "punctuation" }, { - "text": ".", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": "length", - "kind": "propertyName" + "text": "array", + "kind": "parameterName" }, { "text": ":", @@ -2576,30 +1100,16 @@ "kind": "space" }, { - "text": "number", + "text": "string", "kind": "keyword" - } - ], - "documentation": [ - { - "text": "Gets or sets the length of the array. This is a number one higher than the highest index in the array.", - "kind": "text" - } - ] - }, - { - "name": "map", - "kind": "method", - "kindModifiers": "declare", - "sortText": "11", - "displayParts": [ + }, { - "text": "(", + "text": "[", "kind": "punctuation" }, { - "text": "method", - "kind": "text" + "text": "]", + "kind": "punctuation" }, { "text": ")", @@ -2610,51 +1120,27 @@ "kind": "space" }, { - "text": "Array", - "kind": "localName" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ".", + "text": "=>", "kind": "punctuation" }, { - "text": "map", - "kind": "propertyName" - }, - { - "text": "<", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": "unknown", + "text": "void", "kind": "keyword" }, { - "text": ">", - "kind": "punctuation" - }, - { - "text": "(", + "text": ")", "kind": "punctuation" }, { - "text": "callbackfn", - "kind": "parameterName" + "text": " ", + "kind": "space" }, { - "text": ":", + "text": "&", "kind": "punctuation" }, { @@ -2682,7 +1168,7 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, { @@ -2730,7 +1216,7 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, { @@ -2758,19 +1244,27 @@ "kind": "space" }, { - "text": "unknown", + "text": "void", "kind": "keyword" }, { "text": ")", "kind": "punctuation" }, + { + "text": ",", + "kind": "punctuation" + }, { "text": " ", "kind": "space" }, { - "text": "&", + "text": "thisArg", + "kind": "parameterName" + }, + { + "text": ":", "kind": "punctuation" }, { @@ -2778,17 +1272,13 @@ "kind": "space" }, { - "text": "(", - "kind": "punctuation" + "text": "any", + "kind": "keyword" }, { - "text": "(", + "text": ")", "kind": "punctuation" }, - { - "text": "value", - "kind": "parameterName" - }, { "text": ":", "kind": "punctuation" @@ -2798,35 +1288,69 @@ "kind": "space" }, { - "text": "number", + "text": "void", "kind": "keyword" - }, + } + ], + "documentation": [ { - "text": ",", - "kind": "punctuation" - }, + "text": "Performs the specified action for each element in an array.", + "kind": "text" + } + ], + "tags": [ { - "text": " ", - "kind": "space" + "name": "param", + "text": [ + { + "text": "callbackfn", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.", + "kind": "text" + } + ] }, { - "text": "index", - "kind": "parameterName" - }, + "name": "param", + "text": [ + { + "text": "thisArg", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "indexOf", + "kind": "method", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ { - "text": ":", + "text": "(", "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" + "text": "method", + "kind": "text" }, { - "text": ",", + "text": ")", "kind": "punctuation" }, { @@ -2834,39 +1358,39 @@ "kind": "space" }, { - "text": "array", - "kind": "parameterName" + "text": "Array", + "kind": "localName" }, { - "text": ":", + "text": "<", "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "T", + "kind": "typeParameterName" }, { - "text": "number", - "kind": "keyword" + "text": ">", + "kind": "punctuation" }, { - "text": "[", + "text": ".", "kind": "punctuation" }, { - "text": "]", - "kind": "punctuation" + "text": "indexOf", + "kind": "propertyName" }, { - "text": ")", + "text": "(", "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "searchElement", + "kind": "parameterName" }, { - "text": "=>", + "text": ":", "kind": "punctuation" }, { @@ -2874,13 +1398,9 @@ "kind": "space" }, { - "text": "unknown", + "text": "never", "kind": "keyword" }, - { - "text": ")", - "kind": "punctuation" - }, { "text": ",", "kind": "punctuation" @@ -2890,7 +1410,7 @@ "kind": "space" }, { - "text": "thisArg", + "text": "fromIndex", "kind": "parameterName" }, { @@ -2902,7 +1422,7 @@ "kind": "space" }, { - "text": "any", + "text": "number", "kind": "keyword" }, { @@ -2918,21 +1438,13 @@ "kind": "space" }, { - "text": "unknown", + "text": "number", "kind": "keyword" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" } ], "documentation": [ { - "text": "Calls a defined callback function on each element of an array, and returns an array that contains the results.", + "text": "Returns the index of the first occurrence of a value in an array, or -1 if it is not present.", "kind": "text" } ], @@ -2941,7 +1453,7 @@ "name": "param", "text": [ { - "text": "callbackfn", + "text": "searchElement", "kind": "parameterName" }, { @@ -2949,7 +1461,7 @@ "kind": "space" }, { - "text": "A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.", + "text": "The value to locate in the array.", "kind": "text" } ] @@ -2958,7 +1470,7 @@ "name": "param", "text": [ { - "text": "thisArg", + "text": "fromIndex", "kind": "parameterName" }, { @@ -2966,7 +1478,7 @@ "kind": "space" }, { - "text": "An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.", + "text": "The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.", "kind": "text" } ] @@ -2974,7 +1486,7 @@ ] }, { - "name": "pop", + "name": "join", "kind": "method", "kindModifiers": "declare", "sortText": "11", @@ -3016,7 +1528,7 @@ "kind": "punctuation" }, { - "text": "pop", + "text": "join", "kind": "propertyName" }, { @@ -3024,7 +1536,11 @@ "kind": "punctuation" }, { - "text": ")", + "text": "separator", + "kind": "parameterName" + }, + { + "text": "?", "kind": "punctuation" }, { @@ -3040,11 +1556,11 @@ "kind": "keyword" }, { - "text": " ", - "kind": "space" + "text": ")", + "kind": "punctuation" }, { - "text": "|", + "text": ":", "kind": "punctuation" }, { @@ -3052,19 +1568,38 @@ "kind": "space" }, { - "text": "number", + "text": "string", "kind": "keyword" } ], "documentation": [ { - "text": "Removes the last element from an array and returns it.\nIf the array is empty, undefined is returned and the array is not modified.", + "text": "Adds all the elements of an array into a string, separated by the specified separator string.", "kind": "text" } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "separator", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.", + "kind": "text" + } + ] + } ] }, { - "name": "push", + "name": "lastIndexOf", "kind": "method", "kindModifiers": "declare", "sortText": "11", @@ -3106,7 +1641,7 @@ "kind": "punctuation" }, { - "text": "push", + "text": "lastIndexOf", "kind": "propertyName" }, { @@ -3114,7 +1649,7 @@ "kind": "punctuation" }, { - "text": "items", + "text": "searchElement", "kind": "parameterName" }, { @@ -3130,13 +1665,29 @@ "kind": "keyword" }, { - "text": "[", + "text": ",", "kind": "punctuation" }, { - "text": "]", + "text": " ", + "kind": "space" + }, + { + "text": "fromIndex", + "kind": "parameterName" + }, + { + "text": ":", "kind": "punctuation" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, { "text": ")", "kind": "punctuation" @@ -3156,7 +1707,7 @@ ], "documentation": [ { - "text": "Appends new elements to the end of an array, and returns the new length of the array.", + "text": "Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.", "kind": "text" } ], @@ -3165,7 +1716,7 @@ "name": "param", "text": [ { - "text": "items", + "text": "searchElement", "kind": "parameterName" }, { @@ -3173,7 +1724,24 @@ "kind": "space" }, { - "text": "New elements to add to the array.", + "text": "The value to locate in the array.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "fromIndex", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "The array index at which to begin searching backward. If fromIndex is omitted, the search starts at the last index in the array.", "kind": "text" } ] @@ -3181,7 +1749,7 @@ ] }, { - "name": "reduce", + "name": "length", "kind": "property", "kindModifiers": "declare", "sortText": "11", @@ -3223,7 +1791,7 @@ "kind": "punctuation" }, { - "text": "reduce", + "text": "length", "kind": "propertyName" }, { @@ -3231,43 +1799,85 @@ "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "Gets or sets the length of the array. This is a number one higher than the highest index in the array.", + "kind": "text" + } + ] + }, + { + "name": "map", + "kind": "method", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "method", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Array", + "kind": "localName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" }, { - "text": "{", + "text": ">", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" + "text": ".", + "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "map", + "kind": "propertyName" }, { - "text": "(", + "text": "<", "kind": "punctuation" }, { - "text": "callbackfn", - "kind": "parameterName" + "text": "unknown", + "kind": "keyword" }, { - "text": ":", + "text": ">", "kind": "punctuation" }, - { - "text": " ", - "kind": "space" - }, { "text": "(", "kind": "punctuation" }, { - "text": "previousValue", + "text": "callbackfn", "kind": "parameterName" }, { @@ -3279,19 +1889,15 @@ "kind": "space" }, { - "text": "string", - "kind": "keyword" - }, - { - "text": ",", + "text": "(", "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "(", + "kind": "punctuation" }, { - "text": "currentValue", + "text": "value", "kind": "parameterName" }, { @@ -3315,7 +1921,7 @@ "kind": "space" }, { - "text": "currentIndex", + "text": "index", "kind": "parameterName" }, { @@ -3379,47 +1985,19 @@ "kind": "space" }, { - "text": "string", + "text": "unknown", "kind": "keyword" }, { "text": ")", "kind": "punctuation" }, - { - "text": ":", - "kind": "punctuation" - }, { "text": " ", "kind": "space" }, { - "text": "string", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "callbackfn", - "kind": "parameterName" - }, - { - "text": ":", + "text": "&", "kind": "punctuation" }, { @@ -3431,31 +2009,11 @@ "kind": "punctuation" }, { - "text": "previousValue", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ",", + "text": "(", "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "currentValue", + "text": "value", "kind": "parameterName" }, { @@ -3467,7 +2025,7 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, { @@ -3479,7 +2037,7 @@ "kind": "space" }, { - "text": "currentIndex", + "text": "index", "kind": "parameterName" }, { @@ -3515,7 +2073,7 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, { @@ -3543,9 +2101,13 @@ "kind": "space" }, { - "text": "string", + "text": "unknown", "kind": "keyword" }, + { + "text": ")", + "kind": "punctuation" + }, { "text": ",", "kind": "punctuation" @@ -3555,7 +2117,7 @@ "kind": "space" }, { - "text": "initialValue", + "text": "thisArg", "kind": "parameterName" }, { @@ -3567,7 +2129,7 @@ "kind": "space" }, { - "text": "string", + "text": "any", "kind": "keyword" }, { @@ -3583,43 +2145,77 @@ "kind": "space" }, { - "text": "string", + "text": "unknown", "kind": "keyword" }, { - "text": ";", + "text": "[", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "<", + "text": "]", "kind": "punctuation" - }, + } + ], + "documentation": [ { - "text": "U", - "kind": "typeParameterName" - }, + "text": "Calls a defined callback function on each element of an array, and returns an array that contains the results.", + "kind": "text" + } + ], + "tags": [ { - "text": ">", - "kind": "punctuation" + "name": "param", + "text": [ + { + "text": "callbackfn", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.", + "kind": "text" + } + ] }, + { + "name": "param", + "text": [ + { + "text": "thisArg", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "pop", + "kind": "method", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ { "text": "(", "kind": "punctuation" }, { - "text": "callbackfn", - "kind": "parameterName" + "text": "method", + "kind": "text" }, { - "text": ":", + "text": ")", "kind": "punctuation" }, { @@ -3627,60 +2223,36 @@ "kind": "space" }, { - "text": "(", - "kind": "punctuation" - }, - { - "text": "previousValue", - "kind": "parameterName" + "text": "Array", + "kind": "localName" }, { - "text": ":", + "text": "<", "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "U", + "text": "T", "kind": "typeParameterName" }, { - "text": ",", + "text": ">", "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "currentValue", - "kind": "parameterName" - }, - { - "text": ":", + "text": ".", "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" + "text": "pop", + "kind": "propertyName" }, { - "text": ",", + "text": "(", "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "currentIndex", - "kind": "parameterName" + "text": ")", + "kind": "punctuation" }, { "text": ":", @@ -3691,23 +2263,15 @@ "kind": "space" }, { - "text": "number", + "text": "string", "kind": "keyword" }, - { - "text": ",", - "kind": "punctuation" - }, { "text": " ", "kind": "space" }, { - "text": "array", - "kind": "parameterName" - }, - { - "text": ":", + "text": "|", "kind": "punctuation" }, { @@ -3715,27 +2279,33 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" - }, - { - "text": "[", - "kind": "punctuation" - }, + } + ], + "documentation": [ { - "text": "]", - "kind": "punctuation" - }, + "text": "Removes the last element from an array and returns it.\nIf the array is empty, undefined is returned and the array is not modified.", + "kind": "text" + } + ] + }, + { + "name": "push", + "kind": "method", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ { - "text": ")", + "text": "(", "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "method", + "kind": "text" }, { - "text": "=>", + "text": ")", "kind": "punctuation" }, { @@ -3743,36 +2313,36 @@ "kind": "space" }, { - "text": "U", - "kind": "typeParameterName" + "text": "Array", + "kind": "localName" }, { - "text": ",", + "text": "<", "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "T", + "kind": "typeParameterName" }, { - "text": "initialValue", - "kind": "parameterName" + "text": ">", + "kind": "punctuation" }, { - "text": ":", + "text": ".", "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "push", + "kind": "propertyName" }, { - "text": "U", - "kind": "typeParameterName" + "text": "(", + "kind": "punctuation" }, { - "text": ")", - "kind": "punctuation" + "text": "items", + "kind": "parameterName" }, { "text": ":", @@ -3783,65 +2353,37 @@ "kind": "space" }, { - "text": "U", - "kind": "typeParameterName" + "text": "never", + "kind": "keyword" }, { - "text": ";", + "text": "[", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", + "text": "]", "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "|", + "text": ")", "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "{", + "text": ":", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", + "text": " ", "kind": "space" }, { - "text": "...", - "kind": "propertyName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", - "kind": "punctuation" + "text": "number", + "kind": "keyword" } ], "documentation": [ { - "text": "Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.", + "text": "Appends new elements to the end of an array, and returns the new length of the array.", "kind": "text" } ], @@ -3850,58 +2392,7 @@ "name": "param", "text": [ { - "text": "callbackfn", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "initialValue", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "callbackfn", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "initialValue", + "text": "items", "kind": "parameterName" }, { @@ -3909,7 +2400,7 @@ "kind": "space" }, { - "text": "If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.", + "text": "New elements to add to the array.", "kind": "text" } ] @@ -3917,8 +2408,8 @@ ] }, { - "name": "reduceRight", - "kind": "property", + "name": "reduce", + "kind": "method", "kindModifiers": "declare", "sortText": "11", "displayParts": [ @@ -3927,7 +2418,7 @@ "kind": "punctuation" }, { - "text": "property", + "text": "method", "kind": "text" }, { @@ -3959,29 +2450,9 @@ "kind": "punctuation" }, { - "text": "reduceRight", + "text": "reduce", "kind": "propertyName" }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, { "text": "(", "kind": "punctuation" @@ -4018,20 +2489,12 @@ "text": "string", "kind": "keyword" }, - { - "text": ",", - "kind": "punctuation" - }, { "text": " ", "kind": "space" }, { - "text": "currentValue", - "kind": "parameterName" - }, - { - "text": ":", + "text": "|", "kind": "punctuation" }, { @@ -4039,7 +2502,7 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, { @@ -4051,7 +2514,7 @@ "kind": "space" }, { - "text": "currentIndex", + "text": "currentValue", "kind": "parameterName" }, { @@ -4063,23 +2526,15 @@ "kind": "space" }, { - "text": "number", + "text": "string", "kind": "keyword" }, - { - "text": ",", - "kind": "punctuation" - }, { "text": " ", "kind": "space" }, { - "text": "array", - "kind": "parameterName" - }, - { - "text": ":", + "text": "|", "kind": "punctuation" }, { @@ -4087,27 +2542,11 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, { - "text": "[", - "kind": "punctuation" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", + "text": ",", "kind": "punctuation" }, { @@ -4115,12 +2554,8 @@ "kind": "space" }, { - "text": "string", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" + "text": "currentIndex", + "kind": "parameterName" }, { "text": ":", @@ -4131,27 +2566,19 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, { - "text": ";", + "text": ",", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", + "text": " ", "kind": "space" }, { - "text": "(", - "kind": "punctuation" - }, - { - "text": "callbackfn", + "text": "array", "kind": "parameterName" }, { @@ -4167,23 +2594,15 @@ "kind": "punctuation" }, { - "text": "previousValue", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" + "text": "string", + "kind": "keyword" }, { "text": " ", "kind": "space" }, { - "text": "string", - "kind": "keyword" - }, - { - "text": ",", + "text": "|", "kind": "punctuation" }, { @@ -4191,23 +2610,23 @@ "kind": "space" }, { - "text": "currentValue", - "kind": "parameterName" + "text": "number", + "kind": "keyword" }, { - "text": ":", + "text": ")", "kind": "punctuation" }, { - "text": " ", - "kind": "space" + "text": "[", + "kind": "punctuation" }, { - "text": "string", - "kind": "keyword" + "text": "]", + "kind": "punctuation" }, { - "text": ",", + "text": ")", "kind": "punctuation" }, { @@ -4215,11 +2634,7 @@ "kind": "space" }, { - "text": "currentIndex", - "kind": "parameterName" - }, - { - "text": ":", + "text": "=>", "kind": "punctuation" }, { @@ -4227,23 +2642,15 @@ "kind": "space" }, { - "text": "number", - "kind": "keyword" - }, - { - "text": ",", - "kind": "punctuation" + "text": "string", + "kind": "keyword" }, { "text": " ", "kind": "space" }, { - "text": "array", - "kind": "parameterName" - }, - { - "text": ":", + "text": "|", "kind": "punctuation" }, { @@ -4251,27 +2658,31 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, { - "text": "[", + "text": ")", "kind": "punctuation" }, { - "text": "]", + "text": ":", "kind": "punctuation" }, { - "text": ")", - "kind": "punctuation" + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" }, { "text": " ", "kind": "space" }, { - "text": "=>", + "text": "|", "kind": "punctuation" }, { @@ -4279,73 +2690,127 @@ "kind": "space" }, { - "text": "string", + "text": "number", "kind": "keyword" }, - { - "text": ",", - "kind": "punctuation" - }, { "text": " ", "kind": "space" }, { - "text": "initialValue", - "kind": "parameterName" + "text": "(", + "kind": "punctuation" }, { - "text": ":", - "kind": "punctuation" + "text": "+", + "kind": "operator" + }, + { + "text": "2", + "kind": "numericLiteral" }, { "text": " ", "kind": "space" }, { - "text": "string", - "kind": "keyword" + "text": "overloads", + "kind": "text" }, { "text": ")", "kind": "punctuation" - }, + } + ], + "documentation": [ { - "text": ":", - "kind": "punctuation" + "text": "Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "callbackfn", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.", + "kind": "text" + } + ] }, { - "text": " ", - "kind": "space" + "name": "param", + "text": [ + { + "text": "initialValue", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.", + "kind": "text" + } + ] + } + ] + }, + { + "name": "reduceRight", + "kind": "method", + "kindModifiers": "declare", + "sortText": "11", + "displayParts": [ + { + "text": "(", + "kind": "punctuation" }, { - "text": "string", - "kind": "keyword" + "text": "method", + "kind": "text" }, { - "text": ";", + "text": ")", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" + "text": " ", + "kind": "space" }, { - "text": " ", - "kind": "space" + "text": "Array", + "kind": "localName" }, { "text": "<", "kind": "punctuation" }, { - "text": "U", + "text": "T", "kind": "typeParameterName" }, { "text": ">", "kind": "punctuation" }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "reduceRight", + "kind": "propertyName" + }, { "text": "(", "kind": "punctuation" @@ -4379,8 +2844,24 @@ "kind": "space" }, { - "text": "U", - "kind": "typeParameterName" + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" }, { "text": ",", @@ -4406,6 +2887,22 @@ "text": "string", "kind": "keyword" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, { "text": ",", "kind": "punctuation" @@ -4450,10 +2947,34 @@ "text": " ", "kind": "space" }, + { + "text": "(", + "kind": "punctuation" + }, { "text": "string", "kind": "keyword" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, { "text": "[", "kind": "punctuation" @@ -4479,23 +3000,15 @@ "kind": "space" }, { - "text": "U", - "kind": "typeParameterName" - }, - { - "text": ",", - "kind": "punctuation" + "text": "string", + "kind": "keyword" }, { "text": " ", "kind": "space" }, { - "text": "initialValue", - "kind": "parameterName" - }, - { - "text": ":", + "text": "|", "kind": "punctuation" }, { @@ -4503,8 +3016,8 @@ "kind": "space" }, { - "text": "U", - "kind": "typeParameterName" + "text": "number", + "kind": "keyword" }, { "text": ")", @@ -4519,19 +3032,15 @@ "kind": "space" }, { - "text": "U", - "kind": "typeParameterName" - }, - { - "text": ";", - "kind": "punctuation" + "text": "string", + "kind": "keyword" }, { - "text": "\n", - "kind": "lineBreak" + "text": " ", + "kind": "space" }, { - "text": "}", + "text": "|", "kind": "punctuation" }, { @@ -4539,39 +3048,35 @@ "kind": "space" }, { - "text": "|", - "kind": "punctuation" + "text": "number", + "kind": "keyword" }, { "text": " ", "kind": "space" }, { - "text": "{", + "text": "(", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" + "text": "+", + "kind": "operator" }, { - "text": "...", - "kind": "propertyName" + "text": "2", + "kind": "numericLiteral" }, { - "text": ";", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": "\n", - "kind": "lineBreak" + "text": "overloads", + "kind": "text" }, { - "text": "}", + "text": ")", "kind": "punctuation" } ], @@ -4582,40 +3087,6 @@ } ], "tags": [ - { - "name": "param", - "text": [ - { - "text": "callbackfn", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.", - "kind": "text" - } - ] - }, - { - "name": "param", - "text": [ - { - "text": "initialValue", - "kind": "parameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.", - "kind": "text" - } - ] - }, { "name": "param", "text": [ diff --git a/tests/baselines/reference/unionOfArraysFilterCall.js b/tests/baselines/reference/unionOfArraysFilterCall.js new file mode 100644 index 0000000000000..92fb149bfde96 --- /dev/null +++ b/tests/baselines/reference/unionOfArraysFilterCall.js @@ -0,0 +1,36 @@ +//// [unionOfArraysFilterCall.ts] +interface Fizz { + id: number; + fizz: string; +} + +interface Buzz { + id: number; + buzz: string; +} + +([] as Fizz[] | Buzz[]).filter(item => item.id < 5); +([] as Fizz[] | readonly Buzz[]).filter(item => item.id < 5); + +([] as Fizz[] | Buzz[]).find(item => item); +declare function isFizz(x: unknown): x is Fizz; +([] as Fizz[] | Buzz[]).find(isFizz); +declare function isBuzz(x: unknown): x is Buzz; +([] as Fizz[] | Buzz[]).find(isBuzz); + +([] as Fizz[] | Buzz[]).every(item => item.id < 5); + +([] as Fizz[] | Buzz[]).reduce(item => item); + + +([] as [Fizz] | readonly [Buzz?]).filter(item => item?.id < 5); + +//// [unionOfArraysFilterCall.js] +[].filter(item => item.id < 5); +[].filter(item => item.id < 5); +[].find(item => item); +[].find(isFizz); +[].find(isBuzz); +[].every(item => item.id < 5); +[].reduce(item => item); +[].filter(item => (item === null || item === void 0 ? void 0 : item.id) < 5); diff --git a/tests/baselines/reference/unionOfArraysFilterCall.symbols b/tests/baselines/reference/unionOfArraysFilterCall.symbols new file mode 100644 index 0000000000000..ad10e76d9541f --- /dev/null +++ b/tests/baselines/reference/unionOfArraysFilterCall.symbols @@ -0,0 +1,104 @@ +=== tests/cases/compiler/unionOfArraysFilterCall.ts === +interface Fizz { +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) + + id: number; +>id : Symbol(Fizz.id, Decl(unionOfArraysFilterCall.ts, 0, 16)) + + fizz: string; +>fizz : Symbol(Fizz.fizz, Decl(unionOfArraysFilterCall.ts, 1, 15)) +} + +interface Buzz { +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) + + id: number; +>id : Symbol(Buzz.id, Decl(unionOfArraysFilterCall.ts, 5, 16)) + + buzz: string; +>buzz : Symbol(Buzz.buzz, Decl(unionOfArraysFilterCall.ts, 6, 15)) +} + +([] as Fizz[] | Buzz[]).filter(item => item.id < 5); +>([] as Fizz[] | Buzz[]).filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 10, 31)) +>item.id : Symbol(id, Decl(unionOfArraysFilterCall.ts, 0, 16), Decl(unionOfArraysFilterCall.ts, 5, 16)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 10, 31)) +>id : Symbol(id, Decl(unionOfArraysFilterCall.ts, 0, 16), Decl(unionOfArraysFilterCall.ts, 5, 16)) + +([] as Fizz[] | readonly Buzz[]).filter(item => item.id < 5); +>([] as Fizz[] | readonly Buzz[]).filter : Symbol(filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) +>filter : Symbol(filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 11, 40)) +>item.id : Symbol(id, Decl(unionOfArraysFilterCall.ts, 0, 16), Decl(unionOfArraysFilterCall.ts, 5, 16)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 11, 40)) +>id : Symbol(id, Decl(unionOfArraysFilterCall.ts, 0, 16), Decl(unionOfArraysFilterCall.ts, 5, 16)) + +([] as Fizz[] | Buzz[]).find(item => item); +>([] as Fizz[] | Buzz[]).find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 13, 29)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 13, 29)) + +declare function isFizz(x: unknown): x is Fizz; +>isFizz : Symbol(isFizz, Decl(unionOfArraysFilterCall.ts, 13, 43)) +>x : Symbol(x, Decl(unionOfArraysFilterCall.ts, 14, 24)) +>x : Symbol(x, Decl(unionOfArraysFilterCall.ts, 14, 24)) +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) + +([] as Fizz[] | Buzz[]).find(isFizz); +>([] as Fizz[] | Buzz[]).find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>isFizz : Symbol(isFizz, Decl(unionOfArraysFilterCall.ts, 13, 43)) + +declare function isBuzz(x: unknown): x is Buzz; +>isBuzz : Symbol(isBuzz, Decl(unionOfArraysFilterCall.ts, 15, 37)) +>x : Symbol(x, Decl(unionOfArraysFilterCall.ts, 16, 24)) +>x : Symbol(x, Decl(unionOfArraysFilterCall.ts, 16, 24)) +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) + +([] as Fizz[] | Buzz[]).find(isBuzz); +>([] as Fizz[] | Buzz[]).find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>isBuzz : Symbol(isBuzz, Decl(unionOfArraysFilterCall.ts, 15, 37)) + +([] as Fizz[] | Buzz[]).every(item => item.id < 5); +>([] as Fizz[] | Buzz[]).every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 19, 30)) +>item.id : Symbol(id, Decl(unionOfArraysFilterCall.ts, 0, 16), Decl(unionOfArraysFilterCall.ts, 5, 16)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 19, 30)) +>id : Symbol(id, Decl(unionOfArraysFilterCall.ts, 0, 16), Decl(unionOfArraysFilterCall.ts, 5, 16)) + +([] as Fizz[] | Buzz[]).reduce(item => item); +>([] as Fizz[] | Buzz[]).reduce : Symbol(Array.reduce, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more) +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) +>reduce : Symbol(Array.reduce, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --) ... and 1 more) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 21, 31)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 21, 31)) + + +([] as [Fizz] | readonly [Buzz?]).filter(item => item?.id < 5); +>([] as [Fizz] | readonly [Buzz?]).filter : Symbol(filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Fizz : Symbol(Fizz, Decl(unionOfArraysFilterCall.ts, 0, 0)) +>Buzz : Symbol(Buzz, Decl(unionOfArraysFilterCall.ts, 3, 1)) +>filter : Symbol(filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 24, 41)) +>item?.id : Symbol(id, Decl(unionOfArraysFilterCall.ts, 0, 16), Decl(unionOfArraysFilterCall.ts, 5, 16)) +>item : Symbol(item, Decl(unionOfArraysFilterCall.ts, 24, 41)) +>id : Symbol(id, Decl(unionOfArraysFilterCall.ts, 0, 16), Decl(unionOfArraysFilterCall.ts, 5, 16)) + diff --git a/tests/baselines/reference/unionOfArraysFilterCall.types b/tests/baselines/reference/unionOfArraysFilterCall.types new file mode 100644 index 0000000000000..a5799d192b6ec --- /dev/null +++ b/tests/baselines/reference/unionOfArraysFilterCall.types @@ -0,0 +1,126 @@ +=== tests/cases/compiler/unionOfArraysFilterCall.ts === +interface Fizz { + id: number; +>id : number + + fizz: string; +>fizz : string +} + +interface Buzz { + id: number; +>id : number + + buzz: string; +>buzz : string +} + +([] as Fizz[] | Buzz[]).filter(item => item.id < 5); +>([] as Fizz[] | Buzz[]).filter(item => item.id < 5) : (Fizz | Buzz)[] +>([] as Fizz[] | Buzz[]).filter : { (predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): Fizz[]; } | { (predicate: (value: Buzz, index: number, array: Buzz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Buzz, index: number, array: Buzz[]) => unknown, thisArg?: any): Buzz[]; } +>([] as Fizz[] | Buzz[]) : Fizz[] | Buzz[] +>[] as Fizz[] | Buzz[] : Fizz[] | Buzz[] +>[] : undefined[] +>filter : { (predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): Fizz[]; } | { (predicate: (value: Buzz, index: number, array: Buzz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Buzz, index: number, array: Buzz[]) => unknown, thisArg?: any): Buzz[]; } +>item => item.id < 5 : (item: Fizz | Buzz) => boolean +>item : Fizz | Buzz +>item.id < 5 : boolean +>item.id : number +>item : Fizz | Buzz +>id : number +>5 : 5 + +([] as Fizz[] | readonly Buzz[]).filter(item => item.id < 5); +>([] as Fizz[] | readonly Buzz[]).filter(item => item.id < 5) : (Fizz | Buzz)[] +>([] as Fizz[] | readonly Buzz[]).filter : { (predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): Fizz[]; } | { (predicate: (value: Buzz, index: number, array: readonly Buzz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Buzz, index: number, array: readonly Buzz[]) => unknown, thisArg?: any): Buzz[]; } +>([] as Fizz[] | readonly Buzz[]) : Fizz[] | readonly Buzz[] +>[] as Fizz[] | readonly Buzz[] : Fizz[] | readonly Buzz[] +>[] : undefined[] +>filter : { (predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): Fizz[]; } | { (predicate: (value: Buzz, index: number, array: readonly Buzz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Buzz, index: number, array: readonly Buzz[]) => unknown, thisArg?: any): Buzz[]; } +>item => item.id < 5 : (item: Fizz | Buzz) => boolean +>item : Fizz | Buzz +>item.id < 5 : boolean +>item.id : number +>item : Fizz | Buzz +>id : number +>5 : 5 + +([] as Fizz[] | Buzz[]).find(item => item); +>([] as Fizz[] | Buzz[]).find(item => item) : Fizz | Buzz +>([] as Fizz[] | Buzz[]).find : { (predicate: (value: Fizz, index: number, obj: Fizz[]) => value is S, thisArg?: any): S; (predicate: (value: Fizz, index: number, obj: Fizz[]) => unknown, thisArg?: any): Fizz; } | { (predicate: (value: Buzz, index: number, obj: Buzz[]) => value is S, thisArg?: any): S; (predicate: (value: Buzz, index: number, obj: Buzz[]) => unknown, thisArg?: any): Buzz; } +>([] as Fizz[] | Buzz[]) : Fizz[] | Buzz[] +>[] as Fizz[] | Buzz[] : Fizz[] | Buzz[] +>[] : undefined[] +>find : { (predicate: (value: Fizz, index: number, obj: Fizz[]) => value is S, thisArg?: any): S; (predicate: (value: Fizz, index: number, obj: Fizz[]) => unknown, thisArg?: any): Fizz; } | { (predicate: (value: Buzz, index: number, obj: Buzz[]) => value is S, thisArg?: any): S; (predicate: (value: Buzz, index: number, obj: Buzz[]) => unknown, thisArg?: any): Buzz; } +>item => item : (item: Fizz | Buzz) => Fizz | Buzz +>item : Fizz | Buzz +>item : Fizz | Buzz + +declare function isFizz(x: unknown): x is Fizz; +>isFizz : (x: unknown) => x is Fizz +>x : unknown + +([] as Fizz[] | Buzz[]).find(isFizz); +>([] as Fizz[] | Buzz[]).find(isFizz) : Fizz +>([] as Fizz[] | Buzz[]).find : { (predicate: (value: Fizz, index: number, obj: Fizz[]) => value is S, thisArg?: any): S; (predicate: (value: Fizz, index: number, obj: Fizz[]) => unknown, thisArg?: any): Fizz; } | { (predicate: (value: Buzz, index: number, obj: Buzz[]) => value is S, thisArg?: any): S; (predicate: (value: Buzz, index: number, obj: Buzz[]) => unknown, thisArg?: any): Buzz; } +>([] as Fizz[] | Buzz[]) : Fizz[] | Buzz[] +>[] as Fizz[] | Buzz[] : Fizz[] | Buzz[] +>[] : undefined[] +>find : { (predicate: (value: Fizz, index: number, obj: Fizz[]) => value is S, thisArg?: any): S; (predicate: (value: Fizz, index: number, obj: Fizz[]) => unknown, thisArg?: any): Fizz; } | { (predicate: (value: Buzz, index: number, obj: Buzz[]) => value is S, thisArg?: any): S; (predicate: (value: Buzz, index: number, obj: Buzz[]) => unknown, thisArg?: any): Buzz; } +>isFizz : (x: unknown) => x is Fizz + +declare function isBuzz(x: unknown): x is Buzz; +>isBuzz : (x: unknown) => x is Buzz +>x : unknown + +([] as Fizz[] | Buzz[]).find(isBuzz); +>([] as Fizz[] | Buzz[]).find(isBuzz) : Buzz +>([] as Fizz[] | Buzz[]).find : { (predicate: (value: Fizz, index: number, obj: Fizz[]) => value is S, thisArg?: any): S; (predicate: (value: Fizz, index: number, obj: Fizz[]) => unknown, thisArg?: any): Fizz; } | { (predicate: (value: Buzz, index: number, obj: Buzz[]) => value is S, thisArg?: any): S; (predicate: (value: Buzz, index: number, obj: Buzz[]) => unknown, thisArg?: any): Buzz; } +>([] as Fizz[] | Buzz[]) : Fizz[] | Buzz[] +>[] as Fizz[] | Buzz[] : Fizz[] | Buzz[] +>[] : undefined[] +>find : { (predicate: (value: Fizz, index: number, obj: Fizz[]) => value is S, thisArg?: any): S; (predicate: (value: Fizz, index: number, obj: Fizz[]) => unknown, thisArg?: any): Fizz; } | { (predicate: (value: Buzz, index: number, obj: Buzz[]) => value is S, thisArg?: any): S; (predicate: (value: Buzz, index: number, obj: Buzz[]) => unknown, thisArg?: any): Buzz; } +>isBuzz : (x: unknown) => x is Buzz + +([] as Fizz[] | Buzz[]).every(item => item.id < 5); +>([] as Fizz[] | Buzz[]).every(item => item.id < 5) : boolean +>([] as Fizz[] | Buzz[]).every : { (predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): boolean; } | { (predicate: (value: Buzz, index: number, array: Buzz[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Buzz, index: number, array: Buzz[]) => unknown, thisArg?: any): boolean; } +>([] as Fizz[] | Buzz[]) : Fizz[] | Buzz[] +>[] as Fizz[] | Buzz[] : Fizz[] | Buzz[] +>[] : undefined[] +>every : { (predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): boolean; } | { (predicate: (value: Buzz, index: number, array: Buzz[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Buzz, index: number, array: Buzz[]) => unknown, thisArg?: any): boolean; } +>item => item.id < 5 : (item: Fizz | Buzz) => boolean +>item : Fizz | Buzz +>item.id < 5 : boolean +>item.id : number +>item : Fizz | Buzz +>id : number +>5 : 5 + +([] as Fizz[] | Buzz[]).reduce(item => item); +>([] as Fizz[] | Buzz[]).reduce(item => item) : Fizz | Buzz +>([] as Fizz[] | Buzz[]).reduce : { (callbackfn: (previousValue: Fizz, currentValue: Fizz, currentIndex: number, array: Fizz[]) => Fizz): Fizz; (callbackfn: (previousValue: Fizz, currentValue: Fizz, currentIndex: number, array: Fizz[]) => Fizz, initialValue: Fizz): Fizz; (callbackfn: (previousValue: U, currentValue: Fizz, currentIndex: number, array: Fizz[]) => U, initialValue: U): U; } | { (callbackfn: (previousValue: Buzz, currentValue: Buzz, currentIndex: number, array: Buzz[]) => Buzz): Buzz; (callbackfn: (previousValue: Buzz, currentValue: Buzz, currentIndex: number, array: Buzz[]) => Buzz, initialValue: Buzz): Buzz; (callbackfn: (previousValue: U, currentValue: Buzz, currentIndex: number, array: Buzz[]) => U, initialValue: U): U; } +>([] as Fizz[] | Buzz[]) : Fizz[] | Buzz[] +>[] as Fizz[] | Buzz[] : Fizz[] | Buzz[] +>[] : undefined[] +>reduce : { (callbackfn: (previousValue: Fizz, currentValue: Fizz, currentIndex: number, array: Fizz[]) => Fizz): Fizz; (callbackfn: (previousValue: Fizz, currentValue: Fizz, currentIndex: number, array: Fizz[]) => Fizz, initialValue: Fizz): Fizz; (callbackfn: (previousValue: U, currentValue: Fizz, currentIndex: number, array: Fizz[]) => U, initialValue: U): U; } | { (callbackfn: (previousValue: Buzz, currentValue: Buzz, currentIndex: number, array: Buzz[]) => Buzz): Buzz; (callbackfn: (previousValue: Buzz, currentValue: Buzz, currentIndex: number, array: Buzz[]) => Buzz, initialValue: Buzz): Buzz; (callbackfn: (previousValue: U, currentValue: Buzz, currentIndex: number, array: Buzz[]) => U, initialValue: U): U; } +>item => item : (item: Fizz | Buzz) => Fizz | Buzz +>item : Fizz | Buzz +>item : Fizz | Buzz + + +([] as [Fizz] | readonly [Buzz?]).filter(item => item?.id < 5); +>([] as [Fizz] | readonly [Buzz?]).filter(item => item?.id < 5) : (Fizz | Buzz)[] +>([] as [Fizz] | readonly [Buzz?]).filter : { (predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): Fizz[]; } | { (predicate: (value: Buzz, index: number, array: readonly Buzz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Buzz, index: number, array: readonly Buzz[]) => unknown, thisArg?: any): Buzz[]; } +>([] as [Fizz] | readonly [Buzz?]) : [Fizz] | readonly [Buzz?] +>[] as [Fizz] | readonly [Buzz?] : [Fizz] | readonly [Buzz?] +>[] : [] +>filter : { (predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): Fizz[]; } | { (predicate: (value: Buzz, index: number, array: readonly Buzz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Buzz, index: number, array: readonly Buzz[]) => unknown, thisArg?: any): Buzz[]; } +>item => item?.id < 5 : (item: Fizz | Buzz) => boolean +>item : Fizz | Buzz +>item?.id < 5 : boolean +>item?.id : number +>item : Fizz | Buzz +>id : number +>5 : 5 + diff --git a/tests/baselines/reference/unionOfClassCalls.errors.txt b/tests/baselines/reference/unionOfClassCalls.errors.txt deleted file mode 100644 index 386d34414bbf0..0000000000000 --- a/tests/baselines/reference/unionOfClassCalls.errors.txt +++ /dev/null @@ -1,85 +0,0 @@ -tests/cases/compiler/unionOfClassCalls.ts(28,5): error TS2349: This expression is not callable. - Each member of the union type '{ (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; } | { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; (callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }' has signatures, but none of those signatures are compatible with each other. - - -==== tests/cases/compiler/unionOfClassCalls.ts (1 errors) ==== - // from https://github.com/microsoft/TypeScript/issues/30717 - declare class Test { - obj: T; - get(k: K): T[K]; - } - - interface A { t: "A" } - interface B { t: "B" } - - declare const tmp: Test | Test; - - switch (tmp.get('t')) { - case 'A': break; - case 'B': break; - } - - // from https://github.com/microsoft/TypeScript/issues/36390 - - const arr: number[] | string[] = []; // Works with Array - const arr1: number[] = []; - const arr2: string[] = []; - - arr.map((a: number | string, index: number) => { - return index - }) - - // This case still doesn't work because `reduce` has multiple overloads :( - arr.reduce((acc: Array, a: number | string, index: number) => { - ~~~~~~ -!!! error TS2349: This expression is not callable. -!!! error TS2349: Each member of the union type '{ (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; } | { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; (callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; }' has signatures, but none of those signatures are compatible with each other. - return [] - }, []) - - arr.forEach((a: number | string, index: number) => { - return index - }) - - arr1.map((a: number, index: number) => { - return index - }) - - arr1.reduce((acc: number[], a: number, index: number) => { - return [a] - }, []) - - arr1.forEach((a: number, index: number) => { - return index - }) - arr2.map((a: string, index: number) => { - return index - }) - - arr2.reduce((acc: string[], a: string, index: number) => { - return [] - }, []) - - arr2.forEach((a: string, index: number) => { - return index - }) - - // from https://github.com/microsoft/TypeScript/issues/36307 - - declare class Foo { - doThing(): Promise - } - - declare class Bar extends Foo { - bar: number; - } - declare class Baz extends Foo { - baz: number; - } - - declare var a: Bar | Baz; - // note, you must annotate `result` for now - a.doThing().then((result: Bar | Baz) => { - // whatever - }); - \ No newline at end of file diff --git a/tests/baselines/reference/unionOfClassCalls.types b/tests/baselines/reference/unionOfClassCalls.types index 7edd1c7f02ac2..7cd05956ba579 100644 --- a/tests/baselines/reference/unionOfClassCalls.types +++ b/tests/baselines/reference/unionOfClassCalls.types @@ -64,7 +64,7 @@ arr.map((a: number | string, index: number) => { // This case still doesn't work because `reduce` has multiple overloads :( arr.reduce((acc: Array, a: number | string, index: number) => { ->arr.reduce((acc: Array, a: number | string, index: number) => { return []}, []) : any +>arr.reduce((acc: Array, a: number | string, index: number) => { return []}, []) : never[] >arr.reduce : { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; } | { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; (callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; } >arr : number[] | string[] >reduce : { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; } | { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string; (callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U; } diff --git a/tests/cases/compiler/unionOfArraysFilterCall.ts b/tests/cases/compiler/unionOfArraysFilterCall.ts new file mode 100644 index 0000000000000..cfd02d2705964 --- /dev/null +++ b/tests/cases/compiler/unionOfArraysFilterCall.ts @@ -0,0 +1,26 @@ +// @target: es6 +interface Fizz { + id: number; + fizz: string; +} + +interface Buzz { + id: number; + buzz: string; +} + +([] as Fizz[] | Buzz[]).filter(item => item.id < 5); +([] as Fizz[] | readonly Buzz[]).filter(item => item.id < 5); + +([] as Fizz[] | Buzz[]).find(item => item); +declare function isFizz(x: unknown): x is Fizz; +([] as Fizz[] | Buzz[]).find(isFizz); +declare function isBuzz(x: unknown): x is Buzz; +([] as Fizz[] | Buzz[]).find(isBuzz); + +([] as Fizz[] | Buzz[]).every(item => item.id < 5); + +([] as Fizz[] | Buzz[]).reduce(item => item); + + +([] as [Fizz] | readonly [Buzz?]).filter(item => item?.id < 5); \ No newline at end of file