diff --git a/.gitignore b/.gitignore index 79fefb71a85..4f9ec0649b3 100644 --- a/.gitignore +++ b/.gitignore @@ -46,5 +46,6 @@ coverage/ internal/ **/.DS_Store .settings -.vscode/* -!.vscode/tasks.json +**/.vs +**/.vscode +!**/.vscode/tasks.json diff --git a/package.json b/package.json index cc74bf2c27c..bb476070286 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "build": "npm run build:compiler && npm run build:tests", "build:compiler": "jake local", "build:tests": "jake tests", + "start": "node lib/tsc", "clean": "jake clean", "jake": "jake", "lint": "jake lint", diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index c96aa9ad140..baad8dad466 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -650,6 +650,13 @@ namespace ts { }; } + function createFlowLoopLabel(): FlowLabel { + return { + kind: FlowKind.LoopLabel, + antecedents: undefined + }; + } + function addAntecedent(label: FlowLabel, antecedent: FlowNode): void { if (antecedent.kind !== FlowKind.Unreachable && !contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); @@ -760,7 +767,7 @@ namespace ts { } function bindWhileStatement(node: WhileStatement): void { - const preWhileLabel = createFlowLabel(); + const preWhileLabel = createFlowLoopLabel(); const preBodyLabel = createFlowLabel(); const postWhileLabel = createFlowLabel(); addAntecedent(preWhileLabel, currentFlow); @@ -773,7 +780,7 @@ namespace ts { } function bindDoStatement(node: DoStatement): void { - const preDoLabel = createFlowLabel(); + const preDoLabel = createFlowLoopLabel(); const preConditionLabel = createFlowLabel(); const postDoLabel = createFlowLabel(); addAntecedent(preDoLabel, currentFlow); @@ -786,7 +793,7 @@ namespace ts { } function bindForStatement(node: ForStatement): void { - const preLoopLabel = createFlowLabel(); + const preLoopLabel = createFlowLoopLabel(); const preBodyLabel = createFlowLabel(); const postLoopLabel = createFlowLabel(); bind(node.initializer); @@ -801,7 +808,7 @@ namespace ts { } function bindForInOrForOfStatement(node: ForInStatement | ForOfStatement): void { - const preLoopLabel = createFlowLabel(); + const preLoopLabel = createFlowLoopLabel(); const postLoopLabel = createFlowLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; @@ -948,7 +955,7 @@ namespace ts { } function bindLabeledStatement(node: LabeledStatement): void { - const preStatementLabel = createFlowLabel(); + const preStatementLabel = createFlowLoopLabel(); const postStatementLabel = createFlowLabel(); bind(node.label); addAntecedent(preStatementLabel, currentFlow); @@ -1377,7 +1384,8 @@ namespace ts { if (inStrictMode && node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord && - !isIdentifierName(node)) { + !isIdentifierName(node) && + !isInAmbientContext(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 99618654182..020db85a948 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2014,7 +2014,12 @@ namespace ts { writeUnionOrIntersectionType(type, flags); } else if (type.flags & TypeFlags.Anonymous) { - writeAnonymousType(type, flags); + if (type === emptyUnionType) { + writer.writeKeyword("nothing"); + } + else { + writeAnonymousType(type, flags); + } } else if (type.flags & TypeFlags.StringLiteral) { writer.writeStringLiteral(`"${escapeString((type).text)}"`); @@ -4251,7 +4256,9 @@ namespace ts { propTypes.push(getTypeOfSymbol(prop)); } } - return getUnionType(propTypes); + if (propTypes.length) { + return getUnionType(propTypes); + } } return undefined; } @@ -5506,6 +5513,10 @@ namespace ts { return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; } + function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | MethodDeclaration { + return (isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); + } + function getTypeWithoutSignatures(type: Type): Type { if (type.flags & TypeFlags.ObjectType) { const resolved = resolveStructuredTypeMembers(type); @@ -5900,9 +5911,14 @@ namespace ts { if (source.flags & TypeFlags.TypeParameter) { let constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & TypeFlags.Any) { constraint = emptyObjectType; } + + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // Report constraint errors only if the constraint is not the empty object type const reportConstraintErrors = reportErrors && constraint !== emptyObjectType; if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { @@ -7329,27 +7345,29 @@ namespace ts { } function containsMatchingReference(source: Node, target: Node) { - while (true) { + while (source.kind === SyntaxKind.PropertyAccessExpression) { + source = (source).expression; if (isMatchingReference(source, target)) { return true; } - if (source.kind !== SyntaxKind.PropertyAccessExpression) { - return false; - } - source = (source).expression; } + return false; } - function hasMatchingArgument(callExpression: CallExpression, target: Node) { + function isOrContainsMatchingReference(source: Node, target: Node) { + return isMatchingReference(source, target) || containsMatchingReference(source, target); + } + + function hasMatchingArgument(callExpression: CallExpression, reference: Node) { if (callExpression.arguments) { for (const argument of callExpression.arguments) { - if (isMatchingReference(argument, target)) { + if (isOrContainsMatchingReference(reference, argument)) { return true; } } } if (callExpression.expression.kind === SyntaxKind.PropertyAccessExpression && - isMatchingReference((callExpression.expression).expression, target)) { + isOrContainsMatchingReference(reference, (callExpression.expression).expression)) { return true; } return false; @@ -7363,12 +7381,6 @@ namespace ts { return flowTypeCaches[flow.id] || (flowTypeCaches[flow.id] = {}); } - function isNarrowableReference(expr: Node): boolean { - return expr.kind === SyntaxKind.Identifier || - expr.kind === SyntaxKind.ThisKeyword || - expr.kind === SyntaxKind.PropertyAccessExpression && isNarrowableReference((expr).expression); - } - function typeMaybeAssignableTo(source: Type, target: Type) { if (!(source.flags & TypeFlags.Union)) { return isTypeAssignableTo(source, target); @@ -7559,30 +7571,12 @@ namespace ts { getInitialTypeOfBindingElement(node); } - function getNarrowedTypeOfReference(type: Type, reference: Node) { - if (!(type.flags & TypeFlags.Narrowable) || !isNarrowableReference(reference)) { - return type; - } - const leftmostNode = getLeftmostIdentifierOrThis(reference); - if (!leftmostNode) { - return type; - } - if (leftmostNode.kind === SyntaxKind.Identifier) { - const leftmostSymbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(leftmostNode)); - if (!leftmostSymbol) { - return type; - } - const declaration = leftmostSymbol.valueDeclaration; - if (!declaration || declaration.kind !== SyntaxKind.VariableDeclaration && declaration.kind !== SyntaxKind.Parameter && declaration.kind !== SyntaxKind.BindingElement) { - return type; - } - } - return getFlowTypeOfReference(reference, type, type); - } - function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType: Type) { let key: string; - return reference.flowNode ? getTypeAtFlowNode(reference.flowNode) : declaredType; + if (!reference.flowNode || declaredType === initialType && !(declaredType.flags & TypeFlags.Narrowable)) { + return declaredType; + } + return getTypeAtFlowNode(reference.flowNode); function getTypeAtFlowNode(flow: FlowNode): Type { while (true) { @@ -7597,6 +7591,7 @@ namespace ts { case FlowKind.Condition: return getTypeAtFlowCondition(flow); case FlowKind.Label: + case FlowKind.LoopLabel: if ((flow).antecedents.length === 1) { flow = (flow).antecedents[0]; continue; @@ -7635,8 +7630,7 @@ namespace ts { // may be an assignment to a left hand part of the reference. For example, for a // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. - if (reference.kind === SyntaxKind.PropertyAccessExpression && - containsMatchingReference((reference).expression, node)) { + if (containsMatchingReference(reference, node)) { return declaredType; } // Assignment doesn't affect reference @@ -7644,7 +7638,8 @@ namespace ts { } function getTypeAtFlowCondition(flow: FlowCondition) { - return narrowType(getTypeAtFlowNode(flow.antecedent), flow.expression, flow.assumeTrue); + const type = getTypeAtFlowNode(flow.antecedent); + return type && narrowType(type, flow.expression, flow.assumeTrue); } function getTypeAtFlowNodeCached(flow: FlowNode) { @@ -7670,33 +7665,36 @@ namespace ts { flowStackCount--; // Record the result only if the cache is still empty. If checkExpressionCached was called // during processing it is possible we've already recorded a result. - return cache[key] || (cache[key] = type); + return cache[key] || type && (cache[key] = type); } function getTypeAtFlowLabel(flow: FlowLabel) { const antecedentTypes: Type[] = []; for (const antecedent of flow.antecedents) { - const type = getTypeAtFlowNodeCached(antecedent); - if (type) { - // If the type at a particular antecedent path is the declared type and the - // reference is known to always be assigned (i.e. when declared and initial types - // are the same), there is no reason to process more antecedents since the only - // possible outcome is subtypes that will be removed in the final union type anyway. - if (type === declaredType && declaredType === initialType) { - return type; - } - if (!contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + const type = flow.kind === FlowKind.LoopLabel ? + getTypeAtFlowNodeCached(antecedent) : + getTypeAtFlowNode(antecedent); + if (!type) { + break; + } + // If the type at a particular antecedent path is the declared type and the + // reference is known to always be assigned (i.e. when declared and initial types + // are the same), there is no reason to process more antecedents since the only + // possible outcome is subtypes that will be removed in the final union type anyway. + if (type === declaredType && declaredType === initialType) { + return type; + } + if (!contains(antecedentTypes, type)) { + antecedentTypes.push(type); } } - return antecedentTypes.length === 0 ? declaredType : + return antecedentTypes.length === 0 ? undefined : antecedentTypes.length === 1 ? antecedentTypes[0] : getUnionType(antecedentTypes); } function narrowTypeByTruthiness(type: Type, expr: Expression, assumeTrue: boolean): Type { - return isMatchingReference(expr, reference) ? getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy) : type; + return isMatchingReference(reference, expr) ? getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy) : type; } function narrowTypeByBinaryExpression(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { @@ -7728,7 +7726,7 @@ namespace ts { if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) { assumeTrue = !assumeTrue; } - if (!strictNullChecks || !isMatchingReference(expr.left, reference)) { + if (!strictNullChecks || !isMatchingReference(reference, expr.left)) { return type; } const doubleEquals = operator === SyntaxKind.EqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsToken; @@ -7745,7 +7743,12 @@ namespace ts { // and string literal on the right const left = expr.left; const right = expr.right; - if (!isMatchingReference(left.expression, reference)) { + if (!isMatchingReference(reference, left.expression)) { + // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the + // narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, left.expression)) { + return declaredType; + } return type; } if (expr.operatorToken.kind === SyntaxKind.ExclamationEqualsToken || @@ -7768,8 +7771,16 @@ namespace ts { } function narrowTypeByInstanceof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { - // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !isMatchingReference(expr.left, reference)) { + if (!isMatchingReference(reference, expr.left)) { + // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the + // narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, expr.left)) { + return declaredType; + } + return type; + } + // We never narrow type any in an instanceof guard + if (isTypeAny(type)) { return type; } @@ -7844,18 +7855,26 @@ namespace ts { } if (isIdentifierTypePredicate(predicate)) { const predicateArgument = callExpression.arguments[predicate.parameterIndex]; - if (predicateArgument && isMatchingReference(predicateArgument, reference)) { - return getNarrowedType(type, predicate.type, assumeTrue); + if (predicateArgument) { + if (isMatchingReference(reference, predicateArgument)) { + return getNarrowedType(type, predicate.type, assumeTrue); + } + if (containsMatchingReference(reference, predicateArgument)) { + return declaredType; + } } } else { const invokedExpression = skipParenthesizedNodes(callExpression.expression); if (invokedExpression.kind === SyntaxKind.ElementAccessExpression || invokedExpression.kind === SyntaxKind.PropertyAccessExpression) { const accessExpression = invokedExpression as ElementAccessExpression | PropertyAccessExpression; - const possibleReference= skipParenthesizedNodes(accessExpression.expression); - if (isMatchingReference(possibleReference, reference)) { + const possibleReference = skipParenthesizedNodes(accessExpression.expression); + if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue); } + if (containsMatchingReference(reference, possibleReference)) { + return declaredType; + } } } return type; @@ -7886,19 +7905,18 @@ namespace ts { } function getTypeOfSymbolAtLocation(symbol: Symbol, location: Node) { - // The language service will always care about the narrowed type of a symbol, because that is - // the type the language says the symbol should have. - const type = getTypeOfSymbol(symbol); + // If we have an identifier or a property access at the given location, if the location is + // an dotted name expression, and if the location is not an assignment target, obtain the type + // of the expression (which will reflect control flow analysis). If the expression indeed + // resolved to the given symbol, return the narrowed type. if (location.kind === SyntaxKind.Identifier) { if (isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - // If location is an identifier or property access that references the given - // symbol, use the location as the reference with respect to which we narrow. if (isExpression(location) && !isAssignmentTarget(location)) { - checkExpression(location); + const type = checkExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { - return getNarrowedTypeOfReference(type, location); + return type; } } } @@ -7907,7 +7925,7 @@ namespace ts { // to it at the given location. Since we have no control flow information for the // hypotherical reference (control flow information is created and attached by the // binder), we simply return the declared type of the symbol. - return type; + return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression: Expression): Expression { @@ -7973,12 +7991,9 @@ namespace ts { return type; } const declaration = localOrExportSymbol.valueDeclaration; - const defaultsToDeclaredType = !strictNullChecks || !declaration || - declaration.kind === SyntaxKind.Parameter || isInAmbientContext(declaration) || + const defaultsToDeclaredType = !strictNullChecks || type.flags & TypeFlags.Any || !declaration || + getRootDeclaration(declaration).kind === SyntaxKind.Parameter || isInAmbientContext(declaration) || getContainingFunctionOrModule(declaration) !== getContainingFunctionOrModule(node); - if (defaultsToDeclaredType && !(type.flags & TypeFlags.Narrowable)) { - return type; - } const flowType = getFlowTypeOfReference(node, type, defaultsToDeclaredType ? type : undefinedType); if (strictNullChecks && !(type.flags & TypeFlags.Any) && !(getNullableKind(type) & TypeFlags.Undefined) && getNullableKind(flowType) & TypeFlags.Undefined) { error(node, Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); @@ -8201,6 +8216,21 @@ namespace ts { captureLexicalThis(node, container); } if (isFunctionLike(container)) { + // If this is a function in a JS file, it might be a class method. Check if it's the RHS + // of a x.prototype.y = function [name]() { .... } + if (container.kind === SyntaxKind.FunctionExpression && + isInJavaScriptFile(container.parent) && + getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) { + // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') + const className = (((container.parent as BinaryExpression) // x.prototype.y = f + .left as PropertyAccessExpression) // x.prototype.y + .expression as PropertyAccessExpression) // x.prototype + .expression; // x + const classSymbol = checkExpression(className).symbol; + if (classSymbol && classSymbol.members && (classSymbol.flags & SymbolFlags.Function)) { + return getInferredClassType(classSymbol); + } + } const type = getContextuallyTypedThisType(container); if (type) { return type; @@ -8209,19 +8239,11 @@ namespace ts { if (signature.thisType) { return signature.thisType; } - if (container.parent && container.parent.kind === SyntaxKind.ObjectLiteralExpression) { - // Note: this works because object literal methods are deferred, - // which means that the type of the containing object literal is already known. - const type = checkExpressionCached(container.parent); - if (type) { - return type; - } - } } if (isClassLike(container.parent)) { const symbol = getSymbolOfNode(container.parent); const type = container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; - return getNarrowedTypeOfReference(type, node); + return getFlowTypeOfReference(node, type, type); } if (isInJavaScriptFile(node)) { @@ -8229,22 +8251,6 @@ namespace ts { if (type && type !== unknownType) { return type; } - - // If this is a function in a JS file, it might be a class method. Check if it's the RHS - // of a x.prototype.y = function [name]() { .... } - if (container.kind === SyntaxKind.FunctionExpression) { - if (getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) { - // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') - const className = (((container.parent as BinaryExpression) // x.prototype.y = f - .left as PropertyAccessExpression) // x.prototype.y - .expression as PropertyAccessExpression) // x.prototype - .expression; // x - const classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & SymbolFlags.Function)) { - return getInferredClassType(classSymbol); - } - } - } } if (compilerOptions.noImplicitThis) { @@ -8469,9 +8475,7 @@ namespace ts { } function getContextuallyTypedThisType(func: FunctionLikeDeclaration): Type { - if ((isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) && - isContextSensitive(func) && - func.kind !== SyntaxKind.ArrowFunction) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) { const contextualSignature = getContextualSignature(func); if (contextualSignature) { return contextualSignature.thisType; @@ -8484,24 +8488,21 @@ namespace ts { // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter: ParameterDeclaration): Type { const func = parameter.parent; - if (isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) { - if (isContextSensitive(func)) { - const contextualSignature = getContextualSignature(func); - if (contextualSignature) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { + const contextualSignature = getContextualSignature(func); + if (contextualSignature) { + const funcHasRestParameters = hasRestParameter(func); + const len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + const indexOfParameter = indexOf(func.parameters, parameter); + if (indexOfParameter < len) { + return getTypeAtPosition(contextualSignature, indexOfParameter); + } - const funcHasRestParameters = hasRestParameter(func); - const len = func.parameters.length - (funcHasRestParameters ? 1 : 0); - const indexOfParameter = indexOf(func.parameters, parameter); - if (indexOfParameter < len) { - return getTypeAtPosition(contextualSignature, indexOfParameter); - } - - // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(lastOrUndefined(contextualSignature.parameters)); - } + // If last parameter is contextually rest parameter get its type + if (funcHasRestParameters && + indexOfParameter === (func.parameters.length - 1) && + isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { + return getTypeOfSymbol(lastOrUndefined(contextualSignature.parameters)); } } } @@ -8509,9 +8510,9 @@ namespace ts { } // In a variable, parameter or property declaration with a type annotation, - // the contextual type of an initializer expression is the type of the variable, parameter or property. - // Otherwise, in a parameter declaration of a contextually typed function expression, - // the contextual type of an initializer expression is the contextual type of the parameter. + // the contextual type of an initializer expression is the type of the variable, parameter or property. + // Otherwise, in a parameter declaration of a contextually typed function expression, + // the contextual type of an initializer expression is the contextual type of the parameter. // Otherwise, in a variable or parameter declaration with a binding pattern name, // the contextual type of an initializer expression is the type implied by the binding pattern. // Otherwise, in a binding pattern inside a variable or parameter declaration, @@ -8865,6 +8866,12 @@ namespace ts { : undefined; } + function getContextualTypeForFunctionLikeDeclaration(node: FunctionExpression | MethodDeclaration) { + return isObjectLiteralMethod(node) + ? getContextualTypeForObjectLiteralMethod(node) + : getApparentTypeOfContextualType(node); + } + // Return the contextual signature for a given expression node. A contextual type provides a // contextual signature if it has a single call signature and if that call signature is non-generic. // If the contextual type is a union type, get the signature from each type possible and if they are @@ -8872,9 +8879,7 @@ namespace ts { // union type of return types from these signatures function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - const type = isObjectLiteralMethod(node) - ? getContextualTypeForObjectLiteralMethod(node) - : getApparentTypeOfContextualType(node); + const type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; } @@ -9785,8 +9790,24 @@ namespace ts { } const propType = getTypeOfSymbol(prop); - return node.kind === SyntaxKind.PropertyAccessExpression && prop.flags & (SymbolFlags.Variable | SymbolFlags.Property) && !isAssignmentTarget(node) ? - getNarrowedTypeOfReference(propType, node) : propType; + if (node.kind !== SyntaxKind.PropertyAccessExpression || !(prop.flags & (SymbolFlags.Variable | SymbolFlags.Property)) || isAssignmentTarget(node)) { + return propType; + } + const leftmostNode = getLeftmostIdentifierOrThis(node); + if (!leftmostNode) { + return propType; + } + if (leftmostNode.kind === SyntaxKind.Identifier) { + const leftmostSymbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(leftmostNode)); + if (!leftmostSymbol) { + return propType; + } + const declaration = leftmostSymbol.valueDeclaration; + if (!declaration || declaration.kind !== SyntaxKind.VariableDeclaration && declaration.kind !== SyntaxKind.Parameter && declaration.kind !== SyntaxKind.BindingElement) { + return propType; + } + } + return getFlowTypeOfReference(node, propType, propType); } function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 58ce2286627..aceec933227 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -1753,7 +1753,7 @@ namespace ts { if (!emitSkipped) { const declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); - writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM); + writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); } return emitSkipped; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index c4e3c8668fd..a1f02f520d8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1524,6 +1524,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge switch (parent.kind) { case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.AsExpression: + case SyntaxKind.AwaitExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.CallExpression: case SyntaxKind.CaseClause: diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index c391560befd..2550ca78877 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -3,6 +3,11 @@ namespace ts { export type FileWatcherCallback = (fileName: string, removed?: boolean) => void; export type DirectoryWatcherCallback = (directoryName: string) => void; + export interface WatchedFile { + fileName: string; + callback: FileWatcherCallback; + mtime?: Date; + } export interface System { args: string[]; @@ -26,12 +31,6 @@ namespace ts { exit(exitCode?: number): void; } - interface WatchedFile { - fileName: string; - callback: FileWatcherCallback; - mtime?: Date; - } - export interface FileWatcher { close(): void; } @@ -230,83 +229,7 @@ namespace ts { const _os = require("os"); const _crypto = require("crypto"); - // average async stat takes about 30 microseconds - // set chunk size to do 30 files in < 1 millisecond - function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) { - let watchedFiles: WatchedFile[] = []; - let nextFileToCheck = 0; - let watchTimer: any; - - function getModifiedTime(fileName: string): Date { - return _fs.statSync(fileName).mtime; - } - - function poll(checkedIndex: number) { - const watchedFile = watchedFiles[checkedIndex]; - if (!watchedFile) { - return; - } - - _fs.stat(watchedFile.fileName, (err: any, stats: any) => { - if (err) { - watchedFile.callback(watchedFile.fileName); - } - else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); - } - }); - } - - // this implementation uses polling and - // stat due to inconsistencies of fs.watch - // and efficiency of stat on modern filesystems - function startWatchTimer() { - watchTimer = setInterval(() => { - let count = 0; - let nextToCheck = nextFileToCheck; - let firstCheck = -1; - while ((count < chunkSize) && (nextToCheck !== firstCheck)) { - poll(nextToCheck); - if (firstCheck < 0) { - firstCheck = nextToCheck; - } - nextToCheck++; - if (nextToCheck === watchedFiles.length) { - nextToCheck = 0; - } - count++; - } - nextFileToCheck = nextToCheck; - }, interval); - } - - function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile { - const file: WatchedFile = { - fileName, - callback, - mtime: getModifiedTime(fileName) - }; - - watchedFiles.push(file); - if (watchedFiles.length === 1) { - startWatchTimer(); - } - return file; - } - - function removeFile(file: WatchedFile) { - watchedFiles = copyListRemovingItem(file, watchedFiles); - } - - return { - getModifiedTime: getModifiedTime, - poll: poll, - startWatchTimer: startWatchTimer, - addFile: addFile, - removeFile: removeFile - }; - } + const useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { const dirWatchers: Map = {}; @@ -389,26 +312,11 @@ namespace ts { } } } - - // REVIEW: for now this implementation uses polling. - // The advantage of polling is that it works reliably - // on all os and with network mounted files. - // For 90 referenced files, the average time to detect - // changes is 2*msInterval (by default 5 seconds). - // The overhead of this is .04 percent (1/2500) with - // average pause of < 1 millisecond (and max - // pause less than 1.5 milliseconds); question is - // do we anticipate reference sets in the 100s and - // do we care about waiting 10-20 seconds to detect - // changes for large reference sets? If so, do we want - // to increase the chunk size or decrease the interval - // time dynamically to match the large reference set? - const pollingWatchedFileSet = createPollingWatchedFileSet(); const watchedFileSet = createWatchedFileSet(); function isNode4OrLater(): boolean { - return parseInt(process.version.charAt(1)) >= 4; - } + return parseInt(process.version.charAt(1)) >= 4; + } const platform: string = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive @@ -501,7 +409,7 @@ namespace ts { const files = _fs.readdirSync(path || ".").sort(); const directories: string[] = []; for (const current of files) { - // This is necessary because on some file system node fails to exclude + // This is necessary because on some file system node fails to exclude // "." and "..". See https://github.com/nodejs/node/issues/4002 if (current === "." || current === "..") { continue; @@ -535,15 +443,26 @@ namespace ts { readFile, writeFile, watchFile: (fileName, callback) => { - // Node 4.0 stabilized the `fs.watch` function on Windows which avoids polling - // and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 - // and https://github.com/Microsoft/TypeScript/issues/4643), therefore - // if the current node.js version is newer than 4, use `fs.watch` instead. - const watchSet = isNode4OrLater() ? watchedFileSet : pollingWatchedFileSet; - const watchedFile = watchSet.addFile(fileName, callback); - return { - close: () => watchSet.removeFile(watchedFile) - }; + if (useNonPollingWatchers) { + const watchedFile = watchedFileSet.addFile(fileName, callback); + return { + close: () => watchedFileSet.removeFile(watchedFile) + }; + } + else { + _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + return { + close: () => _fs.unwatchFile(fileName, fileChanged) + }; + } + + function fileChanged(curr: any, prev: any) { + if (+curr.mtime <= +prev.mtime) { + return; + } + + callback(fileName); + } }, watchDirectory: (directoryName, callback, recursive) => { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 2e40cfdc53c..e25ae37e21f 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -391,9 +391,21 @@ namespace ts { sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); return; } - if (isWatchSet(configParseResult.options) && !sys.watchFile) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined); - sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + if (isWatchSet(configParseResult.options)) { + if (!sys.watchFile) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined); + sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + + if (!directoryWatcher && sys.watchDirectory && configFileName) { + const directory = ts.getDirectoryPath(configFileName); + directoryWatcher = sys.watchDirectory( + // When the configFileName is just "tsconfig.json", the watched directory should be + // the current directory; if there is a given "project" parameter, then the configFileName + // is an absolute file name. + directory == "" ? "." : directory, + watchedDirectoryChanged, /*recursive*/ true); + }; } return configParseResult; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 88b71e4c5c3..69491cb79e6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1551,6 +1551,7 @@ namespace ts { Unreachable, Start, Label, + LoopLabel, Assignment, Condition } @@ -2539,19 +2540,19 @@ namespace ts { // When options come from a config file, its path is recorded here configFilePath?: string; /* @internal */ - // Path used to used to compute primary search locations + // Path used to used to compute primary search locations typesRoot?: string; types?: string[]; list?: string[]; - [option: string]: CompilerOptionsValue; + [option: string]: CompilerOptionsValue | undefined; } export interface TypingOptions { enableAutoDiscovery?: boolean; include?: string[]; exclude?: string[]; - [option: string]: string[] | boolean; + [option: string]: string[] | boolean | undefined; } export interface DiscoverTypingsInfo { @@ -2856,7 +2857,7 @@ namespace ts { */ resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; /** - * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files + * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c6cf82a6834..d6035aaa026 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -747,7 +747,7 @@ namespace FourSlash { } const missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; - this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(references)})`); + this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(references, undefined, 2)})`); } public verifyReferencesCountIs(count: number, localFilesOnly = true) { @@ -801,7 +801,7 @@ namespace FourSlash { private testDiagnostics(expected: string, diagnostics: ts.Diagnostic[]) { const realized = ts.realizeDiagnostics(diagnostics, "\r\n"); - const actual = JSON.stringify(realized, null, " "); + const actual = JSON.stringify(realized, undefined, 2); assert.equal(actual, expected); } @@ -876,7 +876,7 @@ namespace FourSlash { } if (ranges.length !== references.length) { - this.raiseError("Rename location count does not match result.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references)); + this.raiseError("Rename location count does not match result.\n\nExpected: " + JSON.stringify(ranges, undefined, 2) + "\n\nActual:" + JSON.stringify(references, undefined, 2)); } ranges = ranges.sort((r1, r2) => r1.start - r2.start); @@ -889,7 +889,7 @@ namespace FourSlash { if (reference.textSpan.start !== range.start || ts.textSpanEnd(reference.textSpan) !== range.end) { - this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references)); + this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges, undefined, 2) + "\n\nActual:" + JSON.stringify(references, undefined, 2)); } } } @@ -973,7 +973,7 @@ namespace FourSlash { } else { if (actual) { - this.raiseError(`Expected no signature help, but got "${JSON.stringify(actual)}"`); + this.raiseError(`Expected no signature help, but got "${JSON.stringify(actual, undefined, 2)}"`); } } } @@ -1185,7 +1185,7 @@ namespace FourSlash { public printCurrentParameterHelp() { const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - Harness.IO.log(JSON.stringify(help)); + Harness.IO.log(JSON.stringify(help, undefined, 2)); } public printCurrentQuickInfo() { @@ -1227,7 +1227,7 @@ namespace FourSlash { public printCurrentSignatureHelp() { const sigHelp = this.getActiveSignatureHelpItem(); - Harness.IO.log(JSON.stringify(sigHelp)); + Harness.IO.log(JSON.stringify(sigHelp, undefined, 2)); } public printMemberListMembers() { @@ -1257,7 +1257,7 @@ namespace FourSlash { public printReferences() { const references = this.getReferencesAtCaret(); ts.forEach(references, entry => { - Harness.IO.log(JSON.stringify(entry)); + Harness.IO.log(JSON.stringify(entry, undefined, 2)); }); } @@ -1748,8 +1748,8 @@ namespace FourSlash { function jsonMismatchString() { return Harness.IO.newLine() + - "expected: '" + Harness.IO.newLine() + JSON.stringify(expected, (k, v) => v, 2) + "'" + Harness.IO.newLine() + - "actual: '" + Harness.IO.newLine() + JSON.stringify(actual, (k, v) => v, 2) + "'"; + "expected: '" + Harness.IO.newLine() + JSON.stringify(expected, undefined, 2) + "'" + Harness.IO.newLine() + + "actual: '" + Harness.IO.newLine() + JSON.stringify(actual, undefined, 2) + "'"; } } @@ -1964,7 +1964,7 @@ namespace FourSlash { // if there was an explicit match kind specified, then it should be validated. if (matchKind !== undefined) { const missingItem = { name: name, kind: kind, searchValue: searchValue, matchKind: matchKind, fileName: fileName, parentName: parentName }; - this.raiseError(`verifyNavigationItemsListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(items)})`); + this.raiseError(`verifyNavigationItemsListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(items, undefined, 2)})`); } } @@ -2001,7 +2001,7 @@ namespace FourSlash { } const missingItem = { name: name, kind: kind }; - this.raiseError(`verifyGetScriptLexicalStructureListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(items, null, " ")})`); + this.raiseError(`verifyGetScriptLexicalStructureListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(items, undefined, 2)})`); } private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) { @@ -2066,7 +2066,7 @@ namespace FourSlash { } const missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; - this.raiseError(`verifyOccurrencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(occurrences)})`); + this.raiseError(`verifyOccurrencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(occurrences, undefined, 2)})`); } public verifyOccurrencesAtPositionListCount(expectedCount: number) { @@ -2105,7 +2105,7 @@ namespace FourSlash { } const missingItem = { fileName: fileName, start: start, end: end, kind: kind }; - this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(documentHighlights)})`); + this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(documentHighlights, undefined, 2)})`); } public verifyDocumentHighlightsAtPositionListCount(expectedCount: number, fileNamesToSearch: string[]) { @@ -2171,9 +2171,9 @@ namespace FourSlash { } } - const itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n"); + const itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind }, undefined, 2)).join(",\n"); - this.raiseError(`Expected "${JSON.stringify({ name, text, documentation, kind })}" to be in list [${itemsString}]`); + this.raiseError(`Expected "${JSON.stringify({ name, text, documentation, kind }, undefined, 2)}" to be in list [${itemsString}]`); } private findFile(indexOrName: any) { diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index f3ced0f6011..5865e485754 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -1,3 +1,4 @@ + ///////////////////////////// /// IE DOM APIs ///////////////////////////// @@ -957,7 +958,7 @@ declare var ApplicationCache: { interface AriaRequestEvent extends Event { readonly attributeName: string; - attributeValue: string; + attributeValue: string | null; } declare var AriaRequestEvent: { @@ -968,7 +969,7 @@ declare var AriaRequestEvent: { interface Attr extends Node { readonly name: string; readonly ownerElement: Element; - readonly prefix: string; + readonly prefix: string | null; readonly specified: boolean; value: string; } @@ -994,7 +995,7 @@ declare var AudioBuffer: { } interface AudioBufferSourceNode extends AudioNode { - buffer: AudioBuffer; + buffer: AudioBuffer | null; readonly detune: AudioParam; loop: boolean; loopEnd: number; @@ -1130,7 +1131,7 @@ interface AudioTrackList extends EventTarget { onaddtrack: (ev: TrackEvent) => any; onchange: (ev: Event) => any; onremovetrack: (ev: TrackEvent) => any; - getTrackById(id: string): AudioTrack; + getTrackById(id: string): AudioTrack | null; item(index: number): AudioTrack; addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -1344,343 +1345,343 @@ declare var CSSRuleList: { } interface CSSStyleDeclaration { - alignContent: string; - alignItems: string; - alignSelf: string; - alignmentBaseline: string; - animation: string; - animationDelay: string; - animationDirection: string; - animationDuration: string; - animationFillMode: string; - animationIterationCount: string; - animationName: string; - animationPlayState: string; - animationTimingFunction: string; - backfaceVisibility: string; - background: string; - backgroundAttachment: string; - backgroundClip: string; - backgroundColor: string; - backgroundImage: string; - backgroundOrigin: string; - backgroundPosition: string; - backgroundPositionX: string; - backgroundPositionY: string; - backgroundRepeat: string; - backgroundSize: string; - baselineShift: string; - border: string; - borderBottom: string; - borderBottomColor: string; - borderBottomLeftRadius: string; - borderBottomRightRadius: string; - borderBottomStyle: string; - borderBottomWidth: string; - borderCollapse: string; - borderColor: string; - borderImage: string; - borderImageOutset: string; - borderImageRepeat: string; - borderImageSlice: string; - borderImageSource: string; - borderImageWidth: string; - borderLeft: string; - borderLeftColor: string; - borderLeftStyle: string; - borderLeftWidth: string; - borderRadius: string; - borderRight: string; - borderRightColor: string; - borderRightStyle: string; - borderRightWidth: string; - borderSpacing: string; - borderStyle: string; - borderTop: string; - borderTopColor: string; - borderTopLeftRadius: string; - borderTopRightRadius: string; - borderTopStyle: string; - borderTopWidth: string; - borderWidth: string; - bottom: string; - boxShadow: string; - boxSizing: string; - breakAfter: string; - breakBefore: string; - breakInside: string; - captionSide: string; - clear: string; - clip: string; - clipPath: string; - clipRule: string; - color: string; - colorInterpolationFilters: string; + alignContent: string | null; + alignItems: string | null; + alignSelf: string | null; + alignmentBaseline: string | null; + animation: string | null; + animationDelay: string | null; + animationDirection: string | null; + animationDuration: string | null; + animationFillMode: string | null; + animationIterationCount: string | null; + animationName: string | null; + animationPlayState: string | null; + animationTimingFunction: string | null; + backfaceVisibility: string | null; + background: string | null; + backgroundAttachment: string | null; + backgroundClip: string | null; + backgroundColor: string | null; + backgroundImage: string | null; + backgroundOrigin: string | null; + backgroundPosition: string | null; + backgroundPositionX: string | null; + backgroundPositionY: string | null; + backgroundRepeat: string | null; + backgroundSize: string | null; + baselineShift: string | null; + border: string | null; + borderBottom: string | null; + borderBottomColor: string | null; + borderBottomLeftRadius: string | null; + borderBottomRightRadius: string | null; + borderBottomStyle: string | null; + borderBottomWidth: string | null; + borderCollapse: string | null; + borderColor: string | null; + borderImage: string | null; + borderImageOutset: string | null; + borderImageRepeat: string | null; + borderImageSlice: string | null; + borderImageSource: string | null; + borderImageWidth: string | null; + borderLeft: string | null; + borderLeftColor: string | null; + borderLeftStyle: string | null; + borderLeftWidth: string | null; + borderRadius: string | null; + borderRight: string | null; + borderRightColor: string | null; + borderRightStyle: string | null; + borderRightWidth: string | null; + borderSpacing: string | null; + borderStyle: string | null; + borderTop: string | null; + borderTopColor: string | null; + borderTopLeftRadius: string | null; + borderTopRightRadius: string | null; + borderTopStyle: string | null; + borderTopWidth: string | null; + borderWidth: string | null; + bottom: string | null; + boxShadow: string | null; + boxSizing: string | null; + breakAfter: string | null; + breakBefore: string | null; + breakInside: string | null; + captionSide: string | null; + clear: string | null; + clip: string | null; + clipPath: string | null; + clipRule: string | null; + color: string | null; + colorInterpolationFilters: string | null; columnCount: any; - columnFill: string; + columnFill: string | null; columnGap: any; - columnRule: string; + columnRule: string | null; columnRuleColor: any; - columnRuleStyle: string; + columnRuleStyle: string | null; columnRuleWidth: any; - columnSpan: string; + columnSpan: string | null; columnWidth: any; - columns: string; - content: string; - counterIncrement: string; - counterReset: string; - cssFloat: string; + columns: string | null; + content: string | null; + counterIncrement: string | null; + counterReset: string | null; + cssFloat: string | null; cssText: string; - cursor: string; - direction: string; - display: string; - dominantBaseline: string; - emptyCells: string; - enableBackground: string; - fill: string; - fillOpacity: string; - fillRule: string; - filter: string; - flex: string; - flexBasis: string; - flexDirection: string; - flexFlow: string; - flexGrow: string; - flexShrink: string; - flexWrap: string; - floodColor: string; - floodOpacity: string; - font: string; - fontFamily: string; - fontFeatureSettings: string; - fontSize: string; - fontSizeAdjust: string; - fontStretch: string; - fontStyle: string; - fontVariant: string; - fontWeight: string; - glyphOrientationHorizontal: string; - glyphOrientationVertical: string; - height: string; - imeMode: string; - justifyContent: string; - kerning: string; - left: string; + cursor: string | null; + direction: string | null; + display: string | null; + dominantBaseline: string | null; + emptyCells: string | null; + enableBackground: string | null; + fill: string | null; + fillOpacity: string | null; + fillRule: string | null; + filter: string | null; + flex: string | null; + flexBasis: string | null; + flexDirection: string | null; + flexFlow: string | null; + flexGrow: string | null; + flexShrink: string | null; + flexWrap: string | null; + floodColor: string | null; + floodOpacity: string | null; + font: string | null; + fontFamily: string | null; + fontFeatureSettings: string | null; + fontSize: string | null; + fontSizeAdjust: string | null; + fontStretch: string | null; + fontStyle: string | null; + fontVariant: string | null; + fontWeight: string | null; + glyphOrientationHorizontal: string | null; + glyphOrientationVertical: string | null; + height: string | null; + imeMode: string | null; + justifyContent: string | null; + kerning: string | null; + left: string | null; readonly length: number; - letterSpacing: string; - lightingColor: string; - lineHeight: string; - listStyle: string; - listStyleImage: string; - listStylePosition: string; - listStyleType: string; - margin: string; - marginBottom: string; - marginLeft: string; - marginRight: string; - marginTop: string; - marker: string; - markerEnd: string; - markerMid: string; - markerStart: string; - mask: string; - maxHeight: string; - maxWidth: string; - minHeight: string; - minWidth: string; - msContentZoomChaining: string; - msContentZoomLimit: string; + letterSpacing: string | null; + lightingColor: string | null; + lineHeight: string | null; + listStyle: string | null; + listStyleImage: string | null; + listStylePosition: string | null; + listStyleType: string | null; + margin: string | null; + marginBottom: string | null; + marginLeft: string | null; + marginRight: string | null; + marginTop: string | null; + marker: string | null; + markerEnd: string | null; + markerMid: string | null; + markerStart: string | null; + mask: string | null; + maxHeight: string | null; + maxWidth: string | null; + minHeight: string | null; + minWidth: string | null; + msContentZoomChaining: string | null; + msContentZoomLimit: string | null; msContentZoomLimitMax: any; msContentZoomLimitMin: any; - msContentZoomSnap: string; - msContentZoomSnapPoints: string; - msContentZoomSnapType: string; - msContentZooming: string; - msFlowFrom: string; - msFlowInto: string; - msFontFeatureSettings: string; + msContentZoomSnap: string | null; + msContentZoomSnapPoints: string | null; + msContentZoomSnapType: string | null; + msContentZooming: string | null; + msFlowFrom: string | null; + msFlowInto: string | null; + msFontFeatureSettings: string | null; msGridColumn: any; - msGridColumnAlign: string; + msGridColumnAlign: string | null; msGridColumnSpan: any; - msGridColumns: string; + msGridColumns: string | null; msGridRow: any; - msGridRowAlign: string; + msGridRowAlign: string | null; msGridRowSpan: any; - msGridRows: string; - msHighContrastAdjust: string; - msHyphenateLimitChars: string; + msGridRows: string | null; + msHighContrastAdjust: string | null; + msHyphenateLimitChars: string | null; msHyphenateLimitLines: any; msHyphenateLimitZone: any; - msHyphens: string; - msImeAlign: string; - msOverflowStyle: string; - msScrollChaining: string; - msScrollLimit: string; + msHyphens: string | null; + msImeAlign: string | null; + msOverflowStyle: string | null; + msScrollChaining: string | null; + msScrollLimit: string | null; msScrollLimitXMax: any; msScrollLimitXMin: any; msScrollLimitYMax: any; msScrollLimitYMin: any; - msScrollRails: string; - msScrollSnapPointsX: string; - msScrollSnapPointsY: string; - msScrollSnapType: string; - msScrollSnapX: string; - msScrollSnapY: string; - msScrollTranslation: string; - msTextCombineHorizontal: string; + msScrollRails: string | null; + msScrollSnapPointsX: string | null; + msScrollSnapPointsY: string | null; + msScrollSnapType: string | null; + msScrollSnapX: string | null; + msScrollSnapY: string | null; + msScrollTranslation: string | null; + msTextCombineHorizontal: string | null; msTextSizeAdjust: any; - msTouchAction: string; - msTouchSelect: string; - msUserSelect: string; + msTouchAction: string | null; + msTouchSelect: string | null; + msUserSelect: string | null; msWrapFlow: string; msWrapMargin: any; msWrapThrough: string; - opacity: string; - order: string; - orphans: string; - outline: string; - outlineColor: string; - outlineStyle: string; - outlineWidth: string; - overflow: string; - overflowX: string; - overflowY: string; - padding: string; - paddingBottom: string; - paddingLeft: string; - paddingRight: string; - paddingTop: string; - pageBreakAfter: string; - pageBreakBefore: string; - pageBreakInside: string; + opacity: string | null; + order: string | null; + orphans: string | null; + outline: string | null; + outlineColor: string | null; + outlineStyle: string | null; + outlineWidth: string | null; + overflow: string | null; + overflowX: string | null; + overflowY: string | null; + padding: string | null; + paddingBottom: string | null; + paddingLeft: string | null; + paddingRight: string | null; + paddingTop: string | null; + pageBreakAfter: string | null; + pageBreakBefore: string | null; + pageBreakInside: string | null; readonly parentRule: CSSRule; - perspective: string; - perspectiveOrigin: string; - pointerEvents: string; - position: string; - quotes: string; - right: string; - rubyAlign: string; - rubyOverhang: string; - rubyPosition: string; - stopColor: string; - stopOpacity: string; - stroke: string; - strokeDasharray: string; - strokeDashoffset: string; - strokeLinecap: string; - strokeLinejoin: string; - strokeMiterlimit: string; - strokeOpacity: string; - strokeWidth: string; - tableLayout: string; - textAlign: string; - textAlignLast: string; - textAnchor: string; - textDecoration: string; - textIndent: string; - textJustify: string; - textKashida: string; - textKashidaSpace: string; - textOverflow: string; - textShadow: string; - textTransform: string; - textUnderlinePosition: string; - top: string; - touchAction: string; - transform: string; - transformOrigin: string; - transformStyle: string; - transition: string; - transitionDelay: string; - transitionDuration: string; - transitionProperty: string; - transitionTimingFunction: string; - unicodeBidi: string; - verticalAlign: string; - visibility: string; - webkitAlignContent: string; - webkitAlignItems: string; - webkitAlignSelf: string; - webkitAnimation: string; - webkitAnimationDelay: string; - webkitAnimationDirection: string; - webkitAnimationDuration: string; - webkitAnimationFillMode: string; - webkitAnimationIterationCount: string; - webkitAnimationName: string; - webkitAnimationPlayState: string; - webkitAnimationTimingFunction: string; - webkitAppearance: string; - webkitBackfaceVisibility: string; - webkitBackgroundClip: string; - webkitBackgroundOrigin: string; - webkitBackgroundSize: string; - webkitBorderBottomLeftRadius: string; - webkitBorderBottomRightRadius: string; - webkitBorderImage: string; - webkitBorderRadius: string; - webkitBorderTopLeftRadius: string; - webkitBorderTopRightRadius: string; - webkitBoxAlign: string; - webkitBoxDirection: string; - webkitBoxFlex: string; - webkitBoxOrdinalGroup: string; - webkitBoxOrient: string; - webkitBoxPack: string; - webkitBoxSizing: string; - webkitColumnBreakAfter: string; - webkitColumnBreakBefore: string; - webkitColumnBreakInside: string; + perspective: string | null; + perspectiveOrigin: string | null; + pointerEvents: string | null; + position: string | null; + quotes: string | null; + right: string | null; + rubyAlign: string | null; + rubyOverhang: string | null; + rubyPosition: string | null; + stopColor: string | null; + stopOpacity: string | null; + stroke: string | null; + strokeDasharray: string | null; + strokeDashoffset: string | null; + strokeLinecap: string | null; + strokeLinejoin: string | null; + strokeMiterlimit: string | null; + strokeOpacity: string | null; + strokeWidth: string | null; + tableLayout: string | null; + textAlign: string | null; + textAlignLast: string | null; + textAnchor: string | null; + textDecoration: string | null; + textIndent: string | null; + textJustify: string | null; + textKashida: string | null; + textKashidaSpace: string | null; + textOverflow: string | null; + textShadow: string | null; + textTransform: string | null; + textUnderlinePosition: string | null; + top: string | null; + touchAction: string | null; + transform: string | null; + transformOrigin: string | null; + transformStyle: string | null; + transition: string | null; + transitionDelay: string | null; + transitionDuration: string | null; + transitionProperty: string | null; + transitionTimingFunction: string | null; + unicodeBidi: string | null; + verticalAlign: string | null; + visibility: string | null; + webkitAlignContent: string | null; + webkitAlignItems: string | null; + webkitAlignSelf: string | null; + webkitAnimation: string | null; + webkitAnimationDelay: string | null; + webkitAnimationDirection: string | null; + webkitAnimationDuration: string | null; + webkitAnimationFillMode: string | null; + webkitAnimationIterationCount: string | null; + webkitAnimationName: string | null; + webkitAnimationPlayState: string | null; + webkitAnimationTimingFunction: string | null; + webkitAppearance: string | null; + webkitBackfaceVisibility: string | null; + webkitBackgroundClip: string | null; + webkitBackgroundOrigin: string | null; + webkitBackgroundSize: string | null; + webkitBorderBottomLeftRadius: string | null; + webkitBorderBottomRightRadius: string | null; + webkitBorderImage: string | null; + webkitBorderRadius: string | null; + webkitBorderTopLeftRadius: string | null; + webkitBorderTopRightRadius: string | null; + webkitBoxAlign: string | null; + webkitBoxDirection: string | null; + webkitBoxFlex: string | null; + webkitBoxOrdinalGroup: string | null; + webkitBoxOrient: string | null; + webkitBoxPack: string | null; + webkitBoxSizing: string | null; + webkitColumnBreakAfter: string | null; + webkitColumnBreakBefore: string | null; + webkitColumnBreakInside: string | null; webkitColumnCount: any; webkitColumnGap: any; - webkitColumnRule: string; + webkitColumnRule: string | null; webkitColumnRuleColor: any; - webkitColumnRuleStyle: string; + webkitColumnRuleStyle: string | null; webkitColumnRuleWidth: any; - webkitColumnSpan: string; + webkitColumnSpan: string | null; webkitColumnWidth: any; - webkitColumns: string; - webkitFilter: string; - webkitFlex: string; - webkitFlexBasis: string; - webkitFlexDirection: string; - webkitFlexFlow: string; - webkitFlexGrow: string; - webkitFlexShrink: string; - webkitFlexWrap: string; - webkitJustifyContent: string; - webkitOrder: string; - webkitPerspective: string; - webkitPerspectiveOrigin: string; - webkitTapHighlightColor: string; - webkitTextFillColor: string; + webkitColumns: string | null; + webkitFilter: string | null; + webkitFlex: string | null; + webkitFlexBasis: string | null; + webkitFlexDirection: string | null; + webkitFlexFlow: string | null; + webkitFlexGrow: string | null; + webkitFlexShrink: string | null; + webkitFlexWrap: string | null; + webkitJustifyContent: string | null; + webkitOrder: string | null; + webkitPerspective: string | null; + webkitPerspectiveOrigin: string | null; + webkitTapHighlightColor: string | null; + webkitTextFillColor: string | null; webkitTextSizeAdjust: any; - webkitTransform: string; - webkitTransformOrigin: string; - webkitTransformStyle: string; - webkitTransition: string; - webkitTransitionDelay: string; - webkitTransitionDuration: string; - webkitTransitionProperty: string; - webkitTransitionTimingFunction: string; - webkitUserModify: string; - webkitUserSelect: string; - webkitWritingMode: string; - whiteSpace: string; - widows: string; - width: string; - wordBreak: string; - wordSpacing: string; - wordWrap: string; - writingMode: string; - zIndex: string; - zoom: string; + webkitTransform: string | null; + webkitTransformOrigin: string | null; + webkitTransformStyle: string | null; + webkitTransition: string | null; + webkitTransitionDelay: string | null; + webkitTransitionDuration: string | null; + webkitTransitionProperty: string | null; + webkitTransitionTimingFunction: string | null; + webkitUserModify: string | null; + webkitUserSelect: string | null; + webkitWritingMode: string | null; + whiteSpace: string | null; + widows: string | null; + width: string | null; + wordBreak: string | null; + wordSpacing: string | null; + wordWrap: string | null; + writingMode: string | null; + zIndex: string | null; + zoom: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; removeProperty(propertyName: string): string; - setProperty(propertyName: string, value: string, priority?: string): void; + setProperty(propertyName: string, value: string | null, priority?: string): void; [index: number]: string; } @@ -1772,6 +1773,9 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; + mozImageSmoothingEnabled: boolean; + webkitImageSmoothingEnabled: boolean; + oImageSmoothingEnabled: boolean; beginPath(): void; clearRect(x: number, y: number, w: number, h: number): void; clip(fillRule?: string): void; @@ -1886,7 +1890,7 @@ declare var CloseEvent: { interface CommandEvent extends Event { readonly commandName: string; - readonly detail: string; + readonly detail: string | null; } declare var CommandEvent: { @@ -1945,7 +1949,7 @@ declare var Console: { } interface ConvolverNode extends AudioNode { - buffer: AudioBuffer; + buffer: AudioBuffer | null; normalize: boolean; } @@ -1956,12 +1960,12 @@ declare var ConvolverNode: { interface Coordinates { readonly accuracy: number; - readonly altitude: number; - readonly altitudeAccuracy: number; - readonly heading: number; + readonly altitude: number | null; + readonly altitudeAccuracy: number | null; + readonly heading: number | null; readonly latitude: number; readonly longitude: number; - readonly speed: number; + readonly speed: number | null; } declare var Coordinates: { @@ -2087,10 +2091,10 @@ declare var DOMException: { } interface DOMImplementation { - createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; - createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; + createDocumentType(qualifiedName: string, publicId: string | null, systemId: string | null): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(feature: string, version: string): boolean; + hasFeature(feature: string | null, version: string | null): boolean; } declare var DOMImplementation: { @@ -2119,7 +2123,7 @@ declare var DOMSettableTokenList: { interface DOMStringList { readonly length: number; contains(str: string): boolean; - item(index: number): string; + item(index: number): string | null; [index: number]: string; } @@ -2181,8 +2185,8 @@ declare var DataTransfer: { interface DataTransferItem { readonly kind: string; readonly type: string; - getAsFile(): File; - getAsString(_callback: FunctionStringCallback): void; + getAsFile(): File | null; + getAsString(_callback: FunctionStringCallback | null): void; } declare var DataTransferItem: { @@ -2192,7 +2196,7 @@ declare var DataTransferItem: { interface DataTransferItemList { readonly length: number; - add(data: File): DataTransferItem; + add(data: File): DataTransferItem | null; clear(): void; item(index: number): DataTransferItem; remove(index: number): void; @@ -2227,9 +2231,9 @@ declare var DelayNode: { } interface DeviceAcceleration { - readonly x: number; - readonly y: number; - readonly z: number; + readonly x: number | null; + readonly y: number | null; + readonly z: number | null; } declare var DeviceAcceleration: { @@ -2247,11 +2251,11 @@ declare var DeviceLightEvent: { } interface DeviceMotionEvent extends Event { - readonly acceleration: DeviceAcceleration; - readonly accelerationIncludingGravity: DeviceAcceleration; - readonly interval: number; - readonly rotationRate: DeviceRotationRate; - initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; + readonly acceleration: DeviceAcceleration | null; + readonly accelerationIncludingGravity: DeviceAcceleration | null; + readonly interval: number | null; + readonly rotationRate: DeviceRotationRate | null; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict | null, accelerationIncludingGravity: DeviceAccelerationDict | null, rotationRate: DeviceRotationRateDict | null, interval: number | null): void; } declare var DeviceMotionEvent: { @@ -2261,10 +2265,10 @@ declare var DeviceMotionEvent: { interface DeviceOrientationEvent extends Event { readonly absolute: boolean; - readonly alpha: number; - readonly beta: number; - readonly gamma: number; - initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; + readonly alpha: number | null; + readonly beta: number | null; + readonly gamma: number | null; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number | null, beta: number | null, gamma: number | null, absolute: boolean): void; } declare var DeviceOrientationEvent: { @@ -2273,9 +2277,9 @@ declare var DeviceOrientationEvent: { } interface DeviceRotationRate { - readonly alpha: number; - readonly beta: number; - readonly gamma: number; + readonly alpha: number | null; + readonly beta: number | null; + readonly gamma: number | null; } declare var DeviceRotationRate: { @@ -2368,7 +2372,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Retrieves a collection, in source order, of all form objects in the document. */ forms: HTMLCollectionOf; - readonly fullscreenElement: Element; + readonly fullscreenElement: Element | null; readonly fullscreenEnabled: boolean; readonly head: HTMLHeadElement; readonly hidden: boolean; @@ -2383,7 +2387,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven /** * Returns the character encoding used to create the webpage that is loaded into the document object. */ - readonly inputEncoding: string; + readonly inputEncoding: string | null; /** * Gets the date that the page was last modified, if the page supplies one. */ @@ -2728,7 +2732,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Retrieves a collection of all script objects in the document. */ scripts: HTMLCollectionOf; - readonly scrollingElement: Element; + readonly scrollingElement: Element | null; /** * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. */ @@ -2742,16 +2746,16 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Sets or gets the color of the links that the user has visited. */ vlinkColor: string; - readonly webkitCurrentFullScreenElement: Element; - readonly webkitFullscreenElement: Element; + readonly webkitCurrentFullScreenElement: Element | null; + readonly webkitFullscreenElement: Element | null; readonly webkitFullscreenEnabled: boolean; readonly webkitIsFullScreen: boolean; - readonly xmlEncoding: string; + readonly xmlEncoding: string | null; xmlStandalone: boolean; /** * Gets or sets the version attribute specified in the declaration of an XML document. */ - xmlVersion: string; + xmlVersion: string | null; adoptNode(source: Node): Node; captureEvents(): void; caretRangeFromPoint(x: number, y: number): Range; @@ -2765,7 +2769,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param name String that sets the attribute object's name. */ createAttribute(name: string): Attr; - createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; + createAttributeNS(namespaceURI: string | null, qualifiedName: string): Attr; createCDATASection(data: string): CDATASection; /** * Creates a comment object with the specified data. @@ -2861,6 +2865,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; createElement(tagName: "xmp"): HTMLPreElement; createElement(tagName: string): HTMLElement; + createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "clipPath"): SVGClipPathElement @@ -2923,7 +2928,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "use"): SVGUseElement createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "view"): SVGViewElement createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement - createElementNS(namespaceURI: string, qualifiedName: string): Element; + createElementNS(namespaceURI: string | null, qualifiedName: string): Element; createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; createNSResolver(nodeResolver: Node): XPathNSResolver; /** @@ -2984,12 +2989,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param elementId String that specifies the ID value. Case-insensitive. */ getElementById(elementId: string): HTMLElement; - getElementsByClassName(classNames: string): NodeListOf; + getElementsByClassName(classNames: string): HTMLCollectionOf; /** * Gets a collection of objects based on the value of the NAME or ID attribute. * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. */ - getElementsByName(elementName: string): NodeListOf; + getElementsByName(elementName: string): NodeListOf; /** * Retrieves a collection of objects based on the specified element name. * @param name Specifies the name of an element. @@ -3171,7 +3176,9 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "x-ms-webview"): NodeListOf; getElementsByTagName(tagname: "xmp"): NodeListOf; getElementsByTagName(tagname: string): NodeListOf; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; /** * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. */ @@ -3238,8 +3245,6 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param content The text and HTML tags to write. */ writeln(...content: string[]): void; - createElement(tagName: "picture"): HTMLPictureElement; - getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -3356,11 +3361,11 @@ declare var DocumentFragment: { interface DocumentType extends Node, ChildNode { readonly entities: NamedNodeMap; - readonly internalSubset: string; + readonly internalSubset: string | null; readonly name: string; readonly notations: NamedNodeMap; - readonly publicId: string; - readonly systemId: string; + readonly publicId: string | null; + readonly systemId: string | null; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3451,14 +3456,14 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (ev: Event) => any; onwebkitfullscreenerror: (ev: Event) => any; - readonly prefix: string; + readonly prefix: string | null; readonly scrollHeight: number; scrollLeft: number; scrollTop: number; readonly scrollWidth: number; readonly tagName: string; innerHTML: string; - getAttribute(name?: string): string; + getAttribute(name?: string): string | null; getAttributeNS(namespaceURI: string, localName: string): string; getAttributeNode(name: string): Attr; getAttributeNodeNS(namespaceURI: string, localName: string): Attr; @@ -3641,7 +3646,9 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "x-ms-webview"): NodeListOf; getElementsByTagName(name: "xmp"): NodeListOf; getElementsByTagName(name: string): NodeListOf; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; hasAttribute(name: string): boolean; hasAttributeNS(namespaceURI: string, localName: string): boolean; msGetRegionContent(): MSRangeCollection; @@ -3666,7 +3673,6 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitRequestFullscreen(): void; getElementsByClassName(classNames: string): NodeListOf; matches(selector: string): boolean; - getElementsByTagName(tagname: "picture"): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -3734,7 +3740,7 @@ interface Event { readonly eventPhase: number; readonly isTrusted: boolean; returnValue: boolean; - readonly srcElement: Element; + readonly srcElement: Element | null; readonly target: EventTarget; readonly timeStamp: number; readonly type: string; @@ -4029,7 +4035,7 @@ interface HTMLAppletElement extends HTMLElement { * Sets or retrieves the shape of the object. */ name: string; - object: string; + object: string | null; /** * Sets or retrieves a message to be displayed while an object is loading. */ @@ -6084,7 +6090,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag to specify whether playback should restart after it completes. */ loop: boolean; - readonly mediaKeys: MediaKeys; + readonly mediaKeys: MediaKeys | null; /** * Specifies the purpose of the audio or video media, such as background audio or alerts. */ @@ -6157,7 +6163,7 @@ interface HTMLMediaElement extends HTMLElement { * The address or URL of the a media resource that is to be considered. */ src: string; - srcObject: MediaStream; + srcObject: MediaStream | null; readonly textTracks: TextTrackList; readonly videoTracks: VideoTrackList; /** @@ -6195,7 +6201,7 @@ interface HTMLMediaElement extends HTMLElement { * Loads and starts playback of a media resource. */ play(): void; - setMediaKeys(mediaKeys: MediaKeys): PromiseLike; + setMediaKeys(mediaKeys: MediaKeys | null): PromiseLike; readonly HAVE_CURRENT_DATA: number; readonly HAVE_ENOUGH_DATA: number; readonly HAVE_FUTURE_DATA: number; @@ -7507,8 +7513,8 @@ declare var HTMLVideoElement: { } interface HashChangeEvent extends Event { - readonly newURL: string; - readonly oldURL: string; + readonly newURL: string | null; + readonly oldURL: string | null; } declare var HashChangeEvent: { @@ -7714,7 +7720,7 @@ declare var IDBTransaction: { } interface IDBVersionChangeEvent extends Event { - readonly newVersion: number; + readonly newVersion: number | null; readonly oldVersion: number; } @@ -7737,7 +7743,7 @@ declare var ImageData: { interface KeyboardEvent extends UIEvent { readonly altKey: boolean; - readonly char: string; + readonly char: string | null; readonly charCode: number; readonly ctrlKey: boolean; readonly key: string; @@ -8080,7 +8086,7 @@ declare var MSMediaKeyError: { } interface MSMediaKeyMessageEvent extends Event { - readonly destinationURL: string; + readonly destinationURL: string | null; readonly message: Uint8Array; } @@ -8090,7 +8096,7 @@ declare var MSMediaKeyMessageEvent: { } interface MSMediaKeyNeededEvent extends Event { - readonly initData: Uint8Array; + readonly initData: Uint8Array | null; } declare var MSMediaKeyNeededEvent: { @@ -8099,7 +8105,7 @@ declare var MSMediaKeyNeededEvent: { } interface MSMediaKeySession extends EventTarget { - readonly error: MSMediaKeyError; + readonly error: MSMediaKeyError | null; readonly keySystem: string; readonly sessionId: string; close(): void; @@ -8269,7 +8275,7 @@ declare var MediaElementAudioSourceNode: { } interface MediaEncryptedEvent extends Event { - readonly initData: ArrayBuffer; + readonly initData: ArrayBuffer | null; readonly initDataType: string; } @@ -8411,7 +8417,7 @@ interface MediaStream extends EventTarget { addTrack(track: MediaStreamTrack): void; clone(): MediaStream; getAudioTracks(): MediaStreamTrack[]; - getTrackById(trackId: string): MediaStreamTrack; + getTrackById(trackId: string): MediaStreamTrack | null; getTracks(): MediaStreamTrack[]; getVideoTracks(): MediaStreamTrack[]; removeTrack(track: MediaStreamTrack): void; @@ -8437,8 +8443,8 @@ declare var MediaStreamAudioSourceNode: { } interface MediaStreamError { - readonly constraintName: string; - readonly message: string; + readonly constraintName: string | null; + readonly message: string | null; readonly name: string; } @@ -8448,7 +8454,7 @@ declare var MediaStreamError: { } interface MediaStreamErrorEvent extends Event { - readonly error: MediaStreamError; + readonly error: MediaStreamError | null; } declare var MediaStreamErrorEvent: { @@ -8624,11 +8630,11 @@ declare var MutationObserver: { interface MutationRecord { readonly addedNodes: NodeList; - readonly attributeName: string; - readonly attributeNamespace: string; - readonly nextSibling: Node; - readonly oldValue: string; - readonly previousSibling: Node; + readonly attributeName: string | null; + readonly attributeNamespace: string | null; + readonly nextSibling: Node | null; + readonly oldValue: string | null; + readonly previousSibling: Node | null; readonly removedNodes: NodeList; readonly target: Node; readonly type: string; @@ -8642,10 +8648,10 @@ declare var MutationRecord: { interface NamedNodeMap { readonly length: number; getNamedItem(name: string): Attr; - getNamedItemNS(namespaceURI: string, localName: string): Attr; + getNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; item(index: number): Attr; removeNamedItem(name: string): Attr; - removeNamedItemNS(namespaceURI: string, localName: string): Attr; + removeNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; setNamedItem(arg: Attr): Attr; setNamedItemNS(arg: Attr): Attr; [index: number]: Attr; @@ -8711,33 +8717,33 @@ declare var Navigator: { interface Node extends EventTarget { readonly attributes: NamedNodeMap; - readonly baseURI: string; + readonly baseURI: string | null; readonly childNodes: NodeList; readonly firstChild: Node; readonly lastChild: Node; - readonly localName: string; - readonly namespaceURI: string; + readonly localName: string | null; + readonly namespaceURI: string | null; readonly nextSibling: Node; readonly nodeName: string; readonly nodeType: number; - nodeValue: string; + nodeValue: string | null; readonly ownerDocument: Document; readonly parentElement: HTMLElement; readonly parentNode: Node; readonly previousSibling: Node; - textContent: string; + textContent: string | null; appendChild(newChild: Node): Node; cloneNode(deep?: boolean): Node; compareDocumentPosition(other: Node): number; contains(child: Node): boolean; hasAttributes(): boolean; hasChildNodes(): boolean; - insertBefore(newChild: Node, refChild?: Node): Node; - isDefaultNamespace(namespaceURI: string): boolean; + insertBefore(newChild: Node, refChild: Node): Node; + isDefaultNamespace(namespaceURI: string | null): boolean; isEqualNode(arg: Node): boolean; isSameNode(other: Node): boolean; - lookupNamespaceURI(prefix: string): string; - lookupPrefix(namespaceURI: string): string; + lookupNamespaceURI(prefix: string | null): string | null; + lookupPrefix(namespaceURI: string | null): string | null; normalize(): void; removeChild(oldChild: Node): Node; replaceChild(newChild: Node, oldChild: Node): Node; @@ -8966,10 +8972,10 @@ interface PerfWidgetExternal { addEventListener(eventType: string, callback: Function): void; getMemoryUsage(): number; getProcessCpuUsage(): number; - getRecentCpuUsage(last: number): any; - getRecentFrames(last: number): any; - getRecentMemoryUsage(last: number): any; - getRecentPaintRequests(last: number): any; + getRecentCpuUsage(last: number | null): any; + getRecentFrames(last: number | null): any; + getRecentMemoryUsage(last: number | null): any; + getRecentPaintRequests(last: number | null): any; removeEventListener(eventType: string, callback: Function): void; repositionWindow(x: number, y: number): void; resizeWindow(width: number, height: number): void; @@ -9276,13 +9282,13 @@ declare var RTCDTMFToneChangeEvent: { } interface RTCDtlsTransport extends RTCStatsProvider { - ondtlsstatechange: (ev: RTCDtlsTransportStateChangedEvent) => any; - onerror: (ev: Event) => any; + ondtlsstatechange: ((ev: RTCDtlsTransportStateChangedEvent) => any) | null; + onerror: ((ev: Event) => any) | null; readonly state: string; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; getRemoteCertificates(): ArrayBuffer[]; - getRemoteParameters(): RTCDtlsParameters; + getRemoteParameters(): RTCDtlsParameters | null; start(remoteParameters: RTCDtlsParameters): void; stop(): void; addEventListener(type: "dtlsstatechange", listener: (ev: RTCDtlsTransportStateChangedEvent) => any, useCapture?: boolean): void; @@ -9332,8 +9338,8 @@ declare var RTCIceCandidatePairChangedEvent: { interface RTCIceGatherer extends RTCStatsProvider { readonly component: string; - onerror: (ev: Event) => any; - onlocalcandidate: (ev: RTCIceGathererEvent) => any; + onerror: ((ev: Event) => any) | null; + onlocalcandidate: ((ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; getLocalCandidates(): RTCIceCandidate[]; getLocalParameters(): RTCIceParameters; @@ -9358,16 +9364,16 @@ declare var RTCIceGathererEvent: { interface RTCIceTransport extends RTCStatsProvider { readonly component: string; - readonly iceGatherer: RTCIceGatherer; - oncandidatepairchange: (ev: RTCIceCandidatePairChangedEvent) => any; - onicestatechange: (ev: RTCIceTransportStateChangedEvent) => any; + readonly iceGatherer: RTCIceGatherer | null; + oncandidatepairchange: ((ev: RTCIceCandidatePairChangedEvent) => any) | null; + onicestatechange: ((ev: RTCIceTransportStateChangedEvent) => any) | null; readonly role: string; readonly state: string; addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; - getNominatedCandidatePair(): RTCIceCandidatePair; + getNominatedCandidatePair(): RTCIceCandidatePair | null; getRemoteCandidates(): RTCIceCandidate[]; - getRemoteParameters(): RTCIceParameters; + getRemoteParameters(): RTCIceParameters | null; setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; stop(): void; @@ -9391,9 +9397,9 @@ declare var RTCIceTransportStateChangedEvent: { } interface RTCRtpReceiver extends RTCStatsProvider { - onerror: (ev: Event) => any; + onerror: ((ev: Event) => any) | null; readonly rtcpTransport: RTCDtlsTransport; - readonly track: MediaStreamTrack; + readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; getContributingSources(): RTCRtpContributingSource[]; receive(parameters: RTCRtpParameters): void; @@ -9411,8 +9417,8 @@ declare var RTCRtpReceiver: { } interface RTCRtpSender extends RTCStatsProvider { - onerror: (ev: Event) => any; - onssrcconflict: (ev: RTCSsrcConflictEvent) => any; + onerror: ((ev: Event) => any) | null; + onssrcconflict: ((ev: RTCSsrcConflictEvent) => any) | null; readonly rtcpTransport: RTCDtlsTransport; readonly track: MediaStreamTrack; readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; @@ -9432,7 +9438,7 @@ declare var RTCRtpSender: { } interface RTCSrtpSdesTransport extends EventTarget { - onerror: (ev: Event) => any; + onerror: ((ev: Event) => any) | null; readonly transport: RTCIceTransport; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -11479,9 +11485,9 @@ interface SubtleCrypto { encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): PromiseLike; exportKey(format: string, key: CryptoKey): PromiseLike; generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): PromiseLike; - importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): PromiseLike; + importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm | null, extractable: boolean, keyUsages: string[]): PromiseLike; sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): PromiseLike; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): PromiseLike; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm | null, extractable: boolean, keyUsages: string[]): PromiseLike; verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): PromiseLike; wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): PromiseLike; } @@ -11615,7 +11621,7 @@ declare var TextTrackCueList: { interface TextTrackList extends EventTarget { readonly length: number; - onaddtrack: (ev: TrackEvent) => any; + onaddtrack: ((ev: TrackEvent) => any) | null; item(index: number): TextTrack; addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -11671,7 +11677,7 @@ declare var TouchEvent: { interface TouchList { readonly length: number; - item(index: number): Touch; + item(index: number): Touch | null; [index: number]: Touch; } @@ -11813,7 +11819,7 @@ interface VideoTrackList extends EventTarget { onchange: (ev: Event) => any; onremovetrack: (ev: TrackEvent) => any; readonly selectedIndex: number; - getTrackById(id: string): VideoTrack; + getTrackById(id: string): VideoTrack | null; item(index: number): VideoTrack; addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -11866,7 +11872,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: Float32Array; + curve: Float32Array | null; oversample: string; } @@ -11940,12 +11946,12 @@ interface WebGLRenderingContext { readonly drawingBufferHeight: number; readonly drawingBufferWidth: number; activeTexture(texture: number): void; - attachShader(program: WebGLProgram, shader: WebGLShader): void; - bindAttribLocation(program: WebGLProgram, index: number, name: string): void; - bindBuffer(target: number, buffer: WebGLBuffer): void; - bindFramebuffer(target: number, framebuffer: WebGLFramebuffer): void; - bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer): void; - bindTexture(target: number, texture: WebGLTexture): void; + attachShader(program: WebGLProgram | null, shader: WebGLShader | null): void; + bindAttribLocation(program: WebGLProgram | null, index: number, name: string): void; + bindBuffer(target: number, buffer: WebGLBuffer | null): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer | null): void; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer | null): void; + bindTexture(target: number, texture: WebGLTexture | null): void; blendColor(red: number, green: number, blue: number, alpha: number): void; blendEquation(mode: number): void; blendEquationSeparate(modeRGB: number, modeAlpha: number): void; @@ -11959,28 +11965,28 @@ interface WebGLRenderingContext { clearDepth(depth: number): void; clearStencil(s: number): void; colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; - compileShader(shader: WebGLShader): void; + compileShader(shader: WebGLShader | null): void; compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; - createBuffer(): WebGLBuffer; - createFramebuffer(): WebGLFramebuffer; - createProgram(): WebGLProgram; - createRenderbuffer(): WebGLRenderbuffer; - createShader(type: number): WebGLShader; - createTexture(): WebGLTexture; + createBuffer(): WebGLBuffer | null; + createFramebuffer(): WebGLFramebuffer | null; + createProgram(): WebGLProgram | null; + createRenderbuffer(): WebGLRenderbuffer | null; + createShader(type: number): WebGLShader | null; + createTexture(): WebGLTexture | null; cullFace(mode: number): void; - deleteBuffer(buffer: WebGLBuffer): void; - deleteFramebuffer(framebuffer: WebGLFramebuffer): void; - deleteProgram(program: WebGLProgram): void; - deleteRenderbuffer(renderbuffer: WebGLRenderbuffer): void; - deleteShader(shader: WebGLShader): void; - deleteTexture(texture: WebGLTexture): void; + deleteBuffer(buffer: WebGLBuffer | null): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer | null): void; + deleteProgram(program: WebGLProgram | null): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer | null): void; + deleteShader(shader: WebGLShader | null): void; + deleteTexture(texture: WebGLTexture | null): void; depthFunc(func: number): void; depthMask(flag: boolean): void; depthRange(zNear: number, zFar: number): void; - detachShader(program: WebGLProgram, shader: WebGLShader): void; + detachShader(program: WebGLProgram | null, shader: WebGLShader | null): void; disable(cap: number): void; disableVertexAttribArray(index: number): void; drawArrays(mode: number, first: number, count: number): void; @@ -11989,51 +11995,51 @@ interface WebGLRenderingContext { enableVertexAttribArray(index: number): void; finish(): void; flush(): void; - framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; - framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; + framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer | null): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture | null, level: number): void; frontFace(mode: number): void; generateMipmap(target: number): void; - getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; - getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; - getAttachedShaders(program: WebGLProgram): WebGLShader[]; - getAttribLocation(program: WebGLProgram, name: string): number; + getActiveAttrib(program: WebGLProgram | null, index: number): WebGLActiveInfo | null; + getActiveUniform(program: WebGLProgram | null, index: number): WebGLActiveInfo | null; + getAttachedShaders(program: WebGLProgram | null): WebGLShader[] | null; + getAttribLocation(program: WebGLProgram | null, name: string): number; getBufferParameter(target: number, pname: number): any; getContextAttributes(): WebGLContextAttributes; getError(): number; getExtension(name: string): any; getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): any; getParameter(pname: number): any; - getProgramInfoLog(program: WebGLProgram): string; - getProgramParameter(program: WebGLProgram, pname: number): any; + getProgramInfoLog(program: WebGLProgram | null): string | null; + getProgramParameter(program: WebGLProgram | null, pname: number): any; getRenderbufferParameter(target: number, pname: number): any; - getShaderInfoLog(shader: WebGLShader): string; - getShaderParameter(shader: WebGLShader, pname: number): any; - getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat; - getShaderSource(shader: WebGLShader): string; - getSupportedExtensions(): string[]; + getShaderInfoLog(shader: WebGLShader | null): string | null; + getShaderParameter(shader: WebGLShader | null, pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat | null; + getShaderSource(shader: WebGLShader | null): string | null; + getSupportedExtensions(): string[] | null; getTexParameter(target: number, pname: number): any; - getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; - getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation; + getUniform(program: WebGLProgram | null, location: WebGLUniformLocation | null): any; + getUniformLocation(program: WebGLProgram | null, name: string): WebGLUniformLocation | null; getVertexAttrib(index: number, pname: number): any; getVertexAttribOffset(index: number, pname: number): number; hint(target: number, mode: number): void; - isBuffer(buffer: WebGLBuffer): boolean; + isBuffer(buffer: WebGLBuffer | null): boolean; isContextLost(): boolean; isEnabled(cap: number): boolean; - isFramebuffer(framebuffer: WebGLFramebuffer): boolean; - isProgram(program: WebGLProgram): boolean; - isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; - isShader(shader: WebGLShader): boolean; - isTexture(texture: WebGLTexture): boolean; + isFramebuffer(framebuffer: WebGLFramebuffer | null): boolean; + isProgram(program: WebGLProgram | null): boolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer | null): boolean; + isShader(shader: WebGLShader | null): boolean; + isTexture(texture: WebGLTexture | null): boolean; lineWidth(width: number): void; - linkProgram(program: WebGLProgram): void; + linkProgram(program: WebGLProgram | null): void; pixelStorei(pname: number, param: number): void; polygonOffset(factor: number, units: number): void; - readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; sampleCoverage(value: number, invert: boolean): void; scissor(x: number, y: number, width: number, height: number): void; - shaderSource(shader: WebGLShader, source: string): void; + shaderSource(shader: WebGLShader | null, source: string): void; stencilFunc(func: number, ref: number, mask: number): void; stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; stencilMask(mask: number): void; @@ -12052,27 +12058,27 @@ interface WebGLRenderingContext { texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; - uniform1f(location: WebGLUniformLocation, x: number): void; + uniform1f(location: WebGLUniformLocation | null, x: number): void; uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; - uniform1i(location: WebGLUniformLocation, x: number): void; + uniform1i(location: WebGLUniformLocation | null, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; - uniform2f(location: WebGLUniformLocation, x: number, y: number): void; + uniform2f(location: WebGLUniformLocation | null, x: number, y: number): void; uniform2fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; - uniform2i(location: WebGLUniformLocation, x: number, y: number): void; + uniform2i(location: WebGLUniformLocation | null, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; - uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; + uniform3f(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; uniform3fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; - uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; + uniform3i(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; - uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + uniform4f(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; uniform4fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; - uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + uniform4i(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; - useProgram(program: WebGLProgram): void; - validateProgram(program: WebGLProgram): void; + useProgram(program: WebGLProgram | null): void; + validateProgram(program: WebGLProgram | null): void; vertexAttrib1f(indx: number, x: number): void; vertexAttrib1fv(indx: number, values: Float32Array | number[]): void; vertexAttrib2f(indx: number, x: number, y: number): void; @@ -12982,7 +12988,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window open(url?: string, target?: string, features?: string, replace?: boolean): Window; postMessage(message: any, targetOrigin: string, transfer?: any[]): void; print(): void; - prompt(message?: string, _default?: string): string; + prompt(message?: string, _default?: string): string | null; releaseEvents(): void; requestAnimationFrame(callback: FrameRequestCallback): number; resizeBy(x?: number, y?: number): void; @@ -13135,7 +13141,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { withCredentials: boolean; abort(): void; getAllResponseHeaders(): string; - getResponseHeader(header: string): string; + getResponseHeader(header: string): string | null; msCachingEnabled(): boolean; open(method: string, url: string, async?: boolean, user?: string, password?: string): void; overrideMimeType(mime: string): void; @@ -13659,14 +13665,6 @@ interface ProgressEventInit extends EventInit { total?: number; } -interface HTMLPictureElement extends HTMLElement { -} - -declare var HTMLPictureElement: { - prototype: HTMLPictureElement; - new(): HTMLPictureElement; -} - interface ClipboardEventInit extends EventInit { data?: string; dataType?: string; @@ -13880,7 +13878,7 @@ declare function msWriteProfilerMark(profilerMarkName: string): void; declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; declare function postMessage(message: any, targetOrigin: string, transfer?: any[]): void; declare function print(): void; -declare function prompt(message?: string, _default?: string): string; +declare function prompt(message?: string, _default?: string): string | null; declare function releaseEvents(): void; declare function requestAnimationFrame(callback: FrameRequestCallback): number; declare function resizeBy(x?: number, y?: number): void; diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index fc93847f8af..34833b9c70d 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -1,24 +1,24 @@ declare type PropertyKey = string | number | symbol; interface Array { - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: T) => boolean, thisArg?: any): number | undefined; @@ -26,21 +26,21 @@ interface Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: T, start?: number, end?: number): T[]; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): T[]; } @@ -114,7 +114,7 @@ interface Math { log1p(x: number): number; /** - * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of * the natural logarithms). * @param x A numeric expression. */ @@ -190,14 +190,14 @@ interface Math { interface NumberConstructor { /** * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 - * that is representable as a Number value, which is approximately: + * that is representable as a Number value, which is approximately: * 2.2204460492503130808472633361816 x 10‍−‍16. */ readonly EPSILON: number; /** * Returns true if passed value is finite. - * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a * number. Only finite values of the type number, result in true. * @param number A numeric value. */ @@ -210,7 +210,7 @@ interface NumberConstructor { isInteger(number: number): boolean; /** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter * to a number. Only values of the type number, that are also NaN, result in true. * @param number A numeric value. @@ -223,30 +223,30 @@ interface NumberConstructor { */ isSafeInteger(number: number): boolean; - /** - * The value of the largest integer n such that n and n + 1 are both exactly representable as - * a Number value. + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. */ readonly MAX_SAFE_INTEGER: number; - /** - * The value of the smallest integer n such that n and n − 1 are both exactly representable as - * a Number value. + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). */ readonly MIN_SAFE_INTEGER: number; /** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. */ parseFloat(string: string): number; /** * Converts A string to an integer. * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. * All other strings are considered decimal. */ @@ -255,12 +255,12 @@ interface NumberConstructor { interface Object { /** - * Determines whether an object has a property with the specified name. + * Determines whether an object has a property with the specified name. * @param v A property name. */ hasOwnProperty(v: PropertyKey): boolean - /** + /** * Determines whether a specified property is enumerable. * @param v A property name. */ @@ -269,7 +269,7 @@ interface Object { interface ObjectConstructor { /** - * Copy the values of all of the enumerable own properties from one or more source objects to a + * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. * @param target The target object to copy to. * @param source The source object from which to copy properties. @@ -277,7 +277,7 @@ interface ObjectConstructor { assign(target: T, source: U): T & U; /** - * Copy the values of all of the enumerable own properties from one or more source objects to a + * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. * @param target The target object to copy to. * @param source1 The first source object from which to copy properties. @@ -286,7 +286,7 @@ interface ObjectConstructor { assign(target: T, source1: U, source2: V): T & U & V; /** - * Copy the values of all of the enumerable own properties from one or more source objects to a + * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. * @param target The target object to copy to. * @param source1 The first source object from which to copy properties. @@ -296,7 +296,7 @@ interface ObjectConstructor { assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; /** - * Copy the values of all of the enumerable own properties from one or more source objects to a + * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. * @param target The target object to copy to. * @param sources One or more source objects from which to copy properties @@ -324,17 +324,17 @@ interface ObjectConstructor { setPrototypeOf(o: any, proto: any): any; /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not - * inherited from the object's prototype. + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. * @param o Object that contains the property. * @param p Name of the property. */ getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript * object (that is, a user-defined object or a built in object) or a DOM object. * @param p The property name. * @param attributes Descriptor for the property. It can be for a data property or an accessor @@ -358,47 +358,52 @@ interface RegExp { */ readonly flags: string; - /** - * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular - * expression. Default is false. Read-only. + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. */ readonly sticky: boolean; - /** - * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular - * expression. Default is false. Read-only. + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. */ readonly unicode: boolean; } +interface RegExpConstructor { + new (pattern: RegExp, flags?: string): RegExp; + (pattern: RegExp, flags?: string): RegExp; +} + interface String { /** - * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point - * value of the UTF-16 encoded code point starting at the string element at position pos in - * the String resulting from converting this object to a String. - * If there is no element at that position, the result is undefined. + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. */ codePointAt(pos: number): number | undefined; /** - * Returns true if searchString appears as a substring of the result of converting this - * object to a String, at one or more positions that are + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are * greater than or equal to position; otherwise, returns false. - * @param searchString search string + * @param searchString search string * @param position If position is undefined, 0 is assumed, so as to search all of the String. */ includes(searchString: string, position?: number): boolean; /** - * Returns true if the sequence of elements of searchString converted to a String is the - * same as the corresponding elements of this object (converted to a String) starting at + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at * endPosition – length(this). Otherwise returns false. */ endsWith(searchString: string, endPosition?: number): boolean; /** - * Returns the String value result of normalizing the string into the normalization form + * Returns the String value result of normalizing the string into the normalization form * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default * is "NFC" @@ -406,15 +411,15 @@ interface String { normalize(form?: string): string; /** - * Returns a String value that is made from count copies appended together. If count is 0, + * Returns a String value that is made from count copies appended together. If count is 0, * T is the empty String is returned. * @param count number of copies to append */ repeat(count: number): string; /** - * Returns true if the sequence of elements of searchString converted to a String is the - * same as the corresponding elements of this object (converted to a String) starting at + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at * position. Otherwise returns false. */ startsWith(searchString: string, position?: number): boolean; @@ -474,7 +479,7 @@ interface StringConstructor { /** * String.raw is intended for use as a tag function of a Tagged Template String. When called - * as such the first argument will be a well formed template call site object and the rest + * as such the first argument will be a well formed template call site object and the rest * parameter will contain the substitution values. * @param template A well-formed template string call site representation. * @param substitutions A set of substitution values. diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 17916d5548e..f450371f90d 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -6,7 +6,7 @@ declare const NaN: number; declare const Infinity: number; /** - * Evaluates JavaScript code and executes it. + * Evaluates JavaScript code and executes it. * @param x A String value that contains valid JavaScript code. */ declare function eval(x: string): any; @@ -14,25 +14,25 @@ declare function eval(x: string): any; /** * Converts A string to an integer. * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. * All other strings are considered decimal. */ declare function parseInt(s: string, radix?: number): number; /** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. */ declare function parseFloat(string: string): number; /** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). * @param number A numeric value. */ declare function isNaN(number: number): boolean; -/** +/** * Determines whether a supplied number is finite. * @param number Any numeric value. */ @@ -50,7 +50,7 @@ declare function decodeURI(encodedURI: string): string; */ declare function decodeURIComponent(encodedURIComponent: string): string; -/** +/** * Encodes a text string as a valid Uniform Resource Identifier (URI) * @param uri A value representing an encoded URI. */ @@ -89,18 +89,18 @@ interface Object { valueOf(): Object; /** - * Determines whether an object has a property with the specified name. + * Determines whether an object has a property with the specified name. * @param v A property name. */ hasOwnProperty(v: string): boolean; /** - * Determines whether an object exists in another object's prototype chain. + * Determines whether an object exists in another object's prototype chain. * @param v Another object whose prototype chain is to be checked. */ isPrototypeOf(v: Object): boolean; - /** + /** * Determines whether a specified property is enumerable. * @param v A property name. */ @@ -115,36 +115,36 @@ interface ObjectConstructor { /** A reference to the prototype for a class of objects. */ readonly prototype: Object; - /** - * Returns the prototype of an object. + /** + * Returns the prototype of an object. * @param o The object that references the prototype. */ getPrototypeOf(o: any): any; /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. * @param o Object that contains the property. * @param p Name of the property. */ getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; - /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. * @param o Object that contains the own properties. */ getOwnPropertyNames(o: any): string[]; - /** + /** * Creates an object that has the specified prototype, and that optionally contains specified properties. * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. + * @param properties JavaScript object that contains one or more property descriptors. */ create(o: any, properties?: PropertyDescriptorMap): any; /** - * Adds a property to an object, or modifies attributes of an existing property. + * Adds a property to an object, or modifies attributes of an existing property. * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. * @param p The property name. * @param attributes Descriptor for the property. It can be for a data property or an accessor property. @@ -152,7 +152,7 @@ interface ObjectConstructor { defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * Adds one or more properties to an object, and/or modifies attributes of existing properties. * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. */ @@ -160,7 +160,7 @@ interface ObjectConstructor { /** * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. + * @param o Object on which to lock the attributes. */ seal(o: T): T; @@ -172,25 +172,25 @@ interface ObjectConstructor { /** * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. + * @param o Object to make non-extensible. */ preventExtensions(o: T): T; /** * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. + * @param o Object to test. */ isSealed(o: any): boolean; /** * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. + * @param o Object to test. */ isFrozen(o: any): boolean; /** * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. + * @param o Object to test. */ isExtensible(o: any): boolean; @@ -215,7 +215,6 @@ interface Function { * @param thisArg The object to be used as the this object. * @param argArray A set of arguments to be passed to the function. */ - apply(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; apply(this: Function, thisArg: any, argArray?: any): any; /** @@ -223,16 +222,14 @@ interface Function { * @param thisArg The object to be used as the current object. * @param argArray A list of arguments to be passed to the method. */ - call(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; call(this: Function, thisArg: any, ...argArray: any[]): any; /** - * For a given function, creates a bound function that has the same body as the original function. + * For a given function, creates a bound function that has the same body as the original function. * The this object of the bound function is associated with the specified object, and has the specified initial parameters. * @param thisArg An object to which the this keyword can refer inside the new function. * @param argArray A list of arguments to be passed to the new function. */ - bind(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): (this: void, ...argArray: any[]) => U; bind(this: Function, thisArg: any, ...argArray: any[]): any; prototype: any; @@ -271,7 +268,7 @@ interface String { */ charAt(pos: number): string; - /** + /** * Returns the Unicode value of the character at the specified location. * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. */ @@ -279,12 +276,12 @@ interface String { /** * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. + * @param strings The strings to append to the end of the string. */ concat(...strings: string[]): string; /** - * Returns the position of the first occurrence of a substring. + * Returns the position of the first occurrence of a substring. * @param searchString The substring to search for in the string * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. */ @@ -303,15 +300,15 @@ interface String { */ localeCompare(that: string): number; - /** + /** * Matches a string with a regular expression, and returns an array containing the results of that search. * @param regexp A variable name or string literal containing the regular expression pattern and flags. */ match(regexp: string): RegExpMatchArray | null; - /** + /** * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. */ match(regexp: RegExp): RegExpMatchArray | null; @@ -345,40 +342,40 @@ interface String { /** * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. + * @param regexp The regular expression pattern and applicable flags. */ search(regexp: string): number; /** * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. + * @param regexp The regular expression pattern and applicable flags. */ search(regexp: RegExp): number; /** * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. * If this value is not specified, the substring continues to the end of stringObj. */ slice(start?: number, end?: number): string; /** * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. * @param limit A value used to limit the number of elements returned in the array. */ split(separator: string, limit?: number): string[]; /** * Split a string into substrings using the specified separator and return them as an array. - * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. * @param limit A value used to limit the number of elements returned in the array. */ split(separator: RegExp, limit?: number): string[]; /** - * Returns the substring at the specified location within a String object. + * Returns the substring at the specified location within a String object. * @param start The zero-based index number indicating the beginning of the substring. * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. * If end is omitted, the characters from start through the end of the original string are returned. @@ -424,8 +421,8 @@ interface StringConstructor { fromCharCode(...codes: number[]): string; } -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. */ declare const String: StringConstructor; @@ -449,7 +446,7 @@ interface Number { */ toString(radix?: number): string; - /** + /** * Returns a string representing a number in fixed-point notation. * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. */ @@ -482,21 +479,21 @@ interface NumberConstructor { /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ readonly MIN_VALUE: number; - /** + /** * A value that is not a number. * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. */ readonly NaN: number; - /** + /** * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. */ readonly NEGATIVE_INFINITY: number; /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. */ readonly POSITIVE_INFINITY: number; } @@ -526,23 +523,23 @@ interface Math { /** The square root of 2. */ readonly SQRT2: number; /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). * For example, the absolute value of -5 is the same as the absolute value of 5. * @param x A numeric expression for which the absolute value is needed. */ abs(x: number): number; /** - * Returns the arc cosine (or inverse cosine) of a number. + * Returns the arc cosine (or inverse cosine) of a number. * @param x A numeric expression. */ acos(x: number): number; - /** - * Returns the arcsine of a number. + /** + * Returns the arcsine of a number. * @param x A numeric expression. */ asin(x: number): number; /** - * Returns the arctangent of a number. + * Returns the arctangent of a number. * @param x A numeric expression for which the arctangent is needed. */ atan(x: number): number; @@ -553,49 +550,49 @@ interface Math { */ atan2(y: number, x: number): number; /** - * Returns the smallest number greater than or equal to its numeric argument. + * Returns the smallest number greater than or equal to its numeric argument. * @param x A numeric expression. */ ceil(x: number): number; /** - * Returns the cosine of a number. + * Returns the cosine of a number. * @param x A numeric expression that contains an angle measured in radians. */ cos(x: number): number; /** - * Returns e (the base of natural logarithms) raised to a power. + * Returns e (the base of natural logarithms) raised to a power. * @param x A numeric expression representing the power of e. */ exp(x: number): number; /** - * Returns the greatest number less than or equal to its numeric argument. + * Returns the greatest number less than or equal to its numeric argument. * @param x A numeric expression. */ floor(x: number): number; /** - * Returns the natural logarithm (base e) of a number. + * Returns the natural logarithm (base e) of a number. * @param x A numeric expression. */ log(x: number): number; /** - * Returns the larger of a set of supplied numeric expressions. + * Returns the larger of a set of supplied numeric expressions. * @param values Numeric expressions to be evaluated. */ max(...values: number[]): number; /** - * Returns the smaller of a set of supplied numeric expressions. + * Returns the smaller of a set of supplied numeric expressions. * @param values Numeric expressions to be evaluated. */ min(...values: number[]): number; /** - * Returns the value of a base expression taken to a specified power. + * Returns the value of a base expression taken to a specified power. * @param x The base value of the expression. * @param y The exponent value of the expression. */ pow(x: number, y: number): number; /** Returns a pseudorandom number between 0 and 1. */ random(): number; - /** + /** * Returns a supplied numeric expression rounded to the nearest number. * @param x The value to be rounded to the nearest number. */ @@ -671,24 +668,24 @@ interface Date { getUTCMilliseconds(): number; /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ getTimezoneOffset(): number; - /** + /** * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. */ setTime(time: number): number; /** - * Sets the milliseconds value in the Date object using local time. + * Sets the milliseconds value in the Date object using local time. * @param ms A numeric value equal to the millisecond value. */ setMilliseconds(ms: number): number; - /** + /** * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). - * @param ms A numeric value equal to the millisecond value. + * @param ms A numeric value equal to the millisecond value. */ setUTCMilliseconds(ms: number): number; /** - * Sets the seconds value in the Date object using local time. + * Sets the seconds value in the Date object using local time. * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ @@ -700,16 +697,16 @@ interface Date { */ setUTCSeconds(sec: number, ms?: number): number; /** - * Sets the minutes value in the Date object using local time. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ setMinutes(min: number, sec?: number, ms?: number): number; /** * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ setUTCMinutes(min: number, sec?: number, ms?: number): number; @@ -717,7 +714,7 @@ interface Date { * Sets the hour value in the Date object using local time. * @param hours A numeric value equal to the hours value. * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. + * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ setHours(hours: number, min?: number, sec?: number, ms?: number): number; @@ -725,23 +722,23 @@ interface Date { * Sets the hours value in the Date object using Universal Coordinated Time (UTC). * @param hours A numeric value equal to the hours value. * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. + * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; /** - * Sets the numeric day-of-the-month value of the Date object using local time. + * Sets the numeric day-of-the-month value of the Date object using local time. * @param date A numeric value equal to the day of the month. */ setDate(date: number): number; - /** + /** * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). - * @param date A numeric value equal to the day of the month. + * @param date A numeric value equal to the day of the month. */ setUTCDate(date: number): number; - /** - * Sets the month value in the Date object using local time. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. */ setMonth(month: number, date?: number): number; @@ -786,7 +783,7 @@ interface DateConstructor { */ parse(s: string): number; /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. * @param month The month as an number between 0 and 11 (January to December). * @param date The date as an number between 1 and 31. @@ -812,13 +809,13 @@ interface RegExpExecArray extends Array { } interface RegExp { - /** + /** * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. * @param string The String object or string literal on which to perform the search. */ exec(string: string): RegExpExecArray | null; - /** + /** * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. * @param string String on which to perform the search. */ @@ -843,7 +840,9 @@ interface RegExp { } interface RegExpConstructor { + new (pattern: RegExp): RegExp; new (pattern: string, flags?: string): RegExp; + (pattern: RegExp): RegExp; (pattern: string, flags?: string): RegExp; readonly prototype: RegExp; @@ -945,8 +944,8 @@ interface JSON { /** * Converts a JavaScript Object Notation (JSON) string into an object. * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. */ parse(text: string, reviver?: (key: any, value: any) => any): any; /** @@ -1049,19 +1048,19 @@ interface ReadonlyArray { some(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => any, thisArg?: any): T[]; @@ -1079,13 +1078,13 @@ interface ReadonlyArray { reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; /** * Calls the specified callback function for all the elements in an array, in descending order. 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; @@ -1123,14 +1122,14 @@ interface Array { */ join(separator?: string): string; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): T[]; /** * Removes the first element from an array and returns it. */ shift(): T | undefined; - /** + /** * 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. @@ -1184,19 +1183,19 @@ interface Array { some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; @@ -1212,15 +1211,15 @@ interface Array { * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - /** + /** * Calls the specified callback function for all the elements in an array, in descending order. 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** + /** * Calls the specified callback function for all the elements in an array, in descending order. 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; @@ -1274,10 +1273,10 @@ interface ArrayLike { } /** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. */ interface ArrayBuffer { /** @@ -1300,7 +1299,7 @@ declare const ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -1320,124 +1319,124 @@ interface DataView { readonly byteLength: number; readonly byteOffset: number; /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getFloat32(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getFloat64(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getInt8(byteOffset: number): number; /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getInt16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getInt32(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getUint8(byteOffset: number): number; /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getUint16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getUint32(byteOffset: number, littleEndian?: boolean): number; /** - * Stores an Float32 value at the specified byte offset from the start of the view. + * Stores an Float32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Float64 value at the specified byte offset from the start of the view. + * Stores an Float64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int8 value at the specified byte offset from the start of the view. + * Stores an Int8 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. */ setInt8(byteOffset: number, value: number): void; /** - * Stores an Int16 value at the specified byte offset from the start of the view. + * Stores an Int16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int32 value at the specified byte offset from the start of the view. + * Stores an Int32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint8 value at the specified byte offset from the start of the view. + * Stores an Uint8 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. */ setUint8(byteOffset: number, value: number): void; /** - * Stores an Uint16 value at the specified byte offset from the start of the view. + * Stores an Uint16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint32 value at the specified byte offset from the start of the view. + * Stores an Uint32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1449,17 +1448,17 @@ interface DataViewConstructor { declare const DataView: DataViewConstructor; /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Int8Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBuffer; @@ -1473,21 +1472,21 @@ interface Int8Array { */ readonly byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Int8Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -1497,49 +1496,49 @@ interface Int8Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Int8Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; @@ -1554,7 +1553,7 @@ interface Int8Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -1562,7 +1561,7 @@ interface Int8Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -1573,65 +1572,65 @@ interface Int8Array { readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue 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. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Int8Array; @@ -1649,7 +1648,7 @@ interface Int8Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * 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. @@ -1658,31 +1657,31 @@ interface Int8Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Int8Array; /** * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * 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): Int8Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -1700,7 +1699,7 @@ interface Int8ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -1709,7 +1708,7 @@ interface Int8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int8Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -1722,17 +1721,17 @@ interface Int8ArrayConstructor { declare const Int8Array: Int8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBuffer; @@ -1746,21 +1745,21 @@ interface Uint8Array { */ readonly byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Uint8Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -1770,49 +1769,49 @@ interface Uint8Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Uint8Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; @@ -1827,7 +1826,7 @@ interface Uint8Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -1835,7 +1834,7 @@ interface Uint8Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -1846,65 +1845,65 @@ interface Uint8Array { readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue 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. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Uint8Array; @@ -1922,7 +1921,7 @@ interface Uint8Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * 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. @@ -1931,31 +1930,31 @@ interface Uint8Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Uint8Array; /** * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * 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): Uint8Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -1974,7 +1973,7 @@ interface Uint8ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -1983,7 +1982,7 @@ interface Uint8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint8Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -1996,17 +1995,17 @@ interface Uint8ArrayConstructor { declare const Uint8Array: Uint8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBuffer; @@ -2020,21 +2019,21 @@ interface Uint8ClampedArray { */ readonly byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -2044,49 +2043,49 @@ interface Uint8ClampedArray { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Uint8ClampedArray; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; @@ -2101,7 +2100,7 @@ interface Uint8ClampedArray { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -2109,7 +2108,7 @@ interface Uint8ClampedArray { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -2120,65 +2119,65 @@ interface Uint8ClampedArray { readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue 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. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Uint8ClampedArray; @@ -2196,7 +2195,7 @@ interface Uint8ClampedArray { */ set(array: Uint8ClampedArray, offset?: number): void; - /** + /** * 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. @@ -2205,31 +2204,31 @@ interface Uint8ClampedArray { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; /** * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * 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): Uint8ClampedArray; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -2248,7 +2247,7 @@ interface Uint8ClampedArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -2269,17 +2268,17 @@ interface Uint8ClampedArrayConstructor { declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBuffer; @@ -2293,21 +2292,21 @@ interface Int16Array { */ readonly byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Int16Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -2317,49 +2316,49 @@ interface Int16Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Int16Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; @@ -2374,7 +2373,7 @@ interface Int16Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -2382,7 +2381,7 @@ interface Int16Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -2393,65 +2392,65 @@ interface Int16Array { readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue 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. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Int16Array; @@ -2469,7 +2468,7 @@ interface Int16Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * 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. @@ -2478,31 +2477,31 @@ interface Int16Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Int16Array; /** * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * 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): Int16Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -2521,7 +2520,7 @@ interface Int16ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -2530,7 +2529,7 @@ interface Int16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int16Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -2543,17 +2542,17 @@ interface Int16ArrayConstructor { declare const Int16Array: Int16ArrayConstructor; /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBuffer; @@ -2567,21 +2566,21 @@ interface Uint16Array { */ readonly byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Uint16Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -2591,49 +2590,49 @@ interface Uint16Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Uint16Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; @@ -2648,7 +2647,7 @@ interface Uint16Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -2656,7 +2655,7 @@ interface Uint16Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -2667,65 +2666,65 @@ interface Uint16Array { readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue 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. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Uint16Array; @@ -2743,7 +2742,7 @@ interface Uint16Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * 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. @@ -2752,31 +2751,31 @@ interface Uint16Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Uint16Array; /** * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * 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): Uint16Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -2795,7 +2794,7 @@ interface Uint16ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -2804,7 +2803,7 @@ interface Uint16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint16Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -2816,17 +2815,17 @@ interface Uint16ArrayConstructor { } declare const Uint16Array: Uint16ArrayConstructor; /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBuffer; @@ -2840,21 +2839,21 @@ interface Int32Array { */ readonly byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Int32Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -2864,49 +2863,49 @@ interface Int32Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Int32Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; @@ -2921,7 +2920,7 @@ interface Int32Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -2929,7 +2928,7 @@ interface Int32Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -2940,65 +2939,65 @@ interface Int32Array { readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue 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. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Int32Array; @@ -3016,7 +3015,7 @@ interface Int32Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * 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. @@ -3025,31 +3024,31 @@ interface Int32Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Int32Array; /** * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * 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): Int32Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -3068,7 +3067,7 @@ interface Int32ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -3077,7 +3076,7 @@ interface Int32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int32Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -3089,17 +3088,17 @@ interface Int32ArrayConstructor { declare const Int32Array: Int32ArrayConstructor; /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBuffer; @@ -3113,21 +3112,21 @@ interface Uint32Array { */ readonly byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Uint32Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -3137,49 +3136,49 @@ interface Uint32Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Uint32Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; @@ -3194,7 +3193,7 @@ interface Uint32Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -3202,7 +3201,7 @@ interface Uint32Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -3213,65 +3212,65 @@ interface Uint32Array { readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue 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. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Uint32Array; @@ -3289,7 +3288,7 @@ interface Uint32Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * 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. @@ -3298,31 +3297,31 @@ interface Uint32Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Uint32Array; /** * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * 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): Uint32Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -3341,7 +3340,7 @@ interface Uint32ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -3350,7 +3349,7 @@ interface Uint32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint32Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -3367,12 +3366,12 @@ declare const Uint32Array: Uint32ArrayConstructor; */ interface Float32Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBuffer; @@ -3386,21 +3385,21 @@ interface Float32Array { */ readonly byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Float32Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -3410,49 +3409,49 @@ interface Float32Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Float32Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; @@ -3467,7 +3466,7 @@ interface Float32Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -3475,7 +3474,7 @@ interface Float32Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -3486,65 +3485,65 @@ interface Float32Array { readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue 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. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Float32Array; @@ -3562,7 +3561,7 @@ interface Float32Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * 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. @@ -3571,31 +3570,31 @@ interface Float32Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Float32Array; /** * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * 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): Float32Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -3614,7 +3613,7 @@ interface Float32ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -3623,7 +3622,7 @@ interface Float32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float32Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -3636,17 +3635,17 @@ interface Float32ArrayConstructor { declare const Float32Array: Float32ArrayConstructor; /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBuffer; @@ -3660,21 +3659,21 @@ interface Float64Array { */ readonly byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Float64Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -3684,49 +3683,49 @@ interface Float64Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Float64Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; @@ -3741,7 +3740,7 @@ interface Float64Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -3749,7 +3748,7 @@ interface Float64Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -3760,65 +3759,65 @@ interface Float64Array { readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue 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. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; /** - * 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 + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param initialValue 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. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue 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 + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * 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. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue 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. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Float64Array; @@ -3836,7 +3835,7 @@ interface Float64Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * 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. @@ -3845,31 +3844,31 @@ interface Float64Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Float64Array; /** * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * 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; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -3888,7 +3887,7 @@ interface Float64ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -3897,7 +3896,7 @@ interface Float64ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float64Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -3909,7 +3908,7 @@ interface Float64ArrayConstructor { declare const Float64Array: Float64ArrayConstructor; ///////////////////////////// -/// ECMAScript Internationalization API +/// ECMAScript Internationalization API ///////////////////////////// declare module Intl { @@ -4052,14 +4051,14 @@ interface String { interface Number { /** - * Converts a number to a string by using the current or specified locale. + * Converts a number to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; /** - * Converts a number to a string by using the current or specified locale. + * Converts a number to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ @@ -4068,41 +4067,41 @@ interface Number { interface Date { /** - * Converts a date and time to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a date to a string by using the current or specified locale. + * Converts a date to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a time to a string by using the current or specified locale. + * Converts a time to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; - + /** - * Converts a date and time to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; - + /** - * Converts a date to a string by using the current or specified locale. + * Converts a date to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; /** - * Converts a time to a string by using the current or specified locale. + * Converts a time to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 2b302dea6a2..f5c77b8594d 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -8,6 +8,16 @@ interface EventInit { cancelable?: boolean; } +interface IDBIndexParameters { + multiEntry?: boolean; + unique?: boolean; +} + +interface IDBObjectStoreParameters { + autoIncrement?: boolean; + keyPath?: IDBKeyPath; +} + interface EventListener { (evt: Event): void; } @@ -84,12 +94,12 @@ declare var Console: { interface Coordinates { readonly accuracy: number; - readonly altitude: number; - readonly altitudeAccuracy: number; - readonly heading: number; + readonly altitude: number | null; + readonly altitudeAccuracy: number | null; + readonly heading: number | null; readonly latitude: number; readonly longitude: number; - readonly speed: number; + readonly speed: number | null; } declare var Coordinates: { @@ -176,7 +186,7 @@ declare var DOMException: { interface DOMStringList { readonly length: number; contains(str: string): boolean; - item(index: number): string; + item(index: number): string | null; [index: number]: string; } @@ -459,7 +469,7 @@ declare var IDBTransaction: { } interface IDBVersionChangeEvent extends Event { - readonly newVersion: number; + readonly newVersion: number | null; readonly oldVersion: number; } @@ -712,7 +722,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { withCredentials: boolean; abort(): void; getAllResponseHeaders(): string; - getResponseHeader(header: string): string; + getResponseHeader(header: string): string | null; msCachingEnabled(): boolean; open(method: string, url: string, async?: boolean, user?: string, password?: string): void; overrideMimeType(mime: string): void; @@ -991,4 +1001,5 @@ declare var console: Console; declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +type IDBKeyPath = string; type IDBValidKey = number | string | Date | IDBArrayKey; \ No newline at end of file diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index c4d4a23ebfa..02fe374471b 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -919,6 +919,7 @@ namespace ts.server { configuredProject.updateGraph(); if (configuredProject.getSourceFile(info)) { info.defaultProject = configuredProject; + referencingProjects.push(configuredProject); } } return referencingProjects; @@ -1684,7 +1685,12 @@ namespace ts.server { } reloadFromFile(filename: string, cb?: () => any) { - const content = this.host.readFile(filename); + let content = this.host.readFile(filename); + // If the file doesn't exist or cannot be read, we should + // wipe out its cached content on the server to avoid side effects. + if (!content) { + content = ""; + } this.reload(content); if (cb) cb(); diff --git a/src/server/server.ts b/src/server/server.ts index 3ffd64fe07d..ec83f8cc716 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -153,6 +153,98 @@ namespace ts.server { // This places log file in the directory containing editorServices.js // TODO: check that this location is writable + // average async stat takes about 30 microseconds + // set chunk size to do 30 files in < 1 millisecond + function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) { + let watchedFiles: WatchedFile[] = []; + let nextFileToCheck = 0; + let watchTimer: any; + + function getModifiedTime(fileName: string): Date { + return fs.statSync(fileName).mtime; + } + + function poll(checkedIndex: number) { + const watchedFile = watchedFiles[checkedIndex]; + if (!watchedFile) { + return; + } + + fs.stat(watchedFile.fileName, (err: any, stats: any) => { + if (err) { + watchedFile.callback(watchedFile.fileName); + } + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { + watchedFile.mtime = getModifiedTime(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + } + }); + } + + // this implementation uses polling and + // stat due to inconsistencies of fs.watch + // and efficiency of stat on modern filesystems + function startWatchTimer() { + watchTimer = setInterval(() => { + let count = 0; + let nextToCheck = nextFileToCheck; + let firstCheck = -1; + while ((count < chunkSize) && (nextToCheck !== firstCheck)) { + poll(nextToCheck); + if (firstCheck < 0) { + firstCheck = nextToCheck; + } + nextToCheck++; + if (nextToCheck === watchedFiles.length) { + nextToCheck = 0; + } + count++; + } + nextFileToCheck = nextToCheck; + }, interval); + } + + function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile { + const file: WatchedFile = { + fileName, + callback, + mtime: getModifiedTime(fileName) + }; + + watchedFiles.push(file); + if (watchedFiles.length === 1) { + startWatchTimer(); + } + return file; + } + + function removeFile(file: WatchedFile) { + watchedFiles = copyListRemovingItem(file, watchedFiles); + } + + return { + getModifiedTime: getModifiedTime, + poll: poll, + startWatchTimer: startWatchTimer, + addFile: addFile, + removeFile: removeFile + }; + } + + // REVIEW: for now this implementation uses polling. + // The advantage of polling is that it works reliably + // on all os and with network mounted files. + // For 90 referenced files, the average time to detect + // changes is 2*msInterval (by default 5 seconds). + // The overhead of this is .04 percent (1/2500) with + // average pause of < 1 millisecond (and max + // pause less than 1.5 milliseconds); question is + // do we anticipate reference sets in the 100s and + // do we care about waiting 10-20 seconds to detect + // changes for large reference sets? If so, do we want + // to increase the chunk size or decrease the interval + // time dynamically to match the large reference set? + const pollingWatchedFileSet = createPollingWatchedFileSet(); const logger = createLoggerFromEnv(); const pending: string[] = []; @@ -176,6 +268,12 @@ namespace ts.server { // Override sys.write because fs.writeSync is not reliable on Node 4 ts.sys.write = (s: string) => writeMessage(s); + ts.sys.watchFile = (fileName, callback) => { + const watchedFile = pollingWatchedFileSet.addFile(fileName, callback); + return { + close: () => pollingWatchedFileSet.removeFile(watchedFile) + }; + }; const ioSession = new IOSession(ts.sys, logger); process.on("uncaughtException", function(err: Error) { diff --git a/src/server/session.ts b/src/server/session.ts index df8273116c1..e043fff2246 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -647,7 +647,7 @@ namespace ts.server { const editorOptions: ts.EditorOptions = { IndentSize: formatOptions.IndentSize, TabSize: formatOptions.TabSize, - NewLineCharacter: "\n", + NewLineCharacter: formatOptions.NewLineCharacter, ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, IndentStyle: ts.IndentStyle.Smart, }; diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 1d7e968444e..d83d0738ec8 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -758,9 +758,6 @@ namespace ts.NavigationBar { else if (fnExpr.parent.kind === SyntaxKind.BinaryExpression && (fnExpr.parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken) { fnName = (fnExpr.parent as BinaryExpression).left.getText(); - if (fnName.length > 20) { - fnName = fnName.substring(0, 17) + "..."; - } } // See if it is a property assignment, and if so use the property name else if (fnExpr.parent.kind === SyntaxKind.PropertyAssignment && diff --git a/src/services/services.ts b/src/services/services.ts index c37224d6984..c28530b8de3 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1049,7 +1049,7 @@ namespace ts { getScriptFileNames(): string[]; getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; - getScriptSnapshot(fileName: string): IScriptSnapshot; + getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4913,8 +4913,8 @@ namespace ts { node.kind === SyntaxKind.ThisKeyword || node.kind === SyntaxKind.ThisType || node.kind === SyntaxKind.SuperKeyword || - isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { + node.kind === SyntaxKind.StringLiteral || + isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { const referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false); return convertReferencedSymbols(referencedSymbols); @@ -5581,8 +5581,8 @@ namespace ts { // TODO (drosen): This should be enabled in a later release - currently breaks rename. // node.kind !== SyntaxKind.ThisKeyword && // node.kind !== SyntaxKind.SuperKeyword && - !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && - !isNameOfExternalModuleImportOrDeclaration(node)) { + node.kind !== SyntaxKind.StringLiteral && + !isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return undefined; } @@ -5617,6 +5617,10 @@ namespace ts { const symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol && node.kind === SyntaxKind.StringLiteral) { + return getReferencesForStringLiteral(node, sourceFiles); + } + // Could not find a symbol e.g. unknown identifier if (!symbol) { // Can't have references to something that we have no symbol for. @@ -6174,6 +6178,52 @@ namespace ts { } } + + function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[]): ReferencedSymbol[] { + const typeChecker = program.getTypeChecker(); + const type = getStringLiteralTypeForNode(node, typeChecker); + + if (!type) { + // nothing to do here. moving on + return undefined; + } + + const references: ReferenceEntry[] = []; + + for (const sourceFile of sourceFiles) { + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ScriptElementKind.variableElement, + name: type.text, + textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()) + }, + references: references + }]; + + function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: ReferenceEntry[]): void { + for (const position of possiblePositions) { + cancellationToken.throwIfCancellationRequested(); + + const node = getTouchingWord(sourceFile, position); + if (!node || node.kind !== SyntaxKind.StringLiteral) { + return; + } + + const type = getStringLiteralTypeForNode(node, typeChecker); + if (type === searchType) { + references.push(getReferenceEntryFromNode(node)); + } + } + } + } + function populateSearchSymbolSet(symbol: Symbol, location: Node): Symbol[] { // The search set contains at least the current symbol let result = [symbol]; @@ -7694,6 +7744,14 @@ namespace ts { } } + function getStringLiteralTypeForNode(node: StringLiteral | StringLiteralTypeNode, typeChecker: TypeChecker): StringLiteralType { + const searchNode = node.parent.kind === SyntaxKind.StringLiteralType ? node.parent : node; + const type = typeChecker.getTypeAtLocation(searchNode); + if (type && type.flags & TypeFlags.StringLiteral) { + return type; + } + return undefined; + } function getRenameInfo(fileName: string, position: number): RenameInfo { synchronizeHostData(); @@ -7701,46 +7759,60 @@ namespace ts { const sourceFile = getValidSourceFile(fileName); const typeChecker = program.getTypeChecker(); + const defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); + const canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); // Can only rename an identifier. - if (node && node.kind === SyntaxKind.Identifier) { - const symbol = typeChecker.getSymbolAtLocation(node); + if (node) { + if (node.kind === SyntaxKind.Identifier || + node.kind === SyntaxKind.StringLiteral || + isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + const symbol = typeChecker.getSymbolAtLocation(node); - // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - const declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - const defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - const canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); - if (defaultLibFileName) { - for (const current of declarations) { - const sourceFile = current.getSourceFile(); - // TODO (drosen): When is there no source file? - if (!sourceFile) { - continue; - } + // Only allow a symbol to be renamed if it actually has at least one declaration. + if (symbol) { + const declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + // Disallow rename for elements that are defined in the standard TypeScript library. + if (forEach(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); + } - const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } + const displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); + const kind = getSymbolKind(symbol, node); + if (kind) { + return { + canRename: true, + kind, + displayName, + localizedErrorMessage: undefined, + fullDisplayName: typeChecker.getFullyQualifiedName(symbol), + kindModifiers: getSymbolModifiers(symbol), + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; } } - - const displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); - const kind = getSymbolKind(symbol, node); - if (kind) { - return { - canRename: true, - kind, - displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: getSymbolModifiers(symbol), - triggerSpan: createTextSpan(node.getStart(), node.getWidth()) - }; + } + else if (node.kind === SyntaxKind.StringLiteral) { + const type = getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); + } + else { + const displayName = stripQuotes(type.text); + return { + canRename: true, + kind: ScriptElementKind.variableElement, + displayName, + localizedErrorMessage: undefined, + fullDisplayName: displayName, + kindModifiers: ScriptElementKindModifier.none, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } } } } @@ -7759,6 +7831,28 @@ namespace ts { triggerSpan: undefined }; } + + function isDefinedInLibraryFile(declaration: Node) { + if (defaultLibFileName) { + const sourceFile = declaration.getSourceFile(); + const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); + if (canonicalName === canonicalDefaultLibName) { + return true; + } + } + return false; + } + + function createTriggerSpanForNode(node: Node, sourceFile: SourceFile) { + let start = node.getStart(sourceFile); + let width = node.getWidth(sourceFile); + if (node.kind === SyntaxKind.StringLiteral) { + // Exclude the quotes + start += 1; + width -= 2; + } + return createTextSpan(start, width); + } } return { diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 62b201976cd..4e563c7cac3 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -55,7 +55,7 @@ export function delint(sourceFile: ts.SourceFile) { } } -const fileNames = process.argv.slice(2); +const fileNames: string[] = process.argv.slice(2); fileNames.forEach(fileName => { // Parse a file let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); diff --git a/tests/baselines/reference/APISample_parseConfig.js b/tests/baselines/reference/APISample_parseConfig.js index 1312f8a4f81..75ab80d3f23 100644 --- a/tests/baselines/reference/APISample_parseConfig.js +++ b/tests/baselines/reference/APISample_parseConfig.js @@ -19,7 +19,7 @@ function printError(error: ts.Diagnostic): void { console.log(`${error.file && error.file.fileName}: ${error.messageText}`); } -export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program { +export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program | undefined { const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson) if (error) { printError(error); diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 1b6d52255fb..7573f2ba99e 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -8,7 +8,13 @@ declare var process: any; declare var console: any; -declare var fs: any; +declare var fs: { + existsSync(path: string): boolean; + readdirSync(path: string): string[]; + readFileSync(filename: string, encoding?: string): string; + writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void; +}; declare var path: any; import * as ts from "typescript"; diff --git a/tests/baselines/reference/ambientNameRestrictions.js b/tests/baselines/reference/ambientNameRestrictions.js new file mode 100644 index 00000000000..cd4fbf29371 --- /dev/null +++ b/tests/baselines/reference/ambientNameRestrictions.js @@ -0,0 +1,8 @@ +//// [ambientNameRestrictions.ts] +export declare namespace Foo { + export var static: any; +} + + +//// [ambientNameRestrictions.js] +"use strict"; diff --git a/tests/baselines/reference/ambientNameRestrictions.symbols b/tests/baselines/reference/ambientNameRestrictions.symbols new file mode 100644 index 00000000000..d5b3fafaa57 --- /dev/null +++ b/tests/baselines/reference/ambientNameRestrictions.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ambientNameRestrictions.ts === +export declare namespace Foo { +>Foo : Symbol(Foo, Decl(ambientNameRestrictions.ts, 0, 0)) + + export var static: any; +>static : Symbol(static, Decl(ambientNameRestrictions.ts, 1, 12)) +} + diff --git a/tests/baselines/reference/ambientNameRestrictions.types b/tests/baselines/reference/ambientNameRestrictions.types new file mode 100644 index 00000000000..705319392d8 --- /dev/null +++ b/tests/baselines/reference/ambientNameRestrictions.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ambientNameRestrictions.ts === +export declare namespace Foo { +>Foo : typeof Foo + + export var static: any; +>static : any +} + diff --git a/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt b/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt index 454ac41b5b8..204135cd004 100644 --- a/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt +++ b/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/assignmentToObjectAndFunction.ts(8,5): error TS2322: Type ' Property 'apply' is missing in type '{}'. tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type 'typeof bad' is not assignable to type 'Function'. Types of property 'apply' are incompatible. - Type 'number' is not assignable to type '{ (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }'. + Type 'number' is not assignable to type '(this: Function, thisArg: any, argArray?: any) => any'. ==== tests/cases/compiler/assignmentToObjectAndFunction.ts (3 errors) ==== @@ -48,4 +48,4 @@ tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type ~~~~~~~~~~ !!! error TS2322: Type 'typeof bad' is not assignable to type 'Function'. !!! error TS2322: Types of property 'apply' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type '{ (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type '(this: Function, thisArg: any, argArray?: any) => any'. \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols index 06999513192..4b312fd4646 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols @@ -10,9 +10,9 @@ class C { var fn = async () => await other.apply(this, arguments); >fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 3, 9)) ->other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) ->apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types index 18a08ffface..bb9df9af139 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types @@ -9,13 +9,13 @@ class C { >other : () => void var fn = async () => await other.apply(this, arguments); ->fn : () => Promise ->async () => await other.apply(this, arguments) : () => Promise ->await other.apply(this, arguments) : void ->other.apply(this, arguments) : void ->other.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>fn : () => Promise +>async () => await other.apply(this, arguments) : () => Promise +>await other.apply(this, arguments) : any +>other.apply(this, arguments) : any +>other.apply : (this: Function, thisArg: any, argArray?: any) => any >other : () => void ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >this : this >arguments : IArguments } diff --git a/tests/baselines/reference/commentsOnObjectLiteral3.symbols b/tests/baselines/reference/commentsOnObjectLiteral3.symbols index 81fa15b6a11..3d58fe2d6d7 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral3.symbols +++ b/tests/baselines/reference/commentsOnObjectLiteral3.symbols @@ -21,10 +21,6 @@ var v = { >a : Symbol(a, Decl(commentsOnObjectLiteral3.ts, 8, 13), Decl(commentsOnObjectLiteral3.ts, 12, 18)) return this.prop; ->this.prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) ->this : Symbol(, Decl(commentsOnObjectLiteral3.ts, 1, 7)) ->prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) - } /*trailing 1*/, //setter set a(value) { @@ -32,9 +28,6 @@ var v = { >value : Symbol(value, Decl(commentsOnObjectLiteral3.ts, 14, 7)) this.prop = value; ->this.prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) ->this : Symbol(, Decl(commentsOnObjectLiteral3.ts, 1, 7)) ->prop : Symbol(prop, Decl(commentsOnObjectLiteral3.ts, 1, 9)) >value : Symbol(value, Decl(commentsOnObjectLiteral3.ts, 14, 7)) } // trailing 2 diff --git a/tests/baselines/reference/commentsOnObjectLiteral3.types b/tests/baselines/reference/commentsOnObjectLiteral3.types index 26a1e2e4250..a63920fce0f 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral3.types +++ b/tests/baselines/reference/commentsOnObjectLiteral3.types @@ -24,9 +24,9 @@ var v = { >a : any return this.prop; ->this.prop : number ->this : { prop: number; func: () => void; func1(): void; a: any; } ->prop : number +>this.prop : any +>this : any +>prop : any } /*trailing 1*/, //setter @@ -36,9 +36,9 @@ var v = { this.prop = value; >this.prop = value : any ->this.prop : number ->this : { prop: number; func: () => void; func1(): void; a: any; } ->prop : number +>this.prop : any +>this : any +>prop : any >value : any } // trailing 2 diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.js b/tests/baselines/reference/controlFlowDestructuringParameters.js new file mode 100644 index 00000000000..66b8e656193 --- /dev/null +++ b/tests/baselines/reference/controlFlowDestructuringParameters.js @@ -0,0 +1,15 @@ +//// [controlFlowDestructuringParameters.ts] +// Repro for #8376 + + +[{ x: 1 }].map( + ({ x }) => x +); + + +//// [controlFlowDestructuringParameters.js] +// Repro for #8376 +[{ x: 1 }].map(function (_a) { + var x = _a.x; + return x; +}); diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.symbols b/tests/baselines/reference/controlFlowDestructuringParameters.symbols new file mode 100644 index 00000000000..668d346b929 --- /dev/null +++ b/tests/baselines/reference/controlFlowDestructuringParameters.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/controlFlowDestructuringParameters.ts === +// Repro for #8376 + + +[{ x: 1 }].map( +>[{ x: 1 }].map : Symbol(Array.map, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 3, 2)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) + + ({ x }) => x +>x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 4, 4)) +>x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 4, 4)) + +); + diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.types b/tests/baselines/reference/controlFlowDestructuringParameters.types new file mode 100644 index 00000000000..396852bf37a --- /dev/null +++ b/tests/baselines/reference/controlFlowDestructuringParameters.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/controlFlowDestructuringParameters.ts === +// Repro for #8376 + + +[{ x: 1 }].map( +>[{ x: 1 }].map( ({ x }) => x) : number[] +>[{ x: 1 }].map : (callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any) => U[] +>[{ x: 1 }] : { x: number; }[] +>{ x: 1 } : { x: number; } +>x : number +>1 : number +>map : (callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any) => U[] + + ({ x }) => x +>({ x }) => x : ({x}: { x: number; }) => number +>x : number +>x : number + +); + diff --git a/tests/baselines/reference/controlFlowIteration.js b/tests/baselines/reference/controlFlowIteration.js new file mode 100644 index 00000000000..7b319ba8098 --- /dev/null +++ b/tests/baselines/reference/controlFlowIteration.js @@ -0,0 +1,40 @@ +//// [controlFlowIteration.ts] + +let cond: boolean; + +function ff() { + let x: string | undefined; + while (true) { + if (cond) { + x = ""; + } + else { + if (x) { + x.length; + } + if (x) { + x.length; + } + } + } +} + + +//// [controlFlowIteration.js] +var cond; +function ff() { + var x; + while (true) { + if (cond) { + x = ""; + } + else { + if (x) { + x.length; + } + if (x) { + x.length; + } + } + } +} diff --git a/tests/baselines/reference/controlFlowIteration.symbols b/tests/baselines/reference/controlFlowIteration.symbols new file mode 100644 index 00000000000..84c1c57b69b --- /dev/null +++ b/tests/baselines/reference/controlFlowIteration.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/controlFlow/controlFlowIteration.ts === + +let cond: boolean; +>cond : Symbol(cond, Decl(controlFlowIteration.ts, 1, 3)) + +function ff() { +>ff : Symbol(ff, Decl(controlFlowIteration.ts, 1, 18)) + + let x: string | undefined; +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) + + while (true) { + if (cond) { +>cond : Symbol(cond, Decl(controlFlowIteration.ts, 1, 3)) + + x = ""; +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) + } + else { + if (x) { +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } + if (x) { +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowIteration.ts, 4, 7)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } + } + } +} + diff --git a/tests/baselines/reference/controlFlowIteration.types b/tests/baselines/reference/controlFlowIteration.types new file mode 100644 index 00000000000..52be501d68e --- /dev/null +++ b/tests/baselines/reference/controlFlowIteration.types @@ -0,0 +1,43 @@ +=== tests/cases/conformance/controlFlow/controlFlowIteration.ts === + +let cond: boolean; +>cond : boolean + +function ff() { +>ff : () => void + + let x: string | undefined; +>x : string | undefined + + while (true) { +>true : boolean + + if (cond) { +>cond : boolean + + x = ""; +>x = "" : string +>x : string | undefined +>"" : string + } + else { + if (x) { +>x : string | undefined + + x.length; +>x.length : number +>x : string +>length : number + } + if (x) { +>x : string | undefined + + x.length; +>x.length : number +>x : string +>length : number + } + } + } +} + diff --git a/tests/baselines/reference/controlFlowLoopAnalysis.errors.txt b/tests/baselines/reference/controlFlowLoopAnalysis.errors.txt new file mode 100644 index 00000000000..21bf6b1c19a --- /dev/null +++ b/tests/baselines/reference/controlFlowLoopAnalysis.errors.txt @@ -0,0 +1,39 @@ +tests/cases/compiler/controlFlowLoopAnalysis.ts(13,25): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. + Type 'undefined' is not assignable to type 'number'. + + +==== tests/cases/compiler/controlFlowLoopAnalysis.ts (1 errors) ==== + + // Repro from #8418 + + let cond: boolean; + + function foo(x: number): number { return 1; } + + function test1() { + let x: number | undefined; + while (cond) { + while (cond) { + while (cond) { + x = foo(x); + ~ +!!! error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. +!!! error TS2345: Type 'undefined' is not assignable to type 'number'. + } + } + x = 1; + } + } + + // Repro from #8418 + + function test2() { + let x: number | undefined; + x = 1; + while (cond) { + while (cond) { + x = foo(x); + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/controlFlowLoopAnalysis.js b/tests/baselines/reference/controlFlowLoopAnalysis.js new file mode 100644 index 00000000000..3cf2ce2caac --- /dev/null +++ b/tests/baselines/reference/controlFlowLoopAnalysis.js @@ -0,0 +1,58 @@ +//// [controlFlowLoopAnalysis.ts] + +// Repro from #8418 + +let cond: boolean; + +function foo(x: number): number { return 1; } + +function test1() { + let x: number | undefined; + while (cond) { + while (cond) { + while (cond) { + x = foo(x); + } + } + x = 1; + } +} + +// Repro from #8418 + +function test2() { + let x: number | undefined; + x = 1; + while (cond) { + while (cond) { + x = foo(x); + } + } +} + + +//// [controlFlowLoopAnalysis.js] +// Repro from #8418 +var cond; +function foo(x) { return 1; } +function test1() { + var x; + while (cond) { + while (cond) { + while (cond) { + x = foo(x); + } + } + x = 1; + } +} +// Repro from #8418 +function test2() { + var x; + x = 1; + while (cond) { + while (cond) { + x = foo(x); + } + } +} diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols b/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols index 9b3599da674..862b0b3781e 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols @@ -15,9 +15,6 @@ function /*1*/makePoint(x: number) { set x(a: number) { this.b = a; } >x : Symbol(x, Decl(declFileObjectLiteralWithAccessors.ts, 3, 14), Decl(declFileObjectLiteralWithAccessors.ts, 4, 30)) >a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14)) ->this.b : Symbol(b, Decl(declFileObjectLiteralWithAccessors.ts, 2, 12)) ->this : Symbol(, Decl(declFileObjectLiteralWithAccessors.ts, 2, 10)) ->b : Symbol(b, Decl(declFileObjectLiteralWithAccessors.ts, 2, 12)) >a : Symbol(a, Decl(declFileObjectLiteralWithAccessors.ts, 5, 14)) }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.types b/tests/baselines/reference/declFileObjectLiteralWithAccessors.types index 1bf012605c1..f7bb57b0e1e 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.types +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.types @@ -19,9 +19,9 @@ function /*1*/makePoint(x: number) { >x : number >a : number >this.b = a : number ->this.b : number ->this : { b: number; x: number; } ->b : number +>this.b : any +>this : any +>b : any >a : number }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols index 89b7b9dd747..f7474466140 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols @@ -11,9 +11,6 @@ function /*1*/makePoint(x: number) { set x(a: number) { this.b = a; } >x : Symbol(x, Decl(declFileObjectLiteralWithOnlySetter.ts, 3, 14)) >a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14)) ->this.b : Symbol(b, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 12)) ->this : Symbol(, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 10)) ->b : Symbol(b, Decl(declFileObjectLiteralWithOnlySetter.ts, 2, 12)) >a : Symbol(a, Decl(declFileObjectLiteralWithOnlySetter.ts, 4, 14)) }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types index 1bce86915ad..2b9b98a8963 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types @@ -15,9 +15,9 @@ function /*1*/makePoint(x: number) { >x : number >a : number >this.b = a : number ->this.b : number ->this : { b: number; x: number; } ->b : number +>this.b : any +>this : any +>b : any >a : number }; diff --git a/tests/baselines/reference/declarationEmitPromise.symbols b/tests/baselines/reference/declarationEmitPromise.symbols index 894a20e03a6..2c37e1dfa78 100644 --- a/tests/baselines/reference/declarationEmitPromise.symbols +++ b/tests/baselines/reference/declarationEmitPromise.symbols @@ -68,9 +68,9 @@ export async function runSampleWorks( >T : Symbol(T, Decl(declarationEmitPromise.ts, 8, 16)) f.apply(this, result); ->f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >f : Symbol(f, Decl(declarationEmitPromise.ts, 8, 19)) ->apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >result : Symbol(result, Decl(declarationEmitPromise.ts, 7, 7)) let rfunc: typeof func & {} = func as any; // <- This is the only difference @@ -140,9 +140,9 @@ export async function runSampleBreaks( >T : Symbol(T, Decl(declarationEmitPromise.ts, 17, 16)) f.apply(this, result); ->f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >f : Symbol(f, Decl(declarationEmitPromise.ts, 17, 19)) ->apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >result : Symbol(result, Decl(declarationEmitPromise.ts, 16, 7)) let rfunc: typeof func = func as any; // <- This is the only difference diff --git a/tests/baselines/reference/declarationEmitPromise.types b/tests/baselines/reference/declarationEmitPromise.types index 0306c72762b..4edaa444326 100644 --- a/tests/baselines/reference/declarationEmitPromise.types +++ b/tests/baselines/reference/declarationEmitPromise.types @@ -78,10 +78,10 @@ export async function runSampleWorks( >T : T f.apply(this, result); ->f.apply(this, result) : T ->f.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>f.apply(this, result) : any +>f.apply : (this: Function, thisArg: any, argArray?: any) => any >f : (a: A, b?: B, c?: C, d?: D, e?: E) => T ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >this : any >result : any @@ -163,10 +163,10 @@ export async function runSampleBreaks( >T : T f.apply(this, result); ->f.apply(this, result) : T ->f.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>f.apply(this, result) : any +>f.apply : (this: Function, thisArg: any, argArray?: any) => any >f : (a: A, b?: B, c?: C, d?: D, e?: E) => T ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >this : any >result : any diff --git a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt index d3597ad2507..4d95cf01136 100644 --- a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt @@ -1,9 +1,7 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts(9,10): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts(10,19): error TS2352: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'. - Property 'a' is missing in type '{ m(): this is Foo; }'. -==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts (2 errors) ==== +==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts (1 errors) ==== export interface Foo { a: string; @@ -16,9 +14,6 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredic ~~~~ !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. let dis = this as Foo; - ~~~~~~~~~~~ -!!! error TS2352: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'. -!!! error TS2352: Property 'a' is missing in type '{ m(): this is Foo; }'. return dis.a != null && dis.b != null && dis.c != null; } } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt index 7a4716a92e0..86c0f478133 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt @@ -1,10 +1,8 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(8,14): error TS4025: Exported variable 'obj' has or is using private name 'Foo'. tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(9,10): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(10,19): error TS2352: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'. - Property 'a' is missing in type '{ m(): this is Foo; }'. -==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (3 errors) ==== +==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (2 errors) ==== interface Foo { a: string; @@ -19,9 +17,6 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredic ~~~~ !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. let dis = this as Foo; - ~~~~~~~~~~~ -!!! error TS2352: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'. -!!! error TS2352: Property 'a' is missing in type '{ m(): this is Foo; }'. return dis.a != null && dis.b != null && dis.c != null; } } \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.js b/tests/baselines/reference/defaultExportInAwaitExpression01.js new file mode 100644 index 00000000000..afd4dfa7a56 --- /dev/null +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.js @@ -0,0 +1,53 @@ +//// [tests/cases/conformance/es6/modules/defaultExportInAwaitExpression01.ts] //// + +//// [a.ts] +const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); +export default x; + +//// [b.ts] +import x from './a'; + +( async function() { + const value = await x; +}() ); + + +//// [a.js] +(function (factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(["require", "exports"], factory); + } +})(function (require, exports) { + "use strict"; + const x = new Promise((resolve, reject) => { resolve({}); }); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = x; +}); +//// [b.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +(function (factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(["require", "exports", './a'], factory); + } +})(function (require, exports) { + "use strict"; + const a_1 = require('./a'); + (function () { + return __awaiter(this, void 0, void 0, function* () { + const value = yield a_1.default; + }); + }()); +}); diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.symbols b/tests/baselines/reference/defaultExportInAwaitExpression01.symbols new file mode 100644 index 00000000000..eb833f63895 --- /dev/null +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/es6/modules/a.ts === +const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); +>x : Symbol(x, Decl(a.ts, 0, 5)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(resolve, Decl(a.ts, 0, 24)) +>reject : Symbol(reject, Decl(a.ts, 0, 33)) +>resolve : Symbol(resolve, Decl(a.ts, 0, 24)) + +export default x; +>x : Symbol(x, Decl(a.ts, 0, 5)) + +=== tests/cases/conformance/es6/modules/b.ts === +import x from './a'; +>x : Symbol(x, Decl(b.ts, 0, 6)) + +( async function() { + const value = await x; +>value : Symbol(value, Decl(b.ts, 3, 9)) +>x : Symbol(x, Decl(b.ts, 0, 6)) + +}() ); + diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.types b/tests/baselines/reference/defaultExportInAwaitExpression01.types new file mode 100644 index 00000000000..1f7de76b90e --- /dev/null +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/es6/modules/a.ts === +const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); +>x : Promise<{}> +>new Promise( ( resolve, reject ) => { resolve( {} ); } ) : Promise<{}> +>Promise : PromiseConstructor +>( resolve, reject ) => { resolve( {} ); } : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void +>resolve : (value?: {} | PromiseLike<{}>) => void +>reject : (reason?: any) => void +>resolve( {} ) : void +>resolve : (value?: {} | PromiseLike<{}>) => void +>{} : {} + +export default x; +>x : Promise<{}> + +=== tests/cases/conformance/es6/modules/b.ts === +import x from './a'; +>x : Promise<{}> + +( async function() { +>( async function() { const value = await x;}() ) : Promise +>async function() { const value = await x;}() : Promise +>async function() { const value = await x;} : () => Promise + + const value = await x; +>value : {} +>await x : {} +>x : Promise<{}> + +}() ); + diff --git a/tests/baselines/reference/defaultExportInAwaitExpression02.js b/tests/baselines/reference/defaultExportInAwaitExpression02.js new file mode 100644 index 00000000000..70a9ce6c2d3 --- /dev/null +++ b/tests/baselines/reference/defaultExportInAwaitExpression02.js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/es6/modules/defaultExportInAwaitExpression02.ts] //// + +//// [a.ts] +const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); +export default x; + +//// [b.ts] +import x from './a'; + +( async function() { + const value = await x; +}() ); + + +//// [a.js] +"use strict"; +const x = new Promise((resolve, reject) => { resolve({}); }); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = x; +//// [b.js] +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +const a_1 = require('./a'); +(function () { + return __awaiter(this, void 0, void 0, function* () { + const value = yield a_1.default; + }); +}()); diff --git a/tests/baselines/reference/defaultExportInAwaitExpression02.symbols b/tests/baselines/reference/defaultExportInAwaitExpression02.symbols new file mode 100644 index 00000000000..eb833f63895 --- /dev/null +++ b/tests/baselines/reference/defaultExportInAwaitExpression02.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/es6/modules/a.ts === +const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); +>x : Symbol(x, Decl(a.ts, 0, 5)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(resolve, Decl(a.ts, 0, 24)) +>reject : Symbol(reject, Decl(a.ts, 0, 33)) +>resolve : Symbol(resolve, Decl(a.ts, 0, 24)) + +export default x; +>x : Symbol(x, Decl(a.ts, 0, 5)) + +=== tests/cases/conformance/es6/modules/b.ts === +import x from './a'; +>x : Symbol(x, Decl(b.ts, 0, 6)) + +( async function() { + const value = await x; +>value : Symbol(value, Decl(b.ts, 3, 9)) +>x : Symbol(x, Decl(b.ts, 0, 6)) + +}() ); + diff --git a/tests/baselines/reference/defaultExportInAwaitExpression02.types b/tests/baselines/reference/defaultExportInAwaitExpression02.types new file mode 100644 index 00000000000..1f7de76b90e --- /dev/null +++ b/tests/baselines/reference/defaultExportInAwaitExpression02.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/es6/modules/a.ts === +const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); +>x : Promise<{}> +>new Promise( ( resolve, reject ) => { resolve( {} ); } ) : Promise<{}> +>Promise : PromiseConstructor +>( resolve, reject ) => { resolve( {} ); } : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void +>resolve : (value?: {} | PromiseLike<{}>) => void +>reject : (reason?: any) => void +>resolve( {} ) : void +>resolve : (value?: {} | PromiseLike<{}>) => void +>{} : {} + +export default x; +>x : Promise<{}> + +=== tests/cases/conformance/es6/modules/b.ts === +import x from './a'; +>x : Promise<{}> + +( async function() { +>( async function() { const value = await x;}() ) : Promise +>async function() { const value = await x;}() : Promise +>async function() { const value = await x;} : () => Promise + + const value = await x; +>value : {} +>await x : {} +>x : Promise<{}> + +}() ); + diff --git a/tests/baselines/reference/defaultOfAnyInStrictNullChecks.js b/tests/baselines/reference/defaultOfAnyInStrictNullChecks.js new file mode 100644 index 00000000000..7706181b343 --- /dev/null +++ b/tests/baselines/reference/defaultOfAnyInStrictNullChecks.js @@ -0,0 +1,22 @@ +//// [defaultOfAnyInStrictNullChecks.ts] + +// Regression test for #8295 + +function foo() { + try { + } + catch (e) { + let s = e.message; + } +} + + +//// [defaultOfAnyInStrictNullChecks.js] +// Regression test for #8295 +function foo() { + try { + } + catch (e) { + var s = e.message; + } +} diff --git a/tests/baselines/reference/defaultOfAnyInStrictNullChecks.symbols b/tests/baselines/reference/defaultOfAnyInStrictNullChecks.symbols new file mode 100644 index 00000000000..c7de7f6b2f3 --- /dev/null +++ b/tests/baselines/reference/defaultOfAnyInStrictNullChecks.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts === + +// Regression test for #8295 + +function foo() { +>foo : Symbol(foo, Decl(defaultOfAnyInStrictNullChecks.ts, 0, 0)) + + try { + } + catch (e) { +>e : Symbol(e, Decl(defaultOfAnyInStrictNullChecks.ts, 6, 11)) + + let s = e.message; +>s : Symbol(s, Decl(defaultOfAnyInStrictNullChecks.ts, 7, 11)) +>e : Symbol(e, Decl(defaultOfAnyInStrictNullChecks.ts, 6, 11)) + } +} + diff --git a/tests/baselines/reference/defaultOfAnyInStrictNullChecks.types b/tests/baselines/reference/defaultOfAnyInStrictNullChecks.types new file mode 100644 index 00000000000..8e4c1adcd61 --- /dev/null +++ b/tests/baselines/reference/defaultOfAnyInStrictNullChecks.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts === + +// Regression test for #8295 + +function foo() { +>foo : () => void + + try { + } + catch (e) { +>e : any + + let s = e.message; +>s : any +>e.message : any +>e : any +>message : any + } +} + diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols index 4da659c4a1a..dbd5aa150dc 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols @@ -8,18 +8,11 @@ var object = { get 0() { return this._0; ->this._0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) ->this : Symbol(, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 12)) ->_0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) - }, set 0(x: number) { >x : Symbol(x, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 6, 10)) this._0 = x; ->this._0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) ->this : Symbol(, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 12)) ->_0 : Symbol(_0, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 1, 14)) >x : Symbol(x, Decl(emitCompoundExponentiationAssignmentWithIndexingOnLHS3.ts, 6, 10)) }, diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types index b47c88f3de3..1877f391207 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types @@ -10,9 +10,9 @@ var object = { get 0() { return this._0; ->this._0 : number ->this : { 0: number; _0: number; } ->_0 : number +>this._0 : any +>this : any +>_0 : any }, set 0(x: number) { @@ -20,9 +20,9 @@ var object = { this._0 = x; >this._0 = x : number ->this._0 : number ->this : { 0: number; _0: number; } ->_0 : number +>this._0 : any +>this : any +>_0 : any >x : number }, diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols index b836bc88573..ea0ed9a605c 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols +++ b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols @@ -12,7 +12,7 @@ function fn(x = () => this, y = x()) { } fn.call(4); // Should be 4 ->fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >fn : Symbol(fn, Decl(fatarrowfunctionsInFunctionParameterDefaults.ts, 0, 0)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types index 58c576bf24e..39cd994dcc1 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types +++ b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types @@ -16,8 +16,8 @@ function fn(x = () => this, y = x()) { fn.call(4); // Should be 4 >fn.call(4) : any ->fn.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>fn.call : (this: Function, thisArg: any, ...argArray: any[]) => any >fn : (x?: () => any, y?: any) => any ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >4 : number diff --git a/tests/baselines/reference/functionType.symbols b/tests/baselines/reference/functionType.symbols index 65347d39b5a..30a5a7cc447 100644 --- a/tests/baselines/reference/functionType.symbols +++ b/tests/baselines/reference/functionType.symbols @@ -3,9 +3,9 @@ function salt() {} >salt : Symbol(salt, Decl(functionType.ts, 0, 0)) salt.apply("hello", []); ->salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >salt : Symbol(salt, Decl(functionType.ts, 0, 0)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) (new Function("return 5"))(); >Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/functionType.types b/tests/baselines/reference/functionType.types index 9183ec4a13e..ac3d5c9944d 100644 --- a/tests/baselines/reference/functionType.types +++ b/tests/baselines/reference/functionType.types @@ -3,10 +3,10 @@ function salt() {} >salt : () => void salt.apply("hello", []); ->salt.apply("hello", []) : void ->salt.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>salt.apply("hello", []) : any +>salt.apply : (this: Function, thisArg: any, argArray?: any) => any >salt : () => void ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >"hello" : string >[] : undefined[] diff --git a/tests/baselines/reference/fuzzy.errors.txt b/tests/baselines/reference/fuzzy.errors.txt index 344a3865fb2..19f0ad56a5e 100644 --- a/tests/baselines/reference/fuzzy.errors.txt +++ b/tests/baselines/reference/fuzzy.errors.txt @@ -4,7 +4,6 @@ tests/cases/compiler/fuzzy.ts(21,20): error TS2322: Type '{ anything: number; on Types of property 'oneI' are incompatible. Type 'this' is not assignable to type 'I'. Type 'C' is not assignable to type 'I'. - Property 'alsoWorks' is missing in type 'C'. tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Type '{ oneI: this; }' cannot be converted to type 'R'. Property 'anything' is missing in type '{ oneI: this; }'. @@ -39,7 +38,6 @@ tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Type '{ oneI: this; }' canno !!! error TS2322: Types of property 'oneI' are incompatible. !!! error TS2322: Type 'this' is not assignable to type 'I'. !!! error TS2322: Type 'C' is not assignable to type 'I'. -!!! error TS2322: Property 'alsoWorks' is missing in type 'C'. } worksToo():R { diff --git a/tests/baselines/reference/genericTypeParameterEquivalence2.symbols b/tests/baselines/reference/genericTypeParameterEquivalence2.symbols index 1aa22b1e994..cd558fdd10a 100644 --- a/tests/baselines/reference/genericTypeParameterEquivalence2.symbols +++ b/tests/baselines/reference/genericTypeParameterEquivalence2.symbols @@ -24,9 +24,9 @@ function compose(f: (b: B) => C, g: (a:A) => B): (a:A) => C { return f(g.apply(null, a)); >f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 1, 26)) ->g.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>g.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >g : Symbol(g, Decl(genericTypeParameterEquivalence2.ts, 1, 41)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 2, 21)) }; diff --git a/tests/baselines/reference/genericTypeParameterEquivalence2.types b/tests/baselines/reference/genericTypeParameterEquivalence2.types index 9fdb03b0fbe..44e495088bc 100644 --- a/tests/baselines/reference/genericTypeParameterEquivalence2.types +++ b/tests/baselines/reference/genericTypeParameterEquivalence2.types @@ -26,10 +26,10 @@ function compose(f: (b: B) => C, g: (a:A) => B): (a:A) => C { return f(g.apply(null, a)); >f(g.apply(null, a)) : C >f : (b: B) => C ->g.apply(null, a) : B ->g.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>g.apply(null, a) : any +>g.apply : (this: Function, thisArg: any, argArray?: any) => any >g : (a: A) => B ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >null : null >a : A diff --git a/tests/baselines/reference/instanceOfAssignability.types b/tests/baselines/reference/instanceOfAssignability.types index 5fa55aa6d88..0a9e1a3e996 100644 --- a/tests/baselines/reference/instanceOfAssignability.types +++ b/tests/baselines/reference/instanceOfAssignability.types @@ -133,8 +133,8 @@ function fn5(x: Derived1) { // 1.5: y: Derived1 // Want: ??? let y = x; ->y : {} ->x : {} +>y : nothing +>x : nothing } } diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols index 62e47c8a3c4..f21653d475b 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols @@ -26,39 +26,39 @@ function apply(func, thisArg, args) { >length : Symbol(length, Decl(_apply.js, 12, 7)) case 0: return func.call(thisArg); ->func.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) case 1: return func.call(thisArg, args[0]); ->func.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) >args : Symbol(args, Decl(_apply.js, 11, 29)) case 2: return func.call(thisArg, args[0], args[1]); ->func.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) >args : Symbol(args, Decl(_apply.js, 11, 29)) >args : Symbol(args, Decl(_apply.js, 11, 29)) case 3: return func.call(thisArg, args[0], args[1], args[2]); ->func.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) >args : Symbol(args, Decl(_apply.js, 11, 29)) >args : Symbol(args, Decl(_apply.js, 11, 29)) >args : Symbol(args, Decl(_apply.js, 11, 29)) } return func.apply(thisArg, args); ->func.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) >args : Symbol(args, Decl(_apply.js, 11, 29)) } diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types index 78d0fd1392b..fbfe9d3edae 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types @@ -28,17 +28,17 @@ function apply(func, thisArg, args) { case 0: return func.call(thisArg); >0 : number >func.call(thisArg) : any ->func.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any >func : Function ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any case 1: return func.call(thisArg, args[0]); >1 : number >func.call(thisArg, args[0]) : any ->func.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any >func : Function ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any >args : any[] @@ -47,9 +47,9 @@ function apply(func, thisArg, args) { case 2: return func.call(thisArg, args[0], args[1]); >2 : number >func.call(thisArg, args[0], args[1]) : any ->func.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any >func : Function ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any >args : any[] @@ -61,9 +61,9 @@ function apply(func, thisArg, args) { case 3: return func.call(thisArg, args[0], args[1], args[2]); >3 : number >func.call(thisArg, args[0], args[1], args[2]) : any ->func.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any >func : Function ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any >args : any[] @@ -77,9 +77,9 @@ function apply(func, thisArg, args) { } return func.apply(thisArg, args); >func.apply(thisArg, args) : any ->func.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>func.apply : (this: Function, thisArg: any, argArray?: any) => any >func : Function ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >thisArg : any >args : any[] } diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index b7a36b99ad4..bf76c9c9641 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -32,12 +32,12 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error !!! error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. !!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'C'. - let o = { + let o = { n: 101, - explicitThis: function (m: number) { - return m + this.n.length; // ok, this.n: any + explicitThis: function (m: number) { + return m + this.n.length; // error, 'length' does not exist on 'number' }, - implicitThis(m: number): number { return m; } + implicitThis(m: number): number { return m; } }; let i: I = o; let o2: I = { @@ -63,4 +63,5 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error return this.n.length; // error, this.n: number ~~~~~~ !!! error TS2339: Property 'length' does not exist on type 'number'. - } \ No newline at end of file + } + \ No newline at end of file diff --git a/tests/baselines/reference/looseThisTypeInFunctions.js b/tests/baselines/reference/looseThisTypeInFunctions.js index 3b172877e0e..cb1fbcc8b95 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.js +++ b/tests/baselines/reference/looseThisTypeInFunctions.js @@ -20,12 +20,12 @@ class C implements I { } let c = new C(); c.explicitVoid = c.explicitThis; // error, 'void' is missing everything -let o = { +let o = { n: 101, - explicitThis: function (m: number) { - return m + this.n.length; // ok, this.n: any + explicitThis: function (m: number) { + return m + this.n.length; // error, 'length' does not exist on 'number' }, - implicitThis(m: number): number { return m; } + implicitThis(m: number): number { return m; } }; let i: I = o; let o2: I = { @@ -45,7 +45,8 @@ o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to o.implicitThis = i.explicitThis; i.explicitThis = function(m) { return this.n.length; // error, this.n: number -} +} + //// [looseThisTypeInFunctions.js] var C = (function () { @@ -67,7 +68,7 @@ c.explicitVoid = c.explicitThis; // error, 'void' is missing everything var o = { n: 101, explicitThis: function (m) { - return m + this.n.length; // ok, this.n: any + return m + this.n.length; // error, 'length' does not exist on 'number' }, implicitThis: function (m) { return m; } }; diff --git a/tests/baselines/reference/narrowingOfDottedNames.js b/tests/baselines/reference/narrowingOfDottedNames.js new file mode 100644 index 00000000000..14cdcd55631 --- /dev/null +++ b/tests/baselines/reference/narrowingOfDottedNames.js @@ -0,0 +1,80 @@ +//// [narrowingOfDottedNames.ts] +// Repro from #8383 + +class A { + prop: { a: string; }; +} + +class B { + prop: { b: string; } +} + +function isA(x: any): x is A { + return x instanceof A; +} + +function isB(x: any): x is B { + return x instanceof B; +} + +function f1(x: A | B) { + while (true) { + if (x instanceof A) { + x.prop.a; + } + else if (x instanceof B) { + x.prop.b; + } + } +} + +function f2(x: A | B) { + while (true) { + if (isA(x)) { + x.prop.a; + } + else if (isB(x)) { + x.prop.b; + } + } +} + + +//// [narrowingOfDottedNames.js] +// Repro from #8383 +var A = (function () { + function A() { + } + return A; +}()); +var B = (function () { + function B() { + } + return B; +}()); +function isA(x) { + return x instanceof A; +} +function isB(x) { + return x instanceof B; +} +function f1(x) { + while (true) { + if (x instanceof A) { + x.prop.a; + } + else if (x instanceof B) { + x.prop.b; + } + } +} +function f2(x) { + while (true) { + if (isA(x)) { + x.prop.a; + } + else if (isB(x)) { + x.prop.b; + } + } +} diff --git a/tests/baselines/reference/narrowingOfDottedNames.symbols b/tests/baselines/reference/narrowingOfDottedNames.symbols new file mode 100644 index 00000000000..98f75372a4e --- /dev/null +++ b/tests/baselines/reference/narrowingOfDottedNames.symbols @@ -0,0 +1,105 @@ +=== tests/cases/compiler/narrowingOfDottedNames.ts === +// Repro from #8383 + +class A { +>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0)) + + prop: { a: string; }; +>prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9)) +>a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11)) +} + +class B { +>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1)) + + prop: { b: string; } +>prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9)) +>b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11)) +} + +function isA(x: any): x is A { +>isA : Symbol(isA, Decl(narrowingOfDottedNames.ts, 8, 1)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 10, 13)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 10, 13)) +>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0)) + + return x instanceof A; +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 10, 13)) +>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0)) +} + +function isB(x: any): x is B { +>isB : Symbol(isB, Decl(narrowingOfDottedNames.ts, 12, 1)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 14, 13)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 14, 13)) +>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1)) + + return x instanceof B; +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 14, 13)) +>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1)) +} + +function f1(x: A | B) { +>f1 : Symbol(f1, Decl(narrowingOfDottedNames.ts, 16, 1)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12)) +>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0)) +>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1)) + + while (true) { + if (x instanceof A) { +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12)) +>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0)) + + x.prop.a; +>x.prop.a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11)) +>x.prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12)) +>prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9)) +>a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11)) + } + else if (x instanceof B) { +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12)) +>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1)) + + x.prop.b; +>x.prop.b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11)) +>x.prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12)) +>prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9)) +>b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11)) + } + } +} + +function f2(x: A | B) { +>f2 : Symbol(f2, Decl(narrowingOfDottedNames.ts, 27, 1)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12)) +>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0)) +>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1)) + + while (true) { + if (isA(x)) { +>isA : Symbol(isA, Decl(narrowingOfDottedNames.ts, 8, 1)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12)) + + x.prop.a; +>x.prop.a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11)) +>x.prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12)) +>prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9)) +>a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11)) + } + else if (isB(x)) { +>isB : Symbol(isB, Decl(narrowingOfDottedNames.ts, 12, 1)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12)) + + x.prop.b; +>x.prop.b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11)) +>x.prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9)) +>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12)) +>prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9)) +>b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11)) + } + } +} + diff --git a/tests/baselines/reference/narrowingOfDottedNames.types b/tests/baselines/reference/narrowingOfDottedNames.types new file mode 100644 index 00000000000..697e080b661 --- /dev/null +++ b/tests/baselines/reference/narrowingOfDottedNames.types @@ -0,0 +1,115 @@ +=== tests/cases/compiler/narrowingOfDottedNames.ts === +// Repro from #8383 + +class A { +>A : A + + prop: { a: string; }; +>prop : { a: string; } +>a : string +} + +class B { +>B : B + + prop: { b: string; } +>prop : { b: string; } +>b : string +} + +function isA(x: any): x is A { +>isA : (x: any) => x is A +>x : any +>x : any +>A : A + + return x instanceof A; +>x instanceof A : boolean +>x : any +>A : typeof A +} + +function isB(x: any): x is B { +>isB : (x: any) => x is B +>x : any +>x : any +>B : B + + return x instanceof B; +>x instanceof B : boolean +>x : any +>B : typeof B +} + +function f1(x: A | B) { +>f1 : (x: A | B) => void +>x : A | B +>A : A +>B : B + + while (true) { +>true : boolean + + if (x instanceof A) { +>x instanceof A : boolean +>x : A | B +>A : typeof A + + x.prop.a; +>x.prop.a : string +>x.prop : { a: string; } +>x : A +>prop : { a: string; } +>a : string + } + else if (x instanceof B) { +>x instanceof B : boolean +>x : B +>B : typeof B + + x.prop.b; +>x.prop.b : string +>x.prop : { b: string; } +>x : B +>prop : { b: string; } +>b : string + } + } +} + +function f2(x: A | B) { +>f2 : (x: A | B) => void +>x : A | B +>A : A +>B : B + + while (true) { +>true : boolean + + if (isA(x)) { +>isA(x) : boolean +>isA : (x: any) => x is A +>x : A | B + + x.prop.a; +>x.prop.a : string +>x.prop : { a: string; } +>x : A +>prop : { a: string; } +>a : string + } + else if (isB(x)) { +>isB(x) : boolean +>isB : (x: any) => x is B +>x : B + + x.prop.b; +>x.prop.b : string +>x.prop : { b: string; } +>x : B +>prop : { b: string; } +>b : string + } + } +} + diff --git a/tests/baselines/reference/noImplicitThisObjectLiterals.errors.txt b/tests/baselines/reference/noImplicitThisObjectLiterals.errors.txt new file mode 100644 index 00000000000..6f25f2d3a08 --- /dev/null +++ b/tests/baselines/reference/noImplicitThisObjectLiterals.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/noImplicitThisObjectLiterals.ts(2,8): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisObjectLiterals.ts(4,16): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisObjectLiterals.ts(7,16): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + + +==== tests/cases/compiler/noImplicitThisObjectLiterals.ts (3 errors) ==== + let o = { + d: this, // error, this: any + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + m() { + return this.d.length; // error, this: any + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }, + f: function() { + return this.d.length; // error, this: any + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitThisObjectLiterals.js b/tests/baselines/reference/noImplicitThisObjectLiterals.js new file mode 100644 index 00000000000..3888708a8da --- /dev/null +++ b/tests/baselines/reference/noImplicitThisObjectLiterals.js @@ -0,0 +1,22 @@ +//// [noImplicitThisObjectLiterals.ts] +let o = { + d: this, // error, this: any + m() { + return this.d.length; // error, this: any + }, + f: function() { + return this.d.length; // error, this: any + } +} + + +//// [noImplicitThisObjectLiterals.js] +var o = { + d: this, + m: function () { + return this.d.length; // error, this: any + }, + f: function () { + return this.d.length; // error, this: any + } +}; diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols index 08d3d75e9dc..60b7b08397a 100644 --- a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols +++ b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols @@ -20,9 +20,9 @@ var r2b: (x: any, y?: any) => any = i.apply; >r2b : Symbol(r2b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 9, 3)) >x : Symbol(x, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 9, 10)) >y : Symbol(y, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 9, 17)) ->i.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>i.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >i : Symbol(i, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 7, 3)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) var b: { >b : Symbol(b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 11, 3)) @@ -38,7 +38,7 @@ var rb4: (x: any, y?: any) => any = b.apply; >rb4 : Symbol(rb4, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 16, 3)) >x : Symbol(x, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 16, 10)) >y : Symbol(y, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 16, 17)) ->b.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>b.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >b : Symbol(b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 11, 3)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types index 496734c9183..80408cff962 100644 --- a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types +++ b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types @@ -21,9 +21,9 @@ var r2b: (x: any, y?: any) => any = i.apply; >r2b : (x: any, y?: any) => any >x : any >y : any ->i.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>i.apply : (this: Function, thisArg: any, argArray?: any) => any >i : I ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any var b: { >b : () => void @@ -40,7 +40,7 @@ var rb4: (x: any, y?: any) => any = b.apply; >rb4 : (x: any, y?: any) => any >x : any >y : any ->b.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>b.apply : (this: Function, thisArg: any, argArray?: any) => any >b : () => void ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any diff --git a/tests/baselines/reference/recurringTypeParamForContainerOfBase01.js b/tests/baselines/reference/recurringTypeParamForContainerOfBase01.js new file mode 100644 index 00000000000..b3ef0cba312 --- /dev/null +++ b/tests/baselines/reference/recurringTypeParamForContainerOfBase01.js @@ -0,0 +1,27 @@ +//// [recurringTypeParamForContainerOfBase01.ts] + +interface BoxOfFoo> { + item: T +} + +interface Foo> { + self: T; +} + +interface Bar> extends Foo { + other: BoxOfFoo; +} + +//// [recurringTypeParamForContainerOfBase01.js] + + +//// [recurringTypeParamForContainerOfBase01.d.ts] +interface BoxOfFoo> { + item: T; +} +interface Foo> { + self: T; +} +interface Bar> extends Foo { + other: BoxOfFoo; +} diff --git a/tests/baselines/reference/recurringTypeParamForContainerOfBase01.symbols b/tests/baselines/reference/recurringTypeParamForContainerOfBase01.symbols new file mode 100644 index 00000000000..48ea1ffa0cf --- /dev/null +++ b/tests/baselines/reference/recurringTypeParamForContainerOfBase01.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts === + +interface BoxOfFoo> { +>BoxOfFoo : Symbol(BoxOfFoo, Decl(recurringTypeParamForContainerOfBase01.ts, 0, 0)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 1, 19)) +>Foo : Symbol(Foo, Decl(recurringTypeParamForContainerOfBase01.ts, 3, 1)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 1, 19)) + + item: T +>item : Symbol(BoxOfFoo.item, Decl(recurringTypeParamForContainerOfBase01.ts, 1, 38)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 1, 19)) +} + +interface Foo> { +>Foo : Symbol(Foo, Decl(recurringTypeParamForContainerOfBase01.ts, 3, 1)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 5, 14)) +>Foo : Symbol(Foo, Decl(recurringTypeParamForContainerOfBase01.ts, 3, 1)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 5, 14)) + + self: T; +>self : Symbol(Foo.self, Decl(recurringTypeParamForContainerOfBase01.ts, 5, 33)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 5, 14)) +} + +interface Bar> extends Foo { +>Bar : Symbol(Bar, Decl(recurringTypeParamForContainerOfBase01.ts, 7, 1)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 14)) +>Bar : Symbol(Bar, Decl(recurringTypeParamForContainerOfBase01.ts, 7, 1)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 14)) +>Foo : Symbol(Foo, Decl(recurringTypeParamForContainerOfBase01.ts, 3, 1)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 14)) + + other: BoxOfFoo; +>other : Symbol(Bar.other, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 48)) +>BoxOfFoo : Symbol(BoxOfFoo, Decl(recurringTypeParamForContainerOfBase01.ts, 0, 0)) +>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 14)) +} diff --git a/tests/baselines/reference/recurringTypeParamForContainerOfBase01.types b/tests/baselines/reference/recurringTypeParamForContainerOfBase01.types new file mode 100644 index 00000000000..38b23263f01 --- /dev/null +++ b/tests/baselines/reference/recurringTypeParamForContainerOfBase01.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts === + +interface BoxOfFoo> { +>BoxOfFoo : BoxOfFoo +>T : T +>Foo : Foo +>T : T + + item: T +>item : T +>T : T +} + +interface Foo> { +>Foo : Foo +>T : T +>Foo : Foo +>T : T + + self: T; +>self : T +>T : T +} + +interface Bar> extends Foo { +>Bar : Bar +>T : T +>Bar : Bar +>T : T +>Foo : Foo +>T : T + + other: BoxOfFoo; +>other : BoxOfFoo +>BoxOfFoo : BoxOfFoo +>T : T +} diff --git a/tests/baselines/reference/returnTypeParameterWithModules.symbols b/tests/baselines/reference/returnTypeParameterWithModules.symbols index e3b7c50948f..7f8fab382a3 100644 --- a/tests/baselines/reference/returnTypeParameterWithModules.symbols +++ b/tests/baselines/reference/returnTypeParameterWithModules.symbols @@ -12,13 +12,13 @@ module M1 { >A : Symbol(A, Decl(returnTypeParameterWithModules.ts, 1, 27)) return Array.prototype.reduce.apply(ar, e ? [f, e] : [f]); ->Array.prototype.reduce.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Array.prototype.reduce.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >Array.prototype.reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, --, --)) >reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >ar : Symbol(ar, Decl(returnTypeParameterWithModules.ts, 1, 30)) >e : Symbol(e, Decl(returnTypeParameterWithModules.ts, 1, 36)) >f : Symbol(f, Decl(returnTypeParameterWithModules.ts, 1, 33)) diff --git a/tests/baselines/reference/returnTypeParameterWithModules.types b/tests/baselines/reference/returnTypeParameterWithModules.types index ffb058daa08..584c962a170 100644 --- a/tests/baselines/reference/returnTypeParameterWithModules.types +++ b/tests/baselines/reference/returnTypeParameterWithModules.types @@ -13,13 +13,13 @@ module M1 { return Array.prototype.reduce.apply(ar, e ? [f, e] : [f]); >Array.prototype.reduce.apply(ar, e ? [f, e] : [f]) : any ->Array.prototype.reduce.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>Array.prototype.reduce.apply : (this: Function, thisArg: any, argArray?: any) => any >Array.prototype.reduce : { (callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; (callbackfn: (previousValue: U, currentValue: any, currentIndex: number, array: any[]) => U, initialValue: U): U; } >Array.prototype : any[] >Array : ArrayConstructor >prototype : any[] >reduce : { (callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; (callbackfn: (previousValue: U, currentValue: any, currentIndex: number, array: any[]) => U, initialValue: U): U; } ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >ar : any >e ? [f, e] : [f] : any[] >e : any diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.types b/tests/baselines/reference/stringLiteralTypesAsTags01.types index 243b55c4419..9f273cf93a9 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags01.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.types @@ -116,6 +116,6 @@ if (!hasKind(x, "B")) { } else { let d = x; ->d : {} ->x : {} +>d : nothing +>x : nothing } diff --git a/tests/baselines/reference/stringLiteralTypesAsTags02.types b/tests/baselines/reference/stringLiteralTypesAsTags02.types index 20834e1dfef..bcfa74ef55f 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags02.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags02.types @@ -110,6 +110,6 @@ if (!hasKind(x, "B")) { } else { let d = x; ->d : {} ->x : {} +>d : nothing +>x : nothing } diff --git a/tests/baselines/reference/stringLiteralTypesAsTags03.types b/tests/baselines/reference/stringLiteralTypesAsTags03.types index 78ad260b719..c7fdfc7152e 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags03.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags03.types @@ -113,6 +113,6 @@ if (!hasKind(x, "B")) { } else { let d = x; ->d : {} ->x : {} +>d : nothing +>x : nothing } diff --git a/tests/baselines/reference/thisInObjectLiterals.errors.txt b/tests/baselines/reference/thisInObjectLiterals.errors.txt index b0b1c63a34a..e89980dc244 100644 --- a/tests/baselines/reference/thisInObjectLiterals.errors.txt +++ b/tests/baselines/reference/thisInObjectLiterals.errors.txt @@ -1,8 +1,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(7,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type '{ x: this; y: number; }', but here has type '{ x: MyClass; y: number; }'. -tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(14,21): error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'. -==== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts (2 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts (1 errors) ==== class MyClass { t: number; @@ -19,8 +18,6 @@ tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(14,21): var obj = { f() { return this.spaaace; - ~~~~~~~ -!!! error TS2339: Property 'spaaace' does not exist on type '{ f(): any; }'. } }; var obj: { f: () => any; }; diff --git a/tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.js b/tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.js new file mode 100644 index 00000000000..51cc5a24bb6 --- /dev/null +++ b/tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.js @@ -0,0 +1,27 @@ +//// [thisTypeInBasePropertyAndDerivedContainerOfBase01.ts] + +interface BoxOfFoo { + item: T +} + +interface Foo { + self: this; +} + +interface Bar extends Foo { + other: BoxOfFoo; +} + +//// [thisTypeInBasePropertyAndDerivedContainerOfBase01.js] + + +//// [thisTypeInBasePropertyAndDerivedContainerOfBase01.d.ts] +interface BoxOfFoo { + item: T; +} +interface Foo { + self: this; +} +interface Bar extends Foo { + other: BoxOfFoo; +} diff --git a/tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.symbols b/tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.symbols new file mode 100644 index 00000000000..566bf3aa093 --- /dev/null +++ b/tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts === + +interface BoxOfFoo { +>BoxOfFoo : Symbol(BoxOfFoo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 0, 0)) +>T : Symbol(T, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 1, 19)) +>Foo : Symbol(Foo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 3, 1)) + + item: T +>item : Symbol(BoxOfFoo.item, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 1, 35)) +>T : Symbol(T, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 1, 19)) +} + +interface Foo { +>Foo : Symbol(Foo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 3, 1)) + + self: this; +>self : Symbol(Foo.self, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 5, 15)) +} + +interface Bar extends Foo { +>Bar : Symbol(Bar, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 7, 1)) +>Foo : Symbol(Foo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 3, 1)) + + other: BoxOfFoo; +>other : Symbol(Bar.other, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 9, 27)) +>BoxOfFoo : Symbol(BoxOfFoo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 0, 0)) +} diff --git a/tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.types b/tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.types new file mode 100644 index 00000000000..9f6b83df057 --- /dev/null +++ b/tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts === + +interface BoxOfFoo { +>BoxOfFoo : BoxOfFoo +>T : T +>Foo : Foo + + item: T +>item : T +>T : T +} + +interface Foo { +>Foo : Foo + + self: this; +>self : this +} + +interface Bar extends Foo { +>Bar : Bar +>Foo : Foo + + other: BoxOfFoo; +>other : BoxOfFoo +>BoxOfFoo : BoxOfFoo +} diff --git a/tests/baselines/reference/thisTypeInFunctions2.js b/tests/baselines/reference/thisTypeInFunctions2.js new file mode 100644 index 00000000000..f52438a19ab --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions2.js @@ -0,0 +1,91 @@ +//// [thisTypeInFunctions2.ts] +interface IndexedWithThis { + // this is a workaround for React + init?: (this: this) => void; + willDestroy?: (this: any) => void; + [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); +} +interface IndexedWithoutThis { + // this is what React would like to write (and what they write today) + init?: () => void; + willDestroy?: () => void; + [propName: string]: any; +} +interface SimpleInterface { + foo(n: string); + bar(): number; +} +declare function extend1(args: IndexedWithThis): void; +declare function extend2(args: IndexedWithoutThis): void; +declare function simple(arg: SimpleInterface): void; + +extend1({ + init() { + this // this: IndexedWithThis because of contextual typing. + // this.mine + this.willDestroy + }, + mine: 12, + foo() { + this.url; // this: any because 'foo' matches the string indexer + this.willDestroy; + } +}); +extend2({ + init() { + this // this: any because the contextual signature of init doesn't specify this' type + this.mine + this.willDestroy + }, + mine: 13, + foo() { + this // this: any because of the string indexer + this.mine + this.willDestroy + } +}); + +simple({ + foo(n) { + return n.length + this.bar(); + }, + bar() { + return 14; + } +}) + + +//// [thisTypeInFunctions2.js] +extend1({ + init: function () { + this; // this: IndexedWithThis because of contextual typing. + // this.mine + this.willDestroy; + }, + mine: 12, + foo: function () { + this.url; // this: any because 'foo' matches the string indexer + this.willDestroy; + } +}); +extend2({ + init: function () { + this; // this: any because the contextual signature of init doesn't specify this' type + this.mine; + this.willDestroy; + }, + mine: 13, + foo: function () { + this; // this: any because of the string indexer + this.mine; + this.willDestroy; + } +}); +simple({ + foo: function (n) { + return n.length + this.bar(); + }, + bar: function () { + return 14; + } +}); diff --git a/tests/baselines/reference/thisTypeInFunctions2.symbols b/tests/baselines/reference/thisTypeInFunctions2.symbols new file mode 100644 index 00000000000..cdc7fb321d4 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions2.symbols @@ -0,0 +1,124 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts === +interface IndexedWithThis { +>IndexedWithThis : Symbol(IndexedWithThis, Decl(thisTypeInFunctions2.ts, 0, 0)) + + // this is a workaround for React + init?: (this: this) => void; +>init : Symbol(IndexedWithThis.init, Decl(thisTypeInFunctions2.ts, 0, 27)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 2, 12)) + + willDestroy?: (this: any) => void; +>willDestroy : Symbol(IndexedWithThis.willDestroy, Decl(thisTypeInFunctions2.ts, 2, 32)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 3, 19)) + + [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); +>propName : Symbol(propName, Decl(thisTypeInFunctions2.ts, 4, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 4, 87)) +>args : Symbol(args, Decl(thisTypeInFunctions2.ts, 4, 97)) +} +interface IndexedWithoutThis { +>IndexedWithoutThis : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) + + // this is what React would like to write (and what they write today) + init?: () => void; +>init : Symbol(IndexedWithoutThis.init, Decl(thisTypeInFunctions2.ts, 6, 30)) + + willDestroy?: () => void; +>willDestroy : Symbol(IndexedWithoutThis.willDestroy, Decl(thisTypeInFunctions2.ts, 8, 22)) + + [propName: string]: any; +>propName : Symbol(propName, Decl(thisTypeInFunctions2.ts, 10, 5)) +} +interface SimpleInterface { +>SimpleInterface : Symbol(SimpleInterface, Decl(thisTypeInFunctions2.ts, 11, 1)) + + foo(n: string); +>foo : Symbol(SimpleInterface.foo, Decl(thisTypeInFunctions2.ts, 12, 27)) +>n : Symbol(n, Decl(thisTypeInFunctions2.ts, 13, 8)) + + bar(): number; +>bar : Symbol(SimpleInterface.bar, Decl(thisTypeInFunctions2.ts, 13, 19)) +} +declare function extend1(args: IndexedWithThis): void; +>extend1 : Symbol(extend1, Decl(thisTypeInFunctions2.ts, 15, 1)) +>args : Symbol(args, Decl(thisTypeInFunctions2.ts, 16, 25)) +>IndexedWithThis : Symbol(IndexedWithThis, Decl(thisTypeInFunctions2.ts, 0, 0)) + +declare function extend2(args: IndexedWithoutThis): void; +>extend2 : Symbol(extend2, Decl(thisTypeInFunctions2.ts, 16, 54)) +>args : Symbol(args, Decl(thisTypeInFunctions2.ts, 17, 25)) +>IndexedWithoutThis : Symbol(IndexedWithoutThis, Decl(thisTypeInFunctions2.ts, 5, 1)) + +declare function simple(arg: SimpleInterface): void; +>simple : Symbol(simple, Decl(thisTypeInFunctions2.ts, 17, 57)) +>arg : Symbol(arg, Decl(thisTypeInFunctions2.ts, 18, 24)) +>SimpleInterface : Symbol(SimpleInterface, Decl(thisTypeInFunctions2.ts, 11, 1)) + +extend1({ +>extend1 : Symbol(extend1, Decl(thisTypeInFunctions2.ts, 15, 1)) + + init() { +>init : Symbol(init, Decl(thisTypeInFunctions2.ts, 20, 9)) + + this // this: IndexedWithThis because of contextual typing. +>this : Symbol(IndexedWithThis, Decl(thisTypeInFunctions2.ts, 0, 0)) + + // this.mine + this.willDestroy +>this.willDestroy : Symbol(IndexedWithThis.willDestroy, Decl(thisTypeInFunctions2.ts, 2, 32)) +>this : Symbol(IndexedWithThis, Decl(thisTypeInFunctions2.ts, 0, 0)) +>willDestroy : Symbol(IndexedWithThis.willDestroy, Decl(thisTypeInFunctions2.ts, 2, 32)) + + }, + mine: 12, +>mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 25, 6)) + + foo() { +>foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 26, 13)) + + this.url; // this: any because 'foo' matches the string indexer + this.willDestroy; + } +}); +extend2({ +>extend2 : Symbol(extend2, Decl(thisTypeInFunctions2.ts, 16, 54)) + + init() { +>init : Symbol(init, Decl(thisTypeInFunctions2.ts, 32, 9)) + + this // this: any because the contextual signature of init doesn't specify this' type + this.mine + this.willDestroy + }, + mine: 13, +>mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 37, 6)) + + foo() { +>foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 38, 13)) + + this // this: any because of the string indexer + this.mine + this.willDestroy + } +}); + +simple({ +>simple : Symbol(simple, Decl(thisTypeInFunctions2.ts, 17, 57)) + + foo(n) { +>foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 46, 8)) +>n : Symbol(n, Decl(thisTypeInFunctions2.ts, 47, 8)) + + return n.length + this.bar(); +>n.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>n : Symbol(n, Decl(thisTypeInFunctions2.ts, 47, 8)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + }, + bar() { +>bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 49, 6)) + + return 14; + } +}) + diff --git a/tests/baselines/reference/thisTypeInFunctions2.types b/tests/baselines/reference/thisTypeInFunctions2.types new file mode 100644 index 00000000000..371b5f5cafc --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions2.types @@ -0,0 +1,165 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts === +interface IndexedWithThis { +>IndexedWithThis : IndexedWithThis + + // this is a workaround for React + init?: (this: this) => void; +>init : (this: this) => void +>this : this + + willDestroy?: (this: any) => void; +>willDestroy : (this: any) => void +>this : any + + [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); +>propName : string +>null : null +>this : any +>args : any[] +} +interface IndexedWithoutThis { +>IndexedWithoutThis : IndexedWithoutThis + + // this is what React would like to write (and what they write today) + init?: () => void; +>init : () => void + + willDestroy?: () => void; +>willDestroy : () => void + + [propName: string]: any; +>propName : string +} +interface SimpleInterface { +>SimpleInterface : SimpleInterface + + foo(n: string); +>foo : (n: string) => any +>n : string + + bar(): number; +>bar : () => number +} +declare function extend1(args: IndexedWithThis): void; +>extend1 : (args: IndexedWithThis) => void +>args : IndexedWithThis +>IndexedWithThis : IndexedWithThis + +declare function extend2(args: IndexedWithoutThis): void; +>extend2 : (args: IndexedWithoutThis) => void +>args : IndexedWithoutThis +>IndexedWithoutThis : IndexedWithoutThis + +declare function simple(arg: SimpleInterface): void; +>simple : (arg: SimpleInterface) => void +>arg : SimpleInterface +>SimpleInterface : SimpleInterface + +extend1({ +>extend1({ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }}) : void +>extend1 : (args: IndexedWithThis) => void +>{ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }} : { init(): void; mine: number; foo(): void; } + + init() { +>init : () => void + + this // this: IndexedWithThis because of contextual typing. +>this : IndexedWithThis + + // this.mine + this.willDestroy +>this.willDestroy : (this: any) => void +>this : IndexedWithThis +>willDestroy : (this: any) => void + + }, + mine: 12, +>mine : number +>12 : number + + foo() { +>foo : () => void + + this.url; // this: any because 'foo' matches the string indexer +>this.url : any +>this : any +>url : any + + this.willDestroy; +>this.willDestroy : any +>this : any +>willDestroy : any + } +}); +extend2({ +>extend2({ init() { this // this: any because the contextual signature of init doesn't specify this' type this.mine this.willDestroy }, mine: 13, foo() { this // this: any because of the string indexer this.mine this.willDestroy }}) : void +>extend2 : (args: IndexedWithoutThis) => void +>{ init() { this // this: any because the contextual signature of init doesn't specify this' type this.mine this.willDestroy }, mine: 13, foo() { this // this: any because of the string indexer this.mine this.willDestroy }} : { init(): void; mine: number; foo(): void; } + + init() { +>init : () => void + + this // this: any because the contextual signature of init doesn't specify this' type +>this : any + + this.mine +>this.mine : any +>this : any +>mine : any + + this.willDestroy +>this.willDestroy : any +>this : any +>willDestroy : any + + }, + mine: 13, +>mine : number +>13 : number + + foo() { +>foo : () => void + + this // this: any because of the string indexer +>this : any + + this.mine +>this.mine : any +>this : any +>mine : any + + this.willDestroy +>this.willDestroy : any +>this : any +>willDestroy : any + } +}); + +simple({ +>simple({ foo(n) { return n.length + this.bar(); }, bar() { return 14; }}) : void +>simple : (arg: SimpleInterface) => void +>{ foo(n) { return n.length + this.bar(); }, bar() { return 14; }} : { foo(n: string): any; bar(): number; } + + foo(n) { +>foo : (n: string) => any +>n : string + + return n.length + this.bar(); +>n.length + this.bar() : any +>n.length : number +>n : string +>length : number +>this.bar() : any +>this.bar : any +>this : any +>bar : any + + }, + bar() { +>bar : () => number + + return 14; +>14 : number + } +}) + diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.js b/tests/baselines/reference/thisTypeInObjectLiterals.js index 5af13a41af8..342c9d58c84 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.js +++ b/tests/baselines/reference/thisTypeInObjectLiterals.js @@ -3,8 +3,12 @@ let o = { d: "bar", m() { return this.d.length; + }, + f: function() { + return this.d.length; } } + let mutuallyRecursive = { a: 100, start() { @@ -35,6 +39,9 @@ var o = { d: "bar", m: function () { return this.d.length; + }, + f: function () { + return this.d.length; } }; var mutuallyRecursive = { diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.symbols b/tests/baselines/reference/thisTypeInObjectLiterals.symbols index 9ae4a990d5b..af4badf1c0f 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.symbols +++ b/tests/baselines/reference/thisTypeInObjectLiterals.symbols @@ -9,84 +9,72 @@ let o = { >m : Symbol(m, Decl(thisTypeInObjectLiterals.ts, 1, 13)) return this.d.length; ->this.d.length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->this.d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) ->this : Symbol(, Decl(thisTypeInObjectLiterals.ts, 0, 7)) ->d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) ->length : Symbol(String.length, Decl(lib.d.ts, --, --)) + }, + f: function() { +>f : Symbol(f, Decl(thisTypeInObjectLiterals.ts, 4, 6)) + + return this.d.length; } } + let mutuallyRecursive = { ->mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 6, 3)) +>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 3)) a: 100, ->a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 6, 25)) +>a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 10, 25)) start() { ->start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 7, 11)) +>start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11)) return this.passthrough(this.a); ->this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 10, 6)) ->this : Symbol(, Decl(thisTypeInObjectLiterals.ts, 6, 23)) ->passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 10, 6)) ->this.a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 6, 25)) ->this : Symbol(, Decl(thisTypeInObjectLiterals.ts, 6, 23)) ->a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 6, 25)) - }, passthrough(n: number) { ->passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 10, 6)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 11, 16)) +>passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 14, 6)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 15, 16)) return this.sub1(n); ->this.sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 13, 6)) ->this : Symbol(, Decl(thisTypeInObjectLiterals.ts, 6, 23)) ->sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 13, 6)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 11, 16)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 15, 16)) }, sub1(n: number): number { ->sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 13, 6)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 14, 9)) +>sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 17, 6)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) if (n > 0) { ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 14, 9)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) return this.passthrough(n - 1); ->this.passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 10, 6)) ->this : Symbol(, Decl(thisTypeInObjectLiterals.ts, 6, 23)) ->passthrough : Symbol(passthrough, Decl(thisTypeInObjectLiterals.ts, 10, 6)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 14, 9)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) } return n; ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 14, 9)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 18, 9)) } } var i: number = mutuallyRecursive.start(); ->i : Symbol(i, Decl(thisTypeInObjectLiterals.ts, 21, 3)) ->mutuallyRecursive.start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 7, 11)) ->mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 6, 3)) ->start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 7, 11)) +>i : Symbol(i, Decl(thisTypeInObjectLiterals.ts, 25, 3)) +>mutuallyRecursive.start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11)) +>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 3)) +>start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 11, 11)) interface I { ->I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 21, 42)) +>I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 25, 42)) a: number; ->a : Symbol(I.a, Decl(thisTypeInObjectLiterals.ts, 22, 13)) +>a : Symbol(I.a, Decl(thisTypeInObjectLiterals.ts, 26, 13)) start(): number; ->start : Symbol(I.start, Decl(thisTypeInObjectLiterals.ts, 23, 14)) +>start : Symbol(I.start, Decl(thisTypeInObjectLiterals.ts, 27, 14)) passthrough(n: number): number; ->passthrough : Symbol(I.passthrough, Decl(thisTypeInObjectLiterals.ts, 24, 20)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 25, 16)) +>passthrough : Symbol(I.passthrough, Decl(thisTypeInObjectLiterals.ts, 28, 20)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 29, 16)) sub1(n: number): number; ->sub1 : Symbol(I.sub1, Decl(thisTypeInObjectLiterals.ts, 25, 35)) ->n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 26, 9)) +>sub1 : Symbol(I.sub1, Decl(thisTypeInObjectLiterals.ts, 29, 35)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 30, 9)) } var impl: I = mutuallyRecursive; ->impl : Symbol(impl, Decl(thisTypeInObjectLiterals.ts, 28, 3)) ->I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 21, 42)) ->mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 6, 3)) +>impl : Symbol(impl, Decl(thisTypeInObjectLiterals.ts, 32, 3)) +>I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 25, 42)) +>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 10, 3)) diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.types b/tests/baselines/reference/thisTypeInObjectLiterals.types index 0b164209219..91d95d5f0a8 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.types +++ b/tests/baselines/reference/thisTypeInObjectLiterals.types @@ -1,53 +1,66 @@ === tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts === let o = { ->o : { d: string; m(): number; } ->{ d: "bar", m() { return this.d.length; }} : { d: string; m(): number; } +>o : { d: string; m(): any; f: () => any; } +>{ d: "bar", m() { return this.d.length; }, f: function() { return this.d.length; }} : { d: string; m(): any; f: () => any; } d: "bar", >d : string >"bar" : string m() { ->m : () => number +>m : () => any return this.d.length; ->this.d.length : number ->this.d : string ->this : { d: string; m(): number; } ->d : string ->length : number +>this.d.length : any +>this.d : any +>this : any +>d : any +>length : any + + }, + f: function() { +>f : () => any +>function() { return this.d.length; } : () => any + + return this.d.length; +>this.d.length : any +>this.d : any +>this : any +>d : any +>length : any } } + let mutuallyRecursive = { ->mutuallyRecursive : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } ->{ a: 100, start() { return this.passthrough(this.a); }, passthrough(n: number) { return this.sub1(n); }, sub1(n: number): number { if (n > 0) { return this.passthrough(n - 1); } return n; }} : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } +>mutuallyRecursive : { a: number; start(): any; passthrough(n: number): any; sub1(n: number): number; } +>{ a: 100, start() { return this.passthrough(this.a); }, passthrough(n: number) { return this.sub1(n); }, sub1(n: number): number { if (n > 0) { return this.passthrough(n - 1); } return n; }} : { a: number; start(): any; passthrough(n: number): any; sub1(n: number): number; } a: 100, >a : number >100 : number start() { ->start : () => number +>start : () => any return this.passthrough(this.a); ->this.passthrough(this.a) : number ->this.passthrough : (n: number) => number ->this : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } ->passthrough : (n: number) => number ->this.a : number ->this : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } ->a : number +>this.passthrough(this.a) : any +>this.passthrough : any +>this : any +>passthrough : any +>this.a : any +>this : any +>a : any }, passthrough(n: number) { ->passthrough : (n: number) => number +>passthrough : (n: number) => any >n : number return this.sub1(n); ->this.sub1(n) : number ->this.sub1 : (n: number) => number ->this : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } ->sub1 : (n: number) => number +>this.sub1(n) : any +>this.sub1 : any +>this : any +>sub1 : any >n : number }, @@ -61,10 +74,10 @@ let mutuallyRecursive = { >0 : number return this.passthrough(n - 1); ->this.passthrough(n - 1) : number ->this.passthrough : (n: number) => number ->this : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } ->passthrough : (n: number) => number +>this.passthrough(n - 1) : any +>this.passthrough : any +>this : any +>passthrough : any >n - 1 : number >n : number >1 : number @@ -75,10 +88,10 @@ let mutuallyRecursive = { } var i: number = mutuallyRecursive.start(); >i : number ->mutuallyRecursive.start() : number ->mutuallyRecursive.start : () => number ->mutuallyRecursive : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } ->start : () => number +>mutuallyRecursive.start() : any +>mutuallyRecursive.start : () => any +>mutuallyRecursive : { a: number; start(): any; passthrough(n: number): any; sub1(n: number): number; } +>start : () => any interface I { >I : I @@ -100,5 +113,5 @@ interface I { var impl: I = mutuallyRecursive; >impl : I >I : I ->mutuallyRecursive : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } +>mutuallyRecursive : { a: number; start(): any; passthrough(n: number): any; sub1(n: number): number; } diff --git a/tests/baselines/reference/throwInEnclosingStatements.symbols b/tests/baselines/reference/throwInEnclosingStatements.symbols index 858b6484e53..63ed9dde578 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.symbols +++ b/tests/baselines/reference/throwInEnclosingStatements.symbols @@ -89,7 +89,6 @@ var aa = { >biz : Symbol(biz, Decl(throwInEnclosingStatements.ts, 41, 10)) throw this; ->this : Symbol(, Decl(throwInEnclosingStatements.ts, 40, 8)) } } diff --git a/tests/baselines/reference/throwInEnclosingStatements.types b/tests/baselines/reference/throwInEnclosingStatements.types index 8add6e8b1a8..32f0fb093bc 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.types +++ b/tests/baselines/reference/throwInEnclosingStatements.types @@ -104,7 +104,7 @@ var aa = { >biz : () => void throw this; ->this : { id: number; biz(): void; } +>this : any } } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types index a5dcc9207cd..564c6ceaa72 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types @@ -121,7 +121,7 @@ if (typeof strOrNum === "boolean") { let z1: {} = strOrNum; // {} >z1 : {} ->strOrNum : {} +>strOrNum : nothing } else { let z2: string | number = strOrNum; // string | number @@ -215,6 +215,6 @@ if (typeof strOrNum !== "boolean") { else { let z2: {} = strOrNum; // {} >z2 : {} ->strOrNum : {} +>strOrNum : nothing } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types index 99f927b7137..51326c68cd9 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types @@ -120,7 +120,7 @@ if (typeof strOrBool === "number") { let y1: {} = strOrBool; // {} >y1 : {} ->strOrBool : {} +>strOrBool : nothing } else { let y2: string | boolean = strOrBool; // string | boolean @@ -212,6 +212,6 @@ if (typeof strOrBool !== "number") { else { let y2: {} = strOrBool; // {} >y2 : {} ->strOrBool : {} +>strOrBool : nothing } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.types b/tests/baselines/reference/typeGuardOfFormTypeOfOther.types index aba8e429b8c..c8c150b5a3b 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.types @@ -105,7 +105,7 @@ if (typeof strOrNumOrBool === "Object") { let q1: {} = strOrNumOrBool; // {} >q1 : {} ->strOrNumOrBool : {} +>strOrNumOrBool : nothing } else { let q2: string | number | boolean = strOrNumOrBool; // string | number | boolean @@ -178,6 +178,6 @@ if (typeof strOrNumOrBool !== "Object") { else { let q2: {} = strOrNumOrBool; // {} >q2 : {} ->strOrNumOrBool : {} +>strOrNumOrBool : nothing } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfString.types b/tests/baselines/reference/typeGuardOfFormTypeOfString.types index c77f9f3207a..23c789fb987 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfString.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfString.types @@ -121,7 +121,7 @@ if (typeof numOrBool === "string") { let x1: {} = numOrBool; // {} >x1 : {} ->numOrBool : {} +>numOrBool : nothing } else { let x2: number | boolean = numOrBool; // number | boolean @@ -214,6 +214,6 @@ if (typeof numOrBool !== "string") { else { let x2: {} = numOrBool; // {} >x2 : {} ->numOrBool : {} +>numOrBool : nothing } diff --git a/tests/baselines/reference/typeGuardTautologicalConsistiency.types b/tests/baselines/reference/typeGuardTautologicalConsistiency.types index 100e528f616..cf9e82d9fd2 100644 --- a/tests/baselines/reference/typeGuardTautologicalConsistiency.types +++ b/tests/baselines/reference/typeGuardTautologicalConsistiency.types @@ -15,7 +15,7 @@ if (typeof stringOrNumber === "number") { >"number" : string stringOrNumber; ->stringOrNumber : {} +>stringOrNumber : nothing } } @@ -31,6 +31,6 @@ if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { >"number" : string stringOrNumber; ->stringOrNumber : {} +>stringOrNumber : nothing } diff --git a/tests/baselines/reference/typeGuardTypeOfUndefined.types b/tests/baselines/reference/typeGuardTypeOfUndefined.types index 7073d9aeacb..ac648d36f01 100644 --- a/tests/baselines/reference/typeGuardTypeOfUndefined.types +++ b/tests/baselines/reference/typeGuardTypeOfUndefined.types @@ -47,7 +47,7 @@ function test2(a: any) { >"boolean" : string a; ->a : {} +>a : nothing } else { a; @@ -129,7 +129,7 @@ function test5(a: boolean | void) { } else { a; ->a : {} +>a : nothing } } else { @@ -188,7 +188,7 @@ function test7(a: boolean | void) { } else { a; ->a : {} +>a : nothing } } diff --git a/tests/baselines/reference/typeGuardsWithInstanceOf.errors.txt b/tests/baselines/reference/typeGuardsWithInstanceOf.errors.txt index 28cc85695bc..662d3697159 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOf.errors.txt +++ b/tests/baselines/reference/typeGuardsWithInstanceOf.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts(7,20): error TS2339: Property 'global' does not exist on type '{}'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts(7,20): error TS2339: Property 'global' does not exist on type 'nothing'. ==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts(7,20) result = result2; } else if (!result.global) { ~~~~~~ -!!! error TS2339: Property 'global' does not exist on type '{}'. +!!! error TS2339: Property 'global' does not exist on type 'nothing'. } \ No newline at end of file diff --git a/tests/cases/compiler/APISample_compile.ts b/tests/cases/compiler/APISample_compile.ts index 9672b9863fa..b60c53685aa 100644 --- a/tests/cases/compiler/APISample_compile.ts +++ b/tests/cases/compiler/APISample_compile.ts @@ -1,6 +1,7 @@ // @module: commonjs // @includebuiltfile: typescript_standalone.d.ts -// @stripInternal:true +// @noImplicitAny:true +// @strictNullChecks:true /* * Note: This test is a public API sample. The sample sources can be found diff --git a/tests/cases/compiler/APISample_linter.ts b/tests/cases/compiler/APISample_linter.ts index 8cb6934cee3..89f0be7a0f5 100644 --- a/tests/cases/compiler/APISample_linter.ts +++ b/tests/cases/compiler/APISample_linter.ts @@ -1,6 +1,7 @@ // @module: commonjs // @includebuiltfile: typescript_standalone.d.ts -// @stripInternal:true +// @noImplicitAny:true +// @strictNullChecks:true /* * Note: This test is a public API sample. The sample sources can be found @@ -57,7 +58,7 @@ export function delint(sourceFile: ts.SourceFile) { } } -const fileNames = process.argv.slice(2); +const fileNames: string[] = process.argv.slice(2); fileNames.forEach(fileName => { // Parse a file let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); diff --git a/tests/cases/compiler/APISample_parseConfig.ts b/tests/cases/compiler/APISample_parseConfig.ts index 3e88e50727e..f59f64dc4ad 100644 --- a/tests/cases/compiler/APISample_parseConfig.ts +++ b/tests/cases/compiler/APISample_parseConfig.ts @@ -1,6 +1,7 @@ // @module: commonjs // @includebuiltfile: typescript_standalone.d.ts -// @stripInternal:true +// @noImplicitAny:true +// @strictNullChecks:true /* * Note: This test is a public API sample. The sample sources can be found @@ -21,7 +22,7 @@ function printError(error: ts.Diagnostic): void { console.log(`${error.file && error.file.fileName}: ${error.messageText}`); } -export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program { +export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program | undefined { const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson) if (error) { printError(error); diff --git a/tests/cases/compiler/APISample_transform.ts b/tests/cases/compiler/APISample_transform.ts index 88b9754536a..a76d6b15463 100644 --- a/tests/cases/compiler/APISample_transform.ts +++ b/tests/cases/compiler/APISample_transform.ts @@ -1,6 +1,7 @@ // @module: commonjs // @includebuiltfile: typescript_standalone.d.ts -// @stripInternal:true +// @noImplicitAny:true +// @strictNullChecks:true /* * Note: This test is a public API sample. The sample sources can be found diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts index 9afa53ddf14..34baa04c850 100644 --- a/tests/cases/compiler/APISample_watcher.ts +++ b/tests/cases/compiler/APISample_watcher.ts @@ -1,6 +1,7 @@ // @module: commonjs // @includebuiltfile: typescript_standalone.d.ts -// @stripInternal:true +// @noImplicitAny:true +// @strictNullChecks:true /* * Note: This test is a public API sample. The sample sources can be found @@ -10,7 +11,13 @@ declare var process: any; declare var console: any; -declare var fs: any; +declare var fs: { + existsSync(path: string): boolean; + readdirSync(path: string): string[]; + readFileSync(filename: string, encoding?: string): string; + writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void; +}; declare var path: any; import * as ts from "typescript"; diff --git a/tests/cases/compiler/ambientNameRestrictions.ts b/tests/cases/compiler/ambientNameRestrictions.ts new file mode 100644 index 00000000000..dc601e91851 --- /dev/null +++ b/tests/cases/compiler/ambientNameRestrictions.ts @@ -0,0 +1,3 @@ +export declare namespace Foo { + export var static: any; +} diff --git a/tests/cases/compiler/controlFlowDestructuringParameters.ts b/tests/cases/compiler/controlFlowDestructuringParameters.ts new file mode 100644 index 00000000000..3efcd8c4814 --- /dev/null +++ b/tests/cases/compiler/controlFlowDestructuringParameters.ts @@ -0,0 +1,7 @@ +// Repro for #8376 + +// @strictNullChecks: true + +[{ x: 1 }].map( + ({ x }) => x +); diff --git a/tests/cases/compiler/controlFlowLoopAnalysis.ts b/tests/cases/compiler/controlFlowLoopAnalysis.ts new file mode 100644 index 00000000000..60cb9436006 --- /dev/null +++ b/tests/cases/compiler/controlFlowLoopAnalysis.ts @@ -0,0 +1,31 @@ +// @strictNullChecks: true + +// Repro from #8418 + +let cond: boolean; + +function foo(x: number): number { return 1; } + +function test1() { + let x: number | undefined; + while (cond) { + while (cond) { + while (cond) { + x = foo(x); + } + } + x = 1; + } +} + +// Repro from #8418 + +function test2() { + let x: number | undefined; + x = 1; + while (cond) { + while (cond) { + x = foo(x); + } + } +} diff --git a/tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts b/tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts new file mode 100644 index 00000000000..17568f48029 --- /dev/null +++ b/tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts @@ -0,0 +1,11 @@ +// @strictNullChecks: true + +// Regression test for #8295 + +function foo() { + try { + } + catch (e) { + let s = e.message; + } +} diff --git a/tests/cases/compiler/narrowingOfDottedNames.ts b/tests/cases/compiler/narrowingOfDottedNames.ts new file mode 100644 index 00000000000..af417f0830c --- /dev/null +++ b/tests/cases/compiler/narrowingOfDottedNames.ts @@ -0,0 +1,39 @@ +// Repro from #8383 + +class A { + prop: { a: string; }; +} + +class B { + prop: { b: string; } +} + +function isA(x: any): x is A { + return x instanceof A; +} + +function isB(x: any): x is B { + return x instanceof B; +} + +function f1(x: A | B) { + while (true) { + if (x instanceof A) { + x.prop.a; + } + else if (x instanceof B) { + x.prop.b; + } + } +} + +function f2(x: A | B) { + while (true) { + if (isA(x)) { + x.prop.a; + } + else if (isB(x)) { + x.prop.b; + } + } +} diff --git a/tests/cases/compiler/noImplicitThisObjectLiterals.ts b/tests/cases/compiler/noImplicitThisObjectLiterals.ts new file mode 100644 index 00000000000..abd5d9dcfba --- /dev/null +++ b/tests/cases/compiler/noImplicitThisObjectLiterals.ts @@ -0,0 +1,10 @@ +// @noImplicitThis: true +let o = { + d: this, // error, this: any + m() { + return this.d.length; // error, this: any + }, + f: function() { + return this.d.length; // error, this: any + } +} diff --git a/tests/cases/conformance/controlFlow/controlFlowIteration.ts b/tests/cases/conformance/controlFlow/controlFlowIteration.ts new file mode 100644 index 00000000000..56172b1bbdf --- /dev/null +++ b/tests/cases/conformance/controlFlow/controlFlowIteration.ts @@ -0,0 +1,20 @@ +// @strictNullChecks: true + +let cond: boolean; + +function ff() { + let x: string | undefined; + while (true) { + if (cond) { + x = ""; + } + else { + if (x) { + x.length; + } + if (x) { + x.length; + } + } + } +} diff --git a/tests/cases/conformance/es6/modules/defaultExportInAwaitExpression01.ts b/tests/cases/conformance/es6/modules/defaultExportInAwaitExpression01.ts new file mode 100644 index 00000000000..45f15423016 --- /dev/null +++ b/tests/cases/conformance/es6/modules/defaultExportInAwaitExpression01.ts @@ -0,0 +1,12 @@ +// @target: ES6 +// @module: umd +// @filename: a.ts +const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); +export default x; + +// @filename: b.ts +import x from './a'; + +( async function() { + const value = await x; +}() ); diff --git a/tests/cases/conformance/es6/modules/defaultExportInAwaitExpression02.ts b/tests/cases/conformance/es6/modules/defaultExportInAwaitExpression02.ts new file mode 100644 index 00000000000..cd878540a3c --- /dev/null +++ b/tests/cases/conformance/es6/modules/defaultExportInAwaitExpression02.ts @@ -0,0 +1,12 @@ +// @target: ES6 +// @module: commonjs +// @filename: a.ts +const x = new Promise( ( resolve, reject ) => { resolve( {} ); } ); +export default x; + +// @filename: b.ts +import x from './a'; + +( async function() { + const value = await x; +}() ); diff --git a/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts index b151961e324..b70f064f43a 100644 --- a/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts @@ -19,12 +19,12 @@ class C implements I { } let c = new C(); c.explicitVoid = c.explicitThis; // error, 'void' is missing everything -let o = { +let o = { n: 101, - explicitThis: function (m: number) { - return m + this.n.length; // ok, this.n: any + explicitThis: function (m: number) { + return m + this.n.length; // error, 'length' does not exist on 'number' }, - implicitThis(m: number): number { return m; } + implicitThis(m: number): number { return m; } }; let i: I = o; let o2: I = { @@ -44,4 +44,4 @@ o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to o.implicitThis = i.explicitThis; i.explicitThis = function(m) { return this.n.length; // error, this.n: number -} \ No newline at end of file +} diff --git a/tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts b/tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts new file mode 100644 index 00000000000..6597f32adc9 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts @@ -0,0 +1,13 @@ +// @declaration: true + +interface BoxOfFoo { + item: T +} + +interface Foo { + self: this; +} + +interface Bar extends Foo { + other: BoxOfFoo; +} \ No newline at end of file diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts new file mode 100644 index 00000000000..a574c7a07e9 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts @@ -0,0 +1,54 @@ +interface IndexedWithThis { + // this is a workaround for React + init?: (this: this) => void; + willDestroy?: (this: any) => void; + [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); +} +interface IndexedWithoutThis { + // this is what React would like to write (and what they write today) + init?: () => void; + willDestroy?: () => void; + [propName: string]: any; +} +interface SimpleInterface { + foo(n: string); + bar(): number; +} +declare function extend1(args: IndexedWithThis): void; +declare function extend2(args: IndexedWithoutThis): void; +declare function simple(arg: SimpleInterface): void; + +extend1({ + init() { + this // this: IndexedWithThis because of contextual typing. + // this.mine + this.willDestroy + }, + mine: 12, + foo() { + this.url; // this: any because 'foo' matches the string indexer + this.willDestroy; + } +}); +extend2({ + init() { + this // this: any because the contextual signature of init doesn't specify this' type + this.mine + this.willDestroy + }, + mine: 13, + foo() { + this // this: any because of the string indexer + this.mine + this.willDestroy + } +}); + +simple({ + foo(n) { + return n.length + this.bar(); + }, + bar() { + return 14; + } +}) diff --git a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts index cfdb0883fed..599caf70f30 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts @@ -2,8 +2,12 @@ let o = { d: "bar", m() { return this.d.length; + }, + f: function() { + return this.d.length; } } + let mutuallyRecursive = { a: 100, start() { diff --git a/tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts b/tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts new file mode 100644 index 00000000000..e8484d30f95 --- /dev/null +++ b/tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts @@ -0,0 +1,13 @@ +// @declaration: true + +interface BoxOfFoo> { + item: T +} + +interface Foo> { + self: T; +} + +interface Bar> extends Foo { + other: BoxOfFoo; +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts b/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts new file mode 100644 index 00000000000..dcf7240312c --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts @@ -0,0 +1,14 @@ +/// + +////type Options = "[|option 1|]" | "option 2"; +////let myOption: Options = "[|option 1|]"; + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesStringLiteralTypes.ts b/tests/cases/fourslash/getOccurrencesStringLiteralTypes.ts new file mode 100644 index 00000000000..56af87497d5 --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesStringLiteralTypes.ts @@ -0,0 +1,13 @@ +/// + +////function foo(a: "[|option 1|]") { } +////foo("[|option 1|]"); + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/getOccurrencesStringLiterals.ts b/tests/cases/fourslash/getOccurrencesStringLiterals.ts new file mode 100644 index 00000000000..efa365cbbb8 --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesStringLiterals.ts @@ -0,0 +1,10 @@ +/// + +////var x = "[|string|]"; +////function f(a = "[|initial value|]") { } + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + verify.occurrencesAtPositionCount(0); +} diff --git a/tests/cases/fourslash/quickInfoOnNarrowedType.ts b/tests/cases/fourslash/quickInfoOnNarrowedType.ts index bc1d8126d76..53fe1bed232 100644 --- a/tests/cases/fourslash/quickInfoOnNarrowedType.ts +++ b/tests/cases/fourslash/quickInfoOnNarrowedType.ts @@ -1,5 +1,7 @@ /// +// @strictNullChecks: true + ////function foo(strOrNum: string | number) { //// if (typeof /*1*/strOrNum === "number") { //// return /*2*/strOrNum; @@ -9,6 +11,13 @@ //// } ////} +////function bar() { +//// let s: string | undefined; +//// /*4*/s; +//// /*5*/s = "abc"; +//// /*6*/s; +////} + goTo.marker('1'); verify.quickInfoIs('(parameter) strOrNum: string | number'); verify.completionListContains("strOrNum", "(parameter) strOrNum: string | number"); @@ -20,3 +29,15 @@ verify.completionListContains("strOrNum", "(parameter) strOrNum: number"); goTo.marker('3'); verify.quickInfoIs('(parameter) strOrNum: string'); verify.completionListContains("strOrNum", "(parameter) strOrNum: string"); + +goTo.marker('4'); +verify.quickInfoIs('let s: undefined'); +verify.completionListContains("s", "let s: undefined"); + +goTo.marker('5'); +verify.quickInfoIs('let s: string | undefined'); +verify.completionListContains("s", "let s: string | undefined"); + +goTo.marker('6'); +verify.quickInfoIs('let s: string'); +verify.completionListContains("s", "let s: string"); diff --git a/tests/cases/fourslash/renameStingLiterals.ts b/tests/cases/fourslash/renameStingLiterals.ts new file mode 100644 index 00000000000..0e1222f327a --- /dev/null +++ b/tests/cases/fourslash/renameStingLiterals.ts @@ -0,0 +1,12 @@ +/// + +////var y: "string" = "string; +////var x = "/*1*/string"; +////function f(a = "/*2*/initial value") { } + + +goTo.marker("1"); +verify.renameInfoFailed(); + +goTo.marker("2"); +verify.renameInfoFailed(); diff --git a/tests/cases/fourslash/renameStingPropertyNames.ts b/tests/cases/fourslash/renameStingPropertyNames.ts new file mode 100644 index 00000000000..a948220efad --- /dev/null +++ b/tests/cases/fourslash/renameStingPropertyNames.ts @@ -0,0 +1,20 @@ +/// + +////var o = { +//// [|prop|]: 0 +////}; +//// +////o = { +//// "[|prop|]": 1 +////}; +//// +////o["[|prop|]"]; +////o['[|prop|]']; +////o.[|prop|]; + + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} diff --git a/tests/cases/fourslash/renameStringLiteralTypes.ts b/tests/cases/fourslash/renameStringLiteralTypes.ts new file mode 100644 index 00000000000..f9df83371c1 --- /dev/null +++ b/tests/cases/fourslash/renameStringLiteralTypes.ts @@ -0,0 +1,18 @@ +/// + + +////interface AnimationOptions { +//// deltaX: number; +//// deltaY: number; +//// easing: "ease-in" | "ease-out" | "[|ease-in-out|]"; +////} +//// +////function animate(o: AnimationOptions) { } +//// +////animate({ deltaX: 100, deltaY: 100, easing: "[|ease-in-out|]" }); + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} diff --git a/tests/cases/fourslash/server/referencesInConfiguredProject.ts b/tests/cases/fourslash/server/referencesInConfiguredProject.ts new file mode 100644 index 00000000000..9a0d7095a93 --- /dev/null +++ b/tests/cases/fourslash/server/referencesInConfiguredProject.ts @@ -0,0 +1,20 @@ +/// + +// Global class reference. + +// @Filename: referencesForGlobals_1.ts +////class /*2*/globalClass { +//// public f() { } +////} + +// @Filename: referencesForGlobals_2.ts +////var c = /*1*/globalClass(); + +// @Filename: tsconfig.json +////{ "files": ["referencesForGlobals_1.ts", "referencesForGlobals_2.ts"] } + +goTo.marker("1"); +verify.referencesCountIs(2); + +goTo.marker("2"); +verify.referencesCountIs(2); \ No newline at end of file diff --git a/tests/cases/fourslash/server/renameInConfiguredProject.ts b/tests/cases/fourslash/server/renameInConfiguredProject.ts new file mode 100644 index 00000000000..ecff87493a8 --- /dev/null +++ b/tests/cases/fourslash/server/renameInConfiguredProject.ts @@ -0,0 +1,13 @@ +/// + +// @Filename: referencesForGlobals_1.ts +////var [|globalName|] = 0; + +// @Filename: referencesForGlobals_2.ts +////var y = /*1*/[|globalName|]; + +// @Filename: tsconfig.json +////{ "files": ["referencesForGlobals_1.ts", "referencesForGlobals_2.ts"] } + +goTo.marker("1"); +verify.renameLocations(/*findInStrings:*/ true, /*findInComments:*/ true);