diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3387c4860c7..2e141e720df 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -778,7 +778,7 @@ namespace ts { function isNarrowableReference(expr: Expression): boolean { return expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.ThisKeyword || expr.kind === SyntaxKind.SuperKeyword || (isPropertyAccessExpression(expr) || isNonNullExpression(expr) || isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - isElementAccessExpression(expr) && expr.argumentExpression && + isElementAccessExpression(expr) && (isStringLiteral(expr.argumentExpression) || isNumericLiteral(expr.argumentExpression)) && isNarrowableReference(expr.expression); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5d52dd9b69b..8d166c39888 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -384,11 +384,11 @@ namespace ts { typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, - symbolToEntityName: nodeBuilder.symbolToEntityName as (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => EntityName, // TODO: GH#18217 - symbolToExpression: nodeBuilder.symbolToExpression as (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => Expression, // TODO: GH#18217 + symbolToEntityName: nodeBuilder.symbolToEntityName, + symbolToExpression: nodeBuilder.symbolToExpression, symbolToTypeParameterDeclarations: nodeBuilder.symbolToTypeParameterDeclarations, - symbolToParameterDeclaration: nodeBuilder.symbolToParameterDeclaration as (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => ParameterDeclaration, // TODO: GH#18217 - typeParameterToDeclaration: nodeBuilder.typeParameterToDeclaration as (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => TypeParameterDeclaration, // TODO: GH#18217 + symbolToParameterDeclaration: nodeBuilder.symbolToParameterDeclaration, + typeParameterToDeclaration: nodeBuilder.typeParameterToDeclaration, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -557,7 +557,7 @@ namespace ts { }, getJsxNamespace: n => unescapeLeadingUnderscores(getJsxNamespace(n)), getAccessibleSymbolChain, - getTypePredicateOfSignature: getTypePredicateOfSignature as (signature: Signature) => TypePredicate, // TODO: GH#18217 + getTypePredicateOfSignature, resolveExternalModuleSymbol, tryGetThisTypeAt: (node, includeGlobalThis) => { node = getParseTreeNode(node); @@ -884,7 +884,7 @@ namespace ts { } const jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - const chosenpragma: any = isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + const chosenpragma = isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -2564,10 +2564,6 @@ namespace ts { } function resolveExternalModule(location: Node, moduleReference: string, moduleNotFoundError: DiagnosticMessage | undefined, errorNode: Node, isForAugmentation = false): Symbol | undefined { - if (moduleReference === undefined) { - return; - } - if (startsWith(moduleReference, "@types/")) { const diag = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; const withoutAtTypePrefix = removePrefix(moduleReference, "@types/"); @@ -3265,12 +3261,12 @@ namespace ts { return access.accessibility === SymbolAccessibility.Accessible; } - function isValueSymbolAccessible(typeSymbol: Symbol, enclosingDeclaration: Node): boolean { + function isValueSymbolAccessible(typeSymbol: Symbol, enclosingDeclaration: Node | undefined): boolean { const access = isSymbolAccessible(typeSymbol, enclosingDeclaration, SymbolFlags.Value, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === SymbolAccessibility.Accessible; } - function isAnySymbolAccessible(symbols: Symbol[] | undefined, enclosingDeclaration: Node, initialSymbol: Symbol, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult | undefined { + function isAnySymbolAccessible(symbols: Symbol[] | undefined, enclosingDeclaration: Node | undefined, initialSymbol: Symbol, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult | undefined { if (!length(symbols)) return; let hadAccessibleChain: Symbol | undefined; @@ -3544,7 +3540,7 @@ namespace ts { typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, tracker, context => typeToTypeNodeHelper(type, context)), indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker) => - withContext(enclosingDeclaration, flags, tracker, context => indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context))!, // TODO: GH#18217 + withContext(enclosingDeclaration, flags, tracker, context => indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context)), signatureToSignatureDeclaration: (signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, tracker, context => signatureToSignatureDeclarationHelper(signature, kind, context)), symbolToEntityName: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker) => @@ -3653,7 +3649,7 @@ namespace ts { } if (type.flags & TypeFlags.UniqueESSymbol) { if (!(context.flags & NodeBuilderFlags.AllowUniqueESSymbolType)) { - if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration!)) { + if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; return symbolToTypeNode(type.symbol, context, SymbolFlags.Value); } @@ -3864,7 +3860,7 @@ namespace ts { if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & NodeBuilderFlags.UseTypeOfFunction) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & NodeBuilderFlags.UseStructuralFallback) || isValueSymbolAccessible(symbol, context.enclosingDeclaration!)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & NodeBuilderFlags.UseStructuralFallback) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } @@ -3941,7 +3937,7 @@ namespace ts { else if (context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral && type.symbol.valueDeclaration && isClassLike(type.symbol.valueDeclaration) && - !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration!) + !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration) ) { return createAnonymousTypeNode(type); } @@ -7159,7 +7155,7 @@ namespace ts { const baseConstructorType = getBaseConstructorTypeOfClass(classType); const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } const baseTypeNode = getBaseTypeNodeOfClass(classType)!; const isJavaScript = isInJSFile(baseTypeNode); @@ -10229,9 +10225,11 @@ namespace ts { case SyntaxKind.ReadonlyKeyword: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw Debug.assertNever(node.operator); } } - return links.resolvedType!; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType: Type, indexType: Type) { @@ -10813,11 +10811,11 @@ namespace ts { getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { const errorMessage = targetMeaning === SymbolFlags.Value @@ -10831,17 +10829,17 @@ namespace ts { } } } - return links.resolvedType!; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node: ImportTypeNode, links: NodeLinks, symbol: Symbol, meaning: SymbolFlags) { const resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; if (meaning === SymbolFlags.Value) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } @@ -14204,7 +14202,7 @@ namespace ts { if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === IndexKind.String && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)) as any as Ternary; // TODO: GH#18217 + return kind === IndexKind.String ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : Ternary.False; } if (isObjectTypeWithInferableIndex(source)) { let related = Ternary.True; @@ -17414,7 +17412,7 @@ namespace ts { } function narrowTypeByTypeof(type: Type, typeOfExpr: TypeOfExpression, operator: SyntaxKind, literal: LiteralExpression, assumeTrue: boolean): Type { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands const target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the @@ -19874,6 +19872,12 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { + if (type.flags & TypeFlags.Instantiable) { + const constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } return !!(type.flags & (TypeFlags.AnyOrUnknown | TypeFlags.NonPrimitive | TypeFlags.Object | TypeFlags.InstantiableNonPrimitive) || getFalsyFlags(type) & TypeFlags.DefinitelyFalsy && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & TypeFlags.UnionOrIntersection && every((type).types, isValidSpreadType)); @@ -20822,7 +20826,7 @@ namespace ts { let relatedInfo: Diagnostic | undefined; if (containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Primitive)) { for (const subtype of (containingType as UnionType).types) { - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, IndexKind.String)) { errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(subtype)); break; } @@ -21054,21 +21058,6 @@ namespace ts { const objectType = getAssignmentTargetKind(node) !== AssignmentKind.None || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; const indexExpression = node.argumentExpression; - if (!indexExpression) { - const sourceFile = getSourceFileOfNode(node); - if (node.parent.kind === SyntaxKind.NewExpression && (node.parent).expression === node) { - const start = skipTrivia(sourceFile.text, node.expression.end); - const end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - const start = node.end - "]".length; - const end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Expression_expected); - } - return errorType; - } - const indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { @@ -29737,9 +29726,7 @@ namespace ts { name = ex.name.escapedText; } else { - const argument = ex.argumentExpression; - Debug.assert(isLiteralExpression(argument)); - name = escapeLeadingUnderscores((argument as LiteralExpression).text); + name = escapeLeadingUnderscores(cast(ex.argumentExpression, isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3c282ca092f..492f853c347 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -459,10 +459,6 @@ "category": "Error", "code": 1149 }, - "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { - "category": "Error", - "code": 1150 - }, "'const' declarations must be initialized.": { "category": "Error", "code": 1155 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ee5193975df..292c72fd160 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5490,10 +5490,22 @@ namespace ts { } function parseDeclaration(): Statement { + const modifiers = lookAhead(() => (parseDecorators(), parseModifiers())); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + const isAmbient = some(modifiers, isDeclareModifier); + if (isAmbient) { + const node = tryReuseAmbientDeclaration(); + if (node) { + return node; + } + } + const node = createNodeWithJSDoc(SyntaxKind.Unknown); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (const m of node.modifiers!) { m.flags |= NodeFlags.Ambient; } @@ -5504,6 +5516,15 @@ namespace ts { } } + function tryReuseAmbientDeclaration(): Statement | undefined { + return doInsideOfContext(NodeFlags.Ambient, () => { + const node = currentNode(parsingContext); + if (node) { + return consumeNode(node) as Statement; + } + }); + } + function parseDeclarationWorker(node: Statement): Statement { switch (token()) { case SyntaxKind.VarKeyword: diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b08c09225ed..8bb018f53cb 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1142,7 +1142,7 @@ namespace ts { // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string): boolean { - const resolutionToFile = getResolvedModule(oldSourceFile!, moduleName); + const resolutionToFile = getResolvedModule(oldSourceFile, moduleName); const resolvedFile = resolutionToFile && oldProgram!.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile) { // In the old program, we resolved to an ambient module that was in the same @@ -1831,6 +1831,7 @@ namespace ts { switch (parent.kind) { case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: @@ -1840,7 +1841,7 @@ namespace ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.ArrowFunction: // Check type parameters - if (nodes === (parent).typeParameters) { + if (nodes === (parent).typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index ac6be3ba555..05e41cf6bc7 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -879,7 +879,7 @@ namespace ts { setText(text, start, length); - return { + const scanner: Scanner = { getStartPos: () => startPos, getTextPos: () => pos, getToken: () => token, @@ -915,6 +915,17 @@ namespace ts { scanRange, }; + if (Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: () => { + const text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + + return scanner; + function error(message: DiagnosticMessage): void; function error(message: DiagnosticMessage, errPos: number, length: number): void; function error(message: DiagnosticMessage, errPos: number = pos, length?: number): void { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2eb3eb78066..647d26b4e40 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3346,7 +3346,7 @@ namespace ts { * This should be called in a loop climbing parents of the symbol, so we'll get `N`. */ /* @internal */ getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined; - /* @internal */ getTypePredicateOfSignature(signature: Signature): TypePredicate; + /* @internal */ getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined; /** * An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, * and an external module with no 'export =' declaration resolves to the module itself. diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fbe4210cc3a..b123c2f48f5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -220,7 +220,7 @@ namespace ts { return node.end - node.pos; } - export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull | undefined { + export function getResolvedModule(sourceFile: SourceFile | undefined, moduleNameText: string): ResolvedModuleFull | undefined { return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText); } diff --git a/src/lib/es2019.array.d.ts b/src/lib/es2019.array.d.ts index 07fc76a9c77..9e3e04e5815 100644 --- a/src/lib/es2019.array.d.ts +++ b/src/lib/es2019.array.d.ts @@ -110,7 +110,7 @@ interface ReadonlyArray { * @param depth The maximum recursion depth */ flat(depth?: number): any[]; - } +} interface Array { diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 07048926b35..097830ee032 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1094,7 +1094,7 @@ interface ReadonlyArray { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): T[]; /** @@ -1230,7 +1230,7 @@ interface Array { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): T[]; /** @@ -1860,7 +1860,7 @@ interface Int8Array { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Int8Array; @@ -1887,7 +1887,7 @@ interface Int8Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Int8Array; + subarray(begin?: number, end?: number): Int8Array; /** * Converts a number to a string by using the current locale. @@ -2135,7 +2135,7 @@ interface Uint8Array { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Uint8Array; @@ -2162,7 +2162,7 @@ interface Uint8Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Uint8Array; + subarray(begin?: number, end?: number): Uint8Array; /** * Converts a number to a string by using the current locale. @@ -2410,7 +2410,7 @@ interface Uint8ClampedArray { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Uint8ClampedArray; @@ -2437,7 +2437,7 @@ interface Uint8ClampedArray { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Uint8ClampedArray; + subarray(begin?: number, end?: number): Uint8ClampedArray; /** * Converts a number to a string by using the current locale. @@ -2683,7 +2683,7 @@ interface Int16Array { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Int16Array; @@ -2710,7 +2710,7 @@ interface Int16Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Int16Array; + subarray(begin?: number, end?: number): Int16Array; /** * Converts a number to a string by using the current locale. @@ -2959,7 +2959,7 @@ interface Uint16Array { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Uint16Array; @@ -2986,7 +2986,7 @@ interface Uint16Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Uint16Array; + subarray(begin?: number, end?: number): Uint16Array; /** * Converts a number to a string by using the current locale. @@ -3234,7 +3234,7 @@ interface Int32Array { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Int32Array; @@ -3261,7 +3261,7 @@ interface Int32Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Int32Array; + subarray(begin?: number, end?: number): Int32Array; /** * Converts a number to a string by using the current locale. @@ -3508,7 +3508,7 @@ interface Uint32Array { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Uint32Array; @@ -3535,7 +3535,7 @@ interface Uint32Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Uint32Array; + subarray(begin?: number, end?: number): Uint32Array; /** * Converts a number to a string by using the current locale. @@ -3783,7 +3783,7 @@ interface Float32Array { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Float32Array; @@ -3810,7 +3810,7 @@ interface Float32Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Float32Array; + subarray(begin?: number, end?: number): Float32Array; /** * Converts a number to a string by using the current locale. @@ -4059,7 +4059,7 @@ interface Float64Array { /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. */ slice(start?: number, end?: number): Float64Array; @@ -4081,21 +4081,12 @@ interface Float64Array { sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Float64Array; + subarray(begin?: number, end?: number): Float64Array; - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ toString(): string; [index: number]: number; diff --git a/src/lib/esnext.bigint.d.ts b/src/lib/esnext.bigint.d.ts index b017ebd3799..332b654fc97 100644 --- a/src/lib/esnext.bigint.d.ts +++ b/src/lib/esnext.bigint.d.ts @@ -260,7 +260,7 @@ interface BigInt64Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): BigInt64Array; + subarray(begin?: number, end?: number): BigInt64Array; /** Converts the array to a string by using the current locale. */ toLocaleString(): string; @@ -529,7 +529,7 @@ interface BigUint64Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): BigUint64Array; + subarray(begin?: number, end?: number): BigUint64Array; /** Converts the array to a string by using the current locale. */ toLocaleString(): string; diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index b46f8df7620..9ea131785ba 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,3 +1,3 @@ -/// +/// /// /// diff --git a/src/testRunner/unittests/incrementalParser.ts b/src/testRunner/unittests/incrementalParser.ts index 503462ceb39..5884067d9aa 100644 --- a/src/testRunner/unittests/incrementalParser.ts +++ b/src/testRunner/unittests/incrementalParser.ts @@ -673,7 +673,7 @@ module m3 { }\ const oldText = ScriptSnapshot.fromString(source); const newTextAndChange = withInsert(oldText, 0, "{"); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9); }); it("Removing block around function declarations", () => { @@ -682,7 +682,7 @@ module m3 { }\ const oldText = ScriptSnapshot.fromString(source); const newTextAndChange = withDelete(oldText, 0, "{".length); - compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9); }); it("Moving methods from class to object literal", () => { diff --git a/tests/baselines/reference/bigint64ArraySubarray.js b/tests/baselines/reference/bigint64ArraySubarray.js new file mode 100644 index 00000000000..c68297b17bb --- /dev/null +++ b/tests/baselines/reference/bigint64ArraySubarray.js @@ -0,0 +1,16 @@ +//// [bigint64ArraySubarray.ts] +function bigInt64ArraySubarray() { + var arr = new BigInt64Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + + +//// [bigint64ArraySubarray.js] +function bigInt64ArraySubarray() { + var arr = new BigInt64Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} diff --git a/tests/baselines/reference/bigint64ArraySubarray.symbols b/tests/baselines/reference/bigint64ArraySubarray.symbols new file mode 100644 index 00000000000..b6eb3e1ec75 --- /dev/null +++ b/tests/baselines/reference/bigint64ArraySubarray.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/bigint64ArraySubarray.ts === +function bigInt64ArraySubarray() { +>bigInt64ArraySubarray : Symbol(bigInt64ArraySubarray, Decl(bigint64ArraySubarray.ts, 0, 0)) + + var arr = new BigInt64Array(10); +>arr : Symbol(arr, Decl(bigint64ArraySubarray.ts, 1, 7)) +>BigInt64Array : Symbol(BigInt64Array, Decl(lib.esnext.bigint.d.ts, --, --), Decl(lib.esnext.bigint.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(BigInt64Array.subarray, Decl(lib.esnext.bigint.d.ts, --, --)) +>arr : Symbol(arr, Decl(bigint64ArraySubarray.ts, 1, 7)) +>subarray : Symbol(BigInt64Array.subarray, Decl(lib.esnext.bigint.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(BigInt64Array.subarray, Decl(lib.esnext.bigint.d.ts, --, --)) +>arr : Symbol(arr, Decl(bigint64ArraySubarray.ts, 1, 7)) +>subarray : Symbol(BigInt64Array.subarray, Decl(lib.esnext.bigint.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(BigInt64Array.subarray, Decl(lib.esnext.bigint.d.ts, --, --)) +>arr : Symbol(arr, Decl(bigint64ArraySubarray.ts, 1, 7)) +>subarray : Symbol(BigInt64Array.subarray, Decl(lib.esnext.bigint.d.ts, --, --)) +} + diff --git a/tests/baselines/reference/bigint64ArraySubarray.types b/tests/baselines/reference/bigint64ArraySubarray.types new file mode 100644 index 00000000000..12c92f2dd14 --- /dev/null +++ b/tests/baselines/reference/bigint64ArraySubarray.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/bigint64ArraySubarray.ts === +function bigInt64ArraySubarray() { +>bigInt64ArraySubarray : () => void + + var arr = new BigInt64Array(10); +>arr : BigInt64Array +>new BigInt64Array(10) : BigInt64Array +>BigInt64Array : BigInt64ArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : BigInt64Array +>arr.subarray : (begin?: number, end?: number) => BigInt64Array +>arr : BigInt64Array +>subarray : (begin?: number, end?: number) => BigInt64Array + + arr.subarray(0); +>arr.subarray(0) : BigInt64Array +>arr.subarray : (begin?: number, end?: number) => BigInt64Array +>arr : BigInt64Array +>subarray : (begin?: number, end?: number) => BigInt64Array +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : BigInt64Array +>arr.subarray : (begin?: number, end?: number) => BigInt64Array +>arr : BigInt64Array +>subarray : (begin?: number, end?: number) => BigInt64Array +>0 : 0 +>10 : 10 +} + diff --git a/tests/baselines/reference/bigintIndex.symbols b/tests/baselines/reference/bigintIndex.symbols index dff23a016ee..4a72dcc42c9 100644 --- a/tests/baselines/reference/bigintIndex.symbols +++ b/tests/baselines/reference/bigintIndex.symbols @@ -53,7 +53,7 @@ typedArray[bigNum] = 0xAA; // should error typedArray[String(bigNum)] = 0xAA; >typedArray : Symbol(typedArray, Decl(a.ts, 17, 5)) ->String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 3 more) +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 4 more) >bigNum : Symbol(bigNum, Decl(a.ts, 16, 5)) typedArray["1"] = 0xBB; diff --git a/tests/baselines/reference/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt b/tests/baselines/reference/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt new file mode 100644 index 00000000000..61bf225dddc --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/a.js(1,19): error TS8004: 'type parameter declarations' can only be used in a .ts file. + + +==== tests/cases/compiler/a.js (1 errors) ==== + const Bar = class {}; + ~ +!!! error TS8004: 'type parameter declarations' can only be used in a .ts file. + \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationTypeParameterSyntaxOfClassExpression.symbols b/tests/baselines/reference/jsFileCompilationTypeParameterSyntaxOfClassExpression.symbols new file mode 100644 index 00000000000..f3aa9cd5926 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationTypeParameterSyntaxOfClassExpression.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/a.js === +const Bar = class {}; +>Bar : Symbol(Bar, Decl(a.js, 0, 5)) +>T : Symbol(T, Decl(a.js, 0, 18)) + diff --git a/tests/baselines/reference/jsFileCompilationTypeParameterSyntaxOfClassExpression.types b/tests/baselines/reference/jsFileCompilationTypeParameterSyntaxOfClassExpression.types new file mode 100644 index 00000000000..5538564ec86 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationTypeParameterSyntaxOfClassExpression.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/a.js === +const Bar = class {}; +>Bar : typeof Bar +>class {} : typeof Bar + diff --git a/tests/baselines/reference/regexMatchAll-esnext.js b/tests/baselines/reference/regexMatchAll-esnext.js new file mode 100644 index 00000000000..545a78fcbec --- /dev/null +++ b/tests/baselines/reference/regexMatchAll-esnext.js @@ -0,0 +1,10 @@ +//// [regexMatchAll-esnext.ts] +const matches = /\w/g[Symbol.matchAll]("matchAll"); +const array = [...matches]; +const { index, input } = array[0]; + + +//// [regexMatchAll-esnext.js] +const matches = /\w/g[Symbol.matchAll]("matchAll"); +const array = [...matches]; +const { index, input } = array[0]; diff --git a/tests/baselines/reference/regexMatchAll-esnext.symbols b/tests/baselines/reference/regexMatchAll-esnext.symbols new file mode 100644 index 00000000000..374d076c4d0 --- /dev/null +++ b/tests/baselines/reference/regexMatchAll-esnext.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/regexMatchAll-esnext.ts === +const matches = /\w/g[Symbol.matchAll]("matchAll"); +>matches : Symbol(matches, Decl(regexMatchAll-esnext.ts, 0, 5)) +>Symbol.matchAll : Symbol(SymbolConstructor.matchAll, Decl(lib.es2020.symbol.wellknown.d.ts, --, --)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) +>matchAll : Symbol(SymbolConstructor.matchAll, Decl(lib.es2020.symbol.wellknown.d.ts, --, --)) + +const array = [...matches]; +>array : Symbol(array, Decl(regexMatchAll-esnext.ts, 1, 5)) +>matches : Symbol(matches, Decl(regexMatchAll-esnext.ts, 0, 5)) + +const { index, input } = array[0]; +>index : Symbol(index, Decl(regexMatchAll-esnext.ts, 2, 7)) +>input : Symbol(input, Decl(regexMatchAll-esnext.ts, 2, 14)) +>array : Symbol(array, Decl(regexMatchAll-esnext.ts, 1, 5)) + diff --git a/tests/baselines/reference/regexMatchAll-esnext.types b/tests/baselines/reference/regexMatchAll-esnext.types new file mode 100644 index 00000000000..9a902b60000 --- /dev/null +++ b/tests/baselines/reference/regexMatchAll-esnext.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/regexMatchAll-esnext.ts === +const matches = /\w/g[Symbol.matchAll]("matchAll"); +>matches : IterableIterator +>/\w/g[Symbol.matchAll]("matchAll") : IterableIterator +>/\w/g[Symbol.matchAll] : (str: string) => IterableIterator +>/\w/g : RegExp +>Symbol.matchAll : symbol +>Symbol : SymbolConstructor +>matchAll : symbol +>"matchAll" : "matchAll" + +const array = [...matches]; +>array : RegExpMatchArray[] +>[...matches] : RegExpMatchArray[] +>...matches : RegExpMatchArray +>matches : IterableIterator + +const { index, input } = array[0]; +>index : number +>input : string +>array[0] : RegExpMatchArray +>array : RegExpMatchArray[] +>0 : 0 + diff --git a/tests/baselines/reference/restInvalidArgumentType.errors.txt b/tests/baselines/reference/restInvalidArgumentType.errors.txt index 7e0c852316a..22d2528fbb3 100644 --- a/tests/baselines/reference/restInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/restInvalidArgumentType.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types may only be created from object types. tests/cases/compiler/restInvalidArgumentType.ts(31,13): error TS2700: Rest types may only be created from object types. tests/cases/compiler/restInvalidArgumentType.ts(37,13): error TS2700: Rest types may only be created from object types. tests/cases/compiler/restInvalidArgumentType.ts(40,13): error TS2700: Rest types may only be created from object types. @@ -10,7 +11,7 @@ tests/cases/compiler/restInvalidArgumentType.ts(51,13): error TS2700: Rest types tests/cases/compiler/restInvalidArgumentType.ts(53,13): error TS2700: Rest types may only be created from object types. -==== tests/cases/compiler/restInvalidArgumentType.ts (10 errors) ==== +==== tests/cases/compiler/restInvalidArgumentType.ts (11 errors) ==== enum E { v1, v2 }; function f(p1: T, p2: T[]) { @@ -41,6 +42,8 @@ tests/cases/compiler/restInvalidArgumentType.ts(53,13): error TS2700: Rest types var {...r2} = p2; // OK var {...r3} = t; // Error, generic type paramter var {...r4} = i; // Error, index access + ~~ +!!! error TS2700: Rest types may only be created from object types. var {...r5} = k; // Error, index ~~ !!! error TS2700: Rest types may only be created from object types. diff --git a/tests/baselines/reference/restInvalidArgumentType.types b/tests/baselines/reference/restInvalidArgumentType.types index d88ee53796a..638634e8bea 100644 --- a/tests/baselines/reference/restInvalidArgumentType.types +++ b/tests/baselines/reference/restInvalidArgumentType.types @@ -79,7 +79,7 @@ function f(p1: T, p2: T[]) { >t : T var {...r4} = i; // Error, index access ->r4 : T["b"] +>r4 : any >i : T["b"] var {...r5} = k; // Error, index diff --git a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt index cb2b74b7b19..36bc2b36fe3 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/spreadInvalidArgumentType.ts(33,16): error TS2698: Spread types may only be created from object types. tests/cases/compiler/spreadInvalidArgumentType.ts(34,16): error TS2698: Spread types may only be created from object types. tests/cases/compiler/spreadInvalidArgumentType.ts(39,16): error TS2698: Spread types may only be created from object types. tests/cases/compiler/spreadInvalidArgumentType.ts(42,17): error TS2698: Spread types may only be created from object types. @@ -10,7 +11,7 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(53,17): error TS2698: Spread t tests/cases/compiler/spreadInvalidArgumentType.ts(55,17): error TS2698: Spread types may only be created from object types. -==== tests/cases/compiler/spreadInvalidArgumentType.ts (10 errors) ==== +==== tests/cases/compiler/spreadInvalidArgumentType.ts (11 errors) ==== enum E { v1, v2 }; function f(p1: T, p2: T[]) { @@ -43,7 +44,9 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(55,17): error TS2698: Spread t var o1 = { ...p1 }; // OK, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // OK, generic type paramter - var o4 = { ...i }; // OK, index access + var o4 = { ...i }; // Error, index access + ~~~~ +!!! error TS2698: Spread types may only be created from object types. var o5 = { ...k }; // Error, index ~~~~ !!! error TS2698: Spread types may only be created from object types. diff --git a/tests/baselines/reference/spreadInvalidArgumentType.js b/tests/baselines/reference/spreadInvalidArgumentType.js index b1cb2561eca..fc96c5971fb 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.js +++ b/tests/baselines/reference/spreadInvalidArgumentType.js @@ -31,7 +31,7 @@ function f(p1: T, p2: T[]) { var o1 = { ...p1 }; // OK, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // OK, generic type paramter - var o4 = { ...i }; // OK, index access + var o4 = { ...i }; // Error, index access var o5 = { ...k }; // Error, index var o6 = { ...mapped_generic }; // OK, generic mapped object type var o7 = { ...mapped }; // OK, non-generic mapped type @@ -96,7 +96,7 @@ function f(p1, p2) { var o1 = __assign({}, p1); // OK, generic type paramterre var o2 = __assign({}, p2); // OK var o3 = __assign({}, t); // OK, generic type paramter - var o4 = __assign({}, i); // OK, index access + var o4 = __assign({}, i); // Error, index access var o5 = __assign({}, k); // Error, index var o6 = __assign({}, mapped_generic); // OK, generic mapped object type var o7 = __assign({}, mapped); // OK, non-generic mapped type diff --git a/tests/baselines/reference/spreadInvalidArgumentType.symbols b/tests/baselines/reference/spreadInvalidArgumentType.symbols index 8c29a923d37..f4d7af9cca8 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.symbols +++ b/tests/baselines/reference/spreadInvalidArgumentType.symbols @@ -94,7 +94,7 @@ function f(p1: T, p2: T[]) { >o3 : Symbol(o3, Decl(spreadInvalidArgumentType.ts, 31, 7)) >t : Symbol(t, Decl(spreadInvalidArgumentType.ts, 3, 7)) - var o4 = { ...i }; // OK, index access + var o4 = { ...i }; // Error, index access >o4 : Symbol(o4, Decl(spreadInvalidArgumentType.ts, 32, 7)) >i : Symbol(i, Decl(spreadInvalidArgumentType.ts, 5, 7)) diff --git a/tests/baselines/reference/spreadInvalidArgumentType.types b/tests/baselines/reference/spreadInvalidArgumentType.types index 8a833c966ff..ec1b7faa9ec 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.types +++ b/tests/baselines/reference/spreadInvalidArgumentType.types @@ -82,9 +82,9 @@ function f(p1: T, p2: T[]) { >{ ...t } : T >t : T - var o4 = { ...i }; // OK, index access ->o4 : T["b"] ->{ ...i } : T["b"] + var o4 = { ...i }; // Error, index access +>o4 : any +>{ ...i } : any >i : T["b"] var o5 = { ...k }; // Error, index diff --git a/tests/baselines/reference/spreadTypeVariable.errors.txt b/tests/baselines/reference/spreadTypeVariable.errors.txt new file mode 100644 index 00000000000..b3ac4188670 --- /dev/null +++ b/tests/baselines/reference/spreadTypeVariable.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/types/spread/spreadTypeVariable.ts(2,12): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/spreadTypeVariable.ts(10,12): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/spreadTypeVariable.ts(14,12): error TS2698: Spread types may only be created from object types. + + +==== tests/cases/conformance/types/spread/spreadTypeVariable.ts (3 errors) ==== + function f1(arg: T) { + return { ...arg }; + ~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + } + + function f2(arg: T) { + return { ...arg } + } + + function f3(arg: T) { + return { ...arg } + ~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + } + + function f4(arg: T) { + return { ...arg } + ~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + } + + function f5(arg: T) { + return { ...arg } + } + + function f6(arg: T) { + return { ...arg } + } + + \ No newline at end of file diff --git a/tests/baselines/reference/spreadTypeVariable.js b/tests/baselines/reference/spreadTypeVariable.js new file mode 100644 index 00000000000..7574faab99e --- /dev/null +++ b/tests/baselines/reference/spreadTypeVariable.js @@ -0,0 +1,57 @@ +//// [spreadTypeVariable.ts] +function f1(arg: T) { + return { ...arg }; +} + +function f2(arg: T) { + return { ...arg } +} + +function f3(arg: T) { + return { ...arg } +} + +function f4(arg: T) { + return { ...arg } +} + +function f5(arg: T) { + return { ...arg } +} + +function f6(arg: T) { + return { ...arg } +} + + + +//// [spreadTypeVariable.js] +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +function f1(arg) { + return __assign({}, arg); +} +function f2(arg) { + return __assign({}, arg); +} +function f3(arg) { + return __assign({}, arg); +} +function f4(arg) { + return __assign({}, arg); +} +function f5(arg) { + return __assign({}, arg); +} +function f6(arg) { + return __assign({}, arg); +} diff --git a/tests/baselines/reference/spreadTypeVariable.symbols b/tests/baselines/reference/spreadTypeVariable.symbols new file mode 100644 index 00000000000..dee763309a0 --- /dev/null +++ b/tests/baselines/reference/spreadTypeVariable.symbols @@ -0,0 +1,64 @@ +=== tests/cases/conformance/types/spread/spreadTypeVariable.ts === +function f1(arg: T) { +>f1 : Symbol(f1, Decl(spreadTypeVariable.ts, 0, 0)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 0, 12)) +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 0, 30)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 0, 12)) + + return { ...arg }; +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 0, 30)) +} + +function f2(arg: T) { +>f2 : Symbol(f2, Decl(spreadTypeVariable.ts, 2, 1)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 4, 12)) +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 4, 32)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 4, 12)) + + return { ...arg } +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 4, 32)) +} + +function f3(arg: T) { +>f3 : Symbol(f3, Decl(spreadTypeVariable.ts, 6, 1)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 8, 12)) +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 8, 41)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 8, 12)) + + return { ...arg } +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 8, 41)) +} + +function f4(arg: T) { +>f4 : Symbol(f4, Decl(spreadTypeVariable.ts, 10, 1)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 12, 12)) +>key : Symbol(key, Decl(spreadTypeVariable.ts, 12, 34)) +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 12, 55)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 12, 12)) + + return { ...arg } +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 12, 55)) +} + +function f5(arg: T) { +>f5 : Symbol(f5, Decl(spreadTypeVariable.ts, 14, 1)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 16, 12)) +>key : Symbol(key, Decl(spreadTypeVariable.ts, 16, 36)) +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 16, 57)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 16, 12)) + + return { ...arg } +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 16, 57)) +} + +function f6(arg: T) { +>f6 : Symbol(f6, Decl(spreadTypeVariable.ts, 18, 1)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 20, 12)) +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 20, 15)) +>T : Symbol(T, Decl(spreadTypeVariable.ts, 20, 12)) + + return { ...arg } +>arg : Symbol(arg, Decl(spreadTypeVariable.ts, 20, 15)) +} + + diff --git a/tests/baselines/reference/spreadTypeVariable.types b/tests/baselines/reference/spreadTypeVariable.types new file mode 100644 index 00000000000..c5de712fb19 --- /dev/null +++ b/tests/baselines/reference/spreadTypeVariable.types @@ -0,0 +1,58 @@ +=== tests/cases/conformance/types/spread/spreadTypeVariable.ts === +function f1(arg: T) { +>f1 : (arg: T) => any +>arg : T + + return { ...arg }; +>{ ...arg } : any +>arg : T +} + +function f2(arg: T) { +>f2 : (arg: T) => T +>arg : T + + return { ...arg } +>{ ...arg } : T +>arg : T +} + +function f3(arg: T) { +>f3 : (arg: T) => any +>arg : T + + return { ...arg } +>{ ...arg } : any +>arg : T +} + +function f4(arg: T) { +>f4 : (arg: T) => any +>key : string +>arg : T + + return { ...arg } +>{ ...arg } : any +>arg : T +} + +function f5(arg: T) { +>f5 : (arg: T) => T +>key : string +>arg : T + + return { ...arg } +>{ ...arg } : T +>arg : T +} + +function f6(arg: T) { +>f6 : (arg: T) => T +>arg : T + + return { ...arg } +>{ ...arg } : T +>arg : T +} + + diff --git a/tests/baselines/reference/typedArraysSubarray.js b/tests/baselines/reference/typedArraysSubarray.js new file mode 100644 index 00000000000..c20bfab2edc --- /dev/null +++ b/tests/baselines/reference/typedArraysSubarray.js @@ -0,0 +1,120 @@ +//// [typedArraysSubarray.ts] +function int8ArraySubarray() { + var arr = new Int8Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function uint8ArraySubarray() { + var arr = new Uint8Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function uint8ClampedArraySubarray() { + var arr = new Uint8ClampedArray(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function int16ArraySubarray() { + var arr = new Int16Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function uint16ArraySubarray() { + var arr = new Uint16Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function int32ArraySubarray() { + var arr = new Int32Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function uint32ArraySubarray() { + var arr = new Uint32Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function float32ArraySubarray() { + var arr = new Float32Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function float64ArraySubarray() { + var arr = new Float64Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + + +//// [typedArraysSubarray.js] +function int8ArraySubarray() { + var arr = new Int8Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} +function uint8ArraySubarray() { + var arr = new Uint8Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} +function uint8ClampedArraySubarray() { + var arr = new Uint8ClampedArray(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} +function int16ArraySubarray() { + var arr = new Int16Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} +function uint16ArraySubarray() { + var arr = new Uint16Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} +function int32ArraySubarray() { + var arr = new Int32Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} +function uint32ArraySubarray() { + var arr = new Uint32Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} +function float32ArraySubarray() { + var arr = new Float32Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} +function float64ArraySubarray() { + var arr = new Float64Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} diff --git a/tests/baselines/reference/typedArraysSubarray.symbols b/tests/baselines/reference/typedArraysSubarray.symbols new file mode 100644 index 00000000000..7beebb9d585 --- /dev/null +++ b/tests/baselines/reference/typedArraysSubarray.symbols @@ -0,0 +1,208 @@ +=== tests/cases/compiler/typedArraysSubarray.ts === +function int8ArraySubarray() { +>int8ArraySubarray : Symbol(int8ArraySubarray, Decl(typedArraysSubarray.ts, 0, 0)) + + var arr = new Int8Array(10); +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 1, 7)) +>Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(Int8Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 1, 7)) +>subarray : Symbol(Int8Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(Int8Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 1, 7)) +>subarray : Symbol(Int8Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(Int8Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 1, 7)) +>subarray : Symbol(Int8Array.subarray, Decl(lib.es5.d.ts, --, --)) +} + +function uint8ArraySubarray() { +>uint8ArraySubarray : Symbol(uint8ArraySubarray, Decl(typedArraysSubarray.ts, 5, 1)) + + var arr = new Uint8Array(10); +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 8, 7)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(Uint8Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 8, 7)) +>subarray : Symbol(Uint8Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(Uint8Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 8, 7)) +>subarray : Symbol(Uint8Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(Uint8Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 8, 7)) +>subarray : Symbol(Uint8Array.subarray, Decl(lib.es5.d.ts, --, --)) +} + +function uint8ClampedArraySubarray() { +>uint8ClampedArraySubarray : Symbol(uint8ClampedArraySubarray, Decl(typedArraysSubarray.ts, 12, 1)) + + var arr = new Uint8ClampedArray(10); +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 15, 7)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(Uint8ClampedArray.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 15, 7)) +>subarray : Symbol(Uint8ClampedArray.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(Uint8ClampedArray.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 15, 7)) +>subarray : Symbol(Uint8ClampedArray.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(Uint8ClampedArray.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 15, 7)) +>subarray : Symbol(Uint8ClampedArray.subarray, Decl(lib.es5.d.ts, --, --)) +} + +function int16ArraySubarray() { +>int16ArraySubarray : Symbol(int16ArraySubarray, Decl(typedArraysSubarray.ts, 19, 1)) + + var arr = new Int16Array(10); +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 22, 7)) +>Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(Int16Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 22, 7)) +>subarray : Symbol(Int16Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(Int16Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 22, 7)) +>subarray : Symbol(Int16Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(Int16Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 22, 7)) +>subarray : Symbol(Int16Array.subarray, Decl(lib.es5.d.ts, --, --)) +} + +function uint16ArraySubarray() { +>uint16ArraySubarray : Symbol(uint16ArraySubarray, Decl(typedArraysSubarray.ts, 26, 1)) + + var arr = new Uint16Array(10); +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 29, 7)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(Uint16Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 29, 7)) +>subarray : Symbol(Uint16Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(Uint16Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 29, 7)) +>subarray : Symbol(Uint16Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(Uint16Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 29, 7)) +>subarray : Symbol(Uint16Array.subarray, Decl(lib.es5.d.ts, --, --)) +} + +function int32ArraySubarray() { +>int32ArraySubarray : Symbol(int32ArraySubarray, Decl(typedArraysSubarray.ts, 33, 1)) + + var arr = new Int32Array(10); +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 36, 7)) +>Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(Int32Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 36, 7)) +>subarray : Symbol(Int32Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(Int32Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 36, 7)) +>subarray : Symbol(Int32Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(Int32Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 36, 7)) +>subarray : Symbol(Int32Array.subarray, Decl(lib.es5.d.ts, --, --)) +} + +function uint32ArraySubarray() { +>uint32ArraySubarray : Symbol(uint32ArraySubarray, Decl(typedArraysSubarray.ts, 40, 1)) + + var arr = new Uint32Array(10); +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 43, 7)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(Uint32Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 43, 7)) +>subarray : Symbol(Uint32Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(Uint32Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 43, 7)) +>subarray : Symbol(Uint32Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(Uint32Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 43, 7)) +>subarray : Symbol(Uint32Array.subarray, Decl(lib.es5.d.ts, --, --)) +} + +function float32ArraySubarray() { +>float32ArraySubarray : Symbol(float32ArraySubarray, Decl(typedArraysSubarray.ts, 47, 1)) + + var arr = new Float32Array(10); +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 50, 7)) +>Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(Float32Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 50, 7)) +>subarray : Symbol(Float32Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(Float32Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 50, 7)) +>subarray : Symbol(Float32Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(Float32Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 50, 7)) +>subarray : Symbol(Float32Array.subarray, Decl(lib.es5.d.ts, --, --)) +} + +function float64ArraySubarray() { +>float64ArraySubarray : Symbol(float64ArraySubarray, Decl(typedArraysSubarray.ts, 54, 1)) + + var arr = new Float64Array(10); +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 57, 7)) +>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + arr.subarray(); +>arr.subarray : Symbol(Float64Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 57, 7)) +>subarray : Symbol(Float64Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0); +>arr.subarray : Symbol(Float64Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 57, 7)) +>subarray : Symbol(Float64Array.subarray, Decl(lib.es5.d.ts, --, --)) + + arr.subarray(0, 10); +>arr.subarray : Symbol(Float64Array.subarray, Decl(lib.es5.d.ts, --, --)) +>arr : Symbol(arr, Decl(typedArraysSubarray.ts, 57, 7)) +>subarray : Symbol(Float64Array.subarray, Decl(lib.es5.d.ts, --, --)) +} + diff --git a/tests/baselines/reference/typedArraysSubarray.types b/tests/baselines/reference/typedArraysSubarray.types new file mode 100644 index 00000000000..5e31d7992a5 --- /dev/null +++ b/tests/baselines/reference/typedArraysSubarray.types @@ -0,0 +1,280 @@ +=== tests/cases/compiler/typedArraysSubarray.ts === +function int8ArraySubarray() { +>int8ArraySubarray : () => void + + var arr = new Int8Array(10); +>arr : Int8Array +>new Int8Array(10) : Int8Array +>Int8Array : Int8ArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : Int8Array +>arr.subarray : (begin?: number, end?: number) => Int8Array +>arr : Int8Array +>subarray : (begin?: number, end?: number) => Int8Array + + arr.subarray(0); +>arr.subarray(0) : Int8Array +>arr.subarray : (begin?: number, end?: number) => Int8Array +>arr : Int8Array +>subarray : (begin?: number, end?: number) => Int8Array +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : Int8Array +>arr.subarray : (begin?: number, end?: number) => Int8Array +>arr : Int8Array +>subarray : (begin?: number, end?: number) => Int8Array +>0 : 0 +>10 : 10 +} + +function uint8ArraySubarray() { +>uint8ArraySubarray : () => void + + var arr = new Uint8Array(10); +>arr : Uint8Array +>new Uint8Array(10) : Uint8Array +>Uint8Array : Uint8ArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : Uint8Array +>arr.subarray : (begin?: number, end?: number) => Uint8Array +>arr : Uint8Array +>subarray : (begin?: number, end?: number) => Uint8Array + + arr.subarray(0); +>arr.subarray(0) : Uint8Array +>arr.subarray : (begin?: number, end?: number) => Uint8Array +>arr : Uint8Array +>subarray : (begin?: number, end?: number) => Uint8Array +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : Uint8Array +>arr.subarray : (begin?: number, end?: number) => Uint8Array +>arr : Uint8Array +>subarray : (begin?: number, end?: number) => Uint8Array +>0 : 0 +>10 : 10 +} + +function uint8ClampedArraySubarray() { +>uint8ClampedArraySubarray : () => void + + var arr = new Uint8ClampedArray(10); +>arr : Uint8ClampedArray +>new Uint8ClampedArray(10) : Uint8ClampedArray +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : Uint8ClampedArray +>arr.subarray : (begin?: number, end?: number) => Uint8ClampedArray +>arr : Uint8ClampedArray +>subarray : (begin?: number, end?: number) => Uint8ClampedArray + + arr.subarray(0); +>arr.subarray(0) : Uint8ClampedArray +>arr.subarray : (begin?: number, end?: number) => Uint8ClampedArray +>arr : Uint8ClampedArray +>subarray : (begin?: number, end?: number) => Uint8ClampedArray +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : Uint8ClampedArray +>arr.subarray : (begin?: number, end?: number) => Uint8ClampedArray +>arr : Uint8ClampedArray +>subarray : (begin?: number, end?: number) => Uint8ClampedArray +>0 : 0 +>10 : 10 +} + +function int16ArraySubarray() { +>int16ArraySubarray : () => void + + var arr = new Int16Array(10); +>arr : Int16Array +>new Int16Array(10) : Int16Array +>Int16Array : Int16ArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : Int16Array +>arr.subarray : (begin?: number, end?: number) => Int16Array +>arr : Int16Array +>subarray : (begin?: number, end?: number) => Int16Array + + arr.subarray(0); +>arr.subarray(0) : Int16Array +>arr.subarray : (begin?: number, end?: number) => Int16Array +>arr : Int16Array +>subarray : (begin?: number, end?: number) => Int16Array +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : Int16Array +>arr.subarray : (begin?: number, end?: number) => Int16Array +>arr : Int16Array +>subarray : (begin?: number, end?: number) => Int16Array +>0 : 0 +>10 : 10 +} + +function uint16ArraySubarray() { +>uint16ArraySubarray : () => void + + var arr = new Uint16Array(10); +>arr : Uint16Array +>new Uint16Array(10) : Uint16Array +>Uint16Array : Uint16ArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : Uint16Array +>arr.subarray : (begin?: number, end?: number) => Uint16Array +>arr : Uint16Array +>subarray : (begin?: number, end?: number) => Uint16Array + + arr.subarray(0); +>arr.subarray(0) : Uint16Array +>arr.subarray : (begin?: number, end?: number) => Uint16Array +>arr : Uint16Array +>subarray : (begin?: number, end?: number) => Uint16Array +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : Uint16Array +>arr.subarray : (begin?: number, end?: number) => Uint16Array +>arr : Uint16Array +>subarray : (begin?: number, end?: number) => Uint16Array +>0 : 0 +>10 : 10 +} + +function int32ArraySubarray() { +>int32ArraySubarray : () => void + + var arr = new Int32Array(10); +>arr : Int32Array +>new Int32Array(10) : Int32Array +>Int32Array : Int32ArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : Int32Array +>arr.subarray : (begin?: number, end?: number) => Int32Array +>arr : Int32Array +>subarray : (begin?: number, end?: number) => Int32Array + + arr.subarray(0); +>arr.subarray(0) : Int32Array +>arr.subarray : (begin?: number, end?: number) => Int32Array +>arr : Int32Array +>subarray : (begin?: number, end?: number) => Int32Array +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : Int32Array +>arr.subarray : (begin?: number, end?: number) => Int32Array +>arr : Int32Array +>subarray : (begin?: number, end?: number) => Int32Array +>0 : 0 +>10 : 10 +} + +function uint32ArraySubarray() { +>uint32ArraySubarray : () => void + + var arr = new Uint32Array(10); +>arr : Uint32Array +>new Uint32Array(10) : Uint32Array +>Uint32Array : Uint32ArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : Uint32Array +>arr.subarray : (begin?: number, end?: number) => Uint32Array +>arr : Uint32Array +>subarray : (begin?: number, end?: number) => Uint32Array + + arr.subarray(0); +>arr.subarray(0) : Uint32Array +>arr.subarray : (begin?: number, end?: number) => Uint32Array +>arr : Uint32Array +>subarray : (begin?: number, end?: number) => Uint32Array +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : Uint32Array +>arr.subarray : (begin?: number, end?: number) => Uint32Array +>arr : Uint32Array +>subarray : (begin?: number, end?: number) => Uint32Array +>0 : 0 +>10 : 10 +} + +function float32ArraySubarray() { +>float32ArraySubarray : () => void + + var arr = new Float32Array(10); +>arr : Float32Array +>new Float32Array(10) : Float32Array +>Float32Array : Float32ArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : Float32Array +>arr.subarray : (begin?: number, end?: number) => Float32Array +>arr : Float32Array +>subarray : (begin?: number, end?: number) => Float32Array + + arr.subarray(0); +>arr.subarray(0) : Float32Array +>arr.subarray : (begin?: number, end?: number) => Float32Array +>arr : Float32Array +>subarray : (begin?: number, end?: number) => Float32Array +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : Float32Array +>arr.subarray : (begin?: number, end?: number) => Float32Array +>arr : Float32Array +>subarray : (begin?: number, end?: number) => Float32Array +>0 : 0 +>10 : 10 +} + +function float64ArraySubarray() { +>float64ArraySubarray : () => void + + var arr = new Float64Array(10); +>arr : Float64Array +>new Float64Array(10) : Float64Array +>Float64Array : Float64ArrayConstructor +>10 : 10 + + arr.subarray(); +>arr.subarray() : Float64Array +>arr.subarray : (begin?: number, end?: number) => Float64Array +>arr : Float64Array +>subarray : (begin?: number, end?: number) => Float64Array + + arr.subarray(0); +>arr.subarray(0) : Float64Array +>arr.subarray : (begin?: number, end?: number) => Float64Array +>arr : Float64Array +>subarray : (begin?: number, end?: number) => Float64Array +>0 : 0 + + arr.subarray(0, 10); +>arr.subarray(0, 10) : Float64Array +>arr.subarray : (begin?: number, end?: number) => Float64Array +>arr : Float64Array +>subarray : (begin?: number, end?: number) => Float64Array +>0 : 0 +>10 : 10 +} + diff --git a/tests/baselines/reference/unionTypeWithIndexSignature.errors.txt b/tests/baselines/reference/unionTypeWithIndexSignature.errors.txt index 14a3ffc58a6..8ad20f21060 100644 --- a/tests/baselines/reference/unionTypeWithIndexSignature.errors.txt +++ b/tests/baselines/reference/unionTypeWithIndexSignature.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/union/unionTypeWithIndexSignature.ts(11,3): error TS2339: Property 'bar' does not exist on type 'Missing'. - Property 'bar' does not exist on type '{ [s: string]: string; }'. + Property 'bar' does not exist on type '{ foo: boolean; }'. tests/cases/conformance/types/union/unionTypeWithIndexSignature.ts(14,4): error TS2540: Cannot assign to 'foo' because it is a read-only property. tests/cases/conformance/types/union/unionTypeWithIndexSignature.ts(24,1): error TS7053: Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'Both'. Property '1' does not exist on type 'Both'. @@ -22,7 +22,7 @@ tests/cases/conformance/types/union/unionTypeWithIndexSignature.ts(26,1): error m.bar ~~~ !!! error TS2339: Property 'bar' does not exist on type 'Missing'. -!!! error TS2339: Property 'bar' does not exist on type '{ [s: string]: string; }'. +!!! error TS2339: Property 'bar' does not exist on type '{ foo: boolean; }'. type RO = { foo: number } | { readonly [s: string]: string } declare var ro: RO ro.foo = 'not allowed' diff --git a/tests/cases/compiler/bigint64ArraySubarray.ts b/tests/cases/compiler/bigint64ArraySubarray.ts new file mode 100644 index 00000000000..1f8e3da9d18 --- /dev/null +++ b/tests/cases/compiler/bigint64ArraySubarray.ts @@ -0,0 +1,8 @@ +// @target: esnext + +function bigInt64ArraySubarray() { + var arr = new BigInt64Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} diff --git a/tests/cases/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.ts b/tests/cases/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.ts new file mode 100644 index 00000000000..81b07637422 --- /dev/null +++ b/tests/cases/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.ts @@ -0,0 +1,4 @@ +// @allowJs: true +// @noEmit: true +// @filename: a.js +const Bar = class {}; diff --git a/tests/cases/compiler/regexMatchAll-esnext.ts b/tests/cases/compiler/regexMatchAll-esnext.ts new file mode 100644 index 00000000000..7c72b652540 --- /dev/null +++ b/tests/cases/compiler/regexMatchAll-esnext.ts @@ -0,0 +1,5 @@ +// @target: esnext + +const matches = /\w/g[Symbol.matchAll]("matchAll"); +const array = [...matches]; +const { index, input } = array[0]; diff --git a/tests/cases/compiler/spreadInvalidArgumentType.ts b/tests/cases/compiler/spreadInvalidArgumentType.ts index d75d606cc73..82e59fbac59 100644 --- a/tests/cases/compiler/spreadInvalidArgumentType.ts +++ b/tests/cases/compiler/spreadInvalidArgumentType.ts @@ -30,7 +30,7 @@ function f(p1: T, p2: T[]) { var o1 = { ...p1 }; // OK, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // OK, generic type paramter - var o4 = { ...i }; // OK, index access + var o4 = { ...i }; // Error, index access var o5 = { ...k }; // Error, index var o6 = { ...mapped_generic }; // OK, generic mapped object type var o7 = { ...mapped }; // OK, non-generic mapped type diff --git a/tests/cases/compiler/typedArraysSubarray.ts b/tests/cases/compiler/typedArraysSubarray.ts new file mode 100644 index 00000000000..f85b953b839 --- /dev/null +++ b/tests/cases/compiler/typedArraysSubarray.ts @@ -0,0 +1,62 @@ +function int8ArraySubarray() { + var arr = new Int8Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function uint8ArraySubarray() { + var arr = new Uint8Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function uint8ClampedArraySubarray() { + var arr = new Uint8ClampedArray(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function int16ArraySubarray() { + var arr = new Int16Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function uint16ArraySubarray() { + var arr = new Uint16Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function int32ArraySubarray() { + var arr = new Int32Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function uint32ArraySubarray() { + var arr = new Uint32Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function float32ArraySubarray() { + var arr = new Float32Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} + +function float64ArraySubarray() { + var arr = new Float64Array(10); + arr.subarray(); + arr.subarray(0); + arr.subarray(0, 10); +} diff --git a/tests/cases/conformance/types/spread/spreadTypeVariable.ts b/tests/cases/conformance/types/spread/spreadTypeVariable.ts new file mode 100644 index 00000000000..7a0054cfc86 --- /dev/null +++ b/tests/cases/conformance/types/spread/spreadTypeVariable.ts @@ -0,0 +1,24 @@ +function f1(arg: T) { + return { ...arg }; +} + +function f2(arg: T) { + return { ...arg } +} + +function f3(arg: T) { + return { ...arg } +} + +function f4(arg: T) { + return { ...arg } +} + +function f5(arg: T) { + return { ...arg } +} + +function f6(arg: T) { + return { ...arg } +} + diff --git a/tests/lib/lib.d.ts b/tests/lib/lib.d.ts index 5f089bb3c82..9edbdec2b1b 100644 --- a/tests/lib/lib.d.ts +++ b/tests/lib/lib.d.ts @@ -1622,7 +1622,7 @@ interface Int8Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Int8Array; + subarray(begin?: number, end?: number): Int8Array; /** * Converts a number to a string by using the current locale. @@ -1895,7 +1895,7 @@ interface Uint8Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Uint8Array; + subarray(begin?: number, end?: number): Uint8Array; /** * Converts a number to a string by using the current locale. @@ -2169,7 +2169,7 @@ interface Uint8ClampedArray { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Uint8ClampedArray; + subarray(begin?: number, end?: number): Uint8ClampedArray; /** * Converts a number to a string by using the current locale. @@ -2442,7 +2442,7 @@ interface Int16Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Int16Array; + subarray(begin?: number, end?: number): Int16Array; /** * Converts a number to a string by using the current locale. @@ -2716,7 +2716,7 @@ interface Uint16Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Uint16Array; + subarray(begin?: number, end?: number): Uint16Array; /** * Converts a number to a string by using the current locale. @@ -2989,7 +2989,7 @@ interface Int32Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Int32Array; + subarray(begin?: number, end?: number): Int32Array; /** * Converts a number to a string by using the current locale. @@ -3262,7 +3262,7 @@ interface Uint32Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Uint32Array; + subarray(begin?: number, end?: number): Uint32Array; /** * Converts a number to a string by using the current locale. @@ -3535,7 +3535,7 @@ interface Float32Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Float32Array; + subarray(begin?: number, end?: number): Float32Array; /** * Converts a number to a string by using the current locale. @@ -3809,7 +3809,7 @@ interface Float64Array { * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ - subarray(begin: number, end?: number): Float64Array; + subarray(begin?: number, end?: number): Float64Array; /** * Converts a number to a string by using the current locale.