From 0a968f0868695953537a656c1a7c36f3bb70f076 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:10:43 -0800 Subject: [PATCH 01/48] Parse this type using parameter syntax Syntax is the same as a normal parameter: ```ts function f(this: void, x: number) { } ``` --- src/compiler/parser.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 787a022140f..725092d12c8 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1722,7 +1722,7 @@ namespace ts { }; // Parses a comma-delimited list of elements - function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimeter?: boolean): NodeArray { + function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray { const saveParsingContext = parsingContext; parsingContext |= 1 << kind; const result = >[]; @@ -1751,7 +1751,7 @@ namespace ts { // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimeter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -2002,7 +2002,7 @@ namespace ts { } function isStartOfParameter(): boolean { - return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifierKind(token) || token === SyntaxKind.AtToken; + return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifierKind(token) || token === SyntaxKind.AtToken || token === SyntaxKind.ThisKeyword; } function setModifiers(node: Node, modifiers: ModifiersArray) { @@ -2014,15 +2014,19 @@ namespace ts { function parseParameter(): ParameterDeclaration { const node = createNode(SyntaxKind.Parameter); + if (token === SyntaxKind.ThisKeyword) { + node.name = createIdentifier(/*isIdentifier*/true, undefined); + node.type = parseParameterType(); + return finishNode(node); + } + node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] - node.name = parseIdentifierOrPattern(); - if (getFullWidth(node.name) === 0 && node.flags === 0 && isModifierKind(token)) { // in cases like // 'use strict' @@ -2060,11 +2064,11 @@ namespace ts { } function fillSignature( - returnToken: SyntaxKind, - yieldContext: boolean, - awaitContext: boolean, - requireCompleteParameterList: boolean, - signature: SignatureDeclaration): void { + returnToken: SyntaxKind, + yieldContext: boolean, + awaitContext: boolean, + requireCompleteParameterList: boolean, + signature: SignatureDeclaration): void { const returnTokenRequired = returnToken === SyntaxKind.EqualsGreaterThanToken; signature.typeParameters = parseTypeParameters(); @@ -2464,7 +2468,7 @@ namespace ts { // ( ... return true; } - if (isIdentifier() || isModifierKind(token)) { + if (isIdentifier() || isModifierKind(token) || token === SyntaxKind.ThisKeyword) { nextToken(); if (token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken || token === SyntaxKind.QuestionToken || token === SyntaxKind.EqualsToken || @@ -3981,7 +3985,7 @@ namespace ts { node.flags |= NodeFlags.MultiLine; } - node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); parseExpected(SyntaxKind.CloseBraceToken); return finishNode(node); } From d8a77c00557129f3b24cffb7d35888c8519aaebf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:30:01 -0800 Subject: [PATCH 02/48] Check this type in functions. If `this` is not provided, it defaults to `void` for functions and `this` for methods. The rules for checking are similar to parameter checking, but there's still quite a bit of duplication for this implementation. --- src/compiler/binder.ts | 3 + src/compiler/checker.ts | 161 ++++++++++++++++++++++++++++++++-------- 2 files changed, 134 insertions(+), 30 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index cc81f92fbfc..cbeb35ce56c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1297,6 +1297,9 @@ namespace ts { // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. + if (options.strictThis) { + seenThisKeyword = true; + } return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); case SyntaxKind.FunctionDeclaration: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a0040982356..3940be5d698 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -131,8 +131,8 @@ namespace ts { const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - const anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); - const unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + const anySignature = createSignature(undefined, undefined, emptyArray, undefined, anyType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + const unknownSignature = createSignature(undefined, undefined, emptyArray, undefined, unknownType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); @@ -2194,10 +2194,17 @@ namespace ts { } } - function buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { + function buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { writePunctuation(writer, SyntaxKind.OpenParenToken); + const useThisType = thisType && thisType.symbol; + if (useThisType) { + writeKeyword(writer, SyntaxKind.ThisKeyword); + writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); + buildTypeDisplay(thisType, writer, enclosingDeclaration, flags, symbolStack); + } for (let i = 0; i < parameters.length; i++) { - if (i > 0) { + if (i > 0 || useThisType) { writePunctuation(writer, SyntaxKind.CommaToken); writeSpace(writer); } @@ -2247,7 +2254,7 @@ namespace ts { buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, symbolStack); } - buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack); + buildDisplayForParametersAndDelimiters(signature.thisType, signature.parameters, writer, enclosingDeclaration, flags, symbolStack); buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } @@ -3414,7 +3421,7 @@ namespace ts { // Returns true if the class or interface member given by the symbol is free of "this" references. The // function may return false for symbols that are actually free of "this" references because it is not // feasible to perform a complete analysis in all cases. In particular, property members with types - // inferred from their initializers and function members with inferred return types are convervatively + // inferred from their initializers and function members with inferred return types are conservatively // assumed not to be free of "this" references. function isIndependentMember(symbol: Symbol): boolean { if (symbol.declarations && symbol.declarations.length === 1) { @@ -3426,6 +3433,7 @@ namespace ts { return isIndependentVariableLikeDeclaration(declaration); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: + return compilerOptions.strictThis ? false : isIndependentFunctionLikeDeclaration(declaration); case SyntaxKind.Constructor: return isIndependentFunctionLikeDeclaration(declaration); } @@ -3525,12 +3533,13 @@ namespace ts { resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], parameters: Symbol[], + function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], parameters: Symbol[], thisType: Type, resolvedReturnType: Type, minArgumentCount: number, hasRestParameter: boolean, hasStringLiterals: boolean): Signature { const sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; + sig.thisType = thisType; sig.resolvedReturnType = resolvedReturnType; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; @@ -3539,15 +3548,19 @@ namespace ts { } function cloneSignature(sig: Signature): Signature { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.thisType, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } + function getParameterTypeAtIndex(signature: Signature, i: number, max: number, outOfRangeType?: Type): Type { + return i < max ? getTypeOfSymbol(signature.parameters[i]) : (outOfRangeType || getRestTypeOfSignature(signature)); + } + function getDefaultConstructSignatures(classType: InterfaceType): Signature[] { const baseConstructorType = getBaseConstructorTypeOfClass(classType); const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; + return [createSignature(undefined, classType.localTypeParameters, emptyArray, undefined, classType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; } const baseTypeNode = getBaseTypeNodeOfClass(classType); const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); @@ -4077,6 +4090,7 @@ namespace ts { const parameters: Symbol[] = []; let hasStringLiterals = false; let minArgumentCount = -1; + let thisType: Type = undefined; const isJSConstructSignature = isJSDocConstructSignature(declaration); let returnType: Type = undefined; @@ -4092,15 +4106,23 @@ namespace ts { const resolvedSymbol = resolveName(param, paramSymbol.name, SymbolFlags.Value, undefined, undefined); paramSymbol = resolvedSymbol; } - parameters.push(paramSymbol); - + if (paramSymbol.name === "this") { + thisType = param.type && getTypeOfSymbol(paramSymbol); + if (i !== 0 || declaration.kind === SyntaxKind.Constructor) { + error(param, Diagnostics.this_cannot_be_referenced_in_current_location); + } + } + else { + parameters.push(paramSymbol); + } + if (param.type && param.type.kind === SyntaxKind.StringLiteralType) { hasStringLiterals = true; } if (param.initializer || param.questionToken || param.dotDotDotToken) { if (minArgumentCount < 0) { - minArgumentCount = i; + minArgumentCount = i - (thisType ? 1 : 0); } } else { @@ -4110,7 +4132,22 @@ namespace ts { } if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length; + minArgumentCount = declaration.parameters.length - (thisType ? 1 : 0); + } + if (!thisType && compilerOptions.strictThis) { + if (declaration.kind === SyntaxKind.FunctionDeclaration + || declaration.kind === SyntaxKind.CallSignature + || declaration.kind == SyntaxKind.FunctionExpression + || declaration.kind === SyntaxKind.FunctionType) { + thisType = voidType; + } + else if ((declaration.kind === SyntaxKind.MethodDeclaration || declaration.kind === SyntaxKind.MethodSignature) + && (isClassLike(declaration.parent) || declaration.parent.kind === SyntaxKind.InterfaceDeclaration)) { + thisType = declaration.flags & NodeFlags.Static ? + getWidenedType(checkExpression((declaration.parent).name)) : + getThisType(declaration.name); + Debug.assert(!!thisType, "couldn't find implicit this type"); + } } if (isJSConstructSignature) { @@ -4143,7 +4180,7 @@ namespace ts { } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, thisType, returnType, minArgumentCount, hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -4834,7 +4871,7 @@ namespace ts { return links.resolvedType; } - function getThisType(node: TypeNode): Type { + function getThisType(node: Node): Type { const container = getThisContainer(node, /*includeArrowFunctions*/ false); const parent = container && container.parent; if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) { @@ -5062,6 +5099,7 @@ namespace ts { } const result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), + signature.thisType ? instantiateType(signature.thisType, mapper) : undefined, instantiateType(signature.resolvedReturnType, mapper), signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; @@ -5175,7 +5213,14 @@ namespace ts { } function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration) { - return !node.typeParameters && node.parameters.length && !forEach(node.parameters, p => p.type); + if (compilerOptions.strictThis) { + return !node.typeParameters && + (!forEach(node.parameters, p => p.type) + || (node.kind !== SyntaxKind.ArrowFunction && (!node.parameters.length || (node.parameters[0].name).text !== "this"))); + } + else { + return !node.typeParameters && node.parameters.length && !forEach(node.parameters, p => p.type); + } } function getTypeWithoutSignatures(type: Type): Type { @@ -5252,6 +5297,22 @@ namespace ts { target = getErasedSignature(target); let result = Ternary.True; + if (source.thisType || target.thisType) { + const s = source.thisType || anyType; + const t = target.thisType || anyType; + if (s !== voidType) { + // void sources are assignable to anything. + let related = compareTypes(getApparentType(t), getApparentType(s), reportErrors); + if (!related) { + related = compareTypes(getApparentType(s), getApparentType(t), /*reportErrors*/ false); + if (!related) { + errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, "this", "this"); + return Ternary.False; + } + } + result &= related; + } + } const sourceMax = getNumNonRestParameters(source); const targetMax = getNumNonRestParameters(target); @@ -6434,9 +6495,7 @@ namespace ts { count = sourceMax < targetMax ? sourceMax : targetMax; } for (let i = 0; i < count; i++) { - const s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - const t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - callback(s, t); + callback(getParameterTypeAtIndex(source, i, sourceMax), getParameterTypeAtIndex(target, i, targetMax)); } } @@ -7313,7 +7372,12 @@ namespace ts { if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - + if (isFunctionLike(container)) { + const signature = getSignatureFromDeclaration(container); + if (signature.thisType) { + return signature.thisType; + } + } if (isClassLike(container.parent)) { const symbol = getSymbolOfNode(container.parent); return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; @@ -7330,7 +7394,7 @@ namespace ts { 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.protoype.y = f + const className = (((container.parent as BinaryExpression) // x.prototype.y = f .left as PropertyAccessExpression) // x.prototype.y .expression as PropertyAccessExpression) // x.prototype .expression; // x @@ -9306,7 +9370,7 @@ namespace ts { return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: Expression[], excludeArgument: boolean[], context: InferenceContext): void { + function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: Expression[], excludeCallee: boolean, excludeArgument: boolean[], context: InferenceContext): void { const typeParameters = signature.typeParameters; const inferenceMapper = getInferenceMapper(context); @@ -9332,6 +9396,13 @@ namespace ts { context.failedTypeParameterIndex = undefined; } + const calleeNode = node.kind === SyntaxKind.CallExpression && ((node).expression).expression; + if (signature.thisType) { + const mapper = excludeCallee !== undefined ? identityMapper : inferenceMapper; + const calleeType: Type = calleeNode ? checkExpressionWithContextualType(calleeNode, signature.thisType, mapper) : voidType; + inferTypes(context, calleeType, signature.thisType); + } + // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. const argCount = getEffectiveArgumentCount(node, args, signature); @@ -9361,8 +9432,13 @@ namespace ts { // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed. // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. if (excludeArgument) { + if (signature.thisType && calleeNode) { + if (excludeCallee === false) { + inferTypes(context, checkExpressionWithContextualType(calleeNode, signature.thisType, inferenceMapper), signature.thisType); + } + } for (let i = 0; i < argCount; i++) { - // No need to check for omitted args and template expressions, their exlusion value is always undefined + // No need to check for omitted args and template expressions, their exclusion value is always undefined if (excludeArgument[i] === false) { const arg = args[i]; const paramType = getTypeAtPosition(signature, i); @@ -9405,6 +9481,18 @@ namespace ts { } function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map, excludeArgument: boolean[], reportErrors: boolean) { + const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (signature.thisType && signature.thisType !== voidType && node.kind !== SyntaxKind.NewExpression) { + // If the source is not of the form `x.f`, then sourceType = voidType + // If the target is voidType, then the check is skipped -- anything is compatible. + // If the the expression is a new expression, then the check is skipped. + const calleeNode = node.kind === SyntaxKind.CallExpression && ((node).expression).expression; + const calleeType: Type = calleeNode ? checkExpressionWithContextualType(calleeNode, signature.thisType, undefined) : voidType; + const errorNode = reportErrors ? (calleeNode || node) : undefined; + if (!checkTypeRelatedTo(calleeType, getApparentType(signature.thisType), relation, errorNode, headMessage)) { + return false; + } + } const argCount = getEffectiveArgumentCount(node, args, signature); for (let i = 0; i < argCount; i++) { const arg = getEffectiveArgument(node, args, i); @@ -9424,7 +9512,6 @@ namespace ts { // Use argument expression as error location when reporting errors const errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; if (!checkTypeRelatedTo(argType, paramType, relation, errorNode, headMessage)) { return false; } @@ -9778,8 +9865,13 @@ namespace ts { // // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. + let excludeCallee: boolean; let excludeArgument: boolean[]; if (!isDecorator) { + const calleeNode = node.kind === SyntaxKind.CallExpression && ((node).expression).expression; + if (calleeNode && isContextSensitive(calleeNode)) { + excludeCallee = true; + } // We do not need to call `getEffectiveArgumentCount` here as it only // applies when calculating the number of arguments for a decorator. for (let i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { @@ -9928,7 +10020,7 @@ namespace ts { typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { - inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); + inferTypeArguments(node, candidate, args, excludeCallee, excludeArgument, inferenceContext); typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; } @@ -10086,13 +10178,16 @@ namespace ts { // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the - // operation is Any. + // operation is the function's this type. It is an error to have a Void this type. const callSignatures = getSignaturesOfType(expressionType, SignatureKind.Call); if (callSignatures.length) { const signature = resolveCall(node, callSignatures, candidatesOutArray); if (getReturnTypeOfSignature(signature) !== voidType) { error(node, Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } + if (signature.thisType === voidType) { + error(node, Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void); + } return signature; } @@ -10244,10 +10339,10 @@ namespace ts { if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function)) { return getInferredClassType(funcSymbol); } - else if (compilerOptions.noImplicitAny) { + else if (compilerOptions.noImplicitAny && !signature.thisType) { error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } - return anyType; + return signature.thisType || anyType; } } @@ -10282,11 +10377,17 @@ namespace ts { function getTypeAtPosition(signature: Signature, pos: number): Type { return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; + getParameterTypeAtIndex(signature, pos, signature.parameters.length - 1) : + getParameterTypeAtIndex(signature, pos, signature.parameters.length, anyType); } function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { + if (context.thisType) { + if (signature.declaration.kind !== SyntaxKind.ArrowFunction) { + // do not contextually type thisType for ArrowFunction. + signature.thisType = context.thisType; + } + } const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (let i = 0; i < len; i++) { const parameter = signature.parameters[i]; From a639b71ed0837775593240a1a86cc14594f3213b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:34:44 -0800 Subject: [PATCH 03/48] Skip emit of this types as first parameter. --- src/compiler/emitter.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 4d771bd2538..fc8e811fb65 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4436,8 +4436,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge write("("); if (node) { const parameters = node.parameters; + const skipCount = node.parameters.length && (node.parameters[0].name).text === "this" ? 1 : 0; const omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); + emitList(parameters, skipCount, parameters.length - omitCount - skipCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); decreaseIndent(); From 9bd7afb143fff13458a514da29bd7ad8547a4d68 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:39:01 -0800 Subject: [PATCH 04/48] Add new error message and strictThis flag --- src/compiler/commandLineParser.ts | 4 ++++ src/compiler/diagnosticMessages.json | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d5bf95a6405..3eb42292fb1 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -130,6 +130,10 @@ namespace ts { name: "skipDefaultLibCheck", type: "boolean", }, + { + name: "strictThis", + type: "boolean", + }, { name: "out", type: "string", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ca5a6d9d415..2043a89c8fd 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1819,6 +1819,10 @@ "category": "Error", "code": 2670 }, + "A function that is called with the 'new' keyword cannot have a 'this' type that is void.": { + "category": "Error", + "code": 2671 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From ca162090325e35fe8479d90698b35b2d89360f7f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:43:50 -0800 Subject: [PATCH 05/48] Make compiler strictThis clean. --- src/compiler/core.ts | 19 ++++++----- src/compiler/program.ts | 3 +- src/compiler/sourcemap.ts | 8 ++--- src/compiler/sys.ts | 2 +- src/compiler/types.ts | 18 +++++----- src/compiler/utilities.ts | 20 +++++------ src/harness/harness.ts | 32 ++++++++--------- src/harness/loggedIO.ts | 34 ++++++++++--------- src/server/editorServices.ts | 2 +- src/server/node.d.ts | 4 +-- .../formatting/ruleOperationContext.ts | 4 +-- src/services/utilities.ts | 2 +- 12 files changed, 77 insertions(+), 71 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 21536da36ff..ab8de44ec98 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -818,25 +818,26 @@ namespace ts { getSignatureConstructor(): new (checker: TypeChecker) => Signature; } + // TODO: Add a 'this' parameter after I update the previous-version compiler function Symbol(flags: SymbolFlags, name: string) { - this.flags = flags; - this.name = name; - this.declarations = undefined; + (this).flags = flags; + (this).name = name; + (this).declarations = undefined; } function Type(checker: TypeChecker, flags: TypeFlags) { - this.flags = flags; + (this).flags = flags; } function Signature(checker: TypeChecker) { } function Node(kind: SyntaxKind, pos: number, end: number) { - this.kind = kind; - this.pos = pos; - this.end = end; - this.flags = NodeFlags.None; - this.parent = undefined; + (this).kind = kind; + (this).pos = pos; + (this).end = end; + (this).flags = NodeFlags.None; + (this).parent = undefined; } export let objectAllocator: ObjectAllocator = { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 803ae47b0fd..88c77aa5759 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -933,8 +933,9 @@ namespace ts { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); } + // TODO: needs to have this: Program function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult { - return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken)); + return runWithCancellationToken(() => emitWorker((this), sourceFile, writeFileCallback, cancellationToken)); } function isEmitBlocked(emitFileName: string): boolean { diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 8abf1432b0c..fb61f8b78b8 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -4,10 +4,10 @@ namespace ts { export interface SourceMapWriter { getSourceMapData(): SourceMapData; - setSourceFile(sourceFile: SourceFile): void; - emitPos(pos: number): void; - emitStart(range: TextRange): void; - emitEnd(range: TextRange, stopOverridingSpan?: boolean): void; + setSourceFile: (sourceFile: SourceFile) => void; + emitPos: (pos: number) => void; + emitStart: (range: TextRange) => void; + emitEnd: (range: TextRange, stopOverridingSpan?: boolean) => void; changeEmitSourcePos(): void; getText(): string; getSourceMappingURL(): string; diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index bf25d39aa43..1a9da39bf9a 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -63,7 +63,7 @@ namespace ts { useCaseSensitiveFileNames?: boolean; echo(s: string): void; quit(exitCode?: number): void; - fileExists(path: string): boolean; + fileExists: (path: string) => boolean; directoryExists(path: string): boolean; createDirectory(path: string): void; resolvePath(path: string): string; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 796529d9d4f..9c2612d96b6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1593,8 +1593,8 @@ namespace ts { } export interface ScriptReferenceHost { - getCompilerOptions(): CompilerOptions; - getSourceFile(fileName: string): SourceFile; + getCompilerOptions: () => CompilerOptions; + getSourceFile: (fileName: string) => SourceFile; getCurrentDirectory(): string; } @@ -1625,7 +1625,7 @@ namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): SourceFile[]; + getSourceFiles: () => SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then @@ -1650,7 +1650,7 @@ namespace ts { */ getTypeChecker(): TypeChecker; - /* @internal */ getCommonSourceDirectory(): string; + /* @internal */ getCommonSourceDirectory: () => string; // For testing purposes only. Should not be used by any other consumers (including the // language service). @@ -1781,7 +1781,7 @@ namespace ts { buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; - buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; } @@ -1905,11 +1905,11 @@ namespace ts { getReferencedImportDeclaration(node: Identifier): Declaration; getReferencedDeclarationWithCollidingName(node: Identifier): Declaration; isDeclarationWithCollidingName(node: Declaration): boolean; - isValueAliasDeclaration(node: Node): boolean; - isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; + isValueAliasDeclaration: (node: Node) => boolean; + isReferencedAliasDeclaration: (node: Node, checkChildren?: boolean) => boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; - isDeclarationVisible(node: Declaration): boolean; + isDeclarationVisible: (node: Declaration) => boolean; collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; @@ -2279,6 +2279,7 @@ namespace ts { declaration: SignatureDeclaration; // Originating declaration typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic) parameters: Symbol[]; // Parameters + thisType?: Type; // type of this-type /* @internal */ resolvedReturnType: Type; // Resolved return type /* @internal */ @@ -2429,6 +2430,7 @@ namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; + strictThis?: boolean, suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index bab66eb0688..bce821c3756 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -32,11 +32,11 @@ namespace ts { } export interface EmitHost extends ScriptReferenceHost { - getSourceFiles(): SourceFile[]; + getSourceFiles: () => SourceFile[]; - getCommonSourceDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; + getCommonSourceDirectory: () => string; + getCanonicalFileName: (fileName: string) => string; + getNewLine: () => string; isEmitBlocked(emitFileName: string): boolean; @@ -1869,11 +1869,11 @@ namespace ts { } export interface EmitTextWriter { - write(s: string): void; - writeTextOfNode(text: string, node: Node): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; + write: (s: string) => void; + writeTextOfNode: (text: string, node: Node) => void; + writeLine: () => void; + increaseIndent: () => void; + decreaseIndent: () => void; getText(): string; rawWrite(s: string): void; writeLiteral(s: string): void; @@ -2490,7 +2490,7 @@ namespace ts { * as the fallback implementation does not check for circular references by default. */ export const stringify: (value: any) => string = typeof JSON !== "undefined" && JSON.stringify - ? JSON.stringify + ? JSON.stringify : stringifyFallback; /** diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 2b0c95c0a61..3b211a0d91a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -417,24 +417,24 @@ namespace Harness.Path { namespace Harness { export interface IO { - newLine(): string; - getCurrentDirectory(): string; - useCaseSensitiveFileNames(): boolean; - resolvePath(path: string): string; - readFile(path: string): string; - writeFile(path: string, contents: string): void; - directoryName(path: string): string; - createDirectory(path: string): void; - fileExists(fileName: string): boolean; - directoryExists(path: string): boolean; - deleteFile(fileName: string): void; - listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; - log(text: string): void; - getMemoryUsage?(): number; args(): string[]; - getExecutingFilePath(): string; - exit(exitCode?: number): void; + newLine(): string; + readFile(this: ts.System | IO, path: string): string; + writeFile(path: string, contents: string): void; + resolvePath(path: string): string; + fileExists: (fileName: string) => boolean; + directoryExists: (path: string) => boolean; + createDirectory(path: string): void; + getExecutingFilePath(this: ts.System | IO): string; + getCurrentDirectory(): string; readDirectory(path: string, extension?: string, exclude?: string[]): string[]; + getMemoryUsage?(): number; + exit(exitCode?: number): void; + deleteFile(fileName: string): void; + directoryName: (path: string) => string; + listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; + log: (text: string) => void; + useCaseSensitiveFileNames(): boolean; } export var IO: IO; diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 3d51682f745..dbc05112f3e 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -70,11 +70,11 @@ interface IOLog { interface PlaybackControl { startReplayFromFile(logFileName: string): void; - startReplayFromString(logContents: string): void; - startReplayFromData(log: IOLog): void; + startReplayFromString(this: PlaybackControl, logContents: string): void; + startReplayFromData(this: PlaybackControl, log: IOLog): void; endReplay(): void; startRecord(logFileName: string): void; - endRecord(): void; + endRecord(this: PlaybackControl): void; } namespace Playback { @@ -127,6 +127,8 @@ namespace Playback { function initWrapper(wrapper: PlaybackSystem, underlying: ts.System): void; function initWrapper(wrapper: PlaybackIO, underlying: Harness.IO): void; function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void { + // TODO: Define a common interface over ts.System | Harness.IO and stop passing a union type. + const underlyingShim: any = underlying; ts.forEach(Object.keys(underlying), prop => { (wrapper)[prop] = (underlying)[prop]; }); @@ -154,20 +156,20 @@ namespace Playback { }; wrapper.startReplayFromFile = logFn => { - wrapper.startReplayFromString(underlying.readFile(logFn)); + wrapper.startReplayFromString(underlyingShim.readFile(logFn)); }; wrapper.endRecord = () => { if (recordLog !== undefined) { let i = 0; const fn = () => recordLogFileNameBase + i + ".json"; - while (underlying.fileExists(fn())) i++; - underlying.writeFile(fn(), JSON.stringify(recordLog)); + while (underlyingShim.fileExists(fn())) i++; + underlyingShim.writeFile(fn(), JSON.stringify(recordLog)); recordLog = undefined; } }; wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)( - path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }), + path => callAndRecord(underlyingShim.fileExists(path), recordLog.fileExists, { path }), memoize(path => { // If we read from the file, it must exist if (findResultByPath(wrapper, replayLog.filesRead, path, null) !== null) { @@ -184,10 +186,10 @@ namespace Playback { return replayLog.executingPath; } else if (recordLog !== undefined) { - return recordLog.executingPath = underlying.getExecutingFilePath(); + return recordLog.executingPath = underlyingShim.getExecutingFilePath(); } else { - return underlying.getExecutingFilePath(); + return underlyingShim.getExecutingFilePath(); } }; @@ -196,20 +198,20 @@ namespace Playback { return replayLog.currentDirectory || ""; } else if (recordLog !== undefined) { - return recordLog.currentDirectory = underlying.getCurrentDirectory(); + return recordLog.currentDirectory = underlyingShim.getCurrentDirectory(); } else { - return underlying.getCurrentDirectory(); + return underlyingShim.getCurrentDirectory(); } }; wrapper.resolvePath = recordReplay(wrapper.resolvePath, underlying)( - path => callAndRecord(underlying.resolvePath(path), recordLog.pathsResolved, { path }), + path => callAndRecord(underlyingShim.resolvePath(path), recordLog.pathsResolved, { path }), memoize(path => findResultByFields(replayLog.pathsResolved, { path }, !ts.isRootedDiskPath(ts.normalizeSlashes(path)) && replayLog.currentDirectory ? replayLog.currentDirectory + "/" + path : ts.normalizeSlashes(path)))); wrapper.readFile = recordReplay(wrapper.readFile, underlying)( path => { - const result = underlying.readFile(path); + const result = underlyingShim.readFile(path); const logEntry = { path, codepage: 0, result: { contents: result, codepage: 0 } }; recordLog.filesRead.push(logEntry); return result; @@ -226,14 +228,14 @@ namespace Playback { (path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead.filter(d => d.extension === extension && ts.arrayIsEqualTo(d.exclude, exclude)), path)); wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( - (path, contents) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), - (path, contents) => noOpReplay("writeFile")); + (path: string, contents: string) => callAndRecord(underlyingShim.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), + (path: string, contents: string) => noOpReplay("writeFile")); wrapper.exit = (exitCode) => { if (recordLog !== undefined) { wrapper.endRecord(); } - underlying.exit(exitCode); + underlyingShim.exit(exitCode); }; } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index e2ec5cc159f..5516b18e0de 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1834,7 +1834,7 @@ namespace ts.server { if (!rangeEnd) { rangeEnd = this.root.charCount(); } - const walkFns = { + const walkFns: ILineIndexWalker = { goSubtree: true, done: false, leaf: function (relativeStart: number, relativeLength: number, ll: LineLeaf) { diff --git a/src/server/node.d.ts b/src/server/node.d.ts index 0bde0bb6602..8e4d8c28e9b 100644 --- a/src/server/node.d.ts +++ b/src/server/node.d.ts @@ -68,7 +68,7 @@ interface BufferConstructor { new (array: any[]): Buffer; prototype: Buffer; isBuffer(obj: any): boolean; - byteLength(string: string, encoding?: string): number; + byteLength: (string: string, encoding?: string) => number; concat(list: Buffer[], totalLength?: number): Buffer; } declare var Buffer: BufferConstructor; @@ -190,7 +190,7 @@ declare namespace NodeJS { nextTick(callback: Function): void; umask(mask?: number): number; uptime(): number; - hrtime(time?: number[]): number[]; + hrtime: (time?: number[]) => number[]; // Worker send? (message: any, sendHandle?: any): void; diff --git a/src/services/formatting/ruleOperationContext.ts b/src/services/formatting/ruleOperationContext.ts index 47330faa0dd..3108095e8e6 100644 --- a/src/services/formatting/ruleOperationContext.ts +++ b/src/services/formatting/ruleOperationContext.ts @@ -6,8 +6,8 @@ namespace ts.formatting { export class RuleOperationContext { private customContextChecks: { (context: FormattingContext): boolean; }[]; - constructor(...funcs: { (context: FormattingContext): boolean; }[]) { - this.customContextChecks = funcs; + constructor(...funcs: { (this: typeof Rules, context: FormattingContext): boolean; }[]) { + this.customContextChecks = <{ (this: any, context: FormattingContext): boolean }[]>funcs; } static Any: RuleOperationContext = new RuleOperationContext(); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index afdc85fffd8..0363e45a64a 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -769,7 +769,7 @@ namespace ts { * The default is CRLF. */ export function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost) { - return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + return (host).getNewLine ? (host).getNewLine() : carriageReturnLineFeed; } export function lineBreakPart() { From 22e571f1e9a0250e406734f479d0f1a91fca4347 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:44:20 -0800 Subject: [PATCH 06/48] Add services support for this types. --- src/services/services.ts | 27 ++++++++++++++++++++------- src/services/signatureHelp.ts | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index cb57d415c66..1a43f9a744b 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -19,15 +19,15 @@ namespace ts { getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; - getStart(sourceFile?: SourceFile): number; + getStart(this: Node, sourceFile?: SourceFile): number; getFullStart(): number; - getEnd(): number; + getEnd(this: Node): number; getWidth(sourceFile?: SourceFile): number; getFullWidth(): number; getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; getText(sourceFile?: SourceFile): string; - getFirstToken(sourceFile?: SourceFile): Node; + getFirstToken(this: Node, sourceFile?: SourceFile): Node; getLastToken(sourceFile?: SourceFile): Node; } @@ -740,6 +740,7 @@ namespace ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; + thisType: Type; resolvedReturnType: Type; minArgumentCount: number; hasRestParameter: boolean; @@ -4021,6 +4022,9 @@ namespace ts { if (typeChecker.isArgumentsSymbol(symbol)) { return ScriptElementKind.localVariableElement; } + if (location.kind === SyntaxKind.ThisKeyword && isExpression(location)) { + return ScriptElementKind.parameterElement; + } if (flags & SymbolFlags.Variable) { if (isFirstDeclarationOfSymbolParameter(symbol)) { return ScriptElementKind.parameterElement; @@ -4083,6 +4087,7 @@ namespace ts { const symbolFlags = symbol.flags; let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location); let hasAddedSymbolInfo: boolean; + const isThisExpression: boolean = location.kind === SyntaxKind.ThisKeyword && isExpression(location); let type: Type; // Class at constructor site need to be shown as constructor apart from property,method, vars @@ -4093,7 +4098,7 @@ namespace ts { } let signature: Signature; - type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); + type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) { const right = (location.parent).name; @@ -4204,7 +4209,7 @@ namespace ts { } } } - if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo) { + if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo && !isThisExpression) { if (getDeclarationOfKind(symbol, SyntaxKind.ClassExpression)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) @@ -4346,11 +4351,19 @@ namespace ts { if (!hasAddedSymbolInfo) { if (symbolKind !== ScriptElementKind.unknown) { if (type) { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); + if (isThisExpression) { + addNewLineIfDisplayPartsExist(); + displayParts.push(keywordPart(SyntaxKind.ThisKeyword)); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + // For properties, variables and local vars: show the type if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & SymbolFlags.Variable || - symbolKind === ScriptElementKind.localVariableElement) { + symbolKind === ScriptElementKind.localVariableElement || + isThisExpression) { displayParts.push(punctuationPart(SyntaxKind.ColonToken)); displayParts.push(spacePart()); // If the type is type parameter, format it specially diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 02e36e185a5..cdf0b997bcc 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -559,7 +559,7 @@ namespace ts.SignatureHelp { signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken)); let parameterParts = mapToDisplayParts(writer => - typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation)); + typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisType, candidateSignature.parameters, writer, invocation)); addRange(suffixDisplayParts, parameterParts); } else { From 5fe84781592a08b5294e01a2fbf42d1def07111d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:46:01 -0800 Subject: [PATCH 07/48] Add overloads for Function.apply/call/bind The new overloads use this types to specify the return type of these functions as well as the type of `thisArg`. --- src/lib/core.d.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 31cf0ca3136..fe2fd6b79f6 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -215,14 +215,16 @@ 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(thisArg: any, argArray?: any): any; + apply(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; + apply(this: Function, thisArg: any, argArray?: any): any; /** * Calls a method of an object, substituting another object for the current object. * @param thisArg The object to be used as the current object. * @param argArray A list of arguments to be passed to the method. */ - call(thisArg: any, ...argArray: any[]): any; + 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. @@ -230,7 +232,8 @@ interface Function { * @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(thisArg: any, ...argArray: any[]): any; + bind(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): (...argArray: any[]) => U; + bind(this: Function, thisArg: any, ...argArray: any[]): any; prototype: any; readonly length: number; From 04e7d811054f712276264f87a7574ba2796cd4bd Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:49:52 -0800 Subject: [PATCH 08/48] Add tests and baselines for this-function types. --- .../looseThisTypeInFunctions.errors.txt | 48 + .../reference/looseThisTypeInFunctions.js | 68 ++ .../reference/thisTypeInFunctions.js | 407 +++++++ .../reference/thisTypeInFunctions.symbols | 862 ++++++++++++++ .../reference/thisTypeInFunctions.types | 1037 +++++++++++++++++ .../thisTypeInFunctionsNegative.errors.txt | 509 ++++++++ .../reference/thisTypeInFunctionsNegative.js | 386 ++++++ .../thisType/looseThisTypeInFunctions.ts | 34 + .../types/thisType/thisTypeInFunctions.ts | 209 ++++ .../thisType/thisTypeInFunctionsNegative.ts | 193 +++ .../fourslash/memberListOnExplicitThis.ts | 30 + 11 files changed, 3783 insertions(+) create mode 100644 tests/baselines/reference/looseThisTypeInFunctions.errors.txt create mode 100644 tests/baselines/reference/looseThisTypeInFunctions.js create mode 100644 tests/baselines/reference/thisTypeInFunctions.js create mode 100644 tests/baselines/reference/thisTypeInFunctions.symbols create mode 100644 tests/baselines/reference/thisTypeInFunctions.types create mode 100644 tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt create mode 100644 tests/baselines/reference/thisTypeInFunctionsNegative.js create mode 100644 tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts create mode 100644 tests/cases/conformance/types/thisType/thisTypeInFunctions.ts create mode 100644 tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts create mode 100644 tests/cases/fourslash/memberListOnExplicitThis.ts diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt new file mode 100644 index 00000000000..058a1555ed6 --- /dev/null +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -0,0 +1,48 @@ +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(20,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'void' is not assignable to type 'C'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(27,9): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. + + +==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (2 errors) ==== + interface I { + explicitThis(this: this, m: number): number; + } + interface Unused { + implicitNoThis(m: number): number; + } + class C implements I { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + implicitThis(m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return m + 1; + } + } + let c = new C(); + c.explicitVoid = c.explicitThis; // error, 'void' is missing everything + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'void' is not assignable to type 'C'. + let o = { + explicitThis: function (m) { return m }, + implicitThis(m: number): number { return m } + }; + let i: I = o; + let x = i.explicitThis; + let n = x(12); // callee:void doesn't match this:I + ~~~~~ +!!! error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. + let u: Unused; + let y = u.implicitNoThis; + n = y(12); // ok, callee:void matches this:any + c.explicitVoid = c.implicitThis // ok, implicitThis(this:any) + o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) + o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) + o.implicitThis = i.explicitThis; + \ No newline at end of file diff --git a/tests/baselines/reference/looseThisTypeInFunctions.js b/tests/baselines/reference/looseThisTypeInFunctions.js new file mode 100644 index 00000000000..66677293c5b --- /dev/null +++ b/tests/baselines/reference/looseThisTypeInFunctions.js @@ -0,0 +1,68 @@ +//// [looseThisTypeInFunctions.ts] +interface I { + explicitThis(this: this, m: number): number; +} +interface Unused { + implicitNoThis(m: number): number; +} +class C implements I { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + implicitThis(m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return m + 1; + } +} +let c = new C(); +c.explicitVoid = c.explicitThis; // error, 'void' is missing everything +let o = { + explicitThis: function (m) { return m }, + implicitThis(m: number): number { return m } +}; +let i: I = o; +let x = i.explicitThis; +let n = x(12); // callee:void doesn't match this:I +let u: Unused; +let y = u.implicitNoThis; +n = y(12); // ok, callee:void matches this:any +c.explicitVoid = c.implicitThis // ok, implicitThis(this:any) +o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) +o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) +o.implicitThis = i.explicitThis; + + +//// [looseThisTypeInFunctions.js] +var C = (function () { + function C() { + } + C.prototype.explicitThis = function (m) { + return this.n + m; + }; + C.prototype.implicitThis = function (m) { + return this.n + m; + }; + C.prototype.explicitVoid = function (m) { + return m + 1; + }; + return C; +}()); +var c = new C(); +c.explicitVoid = c.explicitThis; // error, 'void' is missing everything +var o = { + explicitThis: function (m) { return m; }, + implicitThis: function (m) { return m; } +}; +var i = o; +var x = i.explicitThis; +var n = x(12); // callee:void doesn't match this:I +var u; +var y = u.implicitNoThis; +n = y(12); // ok, callee:void matches this:any +c.explicitVoid = c.implicitThis; // ok, implicitThis(this:any) +o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) +o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) +o.implicitThis = i.explicitThis; diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js new file mode 100644 index 00000000000..0798843fc44 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -0,0 +1,407 @@ +//// [thisTypeInFunctions.ts] +// body checking +class C { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + implicitThis(m: number): number { + return this.n + m; + } + explicitC(this: C, m: number): number { + return this.n + m; + } + explicitProperty(this: {n: number}, m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return m + 1; + } +} +class D extends C { } +class B { + n: number; +} +interface I { + a: number; + explicitVoid1(this: void): number; + explicitVoid2(this: void): number; + explicitStructural(this: {a: number}): number; + explicitInterface(this: I): number; + explicitThis(this: this): number; + implicitMethod(): number; + implicitFunction: () => number; +} +function explicitStructural(this: { y: number }, x: number): number { + return x + this.y; +} +function justThis(this: { y: number }): number { + return this.y; +} +function implicitThis(n: number): number { + return 12; +} +let impl: I = { + a: 12, + explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) + explicitVoid1() { return 12; }, + explicitStructural() { + return this.a; + }, + explicitInterface() { + return this.a; + }, + explicitThis() { + return this.a; + }, + implicitMethod() { + return this.a; + }, + implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) +} +impl.explicitVoid1 = function () { return 12; }; +impl.explicitVoid2 = () => 12; +impl.explicitStructural = function() { return this.a; }; +impl.explicitInterface = function() { return this.a; }; +impl.explicitStructural = () => 12; +impl.explicitInterface = () => 12; +impl.explicitThis = function () { return this.a; }; +impl.implicitMethod = function () { return this.a; }; +impl.implicitMethod = () => 12; +impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) +// parameter checking +let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; +let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; +ok.f(13); +implicitThis(12); +implicitAnyOk.f(12); + +let c = new C(); +let d = new D(); +let ripped = c.explicitC; +c.explicitC(12); +c.explicitProperty(12); +c.explicitThis(12); +c.implicitThis(12); +d.explicitC(12); +d.explicitProperty(12); +d.explicitThis(12); +d.implicitThis(12); +let reconstructed: { + n: number, + explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. + implicitThis(m: number): number, + explicitC(this: C, m: number): number, + explicitProperty: (this: {n : number}, m: number) => number, + explicitVoid(this: void, m: number): number, +} = { + n: 12, + explicitThis: c.explicitThis, + implicitThis: c.implicitThis, + explicitC: c.explicitC, + explicitProperty: c.explicitProperty, + explicitVoid: c.explicitVoid +}; +reconstructed.explicitProperty(11); +reconstructed.implicitThis(11); + +// assignment checking +let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any +let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; +let anyToSpecified: (this: { y: number }, x: number) => number = function(x: number): number { return x + 12; }; + +let unspecifiedLambda: (x: number) => number = x => x + 12; +let specifiedLambda: (this: void, x: number) => number = x => x + 12; +let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = unspecifiedLambda; +let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; + + +let explicitCFunction: (this: C, m: number) => number; +let explicitPropertyFunction: (this: {n: number}, m: number) => number; +c.explicitC = explicitCFunction; +c.explicitC = function(this: C, m: number) { return this.n + m }; +c.explicitProperty = explicitPropertyFunction; +c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m }; +c.explicitProperty = reconstructed.explicitProperty; + +// lambdas are assignable to anything +c.explicitC = m => m; +c.explicitThis = m => m; +c.explicitProperty = m => m; + +// this inside lambdas refer to outer scope +// the outer-scoped lambda at top-level is still just `any` +c.explicitC = m => m + this.n; +c.explicitThis = m => m + this.n; +c.explicitProperty = m => m + this.n; + +//NOTE: this=C here, I guess? +c.explicitThis = explicitCFunction; +c.explicitThis = function(this: C, m: number) { return this.n + m }; + +// this:any compatibility +c.explicitC = function(m: number) { return this.n + m }; +c.explicitProperty = function(m: number) { return this.n + m }; +c.explicitThis = function(m: number) { return this.n + m }; +c.implicitThis = function(m: number) { return this.n + m }; +c.implicitThis = reconstructed.implicitThis; + +c.explicitC = function(this: B, m: number) { return this.n + m }; + +// this:void compatibility +c.explicitVoid = n => n; + +// class-based assignability +class Base1 { + x: number; + public implicit(): number { return this.x; } + explicit(this: Base1): number { return this.x; } + static implicitStatic(): number { return this.y; } + static explicitStatic(this: typeof Base1): number { return this.y; } + static y: number; + +} +class Derived1 extends Base1 { + y: number +} +class Base2 { + y: number + implicit(): number { return this.y; } + explicit(this: Base1): number { return this.x; } +} +class Derived2 extends Base2 { + x: number +} +let b1 = new Base1(); +let b2 = new Base2(); +let d1 = new Derived1(); +let d2 = new Derived2(); +d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) +d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) + +// bivariance-allowed cases +d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) +d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) +b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) + +////// use this-type for construction with new //// +function InterfaceThis(this: I) { + this.a = 12; +} +function LiteralTypeThis(this: {x: string}) { + this.x = "ok"; +} +function AnyThis(this: any) { + this.x = "ok"; +} +let interfaceThis = new InterfaceThis(); +let literalTypeThis = new LiteralTypeThis(); +let anyThis = new AnyThis(); + +//// type parameter inference //// +declare var f: { + (this: void, x: number): number, + call(this: (...argArray: any[]) => U, ...argArray: any[]): U; +}; +let n: number = f.call(12); + +function missingTypeIsImplicitAny(this, a: number) { return a; } + +//// [thisTypeInFunctions.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var _this = this; +// body checking +var C = (function () { + function C() { + } + C.prototype.explicitThis = function (m) { + return this.n + m; + }; + C.prototype.implicitThis = function (m) { + return this.n + m; + }; + C.prototype.explicitC = function (m) { + return this.n + m; + }; + C.prototype.explicitProperty = function (m) { + return this.n + m; + }; + C.prototype.explicitVoid = function (m) { + return m + 1; + }; + return C; +}()); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +}(C)); +var B = (function () { + function B() { + } + return B; +}()); +function explicitStructural(x) { + return x + this.y; +} +function justThis() { + return this.y; +} +function implicitThis(n) { + return 12; +} +var impl = { + a: 12, + explicitVoid2: function () { return _this.a; }, + explicitVoid1: function () { return 12; }, + explicitStructural: function () { + return this.a; + }, + explicitInterface: function () { + return this.a; + }, + explicitThis: function () { + return this.a; + }, + implicitMethod: function () { + return this.a; + }, + implicitFunction: function () { return _this.a; } +}; +impl.explicitVoid1 = function () { return 12; }; +impl.explicitVoid2 = function () { return 12; }; +impl.explicitStructural = function () { return this.a; }; +impl.explicitInterface = function () { return this.a; }; +impl.explicitStructural = function () { return 12; }; +impl.explicitInterface = function () { return 12; }; +impl.explicitThis = function () { return this.a; }; +impl.implicitMethod = function () { return this.a; }; +impl.implicitMethod = function () { return 12; }; +impl.implicitFunction = function () { return _this.a; }; // ok, this: any because it refers to some outer object (window?) +// parameter checking +var ok = { y: 12, f: explicitStructural }; +var implicitAnyOk = { notSpecified: 12, f: implicitThis }; +ok.f(13); +implicitThis(12); +implicitAnyOk.f(12); +var c = new C(); +var d = new D(); +var ripped = c.explicitC; +c.explicitC(12); +c.explicitProperty(12); +c.explicitThis(12); +c.implicitThis(12); +d.explicitC(12); +d.explicitProperty(12); +d.explicitThis(12); +d.implicitThis(12); +var reconstructed = { + n: 12, + explicitThis: c.explicitThis, + implicitThis: c.implicitThis, + explicitC: c.explicitC, + explicitProperty: c.explicitProperty, + explicitVoid: c.explicitVoid +}; +reconstructed.explicitProperty(11); +reconstructed.implicitThis(11); +// assignment checking +var unboundToSpecified = function (x) { return x + _this.y; }; // ok, this:any +var specifiedToSpecified = explicitStructural; +var anyToSpecified = function (x) { return x + 12; }; +var unspecifiedLambda = function (x) { return x + 12; }; +var specifiedLambda = function (x) { return x + 12; }; +var unspecifiedLambdaToSpecified = unspecifiedLambda; +var specifiedLambdaToSpecified = specifiedLambda; +var explicitCFunction; +var explicitPropertyFunction; +c.explicitC = explicitCFunction; +c.explicitC = function (m) { return this.n + m; }; +c.explicitProperty = explicitPropertyFunction; +c.explicitProperty = function (m) { return this.n + m; }; +c.explicitProperty = reconstructed.explicitProperty; +// lambdas are assignable to anything +c.explicitC = function (m) { return m; }; +c.explicitThis = function (m) { return m; }; +c.explicitProperty = function (m) { return m; }; +// this inside lambdas refer to outer scope +// the outer-scoped lambda at top-level is still just `any` +c.explicitC = function (m) { return m + _this.n; }; +c.explicitThis = function (m) { return m + _this.n; }; +c.explicitProperty = function (m) { return m + _this.n; }; +//NOTE: this=C here, I guess? +c.explicitThis = explicitCFunction; +c.explicitThis = function (m) { return this.n + m; }; +// this:any compatibility +c.explicitC = function (m) { return this.n + m; }; +c.explicitProperty = function (m) { return this.n + m; }; +c.explicitThis = function (m) { return this.n + m; }; +c.implicitThis = function (m) { return this.n + m; }; +c.implicitThis = reconstructed.implicitThis; +c.explicitC = function (m) { return this.n + m; }; +// this:void compatibility +c.explicitVoid = function (n) { return n; }; +// class-based assignability +var Base1 = (function () { + function Base1() { + } + Base1.prototype.implicit = function () { return this.x; }; + Base1.prototype.explicit = function () { return this.x; }; + Base1.implicitStatic = function () { return this.y; }; + Base1.explicitStatic = function () { return this.y; }; + return Base1; +}()); +var Derived1 = (function (_super) { + __extends(Derived1, _super); + function Derived1() { + _super.apply(this, arguments); + } + return Derived1; +}(Base1)); +var Base2 = (function () { + function Base2() { + } + Base2.prototype.implicit = function () { return this.y; }; + Base2.prototype.explicit = function () { return this.x; }; + return Base2; +}()); +var Derived2 = (function (_super) { + __extends(Derived2, _super); + function Derived2() { + _super.apply(this, arguments); + } + return Derived2; +}(Base2)); +var b1 = new Base1(); +var b2 = new Base2(); +var d1 = new Derived1(); +var d2 = new Derived2(); +d2.implicit = d1.implicit; // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) +d1.implicit = d2.implicit; // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) +// bivariance-allowed cases +d1.implicit = b2.implicit; // ok, 'y' in D: { x, y } (d assignable e) +d2.implicit = d1.explicit; // ok, 'y' in { x, y } (c assignable to f) +b1.implicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) +b1.explicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) +////// use this-type for construction with new //// +function InterfaceThis() { + this.a = 12; +} +function LiteralTypeThis() { + this.x = "ok"; +} +function AnyThis() { + this.x = "ok"; +} +var interfaceThis = new InterfaceThis(); +var literalTypeThis = new LiteralTypeThis(); +var anyThis = new AnyThis(); +var n = f.call(12); +function missingTypeIsImplicitAny(a) { return a; } diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols new file mode 100644 index 00000000000..1d9ebbd0cf4 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -0,0 +1,862 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions.ts === +// body checking +class C { +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) + + n: number; +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) + + explicitThis(this: this, m: number): number { +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 3, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 3, 28)) + + return this.n + m; +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 3, 28)) + } + implicitThis(m: number): number { +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 17)) + + return this.n + m; +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 17)) + } + explicitC(this: C, m: number): number { +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 9, 14)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) + + return this.n + m; +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) + } + explicitProperty(this: {n: number}, m: number): number { +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 21)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) + + return this.n + m; +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) + } + explicitVoid(this: void, m: number): number { +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 15, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 28)) + + return m + 1; +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 28)) + } +} +class D extends C { } +>D : Symbol(D, Decl(thisTypeInFunctions.ts, 18, 1)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) + +class B { +>B : Symbol(B, Decl(thisTypeInFunctions.ts, 19, 21)) + + n: number; +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 20, 9)) +} +interface I { +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) + + a: number; +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 23, 13)) + + explicitVoid1(this: void): number; +>explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 24, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 18)) + + explicitVoid2(this: void): number; +>explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 25, 38)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 18)) + + explicitStructural(this: {a: number}): number; +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 27, 23)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) + + explicitInterface(this: I): number; +>explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 28, 22)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) + + explicitThis(this: this): number; +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 29, 17)) + + implicitMethod(): number; +>implicitMethod : Symbol(implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) + + implicitFunction: () => number; +>implicitFunction : Symbol(implicitFunction, Decl(thisTypeInFunctions.ts, 30, 29)) +} +function explicitStructural(this: { y: number }, x: number): number { +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 32, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 33, 28)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 33, 35)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 33, 48)) + + return x + this.y; +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 33, 48)) +>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 33, 35)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 33, 33)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 33, 35)) +} +function justThis(this: { y: number }): number { +>justThis : Symbol(justThis, Decl(thisTypeInFunctions.ts, 35, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 36, 18)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 36, 25)) + + return this.y; +>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 36, 25)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 36, 23)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 36, 25)) +} +function implicitThis(n: number): number { +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 38, 1)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 39, 22)) + + return 12; +} +let impl: I = { +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) + + a: 12, +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 42, 15)) + + explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) +>explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 43, 10)) + + explicitVoid1() { return 12; }, +>explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 44, 32)) + + explicitStructural() { +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 45, 35)) + + return this.a; +>this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 27, 28)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) + + }, + explicitInterface() { +>explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 48, 6)) + + return this.a; +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) + + }, + explicitThis() { +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 51, 6)) + + return this.a; +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) + + }, + implicitMethod() { +>implicitMethod : Symbol(implicitMethod, Decl(thisTypeInFunctions.ts, 54, 6)) + + return this.a; +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) + + }, + implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) +>implicitFunction : Symbol(implicitFunction, Decl(thisTypeInFunctions.ts, 57, 6)) +} +impl.explicitVoid1 = function () { return 12; }; +>impl.explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 24, 14)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 24, 14)) + +impl.explicitVoid2 = () => 12; +>impl.explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 25, 38)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 25, 38)) + +impl.explicitStructural = function() { return this.a; }; +>impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) +>this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 27, 28)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) + +impl.explicitInterface = function() { return this.a; }; +>impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) + +impl.explicitStructural = () => 12; +>impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) + +impl.explicitInterface = () => 12; +>impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) + +impl.explicitThis = function () { return this.a; }; +>impl.explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) + +impl.implicitMethod = function () { return this.a; }; +>impl.implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) + +impl.implicitMethod = () => 12; +>impl.implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) + +impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) +>impl.implicitFunction : Symbol(I.implicitFunction, Decl(thisTypeInFunctions.ts, 30, 29)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) +>implicitFunction : Symbol(I.implicitFunction, Decl(thisTypeInFunctions.ts, 30, 29)) + +// parameter checking +let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; +>ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 71, 3)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 71, 9)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 19)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 71, 24)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 71, 31)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 71, 44)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 71, 70)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 77)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 32, 1)) + +let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; +>implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 72, 3)) +>notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 72, 20)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 41)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 72, 46)) +>notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 72, 71)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 89)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 38, 1)) + +ok.f(13); +>ok.f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 19)) +>ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 71, 3)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 19)) + +implicitThis(12); +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 38, 1)) + +implicitAnyOk.f(12); +>implicitAnyOk.f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 41)) +>implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 72, 3)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 41)) + +let c = new C(); +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) + +let d = new D(); +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) +>D : Symbol(D, Decl(thisTypeInFunctions.ts, 18, 1)) + +let ripped = c.explicitC; +>ripped : Symbol(ripped, Decl(thisTypeInFunctions.ts, 79, 3)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) + +c.explicitC(12); +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) + +c.explicitProperty(12); +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) + +c.explicitThis(12); +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) + +c.implicitThis(12); +>c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) + +d.explicitC(12); +>d.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) + +d.explicitProperty(12); +>d.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) + +d.explicitThis(12); +>d.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) + +d.implicitThis(12); +>d.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) + +let reconstructed: { +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) + + n: number, +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 88, 20)) + + explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 89, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 90, 17)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 90, 25)) + + implicitThis(m: number): number, +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 91, 17)) + + explicitC(this: C, m: number): number, +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 91, 36)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 92, 14)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 92, 22)) + + explicitProperty: (this: {n : number}, m: number) => number, +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 93, 23)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 93, 30)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 93, 42)) + + explicitVoid(this: void, m: number): number, +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 93, 64)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 94, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 94, 28)) + +} = { + n: 12, +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 95, 5)) + + explicitThis: c.explicitThis, +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 96, 10)) +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) + + implicitThis: c.implicitThis, +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 97, 33)) +>c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) + + explicitC: c.explicitC, +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 98, 33)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) + + explicitProperty: c.explicitProperty, +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 99, 27)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) + + explicitVoid: c.explicitVoid +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 100, 41)) +>c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) + +}; +reconstructed.explicitProperty(11); +>reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) + +reconstructed.implicitThis(11); +>reconstructed.implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) + +// assignment checking +let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any +>unboundToSpecified : Symbol(unboundToSpecified, Decl(thisTypeInFunctions.ts, 107, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 107, 25)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 107, 32)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 107, 45)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 107, 68)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 107, 68)) + +let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; +>specifiedToSpecified : Symbol(specifiedToSpecified, Decl(thisTypeInFunctions.ts, 108, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 108, 27)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 108, 34)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 108, 45)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 32, 1)) + +let anyToSpecified: (this: { y: number }, x: number) => number = function(x: number): number { return x + 12; }; +>anyToSpecified : Symbol(anyToSpecified, Decl(thisTypeInFunctions.ts, 109, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 109, 21)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 109, 28)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 109, 41)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 109, 74)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 109, 74)) + +let unspecifiedLambda: (x: number) => number = x => x + 12; +>unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 111, 3)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 111, 24)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 111, 46)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 111, 46)) + +let specifiedLambda: (this: void, x: number) => number = x => x + 12; +>specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 112, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 112, 22)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 112, 33)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 112, 56)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 112, 56)) + +let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = unspecifiedLambda; +>unspecifiedLambdaToSpecified : Symbol(unspecifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 113, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 113, 35)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 113, 42)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 113, 53)) +>unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 111, 3)) + +let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; +>specifiedLambdaToSpecified : Symbol(specifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 114, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 114, 33)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 114, 40)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 114, 51)) +>specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 112, 3)) + + +let explicitCFunction: (this: C, m: number) => number; +>explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 117, 24)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 32)) + +let explicitPropertyFunction: (this: {n: number}, m: number) => number; +>explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 118, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 118, 31)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 118, 38)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 49)) + +c.explicitC = explicitCFunction; +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) + +c.explicitC = function(this: C, m: number) { return this.n + m }; +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 120, 23)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 120, 31)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 120, 31)) + +c.explicitProperty = explicitPropertyFunction; +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 118, 3)) + +c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m }; +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 122, 30)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 122, 48)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 122, 35)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 122, 48)) + +c.explicitProperty = reconstructed.explicitProperty; +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) + +// lambdas are assignable to anything +c.explicitC = m => m; +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 13)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 13)) + +c.explicitThis = m => m; +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 16)) + +c.explicitProperty = m => m; +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 20)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 20)) + +// this inside lambdas refer to outer scope +// the outer-scoped lambda at top-level is still just `any` +c.explicitC = m => m + this.n; +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 132, 13)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 132, 13)) + +c.explicitThis = m => m + this.n; +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 133, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 133, 16)) + +c.explicitProperty = m => m + this.n; +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 20)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 20)) + +//NOTE: this=C here, I guess? +c.explicitThis = explicitCFunction; +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) + +c.explicitThis = function(this: C, m: number) { return this.n + m }; +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 138, 26)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 138, 34)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 138, 34)) + +// this:any compatibility +c.explicitC = function(m: number) { return this.n + m }; +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 141, 23)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 141, 23)) + +c.explicitProperty = function(m: number) { return this.n + m }; +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 142, 30)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 142, 30)) + +c.explicitThis = function(m: number) { return this.n + m }; +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 143, 26)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 143, 26)) + +c.implicitThis = function(m: number) { return this.n + m }; +>c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 144, 26)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 144, 26)) + +c.implicitThis = reconstructed.implicitThis; +>c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>reconstructed.implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) + +c.explicitC = function(this: B, m: number) { return this.n + m }; +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 147, 23)) +>B : Symbol(B, Decl(thisTypeInFunctions.ts, 19, 21)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 147, 31)) +>this.n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 20, 9)) +>this : Symbol(B, Decl(thisTypeInFunctions.ts, 19, 21)) +>n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 20, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 147, 31)) + +// this:void compatibility +c.explicitVoid = n => n; +>c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 150, 16)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 150, 16)) + +// class-based assignability +class Base1 { +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) + + x: number; +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) + + public implicit(): number { return this.x; } +>implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) + + explicit(this: Base1): number { return this.x; } +>explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 155, 48)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 156, 13)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) + + static implicitStatic(): number { return this.y; } +>implicitStatic : Symbol(Base1.implicitStatic, Decl(thisTypeInFunctions.ts, 156, 52)) +>this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) + + static explicitStatic(this: typeof Base1): number { return this.y; } +>explicitStatic : Symbol(Base1.explicitStatic, Decl(thisTypeInFunctions.ts, 157, 54)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 158, 26)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) + + static y: number; +>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) + +} +class Derived1 extends Base1 { +>Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 161, 1)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) + + y: number +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 162, 30)) +} +class Base2 { +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) + + y: number +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 165, 13)) + + implicit(): number { return this.y; } +>implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 165, 13)) +>this : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 165, 13)) + + explicit(this: Base1): number { return this.x; } +>explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 167, 41)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 168, 13)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 153, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 153, 13)) +} +class Derived2 extends Base2 { +>Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 169, 1)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) + + x: number +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 170, 30)) +} +let b1 = new Base1(); +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 173, 3)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) + +let b2 = new Base2(); +>b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 174, 3)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) + +let d1 = new Derived1(); +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) +>Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 161, 1)) + +let d2 = new Derived2(); +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) +>Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 169, 1)) + +d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) +>d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) +>implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +>d1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) +>implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) + +d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) +>d1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) +>implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +>d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) +>implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) + +// bivariance-allowed cases +d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) +>d1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) +>implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +>b2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +>b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 174, 3)) +>implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) + +d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) +>d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) +>implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +>d1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) + +b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +>b1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 173, 3)) +>implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +>d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) +>implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) + +b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +>b1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 173, 3)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) +>d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) +>implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) + +////// use this-type for construction with new //// +function InterfaceThis(this: I) { +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 187, 23)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) + + this.a = 12; +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +} +function LiteralTypeThis(this: {x: string}) { +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 190, 25)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) + + this.x = "ok"; +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 190, 30)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) +} +function AnyThis(this: any) { +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 193, 17)) + + this.x = "ok"; +} +let interfaceThis = new InterfaceThis(); +>interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 196, 3)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) + +let literalTypeThis = new LiteralTypeThis(); +>literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 197, 3)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) + +let anyThis = new AnyThis(); +>anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 198, 3)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) + +//// type parameter inference //// +declare var f: { +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) + + (this: void, x: number): number, +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 202, 5)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 202, 16)) + + call(this: (...argArray: any[]) => U, ...argArray: any[]): U; +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 203, 12)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 19)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 44)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) + +}; +let n: number = f.call(12); +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 205, 3)) +>f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) + +function missingTypeIsImplicitAny(this, a: number) { return a; } +>missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 205, 27)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 207, 34)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) + diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types new file mode 100644 index 00000000000..36b458b91e0 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -0,0 +1,1037 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions.ts === +// body checking +class C { +>C : C + + n: number; +>n : number + + explicitThis(this: this, m: number): number { +>explicitThis : (this: this, m: number) => number +>this : this +>m : number + + return this.n + m; +>this.n + m : number +>this.n : number +>this : this +>n : number +>m : number + } + implicitThis(m: number): number { +>implicitThis : (this: this, m: number) => number +>m : number + + return this.n + m; +>this.n + m : number +>this.n : number +>this : this +>n : number +>m : number + } + explicitC(this: C, m: number): number { +>explicitC : (this: C, m: number) => number +>this : C +>C : C +>m : number + + return this.n + m; +>this.n + m : number +>this.n : number +>this : C +>n : number +>m : number + } + explicitProperty(this: {n: number}, m: number): number { +>explicitProperty : (this: { n: number; }, m: number) => number +>this : { n: number; } +>n : number +>m : number + + return this.n + m; +>this.n + m : number +>this.n : number +>this : { n: number; } +>n : number +>m : number + } + explicitVoid(this: void, m: number): number { +>explicitVoid : (m: number) => number +>this : void +>m : number + + return m + 1; +>m + 1 : number +>m : number +>1 : number + } +} +class D extends C { } +>D : D +>C : C + +class B { +>B : B + + n: number; +>n : number +} +interface I { +>I : I + + a: number; +>a : number + + explicitVoid1(this: void): number; +>explicitVoid1 : () => number +>this : void + + explicitVoid2(this: void): number; +>explicitVoid2 : () => number +>this : void + + explicitStructural(this: {a: number}): number; +>explicitStructural : (this: { a: number; }) => number +>this : { a: number; } +>a : number + + explicitInterface(this: I): number; +>explicitInterface : (this: I) => number +>this : I +>I : I + + explicitThis(this: this): number; +>explicitThis : (this: this) => number +>this : this + + implicitMethod(): number; +>implicitMethod : (this: this) => number + + implicitFunction: () => number; +>implicitFunction : () => number +} +function explicitStructural(this: { y: number }, x: number): number { +>explicitStructural : (this: { y: number; }, x: number) => number +>this : { y: number; } +>y : number +>x : number + + return x + this.y; +>x + this.y : number +>x : number +>this.y : number +>this : { y: number; } +>y : number +} +function justThis(this: { y: number }): number { +>justThis : (this: { y: number; }) => number +>this : { y: number; } +>y : number + + return this.y; +>this.y : number +>this : { y: number; } +>y : number +} +function implicitThis(n: number): number { +>implicitThis : (n: number) => number +>n : number + + return 12; +>12 : number +} +let impl: I = { +>impl : I +>I : I +>{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; }, implicitMethod() { return this.a; }, implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?)} : { a: number; explicitVoid2: () => any; explicitVoid1(): number; explicitStructural(this: { a: number; }): number; explicitInterface(this: I): number; explicitThis(this: I): number; implicitMethod(this: I): number; implicitFunction: () => any; } + + a: 12, +>a : number +>12 : number + + explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) +>explicitVoid2 : () => any +>() => this.a : () => any +>this.a : any +>this : any +>a : any + + explicitVoid1() { return 12; }, +>explicitVoid1 : () => number +>12 : number + + explicitStructural() { +>explicitStructural : (this: { a: number; }) => number + + return this.a; +>this.a : number +>this : { a: number; } +>a : number + + }, + explicitInterface() { +>explicitInterface : (this: I) => number + + return this.a; +>this.a : number +>this : I +>a : number + + }, + explicitThis() { +>explicitThis : (this: I) => number + + return this.a; +>this.a : number +>this : I +>a : number + + }, + implicitMethod() { +>implicitMethod : (this: I) => number + + return this.a; +>this.a : number +>this : I +>a : number + + }, + implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) +>implicitFunction : () => any +>() => this.a : () => any +>this.a : any +>this : any +>a : any +} +impl.explicitVoid1 = function () { return 12; }; +>impl.explicitVoid1 = function () { return 12; } : () => number +>impl.explicitVoid1 : () => number +>impl : I +>explicitVoid1 : () => number +>function () { return 12; } : () => number +>12 : number + +impl.explicitVoid2 = () => 12; +>impl.explicitVoid2 = () => 12 : () => number +>impl.explicitVoid2 : () => number +>impl : I +>explicitVoid2 : () => number +>() => 12 : () => number +>12 : number + +impl.explicitStructural = function() { return this.a; }; +>impl.explicitStructural = function() { return this.a; } : (this: { a: number; }) => number +>impl.explicitStructural : (this: { a: number; }) => number +>impl : I +>explicitStructural : (this: { a: number; }) => number +>function() { return this.a; } : (this: { a: number; }) => number +>this.a : number +>this : { a: number; } +>a : number + +impl.explicitInterface = function() { return this.a; }; +>impl.explicitInterface = function() { return this.a; } : (this: I) => number +>impl.explicitInterface : (this: I) => number +>impl : I +>explicitInterface : (this: I) => number +>function() { return this.a; } : (this: I) => number +>this.a : number +>this : I +>a : number + +impl.explicitStructural = () => 12; +>impl.explicitStructural = () => 12 : () => number +>impl.explicitStructural : (this: { a: number; }) => number +>impl : I +>explicitStructural : (this: { a: number; }) => number +>() => 12 : () => number +>12 : number + +impl.explicitInterface = () => 12; +>impl.explicitInterface = () => 12 : () => number +>impl.explicitInterface : (this: I) => number +>impl : I +>explicitInterface : (this: I) => number +>() => 12 : () => number +>12 : number + +impl.explicitThis = function () { return this.a; }; +>impl.explicitThis = function () { return this.a; } : (this: I) => number +>impl.explicitThis : (this: I) => number +>impl : I +>explicitThis : (this: I) => number +>function () { return this.a; } : (this: I) => number +>this.a : number +>this : I +>a : number + +impl.implicitMethod = function () { return this.a; }; +>impl.implicitMethod = function () { return this.a; } : (this: I) => number +>impl.implicitMethod : (this: I) => number +>impl : I +>implicitMethod : (this: I) => number +>function () { return this.a; } : (this: I) => number +>this.a : number +>this : I +>a : number + +impl.implicitMethod = () => 12; +>impl.implicitMethod = () => 12 : () => number +>impl.implicitMethod : (this: I) => number +>impl : I +>implicitMethod : (this: I) => number +>() => 12 : () => number +>12 : number + +impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) +>impl.implicitFunction = () => this.a : () => any +>impl.implicitFunction : () => number +>impl : I +>implicitFunction : () => number +>() => this.a : () => any +>this.a : any +>this : any +>a : any + +// parameter checking +let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; +>ok : { y: number; f: (this: { y: number; }, x: number) => number; } +>y : number +>f : (this: { y: number; }, x: number) => number +>this : { y: number; } +>y : number +>x : number +>{ y: 12, f: explicitStructural } : { y: number; f: (this: { y: number; }, x: number) => number; } +>y : number +>12 : number +>f : (this: { y: number; }, x: number) => number +>explicitStructural : (this: { y: number; }, x: number) => number + +let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; +>implicitAnyOk : { notSpecified: number; f: (x: number) => number; } +>notSpecified : number +>f : (x: number) => number +>x : number +>{ notSpecified: 12, f: implicitThis } : { notSpecified: number; f: (n: number) => number; } +>notSpecified : number +>12 : number +>f : (n: number) => number +>implicitThis : (n: number) => number + +ok.f(13); +>ok.f(13) : number +>ok.f : (this: { y: number; }, x: number) => number +>ok : { y: number; f: (this: { y: number; }, x: number) => number; } +>f : (this: { y: number; }, x: number) => number +>13 : number + +implicitThis(12); +>implicitThis(12) : number +>implicitThis : (n: number) => number +>12 : number + +implicitAnyOk.f(12); +>implicitAnyOk.f(12) : number +>implicitAnyOk.f : (x: number) => number +>implicitAnyOk : { notSpecified: number; f: (x: number) => number; } +>f : (x: number) => number +>12 : number + +let c = new C(); +>c : C +>new C() : C +>C : typeof C + +let d = new D(); +>d : D +>new D() : D +>D : typeof D + +let ripped = c.explicitC; +>ripped : (this: C, m: number) => number +>c.explicitC : (this: C, m: number) => number +>c : C +>explicitC : (this: C, m: number) => number + +c.explicitC(12); +>c.explicitC(12) : number +>c.explicitC : (this: C, m: number) => number +>c : C +>explicitC : (this: C, m: number) => number +>12 : number + +c.explicitProperty(12); +>c.explicitProperty(12) : number +>c.explicitProperty : (this: { n: number; }, m: number) => number +>c : C +>explicitProperty : (this: { n: number; }, m: number) => number +>12 : number + +c.explicitThis(12); +>c.explicitThis(12) : number +>c.explicitThis : (this: C, m: number) => number +>c : C +>explicitThis : (this: C, m: number) => number +>12 : number + +c.implicitThis(12); +>c.implicitThis(12) : number +>c.implicitThis : (this: C, m: number) => number +>c : C +>implicitThis : (this: C, m: number) => number +>12 : number + +d.explicitC(12); +>d.explicitC(12) : number +>d.explicitC : (this: C, m: number) => number +>d : D +>explicitC : (this: C, m: number) => number +>12 : number + +d.explicitProperty(12); +>d.explicitProperty(12) : number +>d.explicitProperty : (this: { n: number; }, m: number) => number +>d : D +>explicitProperty : (this: { n: number; }, m: number) => number +>12 : number + +d.explicitThis(12); +>d.explicitThis(12) : number +>d.explicitThis : (this: D, m: number) => number +>d : D +>explicitThis : (this: D, m: number) => number +>12 : number + +d.implicitThis(12); +>d.implicitThis(12) : number +>d.implicitThis : (this: D, m: number) => number +>d : D +>implicitThis : (this: D, m: number) => number +>12 : number + +let reconstructed: { +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } + + n: number, +>n : number + + explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. +>explicitThis : (this: C, m: number) => number +>this : C +>C : C +>m : number + + implicitThis(m: number): number, +>implicitThis : (m: number) => number +>m : number + + explicitC(this: C, m: number): number, +>explicitC : (this: C, m: number) => number +>this : C +>C : C +>m : number + + explicitProperty: (this: {n : number}, m: number) => number, +>explicitProperty : (this: { n: number; }, m: number) => number +>this : { n: number; } +>n : number +>m : number + + explicitVoid(this: void, m: number): number, +>explicitVoid : (m: number) => number +>this : void +>m : number + +} = { +>{ n: 12, explicitThis: c.explicitThis, implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid} : { n: number; explicitThis: (this: C, m: number) => number; implicitThis: (this: C, m: number) => number; explicitC: (this: C, m: number) => number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid: (m: number) => number; } + + n: 12, +>n : number +>12 : number + + explicitThis: c.explicitThis, +>explicitThis : (this: C, m: number) => number +>c.explicitThis : (this: C, m: number) => number +>c : C +>explicitThis : (this: C, m: number) => number + + implicitThis: c.implicitThis, +>implicitThis : (this: C, m: number) => number +>c.implicitThis : (this: C, m: number) => number +>c : C +>implicitThis : (this: C, m: number) => number + + explicitC: c.explicitC, +>explicitC : (this: C, m: number) => number +>c.explicitC : (this: C, m: number) => number +>c : C +>explicitC : (this: C, m: number) => number + + explicitProperty: c.explicitProperty, +>explicitProperty : (this: { n: number; }, m: number) => number +>c.explicitProperty : (this: { n: number; }, m: number) => number +>c : C +>explicitProperty : (this: { n: number; }, m: number) => number + + explicitVoid: c.explicitVoid +>explicitVoid : (m: number) => number +>c.explicitVoid : (m: number) => number +>c : C +>explicitVoid : (m: number) => number + +}; +reconstructed.explicitProperty(11); +>reconstructed.explicitProperty(11) : number +>reconstructed.explicitProperty : (this: { n: number; }, m: number) => number +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } +>explicitProperty : (this: { n: number; }, m: number) => number +>11 : number + +reconstructed.implicitThis(11); +>reconstructed.implicitThis(11) : number +>reconstructed.implicitThis : (m: number) => number +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } +>implicitThis : (m: number) => number +>11 : number + +// assignment checking +let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any +>unboundToSpecified : (this: { y: number; }, x: number) => number +>this : { y: number; } +>y : number +>x : number +>x => x + this.y : (x: number) => any +>x : number +>x + this.y : any +>x : number +>this.y : any +>this : any +>y : any + +let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; +>specifiedToSpecified : (this: { y: number; }, x: number) => number +>this : { y: number; } +>y : number +>x : number +>explicitStructural : (this: { y: number; }, x: number) => number + +let anyToSpecified: (this: { y: number }, x: number) => number = function(x: number): number { return x + 12; }; +>anyToSpecified : (this: { y: number; }, x: number) => number +>this : { y: number; } +>y : number +>x : number +>function(x: number): number { return x + 12; } : (this: { y: number; }, x: number) => number +>x : number +>x + 12 : number +>x : number +>12 : number + +let unspecifiedLambda: (x: number) => number = x => x + 12; +>unspecifiedLambda : (x: number) => number +>x : number +>x => x + 12 : (x: number) => number +>x : number +>x + 12 : number +>x : number +>12 : number + +let specifiedLambda: (this: void, x: number) => number = x => x + 12; +>specifiedLambda : (x: number) => number +>this : void +>x : number +>x => x + 12 : (x: number) => number +>x : number +>x + 12 : number +>x : number +>12 : number + +let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = unspecifiedLambda; +>unspecifiedLambdaToSpecified : (this: { y: number; }, x: number) => number +>this : { y: number; } +>y : number +>x : number +>unspecifiedLambda : (x: number) => number + +let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; +>specifiedLambdaToSpecified : (this: { y: number; }, x: number) => number +>this : { y: number; } +>y : number +>x : number +>specifiedLambda : (x: number) => number + + +let explicitCFunction: (this: C, m: number) => number; +>explicitCFunction : (this: C, m: number) => number +>this : C +>C : C +>m : number + +let explicitPropertyFunction: (this: {n: number}, m: number) => number; +>explicitPropertyFunction : (this: { n: number; }, m: number) => number +>this : { n: number; } +>n : number +>m : number + +c.explicitC = explicitCFunction; +>c.explicitC = explicitCFunction : (this: C, m: number) => number +>c.explicitC : (this: C, m: number) => number +>c : C +>explicitC : (this: C, m: number) => number +>explicitCFunction : (this: C, m: number) => number + +c.explicitC = function(this: C, m: number) { return this.n + m }; +>c.explicitC = function(this: C, m: number) { return this.n + m } : (this: C, m: number) => number +>c.explicitC : (this: C, m: number) => number +>c : C +>explicitC : (this: C, m: number) => number +>function(this: C, m: number) { return this.n + m } : (this: C, m: number) => number +>this : C +>C : C +>m : number +>this.n + m : number +>this.n : number +>this : C +>n : number +>m : number + +c.explicitProperty = explicitPropertyFunction; +>c.explicitProperty = explicitPropertyFunction : (this: { n: number; }, m: number) => number +>c.explicitProperty : (this: { n: number; }, m: number) => number +>c : C +>explicitProperty : (this: { n: number; }, m: number) => number +>explicitPropertyFunction : (this: { n: number; }, m: number) => number + +c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m }; +>c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m } : (this: { n: number; }, m: number) => number +>c.explicitProperty : (this: { n: number; }, m: number) => number +>c : C +>explicitProperty : (this: { n: number; }, m: number) => number +>function(this: {n: number}, m: number) { return this.n + m } : (this: { n: number; }, m: number) => number +>this : { n: number; } +>n : number +>m : number +>this.n + m : number +>this.n : number +>this : { n: number; } +>n : number +>m : number + +c.explicitProperty = reconstructed.explicitProperty; +>c.explicitProperty = reconstructed.explicitProperty : (this: { n: number; }, m: number) => number +>c.explicitProperty : (this: { n: number; }, m: number) => number +>c : C +>explicitProperty : (this: { n: number; }, m: number) => number +>reconstructed.explicitProperty : (this: { n: number; }, m: number) => number +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } +>explicitProperty : (this: { n: number; }, m: number) => number + +// lambdas are assignable to anything +c.explicitC = m => m; +>c.explicitC = m => m : (m: number) => number +>c.explicitC : (this: C, m: number) => number +>c : C +>explicitC : (this: C, m: number) => number +>m => m : (m: number) => number +>m : number +>m : number + +c.explicitThis = m => m; +>c.explicitThis = m => m : (m: number) => number +>c.explicitThis : (this: C, m: number) => number +>c : C +>explicitThis : (this: C, m: number) => number +>m => m : (m: number) => number +>m : number +>m : number + +c.explicitProperty = m => m; +>c.explicitProperty = m => m : (m: number) => number +>c.explicitProperty : (this: { n: number; }, m: number) => number +>c : C +>explicitProperty : (this: { n: number; }, m: number) => number +>m => m : (m: number) => number +>m : number +>m : number + +// this inside lambdas refer to outer scope +// the outer-scoped lambda at top-level is still just `any` +c.explicitC = m => m + this.n; +>c.explicitC = m => m + this.n : (m: number) => any +>c.explicitC : (this: C, m: number) => number +>c : C +>explicitC : (this: C, m: number) => number +>m => m + this.n : (m: number) => any +>m : number +>m + this.n : any +>m : number +>this.n : any +>this : any +>n : any + +c.explicitThis = m => m + this.n; +>c.explicitThis = m => m + this.n : (m: number) => any +>c.explicitThis : (this: C, m: number) => number +>c : C +>explicitThis : (this: C, m: number) => number +>m => m + this.n : (m: number) => any +>m : number +>m + this.n : any +>m : number +>this.n : any +>this : any +>n : any + +c.explicitProperty = m => m + this.n; +>c.explicitProperty = m => m + this.n : (m: number) => any +>c.explicitProperty : (this: { n: number; }, m: number) => number +>c : C +>explicitProperty : (this: { n: number; }, m: number) => number +>m => m + this.n : (m: number) => any +>m : number +>m + this.n : any +>m : number +>this.n : any +>this : any +>n : any + +//NOTE: this=C here, I guess? +c.explicitThis = explicitCFunction; +>c.explicitThis = explicitCFunction : (this: C, m: number) => number +>c.explicitThis : (this: C, m: number) => number +>c : C +>explicitThis : (this: C, m: number) => number +>explicitCFunction : (this: C, m: number) => number + +c.explicitThis = function(this: C, m: number) { return this.n + m }; +>c.explicitThis = function(this: C, m: number) { return this.n + m } : (this: C, m: number) => number +>c.explicitThis : (this: C, m: number) => number +>c : C +>explicitThis : (this: C, m: number) => number +>function(this: C, m: number) { return this.n + m } : (this: C, m: number) => number +>this : C +>C : C +>m : number +>this.n + m : number +>this.n : number +>this : C +>n : number +>m : number + +// this:any compatibility +c.explicitC = function(m: number) { return this.n + m }; +>c.explicitC = function(m: number) { return this.n + m } : (this: C, m: number) => number +>c.explicitC : (this: C, m: number) => number +>c : C +>explicitC : (this: C, m: number) => number +>function(m: number) { return this.n + m } : (this: C, m: number) => number +>m : number +>this.n + m : number +>this.n : number +>this : C +>n : number +>m : number + +c.explicitProperty = function(m: number) { return this.n + m }; +>c.explicitProperty = function(m: number) { return this.n + m } : (this: { n: number; }, m: number) => number +>c.explicitProperty : (this: { n: number; }, m: number) => number +>c : C +>explicitProperty : (this: { n: number; }, m: number) => number +>function(m: number) { return this.n + m } : (this: { n: number; }, m: number) => number +>m : number +>this.n + m : number +>this.n : number +>this : { n: number; } +>n : number +>m : number + +c.explicitThis = function(m: number) { return this.n + m }; +>c.explicitThis = function(m: number) { return this.n + m } : (this: C, m: number) => number +>c.explicitThis : (this: C, m: number) => number +>c : C +>explicitThis : (this: C, m: number) => number +>function(m: number) { return this.n + m } : (this: C, m: number) => number +>m : number +>this.n + m : number +>this.n : number +>this : C +>n : number +>m : number + +c.implicitThis = function(m: number) { return this.n + m }; +>c.implicitThis = function(m: number) { return this.n + m } : (this: C, m: number) => number +>c.implicitThis : (this: C, m: number) => number +>c : C +>implicitThis : (this: C, m: number) => number +>function(m: number) { return this.n + m } : (this: C, m: number) => number +>m : number +>this.n + m : number +>this.n : number +>this : C +>n : number +>m : number + +c.implicitThis = reconstructed.implicitThis; +>c.implicitThis = reconstructed.implicitThis : (m: number) => number +>c.implicitThis : (this: C, m: number) => number +>c : C +>implicitThis : (this: C, m: number) => number +>reconstructed.implicitThis : (m: number) => number +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } +>implicitThis : (m: number) => number + +c.explicitC = function(this: B, m: number) { return this.n + m }; +>c.explicitC = function(this: B, m: number) { return this.n + m } : (this: B, m: number) => number +>c.explicitC : (this: C, m: number) => number +>c : C +>explicitC : (this: C, m: number) => number +>function(this: B, m: number) { return this.n + m } : (this: B, m: number) => number +>this : B +>B : B +>m : number +>this.n + m : number +>this.n : number +>this : B +>n : number +>m : number + +// this:void compatibility +c.explicitVoid = n => n; +>c.explicitVoid = n => n : (n: number) => number +>c.explicitVoid : (m: number) => number +>c : C +>explicitVoid : (m: number) => number +>n => n : (n: number) => number +>n : number +>n : number + +// class-based assignability +class Base1 { +>Base1 : Base1 + + x: number; +>x : number + + public implicit(): number { return this.x; } +>implicit : (this: this) => number +>this.x : number +>this : this +>x : number + + explicit(this: Base1): number { return this.x; } +>explicit : (this: Base1) => number +>this : Base1 +>Base1 : Base1 +>this.x : number +>this : Base1 +>x : number + + static implicitStatic(): number { return this.y; } +>implicitStatic : (this: typeof Base1) => number +>this.y : number +>this : typeof Base1 +>y : number + + static explicitStatic(this: typeof Base1): number { return this.y; } +>explicitStatic : (this: typeof Base1) => number +>this : typeof Base1 +>Base1 : typeof Base1 +>this.y : number +>this : typeof Base1 +>y : number + + static y: number; +>y : number + +} +class Derived1 extends Base1 { +>Derived1 : Derived1 +>Base1 : Base1 + + y: number +>y : number +} +class Base2 { +>Base2 : Base2 + + y: number +>y : number + + implicit(): number { return this.y; } +>implicit : (this: this) => number +>this.y : number +>this : this +>y : number + + explicit(this: Base1): number { return this.x; } +>explicit : (this: Base1) => number +>this : Base1 +>Base1 : Base1 +>this.x : number +>this : Base1 +>x : number +} +class Derived2 extends Base2 { +>Derived2 : Derived2 +>Base2 : Base2 + + x: number +>x : number +} +let b1 = new Base1(); +>b1 : Base1 +>new Base1() : Base1 +>Base1 : typeof Base1 + +let b2 = new Base2(); +>b2 : Base2 +>new Base2() : Base2 +>Base2 : typeof Base2 + +let d1 = new Derived1(); +>d1 : Derived1 +>new Derived1() : Derived1 +>Derived1 : typeof Derived1 + +let d2 = new Derived2(); +>d2 : Derived2 +>new Derived2() : Derived2 +>Derived2 : typeof Derived2 + +d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) +>d2.implicit = d1.implicit : (this: Derived1) => number +>d2.implicit : (this: Derived2) => number +>d2 : Derived2 +>implicit : (this: Derived2) => number +>d1.implicit : (this: Derived1) => number +>d1 : Derived1 +>implicit : (this: Derived1) => number + +d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) +>d1.implicit = d2.implicit : (this: Derived2) => number +>d1.implicit : (this: Derived1) => number +>d1 : Derived1 +>implicit : (this: Derived1) => number +>d2.implicit : (this: Derived2) => number +>d2 : Derived2 +>implicit : (this: Derived2) => number + +// bivariance-allowed cases +d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) +>d1.implicit = b2.implicit : (this: Base2) => number +>d1.implicit : (this: Derived1) => number +>d1 : Derived1 +>implicit : (this: Derived1) => number +>b2.implicit : (this: Base2) => number +>b2 : Base2 +>implicit : (this: Base2) => number + +d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) +>d2.implicit = d1.explicit : (this: Base1) => number +>d2.implicit : (this: Derived2) => number +>d2 : Derived2 +>implicit : (this: Derived2) => number +>d1.explicit : (this: Base1) => number +>d1 : Derived1 +>explicit : (this: Base1) => number + +b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +>b1.implicit = d2.implicit : (this: Derived2) => number +>b1.implicit : (this: Base1) => number +>b1 : Base1 +>implicit : (this: Base1) => number +>d2.implicit : (this: Derived2) => number +>d2 : Derived2 +>implicit : (this: Derived2) => number + +b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +>b1.explicit = d2.implicit : (this: Derived2) => number +>b1.explicit : (this: Base1) => number +>b1 : Base1 +>explicit : (this: Base1) => number +>d2.implicit : (this: Derived2) => number +>d2 : Derived2 +>implicit : (this: Derived2) => number + +////// use this-type for construction with new //// +function InterfaceThis(this: I) { +>InterfaceThis : (this: I) => void +>this : I +>I : I + + this.a = 12; +>this.a = 12 : number +>this.a : number +>this : I +>a : number +>12 : number +} +function LiteralTypeThis(this: {x: string}) { +>LiteralTypeThis : (this: { x: string; }) => void +>this : { x: string; } +>x : string + + this.x = "ok"; +>this.x = "ok" : string +>this.x : string +>this : { x: string; } +>x : string +>"ok" : string +} +function AnyThis(this: any) { +>AnyThis : () => void +>this : any + + this.x = "ok"; +>this.x = "ok" : string +>this.x : any +>this : any +>x : any +>"ok" : string +} +let interfaceThis = new InterfaceThis(); +>interfaceThis : I +>new InterfaceThis() : I +>InterfaceThis : (this: I) => void + +let literalTypeThis = new LiteralTypeThis(); +>literalTypeThis : { x: string; } +>new LiteralTypeThis() : { x: string; } +>LiteralTypeThis : (this: { x: string; }) => void + +let anyThis = new AnyThis(); +>anyThis : any +>new AnyThis() : any +>AnyThis : () => void + +//// type parameter inference //// +declare var f: { +>f : { (x: number): number; call(this: (...argArray: any[]) => U, ...argArray: any[]): U; } + + (this: void, x: number): number, +>this : void +>x : number + + call(this: (...argArray: any[]) => U, ...argArray: any[]): U; +>call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U +>U : U +>this : (...argArray: any[]) => U +>argArray : any[] +>U : U +>argArray : any[] +>U : U + +}; +let n: number = f.call(12); +>n : number +>f.call(12) : number +>f.call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U +>f : { (x: number): number; call(this: (...argArray: any[]) => U, ...argArray: any[]): U; } +>call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U +>12 : number + +function missingTypeIsImplicitAny(this, a: number) { return a; } +>missingTypeIsImplicitAny : (a: number) => number +>this : any +>a : number +>a : number + diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt new file mode 100644 index 00000000000..49a4380977a --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -0,0 +1,509 @@ +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(16,15): error TS2339: Property 'n' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(44,21): error TS2339: Property 'a' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(55,49): error TS2339: Property 'a' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(58,1): error TS2345: Argument of type 'void' is not assignable to parameter of type '{ a: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(60,1): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(62,1): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(70,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(74,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(76,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. + Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(77,97): error TS2322: Type '{ y: string; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. + Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(78,110): error TS2322: Type '{ wrongName: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. + Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(80,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(82,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(83,1): error TS2345: Argument of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. + Types of property 'y' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(84,1): error TS2345: Argument of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. + Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(87,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(88,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(89,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(90,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(91,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(92,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(93,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(94,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(95,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(96,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(97,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(98,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(101,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(x: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'void' is not assignable to type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(124,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'C' is not assignable to type 'D'. + Property 'x' is missing in type 'C'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(125,1): error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type '{ n: number; }' is not assignable to type '{ x: number; }'. + Property 'x' is missing in type '{ n: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(127,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'C' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(128,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'C' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(129,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'C' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(130,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'C' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(131,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'C' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(132,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'C' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(133,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type '{ n: number; }' is not assignable to type 'D'. + Property 'x' is missing in type '{ n: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(134,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type '{ n: number; }' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(135,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(136,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'void' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(137,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'void' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(138,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'void' is not assignable to type 'D'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,51): error TS2339: Property 'x' does not exist on type 'typeof Base1'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(147,69): error TS2339: Property 'x' does not exist on type 'typeof Base1'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'Base1' is not assignable to type 'Base2'. + Property 'y' is missing in type 'Base1'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'Base1' is not assignable to type 'Base2'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. + Types of parameters 'this' and 'this' are incompatible. + Type 'Base1' is not assignable to type 'Base2'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(179,16): error TS2671: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(180,24): error TS2671: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,30): error TS2332: 'this' cannot be referenced in current location. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,26): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,57): error TS2339: Property 'n' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,20): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,23): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,27): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,54): error TS2339: Property 'n' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,23): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,24): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,51): error TS2339: Property 'n' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(188,28): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(188,32): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(188,59): error TS2339: Property 'n' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,32): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,39): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,40): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,42): error TS2304: Cannot find name 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,49): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,1): error TS7027: Unreachable code detected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,29): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,32): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,35): error TS2304: Cannot find name 'm'. + + +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (75 errors) ==== + class C { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + implicitThis(m: number): number { + return this.n + m; + } + explicitC(this: C, m: number): number { + return this.n + m; + } + explicitProperty(this: {n: number}, m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return this.n + m; // 'n' doesn't exist on type 'void'. + ~ +!!! error TS2339: Property 'n' does not exist on type 'void'. + } + } + class D { + x: number; + explicitThis(this: this, m: number): number { + return this.x + m; + } + explicitD(this: D, m: number): number { + return this.x + m; + } + implicitD(m: number): number { + return this.x + m; + } + } + interface I { + a: number; + explicitVoid1(this: void): number; + explicitVoid2(this: void): number; + explicitStructural(this: {a: number}): number; + explicitInterface(this: I): number; + explicitThis(this: this): number; // TODO: Allow `this` types for interfaces + implicitMethod(): number; + implicitFunction: () => number; + } + let impl: I = { + a: 12, + explicitVoid1() { + return this.a; // error, no 'a' in 'void' + ~ +!!! error TS2339: Property 'a' does not exist on type 'void'. + }, + explicitVoid2: () => this.a, // ok, `this:any` because it refers to an outer object + explicitStructural: () => 12, + explicitInterface: () => 12, + explicitThis() { + return this.a; + }, + implicitMethod() { + return this.a; // ok, I.a: number + }, + implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' + ~ +!!! error TS2339: Property 'a' does not exist on type 'void'. + } + let implExplicitStructural = impl.explicitStructural; + implExplicitStructural(); // error, no 'a' in 'void' + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'void' is not assignable to parameter of type '{ a: number; }'. + let implExplicitInterface = impl.explicitInterface; + implExplicitInterface(); // error, no 'a' in 'void' + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. + let implImplicitMethod = impl.implicitMethod; + implImplicitMethod(); // error, no 'a' in 'void' + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. + function explicitStructural(this: { y: number }, x: number): number { + return x + this.y; + } + function propertyName(this: { y: number }, x: number): number { + return x + this.notFound; + ~~~~~~~~ +!!! error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. + } + function voidThisSpecified(this: void, x: number): number { + return x + this.notSpecified; + ~~~~~~~~~~~~ +!!! error TS2339: Property 'notSpecified' does not exist on type 'void'. + } + function noThisSpecified(x: number): number { + // this:void unless loose-this is on + return x + this.notSpecified; + ~~~~~~~~~~~~ +!!! error TS2339: Property 'notSpecified' does not exist on type 'void'. + } + let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, explicitStructural }; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. + let wrongPropertyType: {y: string, f: (this: { y: number }, x: number) => number} = { y: 'foo', explicitStructural }; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ y: string; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. + let wrongPropertyName: {wrongName: number, f: (this: { y: number }, x: number) => number} = { wrongName: 12, explicitStructural }; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ wrongName: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. +!!! error TS2322: Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. + + ok.f(); // not enough arguments + ~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + ok.f('wrong type'); + ~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + ok.f(13, 'too many arguments'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + wrongPropertyType.f(13); + ~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. +!!! error TS2345: Types of property 'y' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + wrongPropertyName.f(13); + ~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. +!!! error TS2345: Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. + + let c = new C(); + c.explicitC(); // not enough arguments + ~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + c.explicitC('wrong type'); + ~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + c.explicitC(13, 'too many arguments'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + c.explicitThis(); // not enough arguments + ~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + c.explicitThis('wrong type 2'); + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + c.explicitThis(14, 'too many arguments 2'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + c.implicitThis(); // not enough arguments + ~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + c.implicitThis('wrong type 2'); + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + c.implicitThis(14, 'too many arguments 2'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + c.explicitProperty(); // not enough arguments + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + c.explicitProperty('wrong type 3'); + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + c.explicitProperty(15, 'too many arguments 3'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + + // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. + let specifiedToImplicitVoid: (x: number) => number = explicitStructural; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(x: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'void' is not assignable to type '{ y: number; }'. + + let reconstructed: { + n: number, + explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. + implicitThis(m: number): number, + explicitC(this: C, m: number): number, + explicitProperty: (this: {n : number}, m: number) => number, + explicitVoid(this: void, m: number): number, + } = { + n: 12, + explicitThis: c.explicitThis, + implicitThis: c.implicitThis, // error not assignable -- c.this:c not assignable to this:void. + explicitC: c.explicitC, + explicitProperty: c.explicitProperty, + explicitVoid: c.explicitVoid + };; + + // lambdas have this: void for assignability purposes (and this unbound (free) for body checking) + let d = new D(); + let explicitXProperty: (this: { x: number }, m: number) => number; + + // from differing object types + c.explicitC = function(this: D, m: number) { return this.x + m }; + ~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'C' is not assignable to type 'D'. +!!! error TS2322: Property 'x' is missing in type 'C'. + c.explicitProperty = explicitXProperty; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type '{ n: number; }' is not assignable to type '{ x: number; }'. +!!! error TS2322: Property 'x' is missing in type '{ n: number; }'. + + c.explicitC = d.implicitD; + ~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'C' is not assignable to type 'D'. + c.explicitC = d.explicitD; + ~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'C' is not assignable to type 'D'. + c.explicitC = d.explicitThis; + ~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'C' is not assignable to type 'D'. + c.explicitThis = d.implicitD; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'C' is not assignable to type 'D'. + c.explicitThis = d.explicitD; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'C' is not assignable to type 'D'. + c.explicitThis = d.explicitThis; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'C' is not assignable to type 'D'. + c.explicitProperty = d.explicitD; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type '{ n: number; }' is not assignable to type 'D'. +!!! error TS2322: Property 'x' is missing in type '{ n: number; }'. + c.explicitProperty = d.implicitD; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type '{ n: number; }' is not assignable to type 'D'. + c.explicitThis = d.explicitThis; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. + c.explicitVoid = d.implicitD; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'void' is not assignable to type 'D'. + c.explicitVoid = d.explicitD; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'void' is not assignable to type 'D'. + c.explicitVoid = d.explicitThis; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'void' is not assignable to type 'D'. + + /// class-based implicit assignability (with inheritance!) /// + + class Base1 { + x: number + public implicit(): number { return this.x; } + explicit(this: Base1): number { return this.x; } + static implicitStatic(): number { return this.x; } + ~ +!!! error TS2339: Property 'x' does not exist on type 'typeof Base1'. + static explicitStatic(this: typeof Base1): number { return this.x; } + ~ +!!! error TS2339: Property 'x' does not exist on type 'typeof Base1'. + } + class Derived1 extends Base1 { + y: number + } + class Base2 { + y: number + implicit(): number { return this.y; } + explicit(this: Base1): number { return this.x; } + } + class Derived2 extends Base2 { + x: number + } + + + let b1 = new Base1(); + let d1 = new Derived1(); + let b2 = new Base2(); + let d2 = new Derived2(); + + b1.implicit = b2.implicit // error, 'this.y' not in C: { x } (c assignable to e) + ~~~~~~~~~~~ +!!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. +!!! error TS2322: Property 'y' is missing in type 'Base1'. + b1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + ~~~~~~~~~~~ +!!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. + + d1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + ~~~~~~~~~~~ +!!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. +!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. + + ////// use this-type for construction with new //// + function VoidThis(this: void) { + + } + function ImplicitVoidThis() { + + } + let voidThis = new VoidThis(); + ~~~~~~~~~~~~~~ +!!! error TS2671: A function that is called with the 'new' keyword cannot have a 'this' type that is void. + let implicitVoidThis = new ImplicitVoidThis(); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2671: A function that is called with the 'new' keyword cannot have a 'this' type that is void. + + + ///// parse errors ///// + function notFirst(a: number, this: C): number { return this.n; } + ~~~~~~~ +!!! error TS2332: 'this' cannot be referenced in current location. + function modifiers(async this: C): number { return this.n; } + ~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS2339: Property 'n' does not exist on type 'void'. + function restParam(...this: C): number { return this.n; } + ~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. + ~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS2339: Property 'n' does not exist on type 'void'. + function optional(this?: C): number { return this.n; } + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS2339: Property 'n' does not exist on type 'void'. + function decorated(@deco() this: C): number { return this.n; } + ~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS2339: Property 'n' does not exist on type 'void'. + function initializer(this: C = new C()): number { return this.n; } + ~ +!!! error TS1005: ',' expected. + ~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2304: Cannot find name 'number'. + ~ +!!! error TS1005: ';' expected. + + // can't name parameters 'this' in a lambda. + c.explicitProperty = (this, m) => m + this.n; + ~ +!!! error TS7027: Unreachable code detected. + ~ +!!! error TS2304: Cannot find name 'm'. + ~~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'm'. + \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js new file mode 100644 index 00000000000..43d83daef0d --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -0,0 +1,386 @@ +//// [thisTypeInFunctionsNegative.ts] +class C { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + implicitThis(m: number): number { + return this.n + m; + } + explicitC(this: C, m: number): number { + return this.n + m; + } + explicitProperty(this: {n: number}, m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return this.n + m; // 'n' doesn't exist on type 'void'. + } +} +class D { + x: number; + explicitThis(this: this, m: number): number { + return this.x + m; + } + explicitD(this: D, m: number): number { + return this.x + m; + } + implicitD(m: number): number { + return this.x + m; + } +} +interface I { + a: number; + explicitVoid1(this: void): number; + explicitVoid2(this: void): number; + explicitStructural(this: {a: number}): number; + explicitInterface(this: I): number; + explicitThis(this: this): number; // TODO: Allow `this` types for interfaces + implicitMethod(): number; + implicitFunction: () => number; +} +let impl: I = { + a: 12, + explicitVoid1() { + return this.a; // error, no 'a' in 'void' + }, + explicitVoid2: () => this.a, // ok, `this:any` because it refers to an outer object + explicitStructural: () => 12, + explicitInterface: () => 12, + explicitThis() { + return this.a; + }, + implicitMethod() { + return this.a; // ok, I.a: number + }, + implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' +} +let implExplicitStructural = impl.explicitStructural; +implExplicitStructural(); // error, no 'a' in 'void' +let implExplicitInterface = impl.explicitInterface; +implExplicitInterface(); // error, no 'a' in 'void' +let implImplicitMethod = impl.implicitMethod; +implImplicitMethod(); // error, no 'a' in 'void' +function explicitStructural(this: { y: number }, x: number): number { + return x + this.y; +} +function propertyName(this: { y: number }, x: number): number { + return x + this.notFound; +} +function voidThisSpecified(this: void, x: number): number { + return x + this.notSpecified; +} +function noThisSpecified(x: number): number { + // this:void unless loose-this is on + return x + this.notSpecified; +} +let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, explicitStructural }; +let wrongPropertyType: {y: string, f: (this: { y: number }, x: number) => number} = { y: 'foo', explicitStructural }; +let wrongPropertyName: {wrongName: number, f: (this: { y: number }, x: number) => number} = { wrongName: 12, explicitStructural }; + +ok.f(); // not enough arguments +ok.f('wrong type'); +ok.f(13, 'too many arguments'); +wrongPropertyType.f(13); +wrongPropertyName.f(13); + +let c = new C(); +c.explicitC(); // not enough arguments +c.explicitC('wrong type'); +c.explicitC(13, 'too many arguments'); +c.explicitThis(); // not enough arguments +c.explicitThis('wrong type 2'); +c.explicitThis(14, 'too many arguments 2'); +c.implicitThis(); // not enough arguments +c.implicitThis('wrong type 2'); +c.implicitThis(14, 'too many arguments 2'); +c.explicitProperty(); // not enough arguments +c.explicitProperty('wrong type 3'); +c.explicitProperty(15, 'too many arguments 3'); + +// oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. +let specifiedToImplicitVoid: (x: number) => number = explicitStructural; + +let reconstructed: { + n: number, + explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. + implicitThis(m: number): number, + explicitC(this: C, m: number): number, + explicitProperty: (this: {n : number}, m: number) => number, + explicitVoid(this: void, m: number): number, +} = { + n: 12, + explicitThis: c.explicitThis, + implicitThis: c.implicitThis, // error not assignable -- c.this:c not assignable to this:void. + explicitC: c.explicitC, + explicitProperty: c.explicitProperty, + explicitVoid: c.explicitVoid +};; + +// lambdas have this: void for assignability purposes (and this unbound (free) for body checking) +let d = new D(); +let explicitXProperty: (this: { x: number }, m: number) => number; + +// from differing object types +c.explicitC = function(this: D, m: number) { return this.x + m }; +c.explicitProperty = explicitXProperty; + +c.explicitC = d.implicitD; +c.explicitC = d.explicitD; +c.explicitC = d.explicitThis; +c.explicitThis = d.implicitD; +c.explicitThis = d.explicitD; +c.explicitThis = d.explicitThis; +c.explicitProperty = d.explicitD; +c.explicitProperty = d.implicitD; +c.explicitThis = d.explicitThis; +c.explicitVoid = d.implicitD; +c.explicitVoid = d.explicitD; +c.explicitVoid = d.explicitThis; + +/// class-based implicit assignability (with inheritance!) /// + +class Base1 { + x: number + public implicit(): number { return this.x; } + explicit(this: Base1): number { return this.x; } + static implicitStatic(): number { return this.x; } + static explicitStatic(this: typeof Base1): number { return this.x; } +} +class Derived1 extends Base1 { + y: number +} +class Base2 { + y: number + implicit(): number { return this.y; } + explicit(this: Base1): number { return this.x; } +} +class Derived2 extends Base2 { + x: number +} + + +let b1 = new Base1(); +let d1 = new Derived1(); +let b2 = new Base2(); +let d2 = new Derived2(); + +b1.implicit = b2.implicit // error, 'this.y' not in C: { x } (c assignable to e) +b1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + +d1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + +////// use this-type for construction with new //// +function VoidThis(this: void) { + +} +function ImplicitVoidThis() { + +} +let voidThis = new VoidThis(); +let implicitVoidThis = new ImplicitVoidThis(); + + +///// parse errors ///// +function notFirst(a: number, this: C): number { return this.n; } +function modifiers(async this: C): number { return this.n; } +function restParam(...this: C): number { return this.n; } +function optional(this?: C): number { return this.n; } +function decorated(@deco() this: C): number { return this.n; } +function initializer(this: C = new C()): number { return this.n; } + +// can't name parameters 'this' in a lambda. +c.explicitProperty = (this, m) => m + this.n; + + +//// [thisTypeInFunctionsNegative.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var _this = this; +var C = (function () { + function C() { + } + C.prototype.explicitThis = function (m) { + return this.n + m; + }; + C.prototype.implicitThis = function (m) { + return this.n + m; + }; + C.prototype.explicitC = function (m) { + return this.n + m; + }; + C.prototype.explicitProperty = function (m) { + return this.n + m; + }; + C.prototype.explicitVoid = function (m) { + return this.n + m; // 'n' doesn't exist on type 'void'. + }; + return C; +}()); +var D = (function () { + function D() { + } + D.prototype.explicitThis = function (m) { + return this.x + m; + }; + D.prototype.explicitD = function (m) { + return this.x + m; + }; + D.prototype.implicitD = function (m) { + return this.x + m; + }; + return D; +}()); +var impl = { + a: 12, + explicitVoid1: function () { + return this.a; // error, no 'a' in 'void' + }, + explicitVoid2: function () { return _this.a; }, + explicitStructural: function () { return 12; }, + explicitInterface: function () { return 12; }, + explicitThis: function () { + return this.a; + }, + implicitMethod: function () { + return this.a; // ok, I.a: number + }, + implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' +}; +var implExplicitStructural = impl.explicitStructural; +implExplicitStructural(); // error, no 'a' in 'void' +var implExplicitInterface = impl.explicitInterface; +implExplicitInterface(); // error, no 'a' in 'void' +var implImplicitMethod = impl.implicitMethod; +implImplicitMethod(); // error, no 'a' in 'void' +function explicitStructural(x) { + return x + this.y; +} +function propertyName(x) { + return x + this.notFound; +} +function voidThisSpecified(x) { + return x + this.notSpecified; +} +function noThisSpecified(x) { + // this:void unless loose-this is on + return x + this.notSpecified; +} +var ok = { y: 12, explicitStructural: explicitStructural }; +var wrongPropertyType = { y: 'foo', explicitStructural: explicitStructural }; +var wrongPropertyName = { wrongName: 12, explicitStructural: explicitStructural }; +ok.f(); // not enough arguments +ok.f('wrong type'); +ok.f(13, 'too many arguments'); +wrongPropertyType.f(13); +wrongPropertyName.f(13); +var c = new C(); +c.explicitC(); // not enough arguments +c.explicitC('wrong type'); +c.explicitC(13, 'too many arguments'); +c.explicitThis(); // not enough arguments +c.explicitThis('wrong type 2'); +c.explicitThis(14, 'too many arguments 2'); +c.implicitThis(); // not enough arguments +c.implicitThis('wrong type 2'); +c.implicitThis(14, 'too many arguments 2'); +c.explicitProperty(); // not enough arguments +c.explicitProperty('wrong type 3'); +c.explicitProperty(15, 'too many arguments 3'); +// oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. +var specifiedToImplicitVoid = explicitStructural; +var reconstructed = { + n: 12, + explicitThis: c.explicitThis, + implicitThis: c.implicitThis, + explicitC: c.explicitC, + explicitProperty: c.explicitProperty, + explicitVoid: c.explicitVoid +}; +; +// lambdas have this: void for assignability purposes (and this unbound (free) for body checking) +var d = new D(); +var explicitXProperty; +// from differing object types +c.explicitC = function (m) { return this.x + m; }; +c.explicitProperty = explicitXProperty; +c.explicitC = d.implicitD; +c.explicitC = d.explicitD; +c.explicitC = d.explicitThis; +c.explicitThis = d.implicitD; +c.explicitThis = d.explicitD; +c.explicitThis = d.explicitThis; +c.explicitProperty = d.explicitD; +c.explicitProperty = d.implicitD; +c.explicitThis = d.explicitThis; +c.explicitVoid = d.implicitD; +c.explicitVoid = d.explicitD; +c.explicitVoid = d.explicitThis; +/// class-based implicit assignability (with inheritance!) /// +var Base1 = (function () { + function Base1() { + } + Base1.prototype.implicit = function () { return this.x; }; + Base1.prototype.explicit = function () { return this.x; }; + Base1.implicitStatic = function () { return this.x; }; + Base1.explicitStatic = function () { return this.x; }; + return Base1; +}()); +var Derived1 = (function (_super) { + __extends(Derived1, _super); + function Derived1() { + _super.apply(this, arguments); + } + return Derived1; +}(Base1)); +var Base2 = (function () { + function Base2() { + } + Base2.prototype.implicit = function () { return this.y; }; + Base2.prototype.explicit = function () { return this.x; }; + return Base2; +}()); +var Derived2 = (function (_super) { + __extends(Derived2, _super); + function Derived2() { + _super.apply(this, arguments); + } + return Derived2; +}(Base2)); +var b1 = new Base1(); +var d1 = new Derived1(); +var b2 = new Base2(); +var d2 = new Derived2(); +b1.implicit = b2.implicit; // error, 'this.y' not in C: { x } (c assignable to e) +b1.explicit = b2.implicit; // error, 'y' not in C: { x } (c assignable to e) +d1.explicit = b2.implicit; // error, 'y' not in C: { x } (c assignable to e) +////// use this-type for construction with new //// +function VoidThis() { +} +function ImplicitVoidThis() { +} +var voidThis = new VoidThis(); +var implicitVoidThis = new ImplicitVoidThis(); +///// parse errors ///// +function notFirst(a, this) { return this.n; } +function modifiers(, C) { + if ( === void 0) { = this; } + return this.n; +} +function restParam(, C) { return this.n; } +function optional(C) { return this.n; } +function decorated(, C) { + if ( === void 0) { = this; } + return this.n; +} +new C(); +number; +{ + return this.n; +} +// can't name parameters 'this' in a lambda. +c.explicitProperty = (this, m); +m + this.n; diff --git a/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts new file mode 100644 index 00000000000..34d1ebd4a8e --- /dev/null +++ b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts @@ -0,0 +1,34 @@ +interface I { + explicitThis(this: this, m: number): number; +} +interface Unused { + implicitNoThis(m: number): number; +} +class C implements I { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + implicitThis(m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return m + 1; + } +} +let c = new C(); +c.explicitVoid = c.explicitThis; // error, 'void' is missing everything +let o = { + explicitThis: function (m) { return m }, + implicitThis(m: number): number { return m } +}; +let i: I = o; +let x = i.explicitThis; +let n = x(12); // callee:void doesn't match this:I +let u: Unused; +let y = u.implicitNoThis; +n = y(12); // ok, callee:void matches this:any +c.explicitVoid = c.implicitThis // ok, implicitThis(this:any) +o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) +o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) +o.implicitThis = i.explicitThis; diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts new file mode 100644 index 00000000000..623c880d339 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts @@ -0,0 +1,209 @@ +// @strictThis: true +// body checking +class C { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + implicitThis(m: number): number { + return this.n + m; + } + explicitC(this: C, m: number): number { + return this.n + m; + } + explicitProperty(this: {n: number}, m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return m + 1; + } +} +class D extends C { } +class B { + n: number; +} +interface I { + a: number; + explicitVoid1(this: void): number; + explicitVoid2(this: void): number; + explicitStructural(this: {a: number}): number; + explicitInterface(this: I): number; + explicitThis(this: this): number; + implicitMethod(): number; + implicitFunction: () => number; +} +function explicitStructural(this: { y: number }, x: number): number { + return x + this.y; +} +function justThis(this: { y: number }): number { + return this.y; +} +function implicitThis(n: number): number { + return 12; +} +let impl: I = { + a: 12, + explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) + explicitVoid1() { return 12; }, + explicitStructural() { + return this.a; + }, + explicitInterface() { + return this.a; + }, + explicitThis() { + return this.a; + }, + implicitMethod() { + return this.a; + }, + implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) +} +impl.explicitVoid1 = function () { return 12; }; +impl.explicitVoid2 = () => 12; +impl.explicitStructural = function() { return this.a; }; +impl.explicitInterface = function() { return this.a; }; +impl.explicitStructural = () => 12; +impl.explicitInterface = () => 12; +impl.explicitThis = function () { return this.a; }; +impl.implicitMethod = function () { return this.a; }; +impl.implicitMethod = () => 12; +impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) +// parameter checking +let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; +let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; +ok.f(13); +implicitThis(12); +implicitAnyOk.f(12); + +let c = new C(); +let d = new D(); +let ripped = c.explicitC; +c.explicitC(12); +c.explicitProperty(12); +c.explicitThis(12); +c.implicitThis(12); +d.explicitC(12); +d.explicitProperty(12); +d.explicitThis(12); +d.implicitThis(12); +let reconstructed: { + n: number, + explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. + implicitThis(m: number): number, + explicitC(this: C, m: number): number, + explicitProperty: (this: {n : number}, m: number) => number, + explicitVoid(this: void, m: number): number, +} = { + n: 12, + explicitThis: c.explicitThis, + implicitThis: c.implicitThis, + explicitC: c.explicitC, + explicitProperty: c.explicitProperty, + explicitVoid: c.explicitVoid +}; +reconstructed.explicitProperty(11); +reconstructed.implicitThis(11); + +// assignment checking +let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any +let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; +let anyToSpecified: (this: { y: number }, x: number) => number = function(x: number): number { return x + 12; }; + +let unspecifiedLambda: (x: number) => number = x => x + 12; +let specifiedLambda: (this: void, x: number) => number = x => x + 12; +let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = unspecifiedLambda; +let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; + + +let explicitCFunction: (this: C, m: number) => number; +let explicitPropertyFunction: (this: {n: number}, m: number) => number; +c.explicitC = explicitCFunction; +c.explicitC = function(this: C, m: number) { return this.n + m }; +c.explicitProperty = explicitPropertyFunction; +c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m }; +c.explicitProperty = reconstructed.explicitProperty; + +// lambdas are assignable to anything +c.explicitC = m => m; +c.explicitThis = m => m; +c.explicitProperty = m => m; + +// this inside lambdas refer to outer scope +// the outer-scoped lambda at top-level is still just `any` +c.explicitC = m => m + this.n; +c.explicitThis = m => m + this.n; +c.explicitProperty = m => m + this.n; + +//NOTE: this=C here, I guess? +c.explicitThis = explicitCFunction; +c.explicitThis = function(this: C, m: number) { return this.n + m }; + +// this:any compatibility +c.explicitC = function(m: number) { return this.n + m }; +c.explicitProperty = function(m: number) { return this.n + m }; +c.explicitThis = function(m: number) { return this.n + m }; +c.implicitThis = function(m: number) { return this.n + m }; +c.implicitThis = reconstructed.implicitThis; + +c.explicitC = function(this: B, m: number) { return this.n + m }; + +// this:void compatibility +c.explicitVoid = n => n; + +// class-based assignability +class Base1 { + x: number; + public implicit(): number { return this.x; } + explicit(this: Base1): number { return this.x; } + static implicitStatic(): number { return this.y; } + static explicitStatic(this: typeof Base1): number { return this.y; } + static y: number; + +} +class Derived1 extends Base1 { + y: number +} +class Base2 { + y: number + implicit(): number { return this.y; } + explicit(this: Base1): number { return this.x; } +} +class Derived2 extends Base2 { + x: number +} +let b1 = new Base1(); +let b2 = new Base2(); +let d1 = new Derived1(); +let d2 = new Derived2(); +d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) +d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) + +// bivariance-allowed cases +d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) +d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) +b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) + +////// use this-type for construction with new //// +function InterfaceThis(this: I) { + this.a = 12; +} +function LiteralTypeThis(this: {x: string}) { + this.x = "ok"; +} +function AnyThis(this: any) { + this.x = "ok"; +} +let interfaceThis = new InterfaceThis(); +let literalTypeThis = new LiteralTypeThis(); +let anyThis = new AnyThis(); + +//// type parameter inference //// +declare var f: { + (this: void, x: number): number, + call(this: (...argArray: any[]) => U, ...argArray: any[]): U; +}; +let n: number = f.call(12); + +function missingTypeIsImplicitAny(this, a: number) { return a; } \ No newline at end of file diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts new file mode 100644 index 00000000000..3fba9ad8a73 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts @@ -0,0 +1,193 @@ +// @strictThis: true +class C { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + implicitThis(m: number): number { + return this.n + m; + } + explicitC(this: C, m: number): number { + return this.n + m; + } + explicitProperty(this: {n: number}, m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return this.n + m; // 'n' doesn't exist on type 'void'. + } +} +class D { + x: number; + explicitThis(this: this, m: number): number { + return this.x + m; + } + explicitD(this: D, m: number): number { + return this.x + m; + } + implicitD(m: number): number { + return this.x + m; + } +} +interface I { + a: number; + explicitVoid1(this: void): number; + explicitVoid2(this: void): number; + explicitStructural(this: {a: number}): number; + explicitInterface(this: I): number; + explicitThis(this: this): number; // TODO: Allow `this` types for interfaces + implicitMethod(): number; + implicitFunction: () => number; +} +let impl: I = { + a: 12, + explicitVoid1() { + return this.a; // error, no 'a' in 'void' + }, + explicitVoid2: () => this.a, // ok, `this:any` because it refers to an outer object + explicitStructural: () => 12, + explicitInterface: () => 12, + explicitThis() { + return this.a; + }, + implicitMethod() { + return this.a; // ok, I.a: number + }, + implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' +} +let implExplicitStructural = impl.explicitStructural; +implExplicitStructural(); // error, no 'a' in 'void' +let implExplicitInterface = impl.explicitInterface; +implExplicitInterface(); // error, no 'a' in 'void' +let implImplicitMethod = impl.implicitMethod; +implImplicitMethod(); // error, no 'a' in 'void' +function explicitStructural(this: { y: number }, x: number): number { + return x + this.y; +} +function propertyName(this: { y: number }, x: number): number { + return x + this.notFound; +} +function voidThisSpecified(this: void, x: number): number { + return x + this.notSpecified; +} +function noThisSpecified(x: number): number { + // this:void unless loose-this is on + return x + this.notSpecified; +} +let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, explicitStructural }; +let wrongPropertyType: {y: string, f: (this: { y: number }, x: number) => number} = { y: 'foo', explicitStructural }; +let wrongPropertyName: {wrongName: number, f: (this: { y: number }, x: number) => number} = { wrongName: 12, explicitStructural }; + +ok.f(); // not enough arguments +ok.f('wrong type'); +ok.f(13, 'too many arguments'); +wrongPropertyType.f(13); +wrongPropertyName.f(13); + +let c = new C(); +c.explicitC(); // not enough arguments +c.explicitC('wrong type'); +c.explicitC(13, 'too many arguments'); +c.explicitThis(); // not enough arguments +c.explicitThis('wrong type 2'); +c.explicitThis(14, 'too many arguments 2'); +c.implicitThis(); // not enough arguments +c.implicitThis('wrong type 2'); +c.implicitThis(14, 'too many arguments 2'); +c.explicitProperty(); // not enough arguments +c.explicitProperty('wrong type 3'); +c.explicitProperty(15, 'too many arguments 3'); + +// oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. +let specifiedToImplicitVoid: (x: number) => number = explicitStructural; + +let reconstructed: { + n: number, + explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. + implicitThis(m: number): number, + explicitC(this: C, m: number): number, + explicitProperty: (this: {n : number}, m: number) => number, + explicitVoid(this: void, m: number): number, +} = { + n: 12, + explicitThis: c.explicitThis, + implicitThis: c.implicitThis, // error not assignable -- c.this:c not assignable to this:void. + explicitC: c.explicitC, + explicitProperty: c.explicitProperty, + explicitVoid: c.explicitVoid +};; + +// lambdas have this: void for assignability purposes (and this unbound (free) for body checking) +let d = new D(); +let explicitXProperty: (this: { x: number }, m: number) => number; + +// from differing object types +c.explicitC = function(this: D, m: number) { return this.x + m }; +c.explicitProperty = explicitXProperty; + +c.explicitC = d.implicitD; +c.explicitC = d.explicitD; +c.explicitC = d.explicitThis; +c.explicitThis = d.implicitD; +c.explicitThis = d.explicitD; +c.explicitThis = d.explicitThis; +c.explicitProperty = d.explicitD; +c.explicitProperty = d.implicitD; +c.explicitThis = d.explicitThis; +c.explicitVoid = d.implicitD; +c.explicitVoid = d.explicitD; +c.explicitVoid = d.explicitThis; + +/// class-based implicit assignability (with inheritance!) /// + +class Base1 { + x: number + public implicit(): number { return this.x; } + explicit(this: Base1): number { return this.x; } + static implicitStatic(): number { return this.x; } + static explicitStatic(this: typeof Base1): number { return this.x; } +} +class Derived1 extends Base1 { + y: number +} +class Base2 { + y: number + implicit(): number { return this.y; } + explicit(this: Base1): number { return this.x; } +} +class Derived2 extends Base2 { + x: number +} + + +let b1 = new Base1(); +let d1 = new Derived1(); +let b2 = new Base2(); +let d2 = new Derived2(); + +b1.implicit = b2.implicit // error, 'this.y' not in C: { x } (c assignable to e) +b1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + +d1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + +////// use this-type for construction with new //// +function VoidThis(this: void) { + +} +function ImplicitVoidThis() { + +} +let voidThis = new VoidThis(); +let implicitVoidThis = new ImplicitVoidThis(); + + +///// parse errors ///// +function notFirst(a: number, this: C): number { return this.n; } +function modifiers(async this: C): number { return this.n; } +function restParam(...this: C): number { return this.n; } +function optional(this?: C): number { return this.n; } +function decorated(@deco() this: C): number { return this.n; } +function initializer(this: C = new C()): number { return this.n; } + +// can't name parameters 'this' in a lambda. +c.explicitProperty = (this, m) => m + this.n; diff --git a/tests/cases/fourslash/memberListOnExplicitThis.ts b/tests/cases/fourslash/memberListOnExplicitThis.ts new file mode 100644 index 00000000000..cf57717183c --- /dev/null +++ b/tests/cases/fourslash/memberListOnExplicitThis.ts @@ -0,0 +1,30 @@ +// @strictThis: true +/// + +////interface Restricted { +//// n: number; +////} +////class C1 implements Restricted { +//// n: number; +//// m: number; +//// f() {this./*1*/} // test on 'this.' +//// g(this: Restricted) {this./*2*/} +////} +////function f() {this./*3*/} +////function g(this: Restricted) {this./*4*/} + +goTo.marker('1'); +verify.memberListContains('f', '(method) C1.f(this: this): void'); +verify.memberListContains('g', '(method) C1.g(this: Restricted): void'); +verify.memberListContains('n', '(property) C1.n: number'); +verify.memberListContains('m', '(property) C1.m: number'); + +goTo.marker('2'); +verify.memberListContains('n', '(property) Restricted.n: number'); + +goTo.marker('3'); +verify.memberListIsEmpty(); + +goTo.marker('4'); +verify.memberListContains('n', '(property) Restricted.n: number'); + From a4f1154377bc62320ddb73d2ac448f3bc0089768 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:51:35 -0800 Subject: [PATCH 09/48] Fix free function bug in cachingInServerLSHost --- tests/cases/unittests/cachingInServerLSHost.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/cases/unittests/cachingInServerLSHost.ts b/tests/cases/unittests/cachingInServerLSHost.ts index 59f97f434e6..6d7b3fdbc28 100644 --- a/tests/cases/unittests/cachingInServerLSHost.ts +++ b/tests/cases/unittests/cachingInServerLSHost.ts @@ -123,7 +123,7 @@ module ts { } fileExistsIsCalled = true; assert.isTrue(fileName.indexOf('/f2.') !== -1); - return originalFileExists(fileName); + return originalFileExists.call(serverHost, fileName); }; let newContent = `import {x} from "f2"`; rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent); @@ -147,7 +147,7 @@ module ts { } fileExistsCalled = true; assert.isTrue(fileName.indexOf('/f1.') !== -1); - return originalFileExists(fileName); + return originalFileExists.call(serverHost, fileName); }; let newContent = `import {x} from "f1"`; @@ -192,7 +192,7 @@ module ts { fileExistsCalledForBar = fileName.indexOf("/bar.") !== -1; } - return originalFileExists(fileName); + return originalFileExists.call(serverHost, fileName); }; let { project, rootScriptInfo } = createProject(root.name, serverHost); From d030889166b56fe3e4a2fb080711807245422c98 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 29 Jan 2016 14:52:47 -0800 Subject: [PATCH 10/48] Update baselines 1. Display of `this` changes for quick info. 2. The type of Function.call/apply/bind is more precise. --- .../assignmentToObjectAndFunction.errors.txt | 4 +- ...ArrowFunctionCapturesArguments_es6.symbols | 4 +- ...ncArrowFunctionCapturesArguments_es6.types | 12 +-- ...nctionsInFunctionParameterDefaults.symbols | 4 +- ...functionsInFunctionParameterDefaults.types | 4 +- .../baselines/reference/functionType.symbols | 4 +- tests/baselines/reference/functionType.types | 6 +- .../genericTypeParameterEquivalence2.symbols | 4 +- .../genericTypeParameterEquivalence2.types | 6 +- ...llSignatureAppearsToBeFunctionType.symbols | 8 +- ...CallSignatureAppearsToBeFunctionType.types | 8 +- .../returnTypeParameterWithModules.symbols | 4 +- .../returnTypeParameterWithModules.types | 4 +- tests/cases/fourslash/commentsClassMembers.ts | 2 +- .../fourslash/instanceTypesForGenericType1.ts | 2 +- tests/cases/fourslash/quickInfoOnThis.ts | 77 +++++++++++++++++-- tests/cases/fourslash/thisBindingInLambda.ts | 2 +- 17 files changed, 108 insertions(+), 47 deletions(-) diff --git a/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt b/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt index 2e85ee101f5..454ac41b5b8 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 '(thisArg: any, argArray?: any) => any'. + 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; }'. ==== 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 '(thisArg: any, argArray?: any) => any'. \ No newline at end of file +!!! 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 diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols index 2f516d7d758..bc061211b88 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.d.ts, --, --)) +>other.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.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 76853858c5c..18a08ffface 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) : any ->other.apply(this, arguments) : any ->other.apply : (thisArg: any, argArray?: any) => any +>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; } >other : () => void ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >this : this >arguments : IArguments } diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols index ea0ed9a605c..b836bc88573 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, --, --)) +>fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >fn : Symbol(fn, Decl(fatarrowfunctionsInFunctionParameterDefaults.ts, 0, 0)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types index 55d72e854d3..58c576bf24e 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 : (thisArg: any, ...argArray: any[]) => any +>fn.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } >fn : (x?: () => any, y?: any) => any ->call : (thisArg: any, ...argArray: any[]) => any +>call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } >4 : number diff --git a/tests/baselines/reference/functionType.symbols b/tests/baselines/reference/functionType.symbols index 30a5a7cc447..65347d39b5a 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, --, --)) +>salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >salt : Symbol(salt, Decl(functionType.ts, 0, 0)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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 e7ea7a47edf..9183ec4a13e 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", []) : any ->salt.apply : (thisArg: any, argArray?: any) => any +>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 : () => void ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >"hello" : string >[] : undefined[] diff --git a/tests/baselines/reference/genericTypeParameterEquivalence2.symbols b/tests/baselines/reference/genericTypeParameterEquivalence2.symbols index cd558fdd10a..1aa22b1e994 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, --, --)) +>g.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >g : Symbol(g, Decl(genericTypeParameterEquivalence2.ts, 1, 41)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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 3b2c533543d..9fdb03b0fbe 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) : any ->g.apply : (thisArg: any, argArray?: any) => any +>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 : (a: A) => B ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >null : null >a : A diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols index 60b7b08397a..08d3d75e9dc 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, --, --)) +>i.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >i : Symbol(i, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 7, 3)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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, --, --)) +>b.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >b : Symbol(b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 11, 3)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types index 74d8ef57d67..496734c9183 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 : (thisArg: any, argArray?: any) => any +>i.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >i : I ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (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 : (thisArg: any, argArray?: any) => any +>b.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >b : () => void ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } diff --git a/tests/baselines/reference/returnTypeParameterWithModules.symbols b/tests/baselines/reference/returnTypeParameterWithModules.symbols index 7f8fab382a3..e3b7c50948f 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, --, --)) +>Array.prototype.reduce.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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 be09b8f46b0..ffb058daa08 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 : (thisArg: any, argArray?: any) => 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 : { (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 : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >ar : any >e ? [f, e] : [f] : any[] >e : any diff --git a/tests/cases/fourslash/commentsClassMembers.ts b/tests/cases/fourslash/commentsClassMembers.ts index 54b4f0253d4..d719253a57b 100644 --- a/tests/cases/fourslash/commentsClassMembers.ts +++ b/tests/cases/fourslash/commentsClassMembers.ts @@ -694,7 +694,7 @@ verify.completionListContains("a", "(parameter) a: number", "this is first param verify.quickInfoIs("(parameter) a: number", "this is first parameter a\nmore info about a"); goTo.marker('116'); -verify.quickInfoIs("class cWithConstructorProperty", ""); +verify.quickInfoIs("this: this", ""); goTo.marker('117'); verify.quickInfoIs("(local var) bbbb: number", ""); diff --git a/tests/cases/fourslash/instanceTypesForGenericType1.ts b/tests/cases/fourslash/instanceTypesForGenericType1.ts index 96ee175383e..a3d119785bf 100644 --- a/tests/cases/fourslash/instanceTypesForGenericType1.ts +++ b/tests/cases/fourslash/instanceTypesForGenericType1.ts @@ -11,4 +11,4 @@ goTo.marker('1'); verify.quickInfoIs('(property) G.self: G'); goTo.marker('2'); -verify.quickInfoIs('class G'); \ No newline at end of file +verify.quickInfoIs('this: this'); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoOnThis.ts b/tests/cases/fourslash/quickInfoOnThis.ts index c4eecfca5d5..cef78efe0cc 100644 --- a/tests/cases/fourslash/quickInfoOnThis.ts +++ b/tests/cases/fourslash/quickInfoOnThis.ts @@ -1,15 +1,76 @@ +// @strictThis: true /// - -////function someFn1(someFn: { (): void; }) { } +////interface Restricted { +//// n: number; +////} +////function wrapper(wrapped: { (): void; }) { } ////class Foo { -//// public bar() { -//// someFn1( -//// function doSomething() { -//// console.log(th/**/is); +//// n: number; +//// public implicitThis() { +//// wrapper( +//// function implicitVoid() { +//// console.log(th/*1*/is); //// } //// ) +//// console.log(th/*2*/is); +//// } +//// public explicitInterface(th/*3*/is: Restricted) { +//// console.log(th/*4*/is); +//// } +//// public explicitClass(th/*5*/is: Foo) { +//// console.log(th/*6*/is); //// } ////} +////class Bar { +//// public implicitThis() { +//// console.log(th/*7*/is); +//// } +//// public explicitThis(this: Bar) { +//// console.log(thi/*8*/s); +//// } +////} +//// +////function implicitVoid(x: number): void { +//// return th/*9*/is; +////} +////function explicitVoid(th/*10*/is: void, x: number): void { +//// return th/*11*/is; +////} +////function explicitInterface(th/*12*/is: Restricted): void { +//// console.log(thi/*13*/s); +////} +////function explicitLiteral(th/*14*/is: { n: number }): void { +//// console.log(th/*15*/is); +////} -goTo.marker(); -verify.quickInfoIs('any'); +goTo.marker('1'); +verify.quickInfoIs('void'); +goTo.marker('2'); +verify.quickInfoIs('this: this'); +goTo.marker('3'); +verify.quickInfoIs('(parameter) this: Restricted'); +goTo.marker('4'); +verify.quickInfoIs('this: Restricted'); +goTo.marker('5'); +verify.quickInfoIs('(parameter) this: Foo'); +goTo.marker('6'); +verify.quickInfoIs('this: Foo'); +goTo.marker('7'); +verify.quickInfoIs('this: this'); +goTo.marker('8'); +verify.quickInfoIs('this: Bar'); +goTo.marker('9'); +verify.quickInfoIs('void'); +goTo.marker('10'); +verify.quickInfoIs('(parameter) this: void'); +goTo.marker('11'); +verify.quickInfoIs('void'); +goTo.marker('12'); +verify.quickInfoIs('(parameter) this: Restricted'); +goTo.marker('13'); +verify.quickInfoIs('this: Restricted'); +goTo.marker('14'); + +verify.quickInfoIs('(parameter) this: {\n n: number;\n}'); +goTo.marker('15'); +verify.quickInfoIs('this: {\n n: number;\n}'); \ No newline at end of file diff --git a/tests/cases/fourslash/thisBindingInLambda.ts b/tests/cases/fourslash/thisBindingInLambda.ts index f6dfdbdec08..d9c43796bd8 100644 --- a/tests/cases/fourslash/thisBindingInLambda.ts +++ b/tests/cases/fourslash/thisBindingInLambda.ts @@ -9,4 +9,4 @@ ////} goTo.marker(); -verify.quickInfoIs('class Greeter'); +verify.quickInfoIs('this: this'); From 675e0816d40cbe1fcd269dc98fff5e8e19bbb9cd Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 2 Feb 2016 14:46:44 -0800 Subject: [PATCH 11/48] Make this-type of bind's return explicit --- src/lib/core.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index fe2fd6b79f6..5a94b21b0fb 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -232,7 +232,7 @@ interface Function { * @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[]): (...argArray: any[]) => U; + 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; From f6361cec665339077ee9df83f0fd887834c5c5a7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 2 Feb 2016 16:00:52 -0800 Subject: [PATCH 12/48] Undo strictThis-clean changes Also fix other lint. --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 19 ++++++----- src/compiler/program.ts | 3 +- src/compiler/sourcemap.ts | 8 ++--- src/compiler/sys.ts | 2 +- src/compiler/types.ts | 16 +++++----- src/compiler/utilities.ts | 20 ++++++------ src/harness/harness.ts | 30 ++++++++--------- src/harness/loggedIO.ts | 32 +++++++++---------- src/server/editorServices.ts | 2 +- src/server/node.d.ts | 4 +-- .../formatting/ruleOperationContext.ts | 4 +-- src/services/services.ts | 6 ++-- src/services/utilities.ts | 2 +- 14 files changed, 73 insertions(+), 77 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3940be5d698..bfa398f190d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4115,7 +4115,7 @@ namespace ts { else { parameters.push(paramSymbol); } - + if (param.type && param.type.kind === SyntaxKind.StringLiteralType) { hasStringLiterals = true; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ab8de44ec98..21536da36ff 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -818,26 +818,25 @@ namespace ts { getSignatureConstructor(): new (checker: TypeChecker) => Signature; } - // TODO: Add a 'this' parameter after I update the previous-version compiler function Symbol(flags: SymbolFlags, name: string) { - (this).flags = flags; - (this).name = name; - (this).declarations = undefined; + this.flags = flags; + this.name = name; + this.declarations = undefined; } function Type(checker: TypeChecker, flags: TypeFlags) { - (this).flags = flags; + this.flags = flags; } function Signature(checker: TypeChecker) { } function Node(kind: SyntaxKind, pos: number, end: number) { - (this).kind = kind; - (this).pos = pos; - (this).end = end; - (this).flags = NodeFlags.None; - (this).parent = undefined; + this.kind = kind; + this.pos = pos; + this.end = end; + this.flags = NodeFlags.None; + this.parent = undefined; } export let objectAllocator: ObjectAllocator = { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 88c77aa5759..803ae47b0fd 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -933,9 +933,8 @@ namespace ts { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false)); } - // TODO: needs to have this: Program function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult { - return runWithCancellationToken(() => emitWorker((this), sourceFile, writeFileCallback, cancellationToken)); + return runWithCancellationToken(() => emitWorker(this, sourceFile, writeFileCallback, cancellationToken)); } function isEmitBlocked(emitFileName: string): boolean { diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index fb61f8b78b8..8abf1432b0c 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -4,10 +4,10 @@ namespace ts { export interface SourceMapWriter { getSourceMapData(): SourceMapData; - setSourceFile: (sourceFile: SourceFile) => void; - emitPos: (pos: number) => void; - emitStart: (range: TextRange) => void; - emitEnd: (range: TextRange, stopOverridingSpan?: boolean) => void; + setSourceFile(sourceFile: SourceFile): void; + emitPos(pos: number): void; + emitStart(range: TextRange): void; + emitEnd(range: TextRange, stopOverridingSpan?: boolean): void; changeEmitSourcePos(): void; getText(): string; getSourceMappingURL(): string; diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 1a9da39bf9a..bf25d39aa43 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -63,7 +63,7 @@ namespace ts { useCaseSensitiveFileNames?: boolean; echo(s: string): void; quit(exitCode?: number): void; - fileExists: (path: string) => boolean; + fileExists(path: string): boolean; directoryExists(path: string): boolean; createDirectory(path: string): void; resolvePath(path: string): string; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9c2612d96b6..6e0ccc3bf66 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1593,8 +1593,8 @@ namespace ts { } export interface ScriptReferenceHost { - getCompilerOptions: () => CompilerOptions; - getSourceFile: (fileName: string) => SourceFile; + getCompilerOptions(): CompilerOptions; + getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } @@ -1625,7 +1625,7 @@ namespace ts { /** * Get a list of files in the program */ - getSourceFiles: () => SourceFile[]; + getSourceFiles(): SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then @@ -1650,7 +1650,7 @@ namespace ts { */ getTypeChecker(): TypeChecker; - /* @internal */ getCommonSourceDirectory: () => string; + /* @internal */ getCommonSourceDirectory(): string; // For testing purposes only. Should not be used by any other consumers (including the // language service). @@ -1905,11 +1905,11 @@ namespace ts { getReferencedImportDeclaration(node: Identifier): Declaration; getReferencedDeclarationWithCollidingName(node: Identifier): Declaration; isDeclarationWithCollidingName(node: Declaration): boolean; - isValueAliasDeclaration: (node: Node) => boolean; - isReferencedAliasDeclaration: (node: Node, checkChildren?: boolean) => boolean; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; - isDeclarationVisible: (node: Declaration) => boolean; + isDeclarationVisible(node: Declaration): boolean; collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; @@ -2430,7 +2430,7 @@ namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; - strictThis?: boolean, + strictThis?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index bce821c3756..bab66eb0688 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -32,11 +32,11 @@ namespace ts { } export interface EmitHost extends ScriptReferenceHost { - getSourceFiles: () => SourceFile[]; + getSourceFiles(): SourceFile[]; - getCommonSourceDirectory: () => string; - getCanonicalFileName: (fileName: string) => string; - getNewLine: () => string; + getCommonSourceDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; isEmitBlocked(emitFileName: string): boolean; @@ -1869,11 +1869,11 @@ namespace ts { } export interface EmitTextWriter { - write: (s: string) => void; - writeTextOfNode: (text: string, node: Node) => void; - writeLine: () => void; - increaseIndent: () => void; - decreaseIndent: () => void; + write(s: string): void; + writeTextOfNode(text: string, node: Node): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; getText(): string; rawWrite(s: string): void; writeLiteral(s: string): void; @@ -2490,7 +2490,7 @@ namespace ts { * as the fallback implementation does not check for circular references by default. */ export const stringify: (value: any) => string = typeof JSON !== "undefined" && JSON.stringify - ? JSON.stringify + ? JSON.stringify : stringifyFallback; /** diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 3b211a0d91a..2b0c95c0a61 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -417,24 +417,24 @@ namespace Harness.Path { namespace Harness { export interface IO { - args(): string[]; newLine(): string; - readFile(this: ts.System | IO, path: string): string; - writeFile(path: string, contents: string): void; - resolvePath(path: string): string; - fileExists: (fileName: string) => boolean; - directoryExists: (path: string) => boolean; - createDirectory(path: string): void; - getExecutingFilePath(this: ts.System | IO): string; getCurrentDirectory(): string; - readDirectory(path: string, extension?: string, exclude?: string[]): string[]; - getMemoryUsage?(): number; - exit(exitCode?: number): void; - deleteFile(fileName: string): void; - directoryName: (path: string) => string; - listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; - log: (text: string) => void; useCaseSensitiveFileNames(): boolean; + resolvePath(path: string): string; + readFile(path: string): string; + writeFile(path: string, contents: string): void; + directoryName(path: string): string; + createDirectory(path: string): void; + fileExists(fileName: string): boolean; + directoryExists(path: string): boolean; + deleteFile(fileName: string): void; + listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; + log(text: string): void; + getMemoryUsage?(): number; + args(): string[]; + getExecutingFilePath(): string; + exit(exitCode?: number): void; + readDirectory(path: string, extension?: string, exclude?: string[]): string[]; } export var IO: IO; diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index dbc05112f3e..cc5e06ab920 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -70,11 +70,11 @@ interface IOLog { interface PlaybackControl { startReplayFromFile(logFileName: string): void; - startReplayFromString(this: PlaybackControl, logContents: string): void; - startReplayFromData(this: PlaybackControl, log: IOLog): void; + startReplayFromString(logContents: string): void; + startReplayFromData(log: IOLog): void; endReplay(): void; startRecord(logFileName: string): void; - endRecord(this: PlaybackControl): void; + endRecord(): void; } namespace Playback { @@ -127,8 +127,6 @@ namespace Playback { function initWrapper(wrapper: PlaybackSystem, underlying: ts.System): void; function initWrapper(wrapper: PlaybackIO, underlying: Harness.IO): void; function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void { - // TODO: Define a common interface over ts.System | Harness.IO and stop passing a union type. - const underlyingShim: any = underlying; ts.forEach(Object.keys(underlying), prop => { (wrapper)[prop] = (underlying)[prop]; }); @@ -156,20 +154,20 @@ namespace Playback { }; wrapper.startReplayFromFile = logFn => { - wrapper.startReplayFromString(underlyingShim.readFile(logFn)); + wrapper.startReplayFromString(underlying.readFile(logFn)); }; wrapper.endRecord = () => { if (recordLog !== undefined) { let i = 0; const fn = () => recordLogFileNameBase + i + ".json"; - while (underlyingShim.fileExists(fn())) i++; - underlyingShim.writeFile(fn(), JSON.stringify(recordLog)); + while (underlying.fileExists(fn())) i++; + underlying.writeFile(fn(), JSON.stringify(recordLog)); recordLog = undefined; } }; wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)( - path => callAndRecord(underlyingShim.fileExists(path), recordLog.fileExists, { path }), + path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }), memoize(path => { // If we read from the file, it must exist if (findResultByPath(wrapper, replayLog.filesRead, path, null) !== null) { @@ -186,10 +184,10 @@ namespace Playback { return replayLog.executingPath; } else if (recordLog !== undefined) { - return recordLog.executingPath = underlyingShim.getExecutingFilePath(); + return recordLog.executingPath = underlying.getExecutingFilePath(); } else { - return underlyingShim.getExecutingFilePath(); + return underlying.getExecutingFilePath(); } }; @@ -198,20 +196,20 @@ namespace Playback { return replayLog.currentDirectory || ""; } else if (recordLog !== undefined) { - return recordLog.currentDirectory = underlyingShim.getCurrentDirectory(); + return recordLog.currentDirectory = underlying.getCurrentDirectory(); } else { - return underlyingShim.getCurrentDirectory(); + return underlying.getCurrentDirectory(); } }; wrapper.resolvePath = recordReplay(wrapper.resolvePath, underlying)( - path => callAndRecord(underlyingShim.resolvePath(path), recordLog.pathsResolved, { path }), + path => callAndRecord(underlying.resolvePath(path), recordLog.pathsResolved, { path }), memoize(path => findResultByFields(replayLog.pathsResolved, { path }, !ts.isRootedDiskPath(ts.normalizeSlashes(path)) && replayLog.currentDirectory ? replayLog.currentDirectory + "/" + path : ts.normalizeSlashes(path)))); wrapper.readFile = recordReplay(wrapper.readFile, underlying)( path => { - const result = underlyingShim.readFile(path); + const result = underlying.readFile(path); const logEntry = { path, codepage: 0, result: { contents: result, codepage: 0 } }; recordLog.filesRead.push(logEntry); return result; @@ -228,14 +226,14 @@ namespace Playback { (path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead.filter(d => d.extension === extension && ts.arrayIsEqualTo(d.exclude, exclude)), path)); wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( - (path: string, contents: string) => callAndRecord(underlyingShim.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), + (path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), (path: string, contents: string) => noOpReplay("writeFile")); wrapper.exit = (exitCode) => { if (recordLog !== undefined) { wrapper.endRecord(); } - underlyingShim.exit(exitCode); + underlying.exit(exitCode); }; } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 5516b18e0de..e2ec5cc159f 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1834,7 +1834,7 @@ namespace ts.server { if (!rangeEnd) { rangeEnd = this.root.charCount(); } - const walkFns: ILineIndexWalker = { + const walkFns = { goSubtree: true, done: false, leaf: function (relativeStart: number, relativeLength: number, ll: LineLeaf) { diff --git a/src/server/node.d.ts b/src/server/node.d.ts index 8e4d8c28e9b..0bde0bb6602 100644 --- a/src/server/node.d.ts +++ b/src/server/node.d.ts @@ -68,7 +68,7 @@ interface BufferConstructor { new (array: any[]): Buffer; prototype: Buffer; isBuffer(obj: any): boolean; - byteLength: (string: string, encoding?: string) => number; + byteLength(string: string, encoding?: string): number; concat(list: Buffer[], totalLength?: number): Buffer; } declare var Buffer: BufferConstructor; @@ -190,7 +190,7 @@ declare namespace NodeJS { nextTick(callback: Function): void; umask(mask?: number): number; uptime(): number; - hrtime: (time?: number[]) => number[]; + hrtime(time?: number[]): number[]; // Worker send? (message: any, sendHandle?: any): void; diff --git a/src/services/formatting/ruleOperationContext.ts b/src/services/formatting/ruleOperationContext.ts index 3108095e8e6..47330faa0dd 100644 --- a/src/services/formatting/ruleOperationContext.ts +++ b/src/services/formatting/ruleOperationContext.ts @@ -6,8 +6,8 @@ namespace ts.formatting { export class RuleOperationContext { private customContextChecks: { (context: FormattingContext): boolean; }[]; - constructor(...funcs: { (this: typeof Rules, context: FormattingContext): boolean; }[]) { - this.customContextChecks = <{ (this: any, context: FormattingContext): boolean }[]>funcs; + constructor(...funcs: { (context: FormattingContext): boolean; }[]) { + this.customContextChecks = funcs; } static Any: RuleOperationContext = new RuleOperationContext(); diff --git a/src/services/services.ts b/src/services/services.ts index 1a43f9a744b..496dd7172ea 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -19,15 +19,15 @@ namespace ts { getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; - getStart(this: Node, sourceFile?: SourceFile): number; + getStart(sourceFile?: SourceFile): number; getFullStart(): number; - getEnd(this: Node): number; + getEnd(): number; getWidth(sourceFile?: SourceFile): number; getFullWidth(): number; getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; getText(sourceFile?: SourceFile): string; - getFirstToken(this: Node, sourceFile?: SourceFile): Node; + getFirstToken(sourceFile?: SourceFile): Node; getLastToken(sourceFile?: SourceFile): Node; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 0363e45a64a..afdc85fffd8 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -769,7 +769,7 @@ namespace ts { * The default is CRLF. */ export function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost) { - return (host).getNewLine ? (host).getNewLine() : carriageReturnLineFeed; + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; } export function lineBreakPart() { From 0af56c0ee201209d997193160567a7547a766fd2 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 2 Feb 2016 16:27:01 -0800 Subject: [PATCH 13/48] Update error numbers in new tests after merge --- .../reference/thisTypeInFunctionsNegative.errors.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 49a4380977a..ce3b3eed6f8 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -91,8 +91,8 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,1): er tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'Base1' is not assignable to type 'Base2'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(179,16): error TS2671: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(180,24): error TS2671: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(179,16): error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(180,24): error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,30): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,26): error TS1003: Identifier expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,30): error TS1005: ',' expected. @@ -442,10 +442,10 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,35): e } let voidThis = new VoidThis(); ~~~~~~~~~~~~~~ -!!! error TS2671: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +!!! error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. let implicitVoidThis = new ImplicitVoidThis(); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2671: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +!!! error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. ///// parse errors ///// From 8c87da523bd927a5579f6286946339ccc6d52de5 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 4 Feb 2016 15:43:43 -0800 Subject: [PATCH 14/48] First round of review comments addressed. Only major thing is a bug fix in `isContextSensitiveFunctionLikeDeclaration`, and turning on context sensitivity to `this` even with `--strictThis` off. --- src/compiler/checker.ts | 66 ++++++++++--------- .../reference/contextualTyping24.errors.txt | 2 +- .../baselines/reference/contextualTyping24.js | 2 +- .../looseThisTypeInFunctions.errors.txt | 32 +++++++-- .../reference/looseThisTypeInFunctions.js | 31 ++++++++- .../reference/thisTypeInFunctions.js | 8 +-- .../reference/thisTypeInFunctions.symbols | 8 +-- .../reference/thisTypeInFunctions.types | 26 ++++---- .../thisTypeInFunctionsNegative.errors.txt | 6 +- tests/cases/compiler/contextualTyping24.ts | 2 +- .../thisType/looseThisTypeInFunctions.ts | 17 ++++- .../types/thisType/thisTypeInFuncTemp.ts | 27 ++++++++ .../types/thisType/thisTypeInFunctions.ts | 8 +-- 13 files changed, 162 insertions(+), 73 deletions(-) create mode 100644 tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9188cfff55d..2303aa539f6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -131,8 +131,8 @@ namespace ts { const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - const anySignature = createSignature(undefined, undefined, emptyArray, undefined, anyType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); - const unknownSignature = createSignature(undefined, undefined, emptyArray, undefined, unknownType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); @@ -3540,7 +3540,7 @@ namespace ts { resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], parameters: Symbol[], thisType: Type, + function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], thisType: Type, parameters: Symbol[], resolvedReturnType: Type, minArgumentCount: number, hasRestParameter: boolean, hasStringLiterals: boolean): Signature { const sig = new Signature(checker); sig.declaration = declaration; @@ -3555,7 +3555,7 @@ namespace ts { } function cloneSignature(sig: Signature): Signature { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.thisType, sig.resolvedReturnType, + return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } @@ -3567,7 +3567,7 @@ namespace ts { const baseConstructorType = getBaseConstructorTypeOfClass(classType); const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, undefined, classType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; } const baseTypeNode = getBaseTypeNodeOfClass(classType); const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); @@ -4098,6 +4098,7 @@ namespace ts { let hasStringLiterals = false; let minArgumentCount = -1; let thisType: Type = undefined; + let hasThisParameter: boolean; const isJSConstructSignature = isJSDocConstructSignature(declaration); let returnType: Type = undefined; @@ -4113,11 +4114,9 @@ namespace ts { const resolvedSymbol = resolveName(param, paramSymbol.name, SymbolFlags.Value, undefined, undefined); paramSymbol = resolvedSymbol; } - if (paramSymbol.name === "this") { - thisType = param.type && getTypeOfSymbol(paramSymbol); - if (i !== 0 || declaration.kind === SyntaxKind.Constructor) { - error(param, Diagnostics.this_cannot_be_referenced_in_current_location); - } + if (i == 0 && paramSymbol.name === "this") { + hasThisParameter = true; + thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType; } else { parameters.push(paramSymbol); @@ -4129,7 +4128,7 @@ namespace ts { if (param.initializer || param.questionToken || param.dotDotDotToken) { if (minArgumentCount < 0) { - minArgumentCount = i - (thisType ? 1 : 0); + minArgumentCount = i - (hasThisParameter ? 1 : 0); } } else { @@ -4139,19 +4138,19 @@ namespace ts { } if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length - (thisType ? 1 : 0); + minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); } - if (!thisType && compilerOptions.strictThis) { - if (declaration.kind === SyntaxKind.FunctionDeclaration - || declaration.kind === SyntaxKind.CallSignature - || declaration.kind == SyntaxKind.FunctionExpression - || declaration.kind === SyntaxKind.FunctionType) { + if (!hasThisParameter && compilerOptions.strictThis) { + if (declaration.kind === SyntaxKind.FunctionDeclaration || + declaration.kind === SyntaxKind.CallSignature || + declaration.kind == SyntaxKind.FunctionExpression || + declaration.kind === SyntaxKind.FunctionType) { thisType = voidType; } else if ((declaration.kind === SyntaxKind.MethodDeclaration || declaration.kind === SyntaxKind.MethodSignature) && (isClassLike(declaration.parent) || declaration.parent.kind === SyntaxKind.InterfaceDeclaration)) { thisType = declaration.flags & NodeFlags.Static ? - getWidenedType(checkExpression((declaration.parent).name)) : + getTypeOfSymbol(getSymbolOfNode(declaration.parent)) : getThisType(declaration.name); Debug.assert(!!thisType, "couldn't find implicit this type"); } @@ -4187,7 +4186,7 @@ namespace ts { } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, thisType, returnType, minArgumentCount, hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, minArgumentCount, hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -5105,8 +5104,8 @@ namespace ts { } } const result = createSignature(signature.declaration, freshTypeParameters, + signature.thisType && instantiateType(signature.thisType, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), - signature.thisType ? instantiateType(signature.thisType, mapper) : undefined, instantiateType(signature.resolvedReturnType, mapper), signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; @@ -5220,14 +5219,12 @@ namespace ts { } function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration) { - if (compilerOptions.strictThis) { - return !node.typeParameters && - (!forEach(node.parameters, p => p.type) - || (node.kind !== SyntaxKind.ArrowFunction && (!node.parameters.length || (node.parameters[0].name).text !== "this"))); - } - else { - return !node.typeParameters && node.parameters.length && !forEach(node.parameters, p => p.type); + const areAllParametersUntyped = !forEach(node.parameters, p => p.type); + if (node.kind === SyntaxKind.ArrowFunction) { + return !node.typeParameters && node.parameters.length && areAllParametersUntyped; } + const hasThisType = node.parameters.length && (node.parameters[0].name).text === "this" && node.parameters[0].type; + return !node.typeParameters && areAllParametersUntyped && !hasThisType; } function getTypeWithoutSignatures(type: Type): Type { @@ -5305,13 +5302,13 @@ namespace ts { let result = Ternary.True; if (source.thisType || target.thisType) { - const s = source.thisType || anyType; - const t = target.thisType || anyType; - if (s !== voidType) { + if (source.thisType !== voidType) { + const s = source.thisType ? getApparentType(source.thisType) : anyType; + const t = target.thisType ? getApparentType(target.thisType) : anyType; // void sources are assignable to anything. - let related = compareTypes(getApparentType(t), getApparentType(s), reportErrors); + let related = compareTypes(t, s, reportErrors); if (!related) { - related = compareTypes(getApparentType(s), getApparentType(t), /*reportErrors*/ false); + related = compareTypes(s, t, /*reportErrors*/ false); if (!related) { errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, "this", "this"); return Ternary.False; @@ -11626,6 +11623,11 @@ namespace ts { if (node.questionToken && isBindingPattern(node.name) && func.body) { error(node, Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } + if ((node.name).text === "this") { + if(indexOf(func.parameters, node) !== 0 || func.kind === SyntaxKind.Constructor) { + error(node, Diagnostics.this_cannot_be_referenced_in_current_location); + } + } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. diff --git a/tests/baselines/reference/contextualTyping24.errors.txt b/tests/baselines/reference/contextualTyping24.errors.txt index a172600e1c5..b4d0d534456 100644 --- a/tests/baselines/reference/contextualTyping24.errors.txt +++ b/tests/baselines/reference/contextualTyping24.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/contextualTyping24.ts(1,55): error TS2322: Type '(a: string ==== tests/cases/compiler/contextualTyping24.ts (1 errors) ==== - var foo:(a:{():number; (i:number):number; })=>number; foo = function(a:string){return 5}; + var foo:(a:{():number; (i:number):number; })=>number; foo = function(this: void, a:string){return 5}; ~~~ !!! error TS2322: Type '(a: string) => number' is not assignable to type '(a: { (): number; (i: number): number; }) => number'. !!! error TS2322: Types of parameters 'a' and 'a' are incompatible. diff --git a/tests/baselines/reference/contextualTyping24.js b/tests/baselines/reference/contextualTyping24.js index 04c4ecba21b..14c1feeb031 100644 --- a/tests/baselines/reference/contextualTyping24.js +++ b/tests/baselines/reference/contextualTyping24.js @@ -1,5 +1,5 @@ //// [contextualTyping24.ts] -var foo:(a:{():number; (i:number):number; })=>number; foo = function(a:string){return 5}; +var foo:(a:{():number; (i:number):number; })=>number; foo = function(this: void, a:string){return 5}; //// [contextualTyping24.js] var foo; diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index 058a1555ed6..317446050a8 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -1,11 +1,15 @@ -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(20,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(m: number) => number'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'C'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(27,9): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(32,5): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,27): error TS2339: Property 'length' does not exist on type 'number'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,19): error TS2339: Property 'length' does not exist on type 'number'. -==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (2 errors) ==== +==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (5 errors) ==== interface I { + n: number; explicitThis(this: this, m: number): number; } interface Unused { @@ -30,10 +34,23 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(27,9): error !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'C'. let o = { - explicitThis: function (m) { return m }, - implicitThis(m: number): number { return m } + n: 101, + explicitThis: function (m: number) { + return m + this.n.length; // ok, this.n: any + }, + implicitThis(m: number): number { return m; } }; let i: I = o; + let o2: I = { + n: 1001 + explicitThis: function (m) { + ~~~~~~~~~~~~ +!!! error TS1005: ',' expected. + return m + this.n.length; // error, this.n: number, no member 'length' + ~~~~~~ +!!! error TS2339: Property 'length' does not exist on type 'number'. + }, + } let x = i.explicitThis; let n = x(12); // callee:void doesn't match this:I ~~~~~ @@ -45,4 +62,9 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(27,9): error o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) o.implicitThis = i.explicitThis; + i.explicitThis = function(m) { + return this.n.length; // error, this.n: number + ~~~~~~ +!!! error TS2339: Property 'length' does not exist on type 'number'. + } \ No newline at end of file diff --git a/tests/baselines/reference/looseThisTypeInFunctions.js b/tests/baselines/reference/looseThisTypeInFunctions.js index 66677293c5b..ecb9f650716 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.js +++ b/tests/baselines/reference/looseThisTypeInFunctions.js @@ -1,5 +1,6 @@ //// [looseThisTypeInFunctions.ts] interface I { + n: number; explicitThis(this: this, m: number): number; } interface Unused { @@ -20,10 +21,19 @@ class C implements I { let c = new C(); c.explicitVoid = c.explicitThis; // error, 'void' is missing everything let o = { - explicitThis: function (m) { return m }, - implicitThis(m: number): number { return m } + n: 101, + explicitThis: function (m: number) { + return m + this.n.length; // ok, this.n: any + }, + implicitThis(m: number): number { return m; } }; let i: I = o; +let o2: I = { + n: 1001 + explicitThis: function (m) { + return m + this.n.length; // error, this.n: number, no member 'length' + }, +} let x = i.explicitThis; let n = x(12); // callee:void doesn't match this:I let u: Unused; @@ -33,6 +43,9 @@ c.explicitVoid = c.implicitThis // ok, implicitThis(this:any) o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) o.implicitThis = i.explicitThis; +i.explicitThis = function(m) { + return this.n.length; // error, this.n: number +} //// [looseThisTypeInFunctions.js] @@ -53,10 +66,19 @@ var C = (function () { var c = new C(); c.explicitVoid = c.explicitThis; // error, 'void' is missing everything var o = { - explicitThis: function (m) { return m; }, + n: 101, + explicitThis: function (m) { + return m + this.n.length; // ok, this.n: any + }, implicitThis: function (m) { return m; } }; var i = o; +var o2 = { + n: 1001, + explicitThis: function (m) { + return m + this.n.length; // error, this.n: number, no member 'length' + } +}; var x = i.explicitThis; var n = x(12); // callee:void doesn't match this:I var u; @@ -66,3 +88,6 @@ c.explicitVoid = c.implicitThis; // ok, implicitThis(this:any) o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) o.implicitThis = i.explicitThis; +i.explicitThis = function (m) { + return this.n.length; // error, this.n: number +}; diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index 0798843fc44..f3ad84acb55 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -140,10 +140,10 @@ c.explicitThis = explicitCFunction; c.explicitThis = function(this: C, m: number) { return this.n + m }; // this:any compatibility -c.explicitC = function(m: number) { return this.n + m }; -c.explicitProperty = function(m: number) { return this.n + m }; -c.explicitThis = function(m: number) { return this.n + m }; -c.implicitThis = function(m: number) { return this.n + m }; +c.explicitC = function(m) { return this.n + m }; +c.explicitProperty = function(m) { return this.n + m }; +c.explicitThis = function(m) { return this.n + m }; +c.implicitThis = function(m) { return this.n + m }; c.implicitThis = reconstructed.implicitThis; c.explicitC = function(this: B, m: number) { return this.n + m }; diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 1d9ebbd0cf4..bb6a9acfdd0 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -585,7 +585,7 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; >m : Symbol(m, Decl(thisTypeInFunctions.ts, 138, 34)) // this:any compatibility -c.explicitC = function(m: number) { return this.n + m }; +c.explicitC = function(m) { return this.n + m }; >c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) >explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) @@ -595,7 +595,7 @@ c.explicitC = function(m: number) { return this.n + m }; >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 141, 23)) -c.explicitProperty = function(m: number) { return this.n + m }; +c.explicitProperty = function(m) { return this.n + m }; >c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) >explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) @@ -605,7 +605,7 @@ c.explicitProperty = function(m: number) { return this.n + m }; >n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 142, 30)) -c.explicitThis = function(m: number) { return this.n + m }; +c.explicitThis = function(m) { return this.n + m }; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) @@ -615,7 +615,7 @@ c.explicitThis = function(m: number) { return this.n + m }; >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 143, 26)) -c.implicitThis = function(m: number) { return this.n + m }; +c.implicitThis = function(m) { return this.n + m }; >c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) >implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 36b458b91e0..b0fc9fc3300 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -520,7 +520,7 @@ let anyToSpecified: (this: { y: number }, x: number) => number = function(x: num >this : { y: number; } >y : number >x : number ->function(x: number): number { return x + 12; } : (this: { y: number; }, x: number) => number +>function(x: number): number { return x + 12; } : (x: number) => number >x : number >x + 12 : number >x : number @@ -718,12 +718,12 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; >m : number // this:any compatibility -c.explicitC = function(m: number) { return this.n + m }; ->c.explicitC = function(m: number) { return this.n + m } : (this: C, m: number) => number +c.explicitC = function(m) { return this.n + m }; +>c.explicitC = function(m) { return this.n + m } : (this: C, m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->function(m: number) { return this.n + m } : (this: C, m: number) => number +>function(m) { return this.n + m } : (this: C, m: number) => number >m : number >this.n + m : number >this.n : number @@ -731,12 +731,12 @@ c.explicitC = function(m: number) { return this.n + m }; >n : number >m : number -c.explicitProperty = function(m: number) { return this.n + m }; ->c.explicitProperty = function(m: number) { return this.n + m } : (this: { n: number; }, m: number) => number +c.explicitProperty = function(m) { return this.n + m }; +>c.explicitProperty = function(m) { return this.n + m } : (this: { n: number; }, m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->function(m: number) { return this.n + m } : (this: { n: number; }, m: number) => number +>function(m) { return this.n + m } : (this: { n: number; }, m: number) => number >m : number >this.n + m : number >this.n : number @@ -744,12 +744,12 @@ c.explicitProperty = function(m: number) { return this.n + m }; >n : number >m : number -c.explicitThis = function(m: number) { return this.n + m }; ->c.explicitThis = function(m: number) { return this.n + m } : (this: C, m: number) => number +c.explicitThis = function(m) { return this.n + m }; +>c.explicitThis = function(m) { return this.n + m } : (this: C, m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->function(m: number) { return this.n + m } : (this: C, m: number) => number +>function(m) { return this.n + m } : (this: C, m: number) => number >m : number >this.n + m : number >this.n : number @@ -757,12 +757,12 @@ c.explicitThis = function(m: number) { return this.n + m }; >n : number >m : number -c.implicitThis = function(m: number) { return this.n + m }; ->c.implicitThis = function(m: number) { return this.n + m } : (this: C, m: number) => number +c.implicitThis = function(m) { return this.n + m }; +>c.implicitThis = function(m) { return this.n + m } : (this: C, m: number) => number >c.implicitThis : (this: C, m: number) => number >c : C >implicitThis : (this: C, m: number) => number ->function(m: number) { return this.n + m } : (this: C, m: number) => number +>function(m) { return this.n + m } : (this: C, m: number) => number >m : number >this.n + m : number >this.n : number diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index ce3b3eed6f8..4e8efd187eb 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -94,6 +94,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,1): er tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(179,16): error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(180,24): error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,30): error TS2332: 'this' cannot be referenced in current location. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,61): error TS2339: Property 'n' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,26): error TS1003: Identifier expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,30): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,57): error TS2339: Property 'n' does not exist on type 'void'. @@ -103,7 +104,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,27): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,54): error TS2339: Property 'n' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,23): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,24): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,51): error TS2339: Property 'n' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(188,28): error TS1003: Identifier expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(188,32): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(188,59): error TS2339: Property 'n' does not exist on type 'void'. @@ -452,6 +452,8 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,35): e function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ !!! error TS2332: 'this' cannot be referenced in current location. + ~ +!!! error TS2339: Property 'n' does not exist on type 'void'. function modifiers(async this: C): number { return this.n; } ~~~~ !!! error TS1003: Identifier expected. @@ -473,8 +475,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,35): e !!! error TS1005: ',' expected. ~ !!! error TS1138: Parameter declaration expected. - ~ -!!! error TS2339: Property 'n' does not exist on type 'void'. function decorated(@deco() this: C): number { return this.n; } ~~~~ !!! error TS1003: Identifier expected. diff --git a/tests/cases/compiler/contextualTyping24.ts b/tests/cases/compiler/contextualTyping24.ts index be28ff3b04c..fad23fa313c 100644 --- a/tests/cases/compiler/contextualTyping24.ts +++ b/tests/cases/compiler/contextualTyping24.ts @@ -1 +1 @@ -var foo:(a:{():number; (i:number):number; })=>number; foo = function(a:string){return 5}; \ No newline at end of file +var foo:(a:{():number; (i:number):number; })=>number; foo = function(this: void, a:string){return 5}; \ No newline at end of file diff --git a/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts index 34d1ebd4a8e..3e8bdb11170 100644 --- a/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts @@ -1,4 +1,5 @@ interface I { + n: number; explicitThis(this: this, m: number): number; } interface Unused { @@ -19,10 +20,19 @@ class C implements I { let c = new C(); c.explicitVoid = c.explicitThis; // error, 'void' is missing everything let o = { - explicitThis: function (m) { return m }, - implicitThis(m: number): number { return m } + n: 101, + explicitThis: function (m: number) { + return m + this.n.length; // ok, this.n: any + }, + implicitThis(m: number): number { return m; } }; let i: I = o; +let o2: I = { + n: 1001 + explicitThis: function (m) { + return m + this.n.length; // error, this.n: number, no member 'length' + }, +} let x = i.explicitThis; let n = x(12); // callee:void doesn't match this:I let u: Unused; @@ -32,3 +42,6 @@ c.explicitVoid = c.implicitThis // ok, implicitThis(this:any) o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) o.implicitThis = i.explicitThis; +i.explicitThis = function(m) { + return this.n.length; // error, this.n: number +} diff --git a/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts b/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts new file mode 100644 index 00000000000..2f4873031fb --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts @@ -0,0 +1,27 @@ +// @strictThis: true +// 1. contextual typing predicate is wrong (currently: method2: function () ...) +// () -> yes (allParametersAreUntyped=t, noThisParameter=t, noTypeParameters=t) +// ok .. fixed? +// 2. contextual typing of this doesn't seem to work +// strictThis was turned off. DUH. +// 3. when it DID work, it was giving bogus types with strictThis OFF (see the last example) +interface T { + (x: number): void; +} +interface I { + n: number + method(this: this): number; + method2(this: this): number; +} +let i: I = { + n: 12, + method: function(this) { // this: I + return this.n.length; // error, 'number' has no property 'length' + }, + method2: function() { // this: I + return this.n.length; // error, 'number' has no property 'length' + } +} +i.method = function () { return this.n.length } // this: I +i.method = function (this) { return this.n.length } // this: I +var t: T = function (this, y) { } // yes! (but this: any NOT number!!) \ No newline at end of file diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts index 623c880d339..f92b8ab4e15 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts @@ -140,10 +140,10 @@ c.explicitThis = explicitCFunction; c.explicitThis = function(this: C, m: number) { return this.n + m }; // this:any compatibility -c.explicitC = function(m: number) { return this.n + m }; -c.explicitProperty = function(m: number) { return this.n + m }; -c.explicitThis = function(m: number) { return this.n + m }; -c.implicitThis = function(m: number) { return this.n + m }; +c.explicitC = function(m) { return this.n + m }; +c.explicitProperty = function(m) { return this.n + m }; +c.explicitThis = function(m) { return this.n + m }; +c.implicitThis = function(m) { return this.n + m }; c.implicitThis = reconstructed.implicitThis; c.explicitC = function(this: B, m: number) { return this.n + m }; From 2f74da112db6491d53321dc947660fb7c3f8e5d3 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 4 Feb 2016 16:01:10 -0800 Subject: [PATCH 15/48] Add specific error messages for out-of-place this Also remove lint in checker. --- src/compiler/checker.ts | 7 +- src/compiler/diagnosticMessages.json | 8 +++ .../thisTypeInFunctionsNegative.errors.txt | 64 +++++++++++-------- .../reference/thisTypeInFunctionsNegative.js | 16 ++++- .../thisType/thisTypeInFunctionsNegative.ts | 7 +- 5 files changed, 69 insertions(+), 33 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2303aa539f6..4508b25383f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11624,8 +11624,11 @@ namespace ts { error(node, Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } if ((node.name).text === "this") { - if(indexOf(func.parameters, node) !== 0 || func.kind === SyntaxKind.Constructor) { - error(node, Diagnostics.this_cannot_be_referenced_in_current_location); + if (indexOf(func.parameters, node) !== 0) { + error(node, Diagnostics.this_parameter_must_be_the_first_parameter); + } + if (func.kind === SyntaxKind.Constructor) { + error(node, Diagnostics.A_constructor_cannot_have_a_this_parameter); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 804b820f11e..116270d0c4d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1827,6 +1827,14 @@ "category": "Error", "code": 2672 }, + "'this' parameter must be the first parameter.": { + "category": "Error", + "code": 2673 + }, + "A constructor cannot have a 'this' parameter.": { + "category": "Error", + "code": 2674 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 4e8efd187eb..0b755b9e0bd 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -93,33 +93,34 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,1): er Type 'Base1' is not assignable to type 'Base2'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(179,16): error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(180,24): error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,30): error TS2332: 'this' cannot be referenced in current location. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,61): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,26): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(185,57): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,20): error TS2370: A rest parameter must be of an array type. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,23): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,27): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(186,54): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,23): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,24): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(188,28): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(188,32): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(188,59): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,32): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,39): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,40): error TS1128: Declaration or statement expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,42): error TS2304: Cannot find name 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(189,49): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,1): error TS7027: Unreachable code detected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,29): error TS2304: Cannot find name 'm'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,32): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,35): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,17): error TS2674: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,30): error TS2673: 'this' parameter must be the first parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,61): error TS2339: Property 'n' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,26): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,57): error TS2339: Property 'n' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,20): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,23): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,27): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,54): error TS2339: Property 'n' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,23): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,24): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(193,28): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(193,32): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(193,59): error TS2339: Property 'n' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,32): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,39): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,40): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,42): error TS2304: Cannot find name 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,49): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,1): error TS7027: Unreachable code detected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,29): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,32): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): error TS2304: Cannot find name 'm'. -==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (75 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (76 errors) ==== class C { n: number; explicitThis(this: this, m: number): number { @@ -447,13 +448,20 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,35): e ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. - - ///// parse errors ///// + ///// syntax-ish errors ///// + class ThisConstructor { + constructor(this: ThisConstructor, private n: number) { + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2674: A constructor cannot have a 'this' parameter. + } + } function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ -!!! error TS2332: 'this' cannot be referenced in current location. +!!! error TS2673: 'this' parameter must be the first parameter. ~ !!! error TS2339: Property 'n' does not exist on type 'void'. + + ///// parse errors ///// function modifiers(async this: C): number { return this.n; } ~~~~ !!! error TS1003: Identifier expected. diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index 43d83daef0d..c0892d9e4c8 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -180,9 +180,14 @@ function ImplicitVoidThis() { let voidThis = new VoidThis(); let implicitVoidThis = new ImplicitVoidThis(); +///// syntax-ish errors ///// +class ThisConstructor { + constructor(this: ThisConstructor, private n: number) { + } +} +function notFirst(a: number, this: C): number { return this.n; } ///// parse errors ///// -function notFirst(a: number, this: C): number { return this.n; } function modifiers(async this: C): number { return this.n; } function restParam(...this: C): number { return this.n; } function optional(this?: C): number { return this.n; } @@ -364,8 +369,15 @@ function ImplicitVoidThis() { } var voidThis = new VoidThis(); var implicitVoidThis = new ImplicitVoidThis(); -///// parse errors ///// +///// syntax-ish errors ///// +var ThisConstructor = (function () { + function ThisConstructor(n) { + this.n = n; + } + return ThisConstructor; +}()); function notFirst(a, this) { return this.n; } +///// parse errors ///// function modifiers(, C) { if ( === void 0) { = this; } return this.n; diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts index 3fba9ad8a73..3afc5a5c69b 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts @@ -180,9 +180,14 @@ function ImplicitVoidThis() { let voidThis = new VoidThis(); let implicitVoidThis = new ImplicitVoidThis(); +///// syntax-ish errors ///// +class ThisConstructor { + constructor(this: ThisConstructor, private n: number) { + } +} +function notFirst(a: number, this: C): number { return this.n; } ///// parse errors ///// -function notFirst(a: number, this: C): number { return this.n; } function modifiers(async this: C): number { return this.n; } function restParam(...this: C): number { return this.n; } function optional(this?: C): number { return this.n; } From 71488fc3b1b75202efceb9b93ad84e571cad07cf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 5 Feb 2016 09:38:17 -0800 Subject: [PATCH 16/48] Refactorings from review comments 1. Add `getThisArgumentOfCall` (and correct the code) 2. Remove `getParameterTypeAtIndex` in favour of `getTypeAtPosition`. Simplify calling code. --- src/compiler/checker.ts | 61 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4508b25383f..f595a588dd7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3559,10 +3559,6 @@ namespace ts { sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } - function getParameterTypeAtIndex(signature: Signature, i: number, max: number, outOfRangeType?: Type): Type { - return i < max ? getTypeOfSymbol(signature.parameters[i]) : (outOfRangeType || getRestTypeOfSignature(signature)); - } - function getDefaultConstructSignatures(classType: InterfaceType): Signature[] { const baseConstructorType = getBaseConstructorTypeOfClass(classType); const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct); @@ -5301,14 +5297,12 @@ namespace ts { target = getErasedSignature(target); let result = Ternary.True; - if (source.thisType || target.thisType) { + if (source.thisType && target.thisType) { if (source.thisType !== voidType) { - const s = source.thisType ? getApparentType(source.thisType) : anyType; - const t = target.thisType ? getApparentType(target.thisType) : anyType; // void sources are assignable to anything. - let related = compareTypes(t, s, reportErrors); + let related = compareTypes(target.thisType, source.thisType, reportErrors); if (!related) { - related = compareTypes(s, t, /*reportErrors*/ false); + related = compareTypes(source.thisType, target.thisType, /*reportErrors*/ false); if (!related) { errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, "this", "this"); return Ternary.False; @@ -6474,27 +6468,23 @@ namespace ts { } function forEachMatchingParameterType(source: Signature, target: Signature, callback: (s: Type, t: Type) => void) { - let sourceMax = source.parameters.length; - let targetMax = target.parameters.length; + const sourceMax = source.parameters.length; + const targetMax = target.parameters.length; let count: number; if (source.hasRestParameter && target.hasRestParameter) { - count = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; + count = Math.max(sourceMax, targetMax); } else if (source.hasRestParameter) { - sourceMax--; count = targetMax; } else if (target.hasRestParameter) { - targetMax--; count = sourceMax; } else { - count = sourceMax < targetMax ? sourceMax : targetMax; + count = Math.min(sourceMax, targetMax); } for (let i = 0; i < count; i++) { - callback(getParameterTypeAtIndex(source, i, sourceMax), getParameterTypeAtIndex(target, i, targetMax)); + callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } @@ -9416,7 +9406,7 @@ namespace ts { context.failedTypeParameterIndex = undefined; } - const calleeNode = node.kind === SyntaxKind.CallExpression && ((node).expression).expression; + const calleeNode = getThisArgumentOfCall(node); if (signature.thisType) { const mapper = excludeCallee !== undefined ? identityMapper : inferenceMapper; const calleeType: Type = calleeNode ? checkExpressionWithContextualType(calleeNode, signature.thisType, mapper) : voidType; @@ -9503,13 +9493,13 @@ namespace ts { function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map, excludeArgument: boolean[], reportErrors: boolean) { const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; if (signature.thisType && signature.thisType !== voidType && node.kind !== SyntaxKind.NewExpression) { - // If the source is not of the form `x.f`, then sourceType = voidType - // If the target is voidType, then the check is skipped -- anything is compatible. - // If the the expression is a new expression, then the check is skipped. - const calleeNode = node.kind === SyntaxKind.CallExpression && ((node).expression).expression; - const calleeType: Type = calleeNode ? checkExpressionWithContextualType(calleeNode, signature.thisType, undefined) : voidType; + // If the source's this is not of the form `x.f` or `x[f]`, then sourceType = voidType + // If the target's this is voidType, then the check is skipped -- anything is compatible. + // If the expression is a new expression, then the check is skipped. + const calleeNode = getThisArgumentOfCall(node); + const calleeType = calleeNode ? checkExpression(calleeNode) : voidType; const errorNode = reportErrors ? (calleeNode || node) : undefined; - if (!checkTypeRelatedTo(calleeType, getApparentType(signature.thisType), relation, errorNode, headMessage)) { + if (!checkTypeRelatedTo(calleeType, signature.thisType, relation, errorNode, headMessage)) { return false; } } @@ -9541,6 +9531,21 @@ namespace ts { return true; } + /** + * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. + */ + function getThisArgumentOfCall(node: CallLikeExpression): LeftHandSideExpression { + if (node.kind === SyntaxKind.CallExpression) { + const callee = (node).expression; + if (callee.kind === SyntaxKind.PropertyAccessExpression) { + return (callee as PropertyAccessExpression).expression; + } + else if (callee.kind === SyntaxKind.ElementAccessExpression) { + return (callee as ElementAccessExpression).expression; + } + } + } + /** * Returns the effective arguments for an expression that works like a function invocation. * @@ -9888,7 +9893,7 @@ namespace ts { let excludeCallee: boolean; let excludeArgument: boolean[]; if (!isDecorator) { - const calleeNode = node.kind === SyntaxKind.CallExpression && ((node).expression).expression; + const calleeNode = getThisArgumentOfCall(node); if (calleeNode && isContextSensitive(calleeNode)) { excludeCallee = true; } @@ -10397,8 +10402,8 @@ namespace ts { function getTypeAtPosition(signature: Signature, pos: number): Type { return signature.hasRestParameter ? - getParameterTypeAtIndex(signature, pos, signature.parameters.length - 1) : - getParameterTypeAtIndex(signature, pos, signature.parameters.length, anyType); + pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : + pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; } function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { From 5821b87eda234e51f8822a6783f2f1864863b2a8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 5 Feb 2016 13:53:33 -0800 Subject: [PATCH 17/48] Do not contextually type object callee arguments --- src/compiler/checker.ts | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f595a588dd7..32e82d9d537 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9380,7 +9380,7 @@ namespace ts { return getSignatureInstantiation(signature, getInferredTypes(context)); } - function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: Expression[], excludeCallee: boolean, excludeArgument: boolean[], context: InferenceContext): void { + function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: Expression[], excludeArgument: boolean[], context: InferenceContext): void { const typeParameters = signature.typeParameters; const inferenceMapper = getInferenceMapper(context); @@ -9406,11 +9406,10 @@ namespace ts { context.failedTypeParameterIndex = undefined; } - const calleeNode = getThisArgumentOfCall(node); if (signature.thisType) { - const mapper = excludeCallee !== undefined ? identityMapper : inferenceMapper; - const calleeType: Type = calleeNode ? checkExpressionWithContextualType(calleeNode, signature.thisType, mapper) : voidType; - inferTypes(context, calleeType, signature.thisType); + const thisArgumentNode = getThisArgumentOfCall(node); + const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + inferTypes(context, thisArgumentType, signature.thisType); } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use @@ -9442,11 +9441,6 @@ namespace ts { // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed. // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. if (excludeArgument) { - if (signature.thisType && calleeNode) { - if (excludeCallee === false) { - inferTypes(context, checkExpressionWithContextualType(calleeNode, signature.thisType, inferenceMapper), signature.thisType); - } - } for (let i = 0; i < argCount; i++) { // No need to check for omitted args and template expressions, their exclusion value is always undefined if (excludeArgument[i] === false) { @@ -9496,10 +9490,10 @@ namespace ts { // If the source's this is not of the form `x.f` or `x[f]`, then sourceType = voidType // If the target's this is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. - const calleeNode = getThisArgumentOfCall(node); - const calleeType = calleeNode ? checkExpression(calleeNode) : voidType; - const errorNode = reportErrors ? (calleeNode || node) : undefined; - if (!checkTypeRelatedTo(calleeType, signature.thisType, relation, errorNode, headMessage)) { + const thisArgumentNode = getThisArgumentOfCall(node); + const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + const errorNode = reportErrors ? (thisArgumentNode || node) : undefined; + if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage)) { return false; } } @@ -9890,13 +9884,8 @@ namespace ts { // // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. - let excludeCallee: boolean; let excludeArgument: boolean[]; if (!isDecorator) { - const calleeNode = getThisArgumentOfCall(node); - if (calleeNode && isContextSensitive(calleeNode)) { - excludeCallee = true; - } // We do not need to call `getEffectiveArgumentCount` here as it only // applies when calculating the number of arguments for a decorator. for (let i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { @@ -10045,7 +10034,7 @@ namespace ts { typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { - inferTypeArguments(node, candidate, args, excludeCallee, excludeArgument, inferenceContext); + inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined; typeArgumentTypes = inferenceContext.inferredTypes; } From 80de700be03700f483d1852a130f490a266e66b4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 5 Feb 2016 16:18:21 -0800 Subject: [PATCH 18/48] Get contextual type of this parameter correctly Now the language service also sees the contextual type. Note that with this change, the type display for contextually typed this parameters goes away because there is no symbol. I'll fix type display next. --- src/compiler/checker.ts | 23 +++++++--- .../reference/thisTypeInFunctions.types | 42 +++++++++---------- tests/cases/fourslash/quickInfoOnThis.ts | 16 ++++++- 3 files changed, 53 insertions(+), 28 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 32e82d9d537..be98dc985b5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7383,6 +7383,10 @@ namespace ts { captureLexicalThis(node, container); } if (isFunctionLike(container)) { + const type = getContextuallyTypedThisType(container); + if (type) { + return type; + } const signature = getSignatureFromDeclaration(container); if (signature.thisType) { return signature.thisType; @@ -7633,6 +7637,19 @@ namespace ts { } } + function getContextuallyTypedThisType(func: FunctionLikeDeclaration): Type { + if ((isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) && + isContextSensitive(func) && + func.kind !== SyntaxKind.ArrowFunction) { + const contextualSignature = getContextualSignature(func); + if (contextualSignature) { + return contextualSignature.thisType; + } + } + + return undefined; + } + // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter: ParameterDeclaration): Type { const func = parameter.parent; @@ -10396,12 +10413,6 @@ namespace ts { } function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { - if (context.thisType) { - if (signature.declaration.kind !== SyntaxKind.ArrowFunction) { - // do not contextually type thisType for ArrowFunction. - signature.thisType = context.thisType; - } - } const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (let i = 0; i < len; i++) { const parameter = signature.parameters[i]; diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index b0fc9fc3300..e1044bb3d90 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -143,7 +143,7 @@ function implicitThis(n: number): number { let impl: I = { >impl : I >I : I ->{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; }, implicitMethod() { return this.a; }, implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?)} : { a: number; explicitVoid2: () => any; explicitVoid1(): number; explicitStructural(this: { a: number; }): number; explicitInterface(this: I): number; explicitThis(this: I): number; implicitMethod(this: I): number; implicitFunction: () => any; } +>{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; }, implicitMethod() { return this.a; }, implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?)} : { a: number; explicitVoid2: () => any; explicitVoid1(): number; explicitStructural(): number; explicitInterface(): number; explicitThis(): number; implicitMethod(): number; implicitFunction: () => any; } a: 12, >a : number @@ -161,7 +161,7 @@ let impl: I = { >12 : number explicitStructural() { ->explicitStructural : (this: { a: number; }) => number +>explicitStructural : () => number return this.a; >this.a : number @@ -170,7 +170,7 @@ let impl: I = { }, explicitInterface() { ->explicitInterface : (this: I) => number +>explicitInterface : () => number return this.a; >this.a : number @@ -179,7 +179,7 @@ let impl: I = { }, explicitThis() { ->explicitThis : (this: I) => number +>explicitThis : () => number return this.a; >this.a : number @@ -188,7 +188,7 @@ let impl: I = { }, implicitMethod() { ->implicitMethod : (this: I) => number +>implicitMethod : () => number return this.a; >this.a : number @@ -220,21 +220,21 @@ impl.explicitVoid2 = () => 12; >12 : number impl.explicitStructural = function() { return this.a; }; ->impl.explicitStructural = function() { return this.a; } : (this: { a: number; }) => number +>impl.explicitStructural = function() { return this.a; } : () => number >impl.explicitStructural : (this: { a: number; }) => number >impl : I >explicitStructural : (this: { a: number; }) => number ->function() { return this.a; } : (this: { a: number; }) => number +>function() { return this.a; } : () => number >this.a : number >this : { a: number; } >a : number impl.explicitInterface = function() { return this.a; }; ->impl.explicitInterface = function() { return this.a; } : (this: I) => number +>impl.explicitInterface = function() { return this.a; } : () => number >impl.explicitInterface : (this: I) => number >impl : I >explicitInterface : (this: I) => number ->function() { return this.a; } : (this: I) => number +>function() { return this.a; } : () => number >this.a : number >this : I >a : number @@ -256,21 +256,21 @@ impl.explicitInterface = () => 12; >12 : number impl.explicitThis = function () { return this.a; }; ->impl.explicitThis = function () { return this.a; } : (this: I) => number +>impl.explicitThis = function () { return this.a; } : () => number >impl.explicitThis : (this: I) => number >impl : I >explicitThis : (this: I) => number ->function () { return this.a; } : (this: I) => number +>function () { return this.a; } : () => number >this.a : number >this : I >a : number impl.implicitMethod = function () { return this.a; }; ->impl.implicitMethod = function () { return this.a; } : (this: I) => number +>impl.implicitMethod = function () { return this.a; } : () => number >impl.implicitMethod : (this: I) => number >impl : I >implicitMethod : (this: I) => number ->function () { return this.a; } : (this: I) => number +>function () { return this.a; } : () => number >this.a : number >this : I >a : number @@ -719,11 +719,11 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; // this:any compatibility c.explicitC = function(m) { return this.n + m }; ->c.explicitC = function(m) { return this.n + m } : (this: C, m: number) => number +>c.explicitC = function(m) { return this.n + m } : (m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->function(m) { return this.n + m } : (this: C, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number @@ -732,11 +732,11 @@ c.explicitC = function(m) { return this.n + m }; >m : number c.explicitProperty = function(m) { return this.n + m }; ->c.explicitProperty = function(m) { return this.n + m } : (this: { n: number; }, m: number) => number +>c.explicitProperty = function(m) { return this.n + m } : (m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->function(m) { return this.n + m } : (this: { n: number; }, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number @@ -745,11 +745,11 @@ c.explicitProperty = function(m) { return this.n + m }; >m : number c.explicitThis = function(m) { return this.n + m }; ->c.explicitThis = function(m) { return this.n + m } : (this: C, m: number) => number +>c.explicitThis = function(m) { return this.n + m } : (m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (this: C, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number @@ -758,11 +758,11 @@ c.explicitThis = function(m) { return this.n + m }; >m : number c.implicitThis = function(m) { return this.n + m }; ->c.implicitThis = function(m) { return this.n + m } : (this: C, m: number) => number +>c.implicitThis = function(m) { return this.n + m } : (m: number) => number >c.implicitThis : (this: C, m: number) => number >c : C >implicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (this: C, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number diff --git a/tests/cases/fourslash/quickInfoOnThis.ts b/tests/cases/fourslash/quickInfoOnThis.ts index cef78efe0cc..3213b85174e 100644 --- a/tests/cases/fourslash/quickInfoOnThis.ts +++ b/tests/cases/fourslash/quickInfoOnThis.ts @@ -42,6 +42,17 @@ ////function explicitLiteral(th/*14*/is: { n: number }): void { //// console.log(th/*15*/is); ////} +//// +//// interface ContextualInterface { +//// m: number; +//// method(this: this, n: number); +//// } +//// let o: ContextualInterface = { +//// m: 12, +//// method(n) { +//// let x = this/*16*/.m; +//// } +//// } goTo.marker('1'); verify.quickInfoIs('void'); @@ -73,4 +84,7 @@ goTo.marker('14'); verify.quickInfoIs('(parameter) this: {\n n: number;\n}'); goTo.marker('15'); -verify.quickInfoIs('this: {\n n: number;\n}'); \ No newline at end of file +verify.quickInfoIs('this: {\n n: number;\n}'); + +goTo.marker('16'); +verify.quickInfoIs('this: ContextualInterface'); \ No newline at end of file From fa598758b12d9b06c2b21579e8512a32bffd5065 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 8 Feb 2016 09:41:57 -0800 Subject: [PATCH 19/48] Improve display and contextual typing of `this` 1. Always display `this` type if annotated. 2. Contextually type un-annotated `this` parameters in addition to `this` expressions. --- src/compiler/checker.ts | 9 +- .../reference/contextualTyping24.errors.txt | 4 +- .../looseThisTypeInFunctions.errors.txt | 4 +- .../reference/thisTypeInFunctions.types | 128 +++++++++--------- .../thisTypeInFunctionsNegative.errors.txt | 16 +-- tests/cases/fourslash/quickInfoOnThis.ts | 16 ++- 6 files changed, 92 insertions(+), 85 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index be98dc985b5..06986107fbb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2203,15 +2203,14 @@ namespace ts { function buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { writePunctuation(writer, SyntaxKind.OpenParenToken); - const useThisType = thisType && thisType.symbol; - if (useThisType) { + if (thisType) { writeKeyword(writer, SyntaxKind.ThisKeyword); writePunctuation(writer, SyntaxKind.ColonToken); writeSpace(writer); buildTypeDisplay(thisType, writer, enclosingDeclaration, flags, symbolStack); } for (let i = 0; i < parameters.length; i++) { - if (i > 0 || useThisType) { + if (i > 0 || thisType) { writePunctuation(writer, SyntaxKind.CommaToken); writeSpace(writer); } @@ -2690,7 +2689,9 @@ namespace ts { } } // Use contextual parameter type if one is available - const type = getContextuallyTypedParameterType(declaration); + const type = declaration.symbol.name === "this" + ? getContextuallyTypedThisType(func) + : getContextuallyTypedParameterType(declaration); if (type) { return type; } diff --git a/tests/baselines/reference/contextualTyping24.errors.txt b/tests/baselines/reference/contextualTyping24.errors.txt index b4d0d534456..d5cb13e4e3e 100644 --- a/tests/baselines/reference/contextualTyping24.errors.txt +++ b/tests/baselines/reference/contextualTyping24.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping24.ts(1,55): error TS2322: Type '(a: string) => number' is not assignable to type '(a: { (): number; (i: number): number; }) => number'. +tests/cases/compiler/contextualTyping24.ts(1,55): error TS2322: Type '(this: void, a: string) => number' is not assignable to type '(a: { (): number; (i: number): number; }) => number'. Types of parameters 'a' and 'a' are incompatible. Type 'string' is not assignable to type '{ (): number; (i: number): number; }'. @@ -6,6 +6,6 @@ tests/cases/compiler/contextualTyping24.ts(1,55): error TS2322: Type '(a: string ==== tests/cases/compiler/contextualTyping24.ts (1 errors) ==== var foo:(a:{():number; (i:number):number; })=>number; foo = function(this: void, a:string){return 5}; ~~~ -!!! error TS2322: Type '(a: string) => number' is not assignable to type '(a: { (): number; (i: number): number; }) => number'. +!!! error TS2322: Type '(this: void, a: string) => number' is not assignable to type '(a: { (): number; (i: number): number; }) => number'. !!! error TS2322: Types of parameters 'a' and 'a' are incompatible. !!! error TS2322: Type 'string' is not assignable to type '{ (): number; (i: number): number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index 317446050a8..4eef7d83f78 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(m: number) => number'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'C'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(32,5): error TS1005: ',' expected. @@ -30,7 +30,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,19): error let c = new C(); c.explicitVoid = c.explicitThis; // error, 'void' is missing everything ~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(m: number) => number'. +!!! error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'C'. let o = { diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index e1044bb3d90..2c334b2caed 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -56,7 +56,7 @@ class C { >m : number } explicitVoid(this: void, m: number): number { ->explicitVoid : (m: number) => number +>explicitVoid : (this: void, m: number) => number >this : void >m : number @@ -83,11 +83,11 @@ interface I { >a : number explicitVoid1(this: void): number; ->explicitVoid1 : () => number +>explicitVoid1 : (this: void) => number >this : void explicitVoid2(this: void): number; ->explicitVoid2 : () => number +>explicitVoid2 : (this: void) => number >this : void explicitStructural(this: {a: number}): number; @@ -108,7 +108,7 @@ interface I { >implicitMethod : (this: this) => number implicitFunction: () => number; ->implicitFunction : () => number +>implicitFunction : (this: void) => number } function explicitStructural(this: { y: number }, x: number): number { >explicitStructural : (this: { y: number; }, x: number) => number @@ -134,7 +134,7 @@ function justThis(this: { y: number }): number { >y : number } function implicitThis(n: number): number { ->implicitThis : (n: number) => number +>implicitThis : (this: void, n: number) => number >n : number return 12; @@ -204,37 +204,37 @@ let impl: I = { >a : any } impl.explicitVoid1 = function () { return 12; }; ->impl.explicitVoid1 = function () { return 12; } : () => number ->impl.explicitVoid1 : () => number +>impl.explicitVoid1 = function () { return 12; } : (this: void) => number +>impl.explicitVoid1 : (this: void) => number >impl : I ->explicitVoid1 : () => number ->function () { return 12; } : () => number +>explicitVoid1 : (this: void) => number +>function () { return 12; } : (this: void) => number >12 : number impl.explicitVoid2 = () => 12; >impl.explicitVoid2 = () => 12 : () => number ->impl.explicitVoid2 : () => number +>impl.explicitVoid2 : (this: void) => number >impl : I ->explicitVoid2 : () => number +>explicitVoid2 : (this: void) => number >() => 12 : () => number >12 : number impl.explicitStructural = function() { return this.a; }; ->impl.explicitStructural = function() { return this.a; } : () => number +>impl.explicitStructural = function() { return this.a; } : (this: void) => number >impl.explicitStructural : (this: { a: number; }) => number >impl : I >explicitStructural : (this: { a: number; }) => number ->function() { return this.a; } : () => number +>function() { return this.a; } : (this: void) => number >this.a : number >this : { a: number; } >a : number impl.explicitInterface = function() { return this.a; }; ->impl.explicitInterface = function() { return this.a; } : () => number +>impl.explicitInterface = function() { return this.a; } : (this: void) => number >impl.explicitInterface : (this: I) => number >impl : I >explicitInterface : (this: I) => number ->function() { return this.a; } : () => number +>function() { return this.a; } : (this: void) => number >this.a : number >this : I >a : number @@ -256,21 +256,21 @@ impl.explicitInterface = () => 12; >12 : number impl.explicitThis = function () { return this.a; }; ->impl.explicitThis = function () { return this.a; } : () => number +>impl.explicitThis = function () { return this.a; } : (this: void) => number >impl.explicitThis : (this: I) => number >impl : I >explicitThis : (this: I) => number ->function () { return this.a; } : () => number +>function () { return this.a; } : (this: void) => number >this.a : number >this : I >a : number impl.implicitMethod = function () { return this.a; }; ->impl.implicitMethod = function () { return this.a; } : () => number +>impl.implicitMethod = function () { return this.a; } : (this: void) => number >impl.implicitMethod : (this: I) => number >impl : I >implicitMethod : (this: I) => number ->function () { return this.a; } : () => number +>function () { return this.a; } : (this: void) => number >this.a : number >this : I >a : number @@ -285,9 +285,9 @@ impl.implicitMethod = () => 12; impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) >impl.implicitFunction = () => this.a : () => any ->impl.implicitFunction : () => number +>impl.implicitFunction : (this: void) => number >impl : I ->implicitFunction : () => number +>implicitFunction : (this: void) => number >() => this.a : () => any >this.a : any >this : any @@ -308,15 +308,15 @@ let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: >explicitStructural : (this: { y: number; }, x: number) => number let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; ->implicitAnyOk : { notSpecified: number; f: (x: number) => number; } +>implicitAnyOk : { notSpecified: number; f: (this: void, x: number) => number; } >notSpecified : number ->f : (x: number) => number +>f : (this: void, x: number) => number >x : number ->{ notSpecified: 12, f: implicitThis } : { notSpecified: number; f: (n: number) => number; } +>{ notSpecified: 12, f: implicitThis } : { notSpecified: number; f: (this: void, n: number) => number; } >notSpecified : number >12 : number ->f : (n: number) => number ->implicitThis : (n: number) => number +>f : (this: void, n: number) => number +>implicitThis : (this: void, n: number) => number ok.f(13); >ok.f(13) : number @@ -327,14 +327,14 @@ ok.f(13); implicitThis(12); >implicitThis(12) : number ->implicitThis : (n: number) => number +>implicitThis : (this: void, n: number) => number >12 : number implicitAnyOk.f(12); >implicitAnyOk.f(12) : number ->implicitAnyOk.f : (x: number) => number ->implicitAnyOk : { notSpecified: number; f: (x: number) => number; } ->f : (x: number) => number +>implicitAnyOk.f : (this: void, x: number) => number +>implicitAnyOk : { notSpecified: number; f: (this: void, x: number) => number; } +>f : (this: void, x: number) => number >12 : number let c = new C(); @@ -410,7 +410,7 @@ d.implicitThis(12); >12 : number let reconstructed: { ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } n: number, >n : number @@ -438,12 +438,12 @@ let reconstructed: { >m : number explicitVoid(this: void, m: number): number, ->explicitVoid : (m: number) => number +>explicitVoid : (this: void, m: number) => number >this : void >m : number } = { ->{ n: 12, explicitThis: c.explicitThis, implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid} : { n: number; explicitThis: (this: C, m: number) => number; implicitThis: (this: C, m: number) => number; explicitC: (this: C, m: number) => number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid: (m: number) => number; } +>{ n: 12, explicitThis: c.explicitThis, implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid} : { n: number; explicitThis: (this: C, m: number) => number; implicitThis: (this: C, m: number) => number; explicitC: (this: C, m: number) => number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid: (this: void, m: number) => number; } n: 12, >n : number @@ -474,23 +474,23 @@ let reconstructed: { >explicitProperty : (this: { n: number; }, m: number) => number explicitVoid: c.explicitVoid ->explicitVoid : (m: number) => number ->c.explicitVoid : (m: number) => number +>explicitVoid : (this: void, m: number) => number +>c.explicitVoid : (this: void, m: number) => number >c : C ->explicitVoid : (m: number) => number +>explicitVoid : (this: void, m: number) => number }; reconstructed.explicitProperty(11); >reconstructed.explicitProperty(11) : number >reconstructed.explicitProperty : (this: { n: number; }, m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >explicitProperty : (this: { n: number; }, m: number) => number >11 : number reconstructed.implicitThis(11); >reconstructed.implicitThis(11) : number >reconstructed.implicitThis : (m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >implicitThis : (m: number) => number >11 : number @@ -520,14 +520,14 @@ let anyToSpecified: (this: { y: number }, x: number) => number = function(x: num >this : { y: number; } >y : number >x : number ->function(x: number): number { return x + 12; } : (x: number) => number +>function(x: number): number { return x + 12; } : (this: void, x: number) => number >x : number >x + 12 : number >x : number >12 : number let unspecifiedLambda: (x: number) => number = x => x + 12; ->unspecifiedLambda : (x: number) => number +>unspecifiedLambda : (this: void, x: number) => number >x : number >x => x + 12 : (x: number) => number >x : number @@ -536,7 +536,7 @@ let unspecifiedLambda: (x: number) => number = x => x + 12; >12 : number let specifiedLambda: (this: void, x: number) => number = x => x + 12; ->specifiedLambda : (x: number) => number +>specifiedLambda : (this: void, x: number) => number >this : void >x : number >x => x + 12 : (x: number) => number @@ -550,14 +550,14 @@ let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = uns >this : { y: number; } >y : number >x : number ->unspecifiedLambda : (x: number) => number +>unspecifiedLambda : (this: void, x: number) => number let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; >specifiedLambdaToSpecified : (this: { y: number; }, x: number) => number >this : { y: number; } >y : number >x : number ->specifiedLambda : (x: number) => number +>specifiedLambda : (this: void, x: number) => number let explicitCFunction: (this: C, m: number) => number; @@ -622,7 +622,7 @@ c.explicitProperty = reconstructed.explicitProperty; >c : C >explicitProperty : (this: { n: number; }, m: number) => number >reconstructed.explicitProperty : (this: { n: number; }, m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >explicitProperty : (this: { n: number; }, m: number) => number // lambdas are assignable to anything @@ -719,11 +719,11 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; // this:any compatibility c.explicitC = function(m) { return this.n + m }; ->c.explicitC = function(m) { return this.n + m } : (m: number) => number +>c.explicitC = function(m) { return this.n + m } : (this: void, m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: void, m: number) => number >m : number >this.n + m : number >this.n : number @@ -732,11 +732,11 @@ c.explicitC = function(m) { return this.n + m }; >m : number c.explicitProperty = function(m) { return this.n + m }; ->c.explicitProperty = function(m) { return this.n + m } : (m: number) => number +>c.explicitProperty = function(m) { return this.n + m } : (this: void, m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: void, m: number) => number >m : number >this.n + m : number >this.n : number @@ -745,11 +745,11 @@ c.explicitProperty = function(m) { return this.n + m }; >m : number c.explicitThis = function(m) { return this.n + m }; ->c.explicitThis = function(m) { return this.n + m } : (m: number) => number +>c.explicitThis = function(m) { return this.n + m } : (this: void, m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: void, m: number) => number >m : number >this.n + m : number >this.n : number @@ -758,11 +758,11 @@ c.explicitThis = function(m) { return this.n + m }; >m : number c.implicitThis = function(m) { return this.n + m }; ->c.implicitThis = function(m) { return this.n + m } : (m: number) => number +>c.implicitThis = function(m) { return this.n + m } : (this: void, m: number) => number >c.implicitThis : (this: C, m: number) => number >c : C >implicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: void, m: number) => number >m : number >this.n + m : number >this.n : number @@ -776,7 +776,7 @@ c.implicitThis = reconstructed.implicitThis; >c : C >implicitThis : (this: C, m: number) => number >reconstructed.implicitThis : (m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >implicitThis : (m: number) => number c.explicitC = function(this: B, m: number) { return this.n + m }; @@ -797,9 +797,9 @@ c.explicitC = function(this: B, m: number) { return this.n + m }; // this:void compatibility c.explicitVoid = n => n; >c.explicitVoid = n => n : (n: number) => number ->c.explicitVoid : (m: number) => number +>c.explicitVoid : (this: void, m: number) => number >c : C ->explicitVoid : (m: number) => number +>explicitVoid : (this: void, m: number) => number >n => n : (n: number) => number >n : number >n : number @@ -978,7 +978,7 @@ function LiteralTypeThis(this: {x: string}) { >"ok" : string } function AnyThis(this: any) { ->AnyThis : () => void +>AnyThis : (this: any) => void >this : any this.x = "ok"; @@ -1001,20 +1001,20 @@ let literalTypeThis = new LiteralTypeThis(); let anyThis = new AnyThis(); >anyThis : any >new AnyThis() : any ->AnyThis : () => void +>AnyThis : (this: any) => void //// type parameter inference //// declare var f: { ->f : { (x: number): number; call(this: (...argArray: any[]) => U, ...argArray: any[]): U; } +>f : { (this: void, x: number): number; call(this: (this: void, ...argArray: any[]) => U, ...argArray: any[]): U; } (this: void, x: number): number, >this : void >x : number call(this: (...argArray: any[]) => U, ...argArray: any[]): U; ->call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U +>call : (this: (this: void, ...argArray: any[]) => U, ...argArray: any[]) => U >U : U ->this : (...argArray: any[]) => U +>this : (this: void, ...argArray: any[]) => U >argArray : any[] >U : U >argArray : any[] @@ -1024,13 +1024,13 @@ declare var f: { let n: number = f.call(12); >n : number >f.call(12) : number ->f.call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U ->f : { (x: number): number; call(this: (...argArray: any[]) => U, ...argArray: any[]): U; } ->call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U +>f.call : (this: (this: void, ...argArray: any[]) => U, ...argArray: any[]) => U +>f : { (this: void, x: number): number; call(this: (this: void, ...argArray: any[]) => U, ...argArray: any[]): U; } +>call : (this: (this: void, ...argArray: any[]) => U, ...argArray: any[]) => U >12 : number function missingTypeIsImplicitAny(this, a: number) { return a; } ->missingTypeIsImplicitAny : (a: number) => number +>missingTypeIsImplicitAny : (this: any, a: number) => number >this : any >a : number >a : number diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 0b755b9e0bd..fdb9489f639 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -33,7 +33,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(95,1): err tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(96,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(97,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(98,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(101,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(x: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(101,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type '{ y: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(124,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. @@ -70,13 +70,13 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(134,1): er Types of parameters 'this' and 'this' are incompatible. Type '{ n: number; }' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(135,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(136,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(136,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(137,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(137,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(138,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(138,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,51): error TS2339: Property 'x' does not exist on type 'typeof Base1'. @@ -287,7 +287,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. let specifiedToImplicitVoid: (x: number) => number = explicitStructural; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(x: number) => number'. +!!! error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type '{ y: number; }'. @@ -371,17 +371,17 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. c.explicitVoid = d.implicitD; ~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'D'. c.explicitVoid = d.explicitD; ~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'D'. c.explicitVoid = d.explicitThis; ~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(m: number) => number'. +!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'D'. diff --git a/tests/cases/fourslash/quickInfoOnThis.ts b/tests/cases/fourslash/quickInfoOnThis.ts index 3213b85174e..57bbb6c5a3e 100644 --- a/tests/cases/fourslash/quickInfoOnThis.ts +++ b/tests/cases/fourslash/quickInfoOnThis.ts @@ -43,16 +43,20 @@ //// console.log(th/*15*/is); ////} //// -//// interface ContextualInterface { +////interface ContextualInterface { //// m: number; //// method(this: this, n: number); -//// } -//// let o: ContextualInterface = { +////} +////let o: ContextualInterface = { //// m: 12, //// method(n) { //// let x = this/*16*/.m; //// } -//// } +////} +////interface ContextualInterface2 { +//// (this: void, n: number): void; +////} +////let contextualInterface2: ContextualInterface2 = function (th/*17*/is, n) { } goTo.marker('1'); verify.quickInfoIs('void'); @@ -87,4 +91,6 @@ goTo.marker('15'); verify.quickInfoIs('this: {\n n: number;\n}'); goTo.marker('16'); -verify.quickInfoIs('this: ContextualInterface'); \ No newline at end of file +verify.quickInfoIs('this: ContextualInterface'); +goTo.marker('17'); +verify.quickInfoIs('(parameter) this: void'); \ No newline at end of file From 738713b146d055194254640d8b079cc54ca6cd7f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 8 Feb 2016 14:01:51 -0800 Subject: [PATCH 20/48] Improve error reporting 1. Fix bug in error reporting in compareSignaturesRelated. 2. When the this-argument is a union type, allow assignability when the method's signature is assignable to *any* member of the union. --- src/compiler/checker.ts | 12 +- src/compiler/core.ts | 17 + .../reference/thisTypeInFunctions.js | 24 +- .../reference/thisTypeInFunctions.symbols | 382 +++++++++--------- .../reference/thisTypeInFunctions.types | 25 +- .../types/thisType/thisTypeInFunctions.ts | 11 +- 6 files changed, 267 insertions(+), 204 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06986107fbb..0acb3a127d5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5305,7 +5305,9 @@ namespace ts { if (!related) { related = compareTypes(source.thisType, target.thisType, /*reportErrors*/ false); if (!related) { - errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, "this", "this"); + if (reportErrors) { + errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, "this", "this"); + } return Ternary.False; } } @@ -9511,7 +9513,13 @@ namespace ts { const thisArgumentNode = getThisArgumentOfCall(node); const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; const errorNode = reportErrors ? (thisArgumentNode || node) : undefined; - if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage)) { + if (thisArgumentType.flags & TypeFlags.UnionOrIntersection) { + const u = thisArgumentType; + if (!forEach(u.types, t => checkTypeRelatedTo(t, signature.thisType, relation, errorNode, headMessage))) { + return false; + } + } + else if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage)) { return false; } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 21536da36ff..f1f9d93c5d2 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -91,6 +91,23 @@ namespace ts { return undefined; } + /** + * Iterates through `array` by index and performs the callback on each element of array until the callback + * returns a falsey value, then returns false. + * If no such value is found, the callback is applied to each element of array and `true` is returned. + */ + export function trueForAll(array: T[], callback: (element: T, index: number) => boolean): boolean { + if (array) { + for (let i = 0, len = array.length; i < len; i++) { + if (!callback(array[i], i)) { + return false; + } + } + } + + return true; + } + export function contains(array: T[], value: T): boolean { if (array) { for (const v of array) { diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index f3ad84acb55..af55603a4b7 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -1,5 +1,8 @@ //// [thisTypeInFunctions.ts] // body checking +class B { + n: number; +} class C { n: number; explicitThis(this: this, m: number): number { @@ -19,9 +22,6 @@ class C { } } class D extends C { } -class B { - n: number; -} interface I { a: number; explicitVoid1(this: void): number; @@ -185,6 +185,11 @@ d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +// union assignability + +let b1b2: Base1 | Base2; +b1b2.implicit(); + ////// use this-type for construction with new //// function InterfaceThis(this: I) { this.a = 12; @@ -216,6 +221,11 @@ var __extends = (this && this.__extends) || function (d, b) { }; var _this = this; // body checking +var B = (function () { + function B() { + } + return B; +}()); var C = (function () { function C() { } @@ -243,11 +253,6 @@ var D = (function (_super) { } return D; }(C)); -var B = (function () { - function B() { - } - return B; -}()); function explicitStructural(x) { return x + this.y; } @@ -390,6 +395,9 @@ d1.implicit = b2.implicit; // ok, 'y' in D: { x, y } (d assignable e) d2.implicit = d1.explicit; // ok, 'y' in { x, y } (c assignable to f) b1.implicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) b1.explicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) +// union assignability +var b1b2; +b1b2.implicit(); ////// use this-type for construction with new //// function InterfaceThis() { this.a = 12; diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index bb6a9acfdd0..120494c206f 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -1,77 +1,77 @@ === tests/cases/conformance/types/thisType/thisTypeInFunctions.ts === // body checking -class C { ->C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +class B { +>B : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) n: number; >n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) +} +class C { +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) + + n: number; +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) explicitThis(this: this, m: number): number { ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 3, 17)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 3, 28)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 6, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 28)) return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 3, 28)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 28)) } implicitThis(m: number): number { ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 17)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 17)) return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 17)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 17)) } explicitC(this: C, m: number): number { ->explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 9, 14)) ->C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 14)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 22)) return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 22)) } explicitProperty(this: {n: number}, m: number): number { ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 21)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 15, 21)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 39)) return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 15, 26)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 39)) } explicitVoid(this: void, m: number): number { ->explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 15, 17)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 28)) +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 18, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 18, 28)) return m + 1; ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 18, 28)) } } class D extends C { } ->D : Symbol(D, Decl(thisTypeInFunctions.ts, 18, 1)) ->C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>D : Symbol(D, Decl(thisTypeInFunctions.ts, 21, 1)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) -class B { ->B : Symbol(B, Decl(thisTypeInFunctions.ts, 19, 21)) - - n: number; ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 20, 9)) -} interface I { ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) a: number; >a : Symbol(a, Decl(thisTypeInFunctions.ts, 23, 13)) @@ -92,7 +92,7 @@ interface I { explicitInterface(this: I): number; >explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 28, 22)) ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) explicitThis(this: this): number; >explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) @@ -134,7 +134,7 @@ function implicitThis(n: number): number { } let impl: I = { >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) a: 12, >a : Symbol(a, Decl(thisTypeInFunctions.ts, 42, 15)) @@ -159,7 +159,7 @@ let impl: I = { return this.a; >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) }, @@ -168,7 +168,7 @@ let impl: I = { return this.a; >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) }, @@ -177,7 +177,7 @@ let impl: I = { return this.a; >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) }, @@ -207,7 +207,7 @@ impl.explicitInterface = function() { return this.a; }; >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) >explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) impl.explicitStructural = () => 12; @@ -225,7 +225,7 @@ impl.explicitThis = function () { return this.a; }; >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) >explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) impl.implicitMethod = function () { return this.a; }; @@ -233,7 +233,7 @@ impl.implicitMethod = function () { return this.a; }; >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) >implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) impl.implicitMethod = () => 12; @@ -282,57 +282,57 @@ implicitAnyOk.f(12); let c = new C(); >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) let d = new D(); >d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->D : Symbol(D, Decl(thisTypeInFunctions.ts, 18, 1)) +>D : Symbol(D, Decl(thisTypeInFunctions.ts, 21, 1)) let ripped = c.explicitC; >ripped : Symbol(ripped, Decl(thisTypeInFunctions.ts, 79, 3)) ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) c.explicitC(12); ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) c.explicitProperty(12); ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) c.explicitThis(12); ->c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) c.implicitThis(12); ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) d.explicitC(12); ->d.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>d.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) d.explicitProperty(12); ->d.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>d.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) d.explicitThis(12); ->d.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>d.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) d.implicitThis(12); ->d.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>d.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) >d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) let reconstructed: { >reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) @@ -343,7 +343,7 @@ let reconstructed: { explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. >explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 89, 14)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 90, 17)) ->C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 90, 25)) implicitThis(m: number): number, @@ -353,7 +353,7 @@ let reconstructed: { explicitC(this: C, m: number): number, >explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 91, 36)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 92, 14)) ->C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 92, 22)) explicitProperty: (this: {n : number}, m: number) => number, @@ -373,33 +373,33 @@ let reconstructed: { explicitThis: c.explicitThis, >explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 96, 10)) ->c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) implicitThis: c.implicitThis, >implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 97, 33)) ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) explicitC: c.explicitC, >explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 98, 33)) ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) explicitProperty: c.explicitProperty, >explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 99, 27)) ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) explicitVoid: c.explicitVoid >explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 100, 41)) ->c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) }; reconstructed.explicitProperty(11); @@ -467,7 +467,7 @@ let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = speci let explicitCFunction: (this: C, m: number) => number; >explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 117, 24)) ->C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 32)) let explicitPropertyFunction: (this: {n: number}, m: number) => number; @@ -477,33 +477,33 @@ let explicitPropertyFunction: (this: {n: number}, m: number) => number; >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 49)) c.explicitC = explicitCFunction; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) c.explicitC = function(this: C, m: number) { return this.n + m }; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 120, 23)) ->C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 120, 31)) ->this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) ->n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 120, 31)) c.explicitProperty = explicitPropertyFunction; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 118, 3)) c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m }; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 122, 30)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 122, 48)) @@ -513,143 +513,143 @@ c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m >m : Symbol(m, Decl(thisTypeInFunctions.ts, 122, 48)) c.explicitProperty = reconstructed.explicitProperty; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) >reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) >explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) // lambdas are assignable to anything c.explicitC = m => m; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 13)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 13)) c.explicitThis = m => m; ->c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 16)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 16)) c.explicitProperty = m => m; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 20)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 20)) // this inside lambdas refer to outer scope // the outer-scoped lambda at top-level is still just `any` c.explicitC = m => m + this.n; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 132, 13)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 132, 13)) c.explicitThis = m => m + this.n; ->c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 133, 16)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 133, 16)) c.explicitProperty = m => m + this.n; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 20)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 20)) //NOTE: this=C here, I guess? c.explicitThis = explicitCFunction; ->c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) c.explicitThis = function(this: C, m: number) { return this.n + m }; ->c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 138, 26)) ->C : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) +>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 138, 34)) ->this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) ->n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 138, 34)) // this:any compatibility c.explicitC = function(m) { return this.n + m }; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 141, 23)) ->this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) ->n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 141, 23)) c.explicitProperty = function(m) { return this.n + m }; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 142, 30)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 15, 26)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 142, 30)) c.explicitThis = function(m) { return this.n + m }; ->c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 2, 14)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 143, 26)) ->this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) ->n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 143, 26)) c.implicitThis = function(m) { return this.n + m }; ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 144, 26)) ->this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 0, 0)) ->n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 144, 26)) c.implicitThis = reconstructed.implicitThis; ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 5, 5)) +>implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) >reconstructed.implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) >reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) >implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) c.explicitC = function(this: B, m: number) { return this.n + m }; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 147, 23)) ->B : Symbol(B, Decl(thisTypeInFunctions.ts, 19, 21)) +>B : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 147, 31)) ->this.n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 20, 9)) ->this : Symbol(B, Decl(thisTypeInFunctions.ts, 19, 21)) ->n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 20, 9)) +>this.n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9)) +>this : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) +>n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 147, 31)) // this:void compatibility c.explicitVoid = n => n; ->c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 150, 16)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 150, 16)) @@ -791,72 +791,84 @@ b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) >d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) >implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +// union assignability + +let b1b2: Base1 | Base2; +>b1b2 : Symbol(b1b2, Decl(thisTypeInFunctions.ts, 188, 3)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) + +b1b2.implicit(); +>b1b2.implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 154, 14), Decl(thisTypeInFunctions.ts, 166, 13)) +>b1b2 : Symbol(b1b2, Decl(thisTypeInFunctions.ts, 188, 3)) +>implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 154, 14), Decl(thisTypeInFunctions.ts, 166, 13)) + ////// use this-type for construction with new //// function InterfaceThis(this: I) { ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 187, 23)) ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 189, 16)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 192, 23)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) this.a = 12; >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 1)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) } function LiteralTypeThis(this: {x: string}) { ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 190, 25)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 194, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 195, 25)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 195, 32)) this.x = "ok"; ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 190, 30)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 195, 32)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 195, 30)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 195, 32)) } function AnyThis(this: any) { ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 193, 17)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 197, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 198, 17)) this.x = "ok"; } let interfaceThis = new InterfaceThis(); ->interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 196, 3)) ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) +>interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 201, 3)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 189, 16)) let literalTypeThis = new LiteralTypeThis(); ->literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 197, 3)) ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) +>literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 202, 3)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 194, 1)) let anyThis = new AnyThis(); ->anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 198, 3)) ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) +>anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 203, 3)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 197, 1)) //// type parameter inference //// declare var f: { ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 206, 11)) (this: void, x: number): number, ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 202, 5)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 202, 16)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 207, 5)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 207, 16)) call(this: (...argArray: any[]) => U, ...argArray: any[]): U; ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 203, 12)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 19)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 44)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 207, 36)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 208, 9)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 208, 12)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 208, 19)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 208, 9)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 208, 44)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 208, 9)) }; let n: number = f.call(12); ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 205, 3)) ->f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 210, 3)) +>f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 207, 36)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 206, 11)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 207, 36)) function missingTypeIsImplicitAny(this, a: number) { return a; } ->missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 205, 27)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 207, 34)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) +>missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 210, 27)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 212, 34)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 212, 39)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 212, 39)) diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 2c334b2caed..e5f6a561d59 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -1,5 +1,11 @@ === tests/cases/conformance/types/thisType/thisTypeInFunctions.ts === // body checking +class B { +>B : B + + n: number; +>n : number +} class C { >C : C @@ -70,12 +76,6 @@ class D extends C { } >D : D >C : C -class B { ->B : B - - n: number; ->n : number -} interface I { >I : I @@ -952,6 +952,19 @@ b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) >d2 : Derived2 >implicit : (this: Derived2) => number +// union assignability + +let b1b2: Base1 | Base2; +>b1b2 : Base1 | Base2 +>Base1 : Base1 +>Base2 : Base2 + +b1b2.implicit(); +>b1b2.implicit() : number +>b1b2.implicit : ((this: Base1) => number) | ((this: Base2) => number) +>b1b2 : Base1 | Base2 +>implicit : ((this: Base1) => number) | ((this: Base2) => number) + ////// use this-type for construction with new //// function InterfaceThis(this: I) { >InterfaceThis : (this: I) => void diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts index f92b8ab4e15..e5cc9e45ba2 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts @@ -1,5 +1,8 @@ // @strictThis: true // body checking +class B { + n: number; +} class C { n: number; explicitThis(this: this, m: number): number { @@ -19,9 +22,6 @@ class C { } } class D extends C { } -class B { - n: number; -} interface I { a: number; explicitVoid1(this: void): number; @@ -185,6 +185,11 @@ d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +// union assignability + +let b1b2: Base1 | Base2; +b1b2.implicit(); + ////// use this-type for construction with new //// function InterfaceThis(this: I) { this.a = 12; From 41bb4468652243e2df9f1bd563f7544469bb3021 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 8 Feb 2016 16:39:19 -0800 Subject: [PATCH 21/48] Revert unioning of this argument types The right solution is to not instantiate this-types of unions, which is a separate problem more to do with this-class types. --- src/compiler/checker.ts | 8 +- src/compiler/core.ts | 17 ---- .../looseThisTypeInFunctions.errors.txt | 22 +++-- .../reference/looseThisTypeInFunctions.js | 9 +-- .../reference/thisTypeInFunctions.js | 8 -- .../reference/thisTypeInFunctions.symbols | 80 ++++++++----------- .../reference/thisTypeInFunctions.types | 13 --- .../thisType/looseThisTypeInFunctions.ts | 8 +- .../types/thisType/thisTypeInFuncTemp.ts | 36 +++------ .../types/thisType/thisTypeInFunctions.ts | 5 -- 10 files changed, 61 insertions(+), 145 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0acb3a127d5..b9343a2cdbe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9513,13 +9513,7 @@ namespace ts { const thisArgumentNode = getThisArgumentOfCall(node); const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; const errorNode = reportErrors ? (thisArgumentNode || node) : undefined; - if (thisArgumentType.flags & TypeFlags.UnionOrIntersection) { - const u = thisArgumentType; - if (!forEach(u.types, t => checkTypeRelatedTo(t, signature.thisType, relation, errorNode, headMessage))) { - return false; - } - } - else if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage)) { + if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage)) { return false; } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f1f9d93c5d2..21536da36ff 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -91,23 +91,6 @@ namespace ts { return undefined; } - /** - * Iterates through `array` by index and performs the callback on each element of array until the callback - * returns a falsey value, then returns false. - * If no such value is found, the callback is applied to each element of array and `true` is returned. - */ - export function trueForAll(array: T[], callback: (element: T, index: number) => boolean): boolean { - if (array) { - for (let i = 0, len = array.length; i < len; i++) { - if (!callback(array[i], i)) { - return false; - } - } - } - - return true; - } - export function contains(array: T[], value: T): boolean { if (array) { for (const v of array) { diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index 4eef7d83f78..caaf7afb09c 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -1,13 +1,12 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'C'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(32,5): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,27): error TS2339: Property 'length' does not exist on type 'number'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,28): error TS2339: Property 'length' does not exist on type 'number'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,19): error TS2339: Property 'length' does not exist on type 'number'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error TS2339: Property 'length' does not exist on type 'number'. -==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (5 errors) ==== +==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (4 errors) ==== interface I { n: number; explicitThis(this: this, m: number): number; @@ -42,12 +41,10 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,19): error }; let i: I = o; let o2: I = { - n: 1001 + n: 1001, explicitThis: function (m) { - ~~~~~~~~~~~~ -!!! error TS1005: ',' expected. - return m + this.n.length; // error, this.n: number, no member 'length' - ~~~~~~ + return m + this.n.length; // error, this.n: number, no member 'length' + ~~~~~~ !!! error TS2339: Property 'length' does not exist on type 'number'. }, } @@ -63,8 +60,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,19): error o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) o.implicitThis = i.explicitThis; i.explicitThis = function(m) { - return this.n.length; // error, this.n: number - ~~~~~~ + 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 ecb9f650716..3b172877e0e 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.js +++ b/tests/baselines/reference/looseThisTypeInFunctions.js @@ -29,9 +29,9 @@ let o = { }; let i: I = o; let o2: I = { - n: 1001 + n: 1001, explicitThis: function (m) { - return m + this.n.length; // error, this.n: number, no member 'length' + return m + this.n.length; // error, this.n: number, no member 'length' }, } let x = i.explicitThis; @@ -44,9 +44,8 @@ o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) o.implicitThis = i.explicitThis; i.explicitThis = function(m) { - return this.n.length; // error, this.n: number -} - + return this.n.length; // error, this.n: number +} //// [looseThisTypeInFunctions.js] var C = (function () { diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index af55603a4b7..8d34f9bc2cf 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -185,11 +185,6 @@ d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) -// union assignability - -let b1b2: Base1 | Base2; -b1b2.implicit(); - ////// use this-type for construction with new //// function InterfaceThis(this: I) { this.a = 12; @@ -395,9 +390,6 @@ d1.implicit = b2.implicit; // ok, 'y' in D: { x, y } (d assignable e) d2.implicit = d1.explicit; // ok, 'y' in { x, y } (c assignable to f) b1.implicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) b1.explicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) -// union assignability -var b1b2; -b1b2.implicit(); ////// use this-type for construction with new //// function InterfaceThis() { this.a = 12; diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 120494c206f..9cd1915fc94 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -791,22 +791,10 @@ b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) >d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) >implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) -// union assignability - -let b1b2: Base1 | Base2; ->b1b2 : Symbol(b1b2, Decl(thisTypeInFunctions.ts, 188, 3)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) - -b1b2.implicit(); ->b1b2.implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 154, 14), Decl(thisTypeInFunctions.ts, 166, 13)) ->b1b2 : Symbol(b1b2, Decl(thisTypeInFunctions.ts, 188, 3)) ->implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 154, 14), Decl(thisTypeInFunctions.ts, 166, 13)) - ////// use this-type for construction with new //// function InterfaceThis(this: I) { ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 189, 16)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 192, 23)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 187, 23)) >I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) this.a = 12; @@ -815,60 +803,60 @@ function InterfaceThis(this: I) { >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) } function LiteralTypeThis(this: {x: string}) { ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 194, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 195, 25)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 195, 32)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 190, 25)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) this.x = "ok"; ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 195, 32)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 195, 30)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 195, 32)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 190, 30)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) } function AnyThis(this: any) { ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 197, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 198, 17)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 193, 17)) this.x = "ok"; } let interfaceThis = new InterfaceThis(); ->interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 201, 3)) ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 189, 16)) +>interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 196, 3)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) let literalTypeThis = new LiteralTypeThis(); ->literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 202, 3)) ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 194, 1)) +>literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 197, 3)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) let anyThis = new AnyThis(); ->anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 203, 3)) ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 197, 1)) +>anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 198, 3)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) //// type parameter inference //// declare var f: { ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 206, 11)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) (this: void, x: number): number, ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 207, 5)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 207, 16)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 202, 5)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 202, 16)) call(this: (...argArray: any[]) => U, ...argArray: any[]): U; ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 207, 36)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 208, 9)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 208, 12)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 208, 19)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 208, 9)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 208, 44)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 208, 9)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 203, 12)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 19)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 44)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) }; let n: number = f.call(12); ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 210, 3)) ->f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 207, 36)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 206, 11)) ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 207, 36)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 205, 3)) +>f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) function missingTypeIsImplicitAny(this, a: number) { return a; } ->missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 210, 27)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 212, 34)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 212, 39)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 212, 39)) +>missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 205, 27)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 207, 34)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index e5f6a561d59..3922e454c3f 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -952,19 +952,6 @@ b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) >d2 : Derived2 >implicit : (this: Derived2) => number -// union assignability - -let b1b2: Base1 | Base2; ->b1b2 : Base1 | Base2 ->Base1 : Base1 ->Base2 : Base2 - -b1b2.implicit(); ->b1b2.implicit() : number ->b1b2.implicit : ((this: Base1) => number) | ((this: Base2) => number) ->b1b2 : Base1 | Base2 ->implicit : ((this: Base1) => number) | ((this: Base2) => number) - ////// use this-type for construction with new //// function InterfaceThis(this: I) { >InterfaceThis : (this: I) => void diff --git a/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts index 3e8bdb11170..b151961e324 100644 --- a/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts @@ -28,9 +28,9 @@ let o = { }; let i: I = o; let o2: I = { - n: 1001 + n: 1001, explicitThis: function (m) { - return m + this.n.length; // error, this.n: number, no member 'length' + return m + this.n.length; // error, this.n: number, no member 'length' }, } let x = i.explicitThis; @@ -43,5 +43,5 @@ o.implicitThis = c.implicitThis; // ok, implicitThis(this:any) o.implicitThis = c.explicitThis; // ok, implicitThis(this:any) is assignable to explicitThis(this: this) o.implicitThis = i.explicitThis; i.explicitThis = function(m) { - return this.n.length; // error, this.n: number -} + return this.n.length; // error, this.n: number +} \ No newline at end of file diff --git a/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts b/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts index 2f4873031fb..e4ae3deb171 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts @@ -1,27 +1,9 @@ -// @strictThis: true -// 1. contextual typing predicate is wrong (currently: method2: function () ...) -// () -> yes (allParametersAreUntyped=t, noThisParameter=t, noTypeParameters=t) -// ok .. fixed? -// 2. contextual typing of this doesn't seem to work -// strictThis was turned off. DUH. -// 3. when it DID work, it was giving bogus types with strictThis OFF (see the last example) -interface T { - (x: number): void; -} -interface I { - n: number - method(this: this): number; - method2(this: this): number; -} -let i: I = { - n: 12, - method: function(this) { // this: I - return this.n.length; // error, 'number' has no property 'length' - }, - method2: function() { // this: I - return this.n.length; // error, 'number' has no property 'length' - } -} -i.method = function () { return this.n.length } // this: I -i.method = function (this) { return this.n.length } // this: I -var t: T = function (this, y) { } // yes! (but this: any NOT number!!) \ No newline at end of file +//@strictThis: true +interface A { a: number; m(this: this): number } +interface B { b: number, m(this: this): number } +interface C { c: number; m(): number } +let a: A; +let ab: A | B; +let abc: A | B | C; +// ab.m().length; +abc.m().length; // should be OK? this: any, right? \ No newline at end of file diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts index e5cc9e45ba2..8676d12c5ab 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts @@ -185,11 +185,6 @@ d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) -// union assignability - -let b1b2: Base1 | Base2; -b1b2.implicit(); - ////// use this-type for construction with new //// function InterfaceThis(this: I) { this.a = 12; From a014edf55a61376839682b537463b01d03929c66 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 16 Feb 2016 13:00:21 -0800 Subject: [PATCH 22/48] Address more comments and remove temp test. I added the temp test by mistake. --- src/lib/core.d.ts | 4 ++-- .../conformance/types/thisType/thisTypeInFuncTemp.ts | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 5a94b21b0fb..efc6e12fc6d 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -215,7 +215,7 @@ 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: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; apply(this: Function, thisArg: any, argArray?: any): any; /** @@ -223,7 +223,7 @@ 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: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; call(this: Function, thisArg: any, ...argArray: any[]): any; /** diff --git a/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts b/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts deleted file mode 100644 index e4ae3deb171..00000000000 --- a/tests/cases/conformance/types/thisType/thisTypeInFuncTemp.ts +++ /dev/null @@ -1,9 +0,0 @@ -//@strictThis: true -interface A { a: number; m(this: this): number } -interface B { b: number, m(this: this): number } -interface C { c: number; m(): number } -let a: A; -let ab: A | B; -let abc: A | B | C; -// ab.m().length; -abc.m().length; // should be OK? this: any, right? \ No newline at end of file From 482acccadaa754c96e09059dff68c50619e5f8aa Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 8 Mar 2016 13:05:00 -0800 Subject: [PATCH 23/48] Union this-types of unioned call signatures And and tests and baselines --- src/compiler/checker.ts | 26 +++++++++----- .../reference/unionThisTypeInFunctions.js | 18 ++++++++++ .../unionThisTypeInFunctions.symbols | 33 +++++++++++++++++ .../reference/unionThisTypeInFunctions.types | 35 +++++++++++++++++++ .../thisType/unionThisTypeInFunctions.ts | 12 +++++++ 5 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/unionThisTypeInFunctions.js create mode 100644 tests/baselines/reference/unionThisTypeInFunctions.symbols create mode 100644 tests/baselines/reference/unionThisTypeInFunctions.types create mode 100644 tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d1b6dc5435e..b5337082c0f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3610,9 +3610,9 @@ namespace ts { setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo); } - function findMatchingSignature(signatureList: Signature[], signature: Signature, partialMatch: boolean, ignoreReturnTypes: boolean): Signature { + function findMatchingSignature(signatureList: Signature[], signature: Signature, partialMatch: boolean, ignoreThisTypes: boolean, ignoreReturnTypes: boolean): Signature { for (const s of signatureList) { - if (compareSignaturesIdentical(s, signature, partialMatch, ignoreReturnTypes, compareTypesIdentical)) { + if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypesIdentical)) { return s; } } @@ -3626,7 +3626,7 @@ namespace ts { return undefined; } for (let i = 1; i < signatureLists.length; i++) { - if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false)) { return undefined; } } @@ -3635,7 +3635,7 @@ namespace ts { let result: Signature[] = undefined; for (let i = 0; i < signatureLists.length; i++) { // Allow matching non-generic signatures to have excess parameters and different return types - const match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + const match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -3656,13 +3656,16 @@ namespace ts { for (let i = 0; i < signatureLists.length; i++) { for (const signature of signatureLists[i]) { // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { const unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { let s = signature; // Union the result types when more than one signature matches if (unionSignatures.length > 1) { s = cloneSignature(signature); + if (forEach(unionSignatures, sig => sig.thisType)) { + s.thisType = getUnionType(map(unionSignatures, sig => sig.thisType || anyType)); + } // Clear resolved return type we possibly got from cloneSignature s.resolvedReturnType = undefined; s.unionSignatures = unionSignatures; @@ -6002,7 +6005,7 @@ namespace ts { } let result = Ternary.True; for (let i = 0, len = sourceSignatures.length; i < len; i++) { - const related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); + const related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return Ternary.False; } @@ -6203,7 +6206,7 @@ namespace ts { /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesIdentical(source: Signature, target: Signature, partialMatch: boolean, ignoreReturnTypes: boolean, compareTypes: (s: Type, t: Type) => Ternary): Ternary { + function compareSignaturesIdentical(source: Signature, target: Signature, partialMatch: boolean, ignoreThisTypes: boolean, ignoreReturnTypes: boolean, compareTypes: (s: Type, t: Type) => Ternary): Ternary { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return Ternary.True; @@ -6224,6 +6227,13 @@ namespace ts { source = getErasedSignature(source); target = getErasedSignature(target); let result = Ternary.True; + if (!ignoreThisTypes && source.thisType && target.thisType) { + const related = compareTypes(source.thisType, target.thisType); + if (!related) { + return Ternary.False; + } + result &= related; + } const targetLen = target.parameters.length; for (let i = 0; i < targetLen; i++) { const s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); @@ -8137,7 +8147,7 @@ namespace ts { // This signature will contribute to contextual union signature signatureList = [signature]; } - else if (!compareSignaturesIdentical(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + else if (!compareSignaturesIdentical(signatureList[0], signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { // Signatures aren't identical, do not use return undefined; } diff --git a/tests/baselines/reference/unionThisTypeInFunctions.js b/tests/baselines/reference/unionThisTypeInFunctions.js new file mode 100644 index 00000000000..31ff266087b --- /dev/null +++ b/tests/baselines/reference/unionThisTypeInFunctions.js @@ -0,0 +1,18 @@ +//// [unionThisTypeInFunctions.ts] +interface Real { + method(n: number): void; + data: string; +} +interface Fake { + method(n: number): void; + data: number; +} +function test(r: Real | Fake) { + r.method(12); +} + + +//// [unionThisTypeInFunctions.js] +function test(r) { + r.method(12); +} diff --git a/tests/baselines/reference/unionThisTypeInFunctions.symbols b/tests/baselines/reference/unionThisTypeInFunctions.symbols new file mode 100644 index 00000000000..8b5f2af01e0 --- /dev/null +++ b/tests/baselines/reference/unionThisTypeInFunctions.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts === +interface Real { +>Real : Symbol(Real, Decl(unionThisTypeInFunctions.ts, 0, 0)) + + method(n: number): void; +>method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 0, 16)) +>n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 1, 11)) + + data: string; +>data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 1, 28)) +} +interface Fake { +>Fake : Symbol(Fake, Decl(unionThisTypeInFunctions.ts, 3, 1)) + + method(n: number): void; +>method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 4, 16)) +>n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 5, 11)) + + data: number; +>data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 5, 28)) +} +function test(r: Real | Fake) { +>test : Symbol(test, Decl(unionThisTypeInFunctions.ts, 7, 1)) +>r : Symbol(r, Decl(unionThisTypeInFunctions.ts, 8, 14)) +>Real : Symbol(Real, Decl(unionThisTypeInFunctions.ts, 0, 0)) +>Fake : Symbol(Fake, Decl(unionThisTypeInFunctions.ts, 3, 1)) + + r.method(12); +>r.method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 0, 16), Decl(unionThisTypeInFunctions.ts, 4, 16)) +>r : Symbol(r, Decl(unionThisTypeInFunctions.ts, 8, 14)) +>method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 0, 16), Decl(unionThisTypeInFunctions.ts, 4, 16)) +} + diff --git a/tests/baselines/reference/unionThisTypeInFunctions.types b/tests/baselines/reference/unionThisTypeInFunctions.types new file mode 100644 index 00000000000..f2c4f7ee4ec --- /dev/null +++ b/tests/baselines/reference/unionThisTypeInFunctions.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts === +interface Real { +>Real : Real + + method(n: number): void; +>method : (this: this, n: number) => void +>n : number + + data: string; +>data : string +} +interface Fake { +>Fake : Fake + + method(n: number): void; +>method : (this: this, n: number) => void +>n : number + + data: number; +>data : number +} +function test(r: Real | Fake) { +>test : (this: void, r: Real | Fake) => void +>r : Real | Fake +>Real : Real +>Fake : Fake + + r.method(12); +>r.method(12) : void +>r.method : ((this: Real, n: number) => void) | ((this: Fake, n: number) => void) +>r : Real | Fake +>method : ((this: Real, n: number) => void) | ((this: Fake, n: number) => void) +>12 : number +} + diff --git a/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts new file mode 100644 index 00000000000..a140c3fba95 --- /dev/null +++ b/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts @@ -0,0 +1,12 @@ +// @strictThis: true +interface Real { + method(n: number): void; + data: string; +} +interface Fake { + method(n: number): void; + data: number; +} +function test(r: Real | Fake) { + r.method(12); +} From 7b531fcd05334c059a1eaa27c67807046a8bfeec Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 9 Mar 2016 13:06:06 -0800 Subject: [PATCH 24/48] Check this expressions in object literal methods Add a test and baseline --- src/compiler/checker.ts | 8 +++++++ .../reference/thisTypeInObjectLiterals.js | 16 ++++++++++++++ .../thisTypeInObjectLiterals.symbols | 19 +++++++++++++++++ .../reference/thisTypeInObjectLiterals.types | 21 +++++++++++++++++++ .../thisType/thisTypeInObjectLiterals.ts | 6 ++++++ 5 files changed, 70 insertions(+) create mode 100644 tests/baselines/reference/thisTypeInObjectLiterals.js create mode 100644 tests/baselines/reference/thisTypeInObjectLiterals.symbols create mode 100644 tests/baselines/reference/thisTypeInObjectLiterals.types create mode 100644 tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b5337082c0f..7073af85fcf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7494,6 +7494,14 @@ namespace ts { const symbol = getSymbolOfNode(container.parent); return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).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 (isInJavaScriptFile(node)) { const type = getTypeForThisExpressionFromJSDoc(container); diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.js b/tests/baselines/reference/thisTypeInObjectLiterals.js new file mode 100644 index 00000000000..78854bf2388 --- /dev/null +++ b/tests/baselines/reference/thisTypeInObjectLiterals.js @@ -0,0 +1,16 @@ +//// [thisTypeInObjectLiterals.ts] +let o = { + d: "bar", + m() { + return this.d.length; + } +} + + +//// [thisTypeInObjectLiterals.js] +var o = { + d: "bar", + m: function () { + return this.d.length; + } +}; diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.symbols b/tests/baselines/reference/thisTypeInObjectLiterals.symbols new file mode 100644 index 00000000000..6bea6d88c58 --- /dev/null +++ b/tests/baselines/reference/thisTypeInObjectLiterals.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts === +let o = { +>o : Symbol(o, Decl(thisTypeInObjectLiterals.ts, 0, 3)) + + d: "bar", +>d : Symbol(d, Decl(thisTypeInObjectLiterals.ts, 0, 9)) + + m() { +>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, --, --)) + } +} + diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.types b/tests/baselines/reference/thisTypeInObjectLiterals.types new file mode 100644 index 00000000000..824b0b00f4c --- /dev/null +++ b/tests/baselines/reference/thisTypeInObjectLiterals.types @@ -0,0 +1,21 @@ +=== 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; } + + d: "bar", +>d : string +>"bar" : string + + m() { +>m : () => number + + return this.d.length; +>this.d.length : number +>this.d : string +>this : { d: string; m(): number; } +>d : string +>length : number + } +} + diff --git a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts new file mode 100644 index 00000000000..11c6b58d710 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts @@ -0,0 +1,6 @@ +let o = { + d: "bar", + m() { + return this.d.length; + } +} From 4012587808d3027c88360c2f16e90075c2a32b90 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 9 Mar 2016 13:08:09 -0800 Subject: [PATCH 25/48] Update baselines: 'this' in object literal methods --- .../reference/commentsOnObjectLiteral3.symbols | 7 +++++++ .../reference/commentsOnObjectLiteral3.types | 12 ++++++------ .../baselines/reference/commentsOnObjectLiteral4.js | 7 ++++--- .../reference/commentsOnObjectLiteral4.symbols | 3 ++- .../reference/commentsOnObjectLiteral4.types | 9 ++++----- .../declFileObjectLiteralWithAccessors.symbols | 3 +++ .../declFileObjectLiteralWithAccessors.types | 6 +++--- .../declFileObjectLiteralWithOnlySetter.symbols | 3 +++ .../declFileObjectLiteralWithOnlySetter.types | 6 +++--- .../declarationEmitThisPredicates02.errors.txt | 7 ++++++- ...ionEmitThisPredicatesWithPrivateName02.errors.txt | 7 ++++++- ...xponentiationAssignmentWithIndexingOnLHS3.symbols | 7 +++++++ ...dExponentiationAssignmentWithIndexingOnLHS3.types | 12 ++++++------ .../reference/thisInObjectLiterals.errors.txt | 5 ++++- .../reference/throwInEnclosingStatements.symbols | 1 + .../reference/throwInEnclosingStatements.types | 2 +- tests/cases/compiler/commentsOnObjectLiteral4.ts | 4 ++-- .../expressions/thisKeyword/thisInObjectLiterals.ts | 2 +- 18 files changed, 69 insertions(+), 34 deletions(-) diff --git a/tests/baselines/reference/commentsOnObjectLiteral3.symbols b/tests/baselines/reference/commentsOnObjectLiteral3.symbols index 3d58fe2d6d7..81fa15b6a11 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral3.symbols +++ b/tests/baselines/reference/commentsOnObjectLiteral3.symbols @@ -21,6 +21,10 @@ 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) { @@ -28,6 +32,9 @@ 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 a63920fce0f..26a1e2e4250 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 : any ->this : any ->prop : any +>this.prop : number +>this : { prop: number; func: () => void; func1(): void; a: any; } +>prop : number } /*trailing 1*/, //setter @@ -36,9 +36,9 @@ var v = { this.prop = value; >this.prop = value : any ->this.prop : any ->this : any ->prop : any +>this.prop : number +>this : { prop: number; func: () => void; func1(): void; a: any; } +>prop : number >value : any } // trailing 2 diff --git a/tests/baselines/reference/commentsOnObjectLiteral4.js b/tests/baselines/reference/commentsOnObjectLiteral4.js index 3b7efefdff4..23e238b8307 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral4.js +++ b/tests/baselines/reference/commentsOnObjectLiteral4.js @@ -5,9 +5,10 @@ var v = { * @type {number} */ get bar(): number { - return this._bar; + return 12; } -} +} + //// [commentsOnObjectLiteral4.js] var v = { @@ -15,6 +16,6 @@ var v = { * @type {number} */ get bar() { - return this._bar; + return 12; } }; diff --git a/tests/baselines/reference/commentsOnObjectLiteral4.symbols b/tests/baselines/reference/commentsOnObjectLiteral4.symbols index c1762cb75c8..568d6332126 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral4.symbols +++ b/tests/baselines/reference/commentsOnObjectLiteral4.symbols @@ -9,6 +9,7 @@ var v = { get bar(): number { >bar : Symbol(bar, Decl(commentsOnObjectLiteral4.ts, 1, 9)) - return this._bar; + return 12; } } + diff --git a/tests/baselines/reference/commentsOnObjectLiteral4.types b/tests/baselines/reference/commentsOnObjectLiteral4.types index f458d73ae36..5d20d4f79cc 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral4.types +++ b/tests/baselines/reference/commentsOnObjectLiteral4.types @@ -2,7 +2,7 @@ var v = { >v : { readonly bar: number; } ->{ /** * @type {number} */ get bar(): number { return this._bar; }} : { readonly bar: number; } +>{ /** * @type {number} */ get bar(): number { return 12; }} : { readonly bar: number; } /** * @type {number} @@ -10,9 +10,8 @@ var v = { get bar(): number { >bar : number - return this._bar; ->this._bar : any ->this : any ->_bar : any + return 12; +>12 : number } } + diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols b/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols index 862b0b3781e..9b3599da674 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.symbols @@ -15,6 +15,9 @@ 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 f7bb57b0e1e..1bf012605c1 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 : any ->this : any ->b : any +>this.b : number +>this : { b: number; x: number; } +>b : number >a : number }; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols index f7474466140..89b7b9dd747 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.symbols @@ -11,6 +11,9 @@ 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 2b9b98a8963..1bce86915ad 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 : any ->this : any ->b : any +>this.b : number +>this : { b: number; x: number; } +>b : number >a : number }; diff --git a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt index 4d95cf01136..8cf85d4f764 100644 --- a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt @@ -1,7 +1,9 @@ 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: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. + Property 'a' is missing in type '{ m(): this is Foo; }'. -==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts (1 errors) ==== +==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts (2 errors) ==== export interface Foo { a: string; @@ -14,6 +16,9 @@ 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: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +!!! 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 86c0f478133..0c0661023f5 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt @@ -1,8 +1,10 @@ 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: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. + Property 'a' is missing in type '{ m(): this is Foo; }'. -==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (2 errors) ==== +==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (3 errors) ==== interface Foo { a: string; @@ -17,6 +19,9 @@ 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: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +!!! 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/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols index dbd5aa150dc..4da659c4a1a 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.symbols @@ -8,11 +8,18 @@ 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 1877f391207..b47c88f3de3 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 : any ->this : any ->_0 : any +>this._0 : number +>this : { 0: number; _0: number; } +>_0 : number }, set 0(x: number) { @@ -20,9 +20,9 @@ var object = { this._0 = x; >this._0 = x : number ->this._0 : any ->this : any ->_0 : any +>this._0 : number +>this : { 0: number; _0: number; } +>_0 : number >x : number }, diff --git a/tests/baselines/reference/thisInObjectLiterals.errors.txt b/tests/baselines/reference/thisInObjectLiterals.errors.txt index 73300d86d74..f956ce42e34 100644 --- a/tests/baselines/reference/thisInObjectLiterals.errors.txt +++ b/tests/baselines/reference/thisInObjectLiterals.errors.txt @@ -1,7 +1,8 @@ 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 (1 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts (2 errors) ==== class MyClass { t: number; @@ -18,6 +19,8 @@ tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(7,13): e 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/throwInEnclosingStatements.symbols b/tests/baselines/reference/throwInEnclosingStatements.symbols index 42053c60efa..06fd9d53ff8 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.symbols +++ b/tests/baselines/reference/throwInEnclosingStatements.symbols @@ -89,6 +89,7 @@ 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 32f0fb093bc..8add6e8b1a8 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.types +++ b/tests/baselines/reference/throwInEnclosingStatements.types @@ -104,7 +104,7 @@ var aa = { >biz : () => void throw this; ->this : any +>this : { id: number; biz(): void; } } } diff --git a/tests/cases/compiler/commentsOnObjectLiteral4.ts b/tests/cases/compiler/commentsOnObjectLiteral4.ts index d685304f31e..dfb9e42b3cb 100644 --- a/tests/cases/compiler/commentsOnObjectLiteral4.ts +++ b/tests/cases/compiler/commentsOnObjectLiteral4.ts @@ -6,6 +6,6 @@ var v = { * @type {number} */ get bar(): number { - return this._bar; + return 12; } -} \ No newline at end of file +} diff --git a/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts b/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts index da38484bc07..ddfbb790980 100644 --- a/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts +++ b/tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts @@ -8,7 +8,7 @@ class MyClass { } } -//type of 'this' in an object literal property of a function type is Any +//type of 'this' in an object literal method is the type of the object literal var obj = { f() { return this.spaaace; From 32978247bd1778136a2d83a87a2d6cf7fb729e09 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 9 Mar 2016 13:20:49 -0800 Subject: [PATCH 26/48] Add missed update of thisInObjectLiterals baseline --- tests/baselines/reference/thisInObjectLiterals.errors.txt | 2 +- tests/baselines/reference/thisInObjectLiterals.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/thisInObjectLiterals.errors.txt b/tests/baselines/reference/thisInObjectLiterals.errors.txt index f956ce42e34..b0b1c63a34a 100644 --- a/tests/baselines/reference/thisInObjectLiterals.errors.txt +++ b/tests/baselines/reference/thisInObjectLiterals.errors.txt @@ -15,7 +15,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(14,21): } } - //type of 'this' in an object literal property of a function type is Any + //type of 'this' in an object literal method is the type of the object literal var obj = { f() { return this.spaaace; diff --git a/tests/baselines/reference/thisInObjectLiterals.js b/tests/baselines/reference/thisInObjectLiterals.js index 4e71347a366..6c8380060a7 100644 --- a/tests/baselines/reference/thisInObjectLiterals.js +++ b/tests/baselines/reference/thisInObjectLiterals.js @@ -9,7 +9,7 @@ class MyClass { } } -//type of 'this' in an object literal property of a function type is Any +//type of 'this' in an object literal method is the type of the object literal var obj = { f() { return this.spaaace; @@ -29,7 +29,7 @@ var MyClass = (function () { }; return MyClass; }()); -//type of 'this' in an object literal property of a function type is Any +//type of 'this' in an object literal method is the type of the object literal var obj = { f: function () { return this.spaaace; From 3a46e72bde6f3fd8f9801022575f9024e95a9339 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 9 Mar 2016 13:40:17 -0800 Subject: [PATCH 27/48] After merge, update error numbers in baselines --- .../thisTypeInFunctionsNegative.errors.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index fdb9489f639..c48ea11b3b0 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -91,10 +91,10 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,1): er tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'Base1' is not assignable to type 'Base2'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(179,16): error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(180,24): error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,17): error TS2674: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,30): error TS2673: 'this' parameter must be the first parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(179,16): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(180,24): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,17): error TS2680: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,30): error TS2679: 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,61): error TS2339: Property 'n' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,26): error TS1003: Identifier expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,30): error TS1005: ',' expected. @@ -443,21 +443,21 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e } let voidThis = new VoidThis(); ~~~~~~~~~~~~~~ -!!! error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +!!! error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. let implicitVoidThis = new ImplicitVoidThis(); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2672: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +!!! error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. ///// syntax-ish errors ///// class ThisConstructor { constructor(this: ThisConstructor, private n: number) { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2674: A constructor cannot have a 'this' parameter. +!!! error TS2680: A constructor cannot have a 'this' parameter. } } function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ -!!! error TS2673: 'this' parameter must be the first parameter. +!!! error TS2679: 'this' parameter must be the first parameter. ~ !!! error TS2339: Property 'n' does not exist on type 'void'. From 1032cc54089c48025e361f91303942b9b7a54122 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 11 Mar 2016 13:24:31 -0800 Subject: [PATCH 28/48] Rename --strictThis to --strictThisChecks Use the upcoming naming scheme for --strict.*Checks and --strictChecks flags. --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 4 ++-- src/compiler/commandLineParser.ts | 2 +- src/compiler/types.ts | 2 +- tests/baselines/reference/thisTypeInFunctions.js | 3 ++- tests/cases/conformance/types/thisType/thisTypeInFunctions.ts | 4 ++-- .../conformance/types/thisType/thisTypeInFunctionsNegative.ts | 2 +- .../conformance/types/thisType/unionThisTypeInFunctions.ts | 2 +- tests/cases/fourslash/memberListOnExplicitThis.ts | 2 +- tests/cases/fourslash/quickInfoOnThis.ts | 4 ++-- 10 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 10183f9a63f..7ae21a6338e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1307,7 +1307,7 @@ namespace ts { // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - if (options.strictThis) { + if (options.strictThisChecks) { seenThisKeyword = true; } return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4a1299196f1..5017f0dcd2c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3520,7 +3520,7 @@ namespace ts { return isIndependentVariableLikeDeclaration(declaration); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - return compilerOptions.strictThis ? false : isIndependentFunctionLikeDeclaration(declaration); + return compilerOptions.strictThisChecks ? false : isIndependentFunctionLikeDeclaration(declaration); case SyntaxKind.Constructor: return isIndependentFunctionLikeDeclaration(declaration); } @@ -4234,7 +4234,7 @@ namespace ts { if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); } - if (!hasThisParameter && compilerOptions.strictThis) { + if (!hasThisParameter && compilerOptions.strictThisChecks) { if (declaration.kind === SyntaxKind.FunctionDeclaration || declaration.kind === SyntaxKind.CallSignature || declaration.kind == SyntaxKind.FunctionExpression || diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 01d18d3a755..f6e1d9b48d7 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -138,7 +138,7 @@ namespace ts { type: "boolean", }, { - name: "strictThis", + name: "strictThisChecks", type: "boolean", }, { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4d12e0bce99..dfa1b54e428 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2407,7 +2407,7 @@ namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; - strictThis?: boolean; + strictThisChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index 8d34f9bc2cf..e963dad60f7 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -206,7 +206,8 @@ declare var f: { }; let n: number = f.call(12); -function missingTypeIsImplicitAny(this, a: number) { return a; } +function missingTypeIsImplicitAny(this, a: number) { return a; } + //// [thisTypeInFunctions.js] var __extends = (this && this.__extends) || function (d, b) { diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts index 8676d12c5ab..3a1de178eea 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts @@ -1,4 +1,4 @@ -// @strictThis: true +// @strictThisChecks: true // body checking class B { n: number; @@ -206,4 +206,4 @@ declare var f: { }; let n: number = f.call(12); -function missingTypeIsImplicitAny(this, a: number) { return a; } \ No newline at end of file +function missingTypeIsImplicitAny(this, a: number) { return a; } diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts index 3afc5a5c69b..bec0b9ab434 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts @@ -1,4 +1,4 @@ -// @strictThis: true +// @strictThisChecks: true class C { n: number; explicitThis(this: this, m: number): number { diff --git a/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts index a140c3fba95..c0a55f138ce 100644 --- a/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts @@ -1,4 +1,4 @@ -// @strictThis: true +// @strictThisChecks: true interface Real { method(n: number): void; data: string; diff --git a/tests/cases/fourslash/memberListOnExplicitThis.ts b/tests/cases/fourslash/memberListOnExplicitThis.ts index cf57717183c..207ec8796fa 100644 --- a/tests/cases/fourslash/memberListOnExplicitThis.ts +++ b/tests/cases/fourslash/memberListOnExplicitThis.ts @@ -1,4 +1,4 @@ -// @strictThis: true +// @strictThisChecks: true /// ////interface Restricted { diff --git a/tests/cases/fourslash/quickInfoOnThis.ts b/tests/cases/fourslash/quickInfoOnThis.ts index 57bbb6c5a3e..bfed13ea89c 100644 --- a/tests/cases/fourslash/quickInfoOnThis.ts +++ b/tests/cases/fourslash/quickInfoOnThis.ts @@ -1,4 +1,4 @@ -// @strictThis: true +// @strictThisChecks: true /// ////interface Restricted { //// n: number; @@ -93,4 +93,4 @@ verify.quickInfoIs('this: {\n n: number;\n}'); goTo.marker('16'); verify.quickInfoIs('this: ContextualInterface'); goTo.marker('17'); -verify.quickInfoIs('(parameter) this: void'); \ No newline at end of file +verify.quickInfoIs('(parameter) this: void'); From 07185c1c4a96230a783aa8a578318c6498ab8c5d Mon Sep 17 00:00:00 2001 From: zhengbli Date: Mon, 21 Mar 2016 12:55:55 -0700 Subject: [PATCH 29/48] Routine update of dom-related lib.d.ts --- src/lib/dom.generated.d.ts | 2219 ++++++++++++++++++++++-------- src/lib/webworker.generated.d.ts | 62 +- 2 files changed, 1666 insertions(+), 615 deletions(-) diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index ec71fa78e8d..59cd2675e7a 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -12,11 +12,6 @@ interface AriaRequestEventInit extends EventInit { attributeValue?: string; } -interface ClipboardEventInit extends EventInit { - data?: string; - dataType?: string; -} - interface CommandEventInit extends EventInit { commandName?: string; detail?: string; @@ -30,6 +25,31 @@ interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation arrayOfDomainStrings?: string[]; } +interface ConstrainBooleanParameters { + exact?: boolean; + ideal?: boolean; +} + +interface ConstrainDOMStringParameters { + exact?: string | string[]; + ideal?: string | string[]; +} + +interface ConstrainDoubleRange extends DoubleRange { + exact?: number; + ideal?: number; +} + +interface ConstrainLongRange extends LongRange { + exact?: number; + ideal?: number; +} + +interface ConstrainVideoFacingModeParameters { + exact?: string | string[]; + ideal?: string | string[]; +} + interface CustomEventInit extends EventInit { detail?: any; } @@ -40,17 +60,44 @@ interface DeviceAccelerationDict { z?: number; } +interface DeviceLightEventInit extends EventInit { + value?: number; +} + interface DeviceRotationRateDict { alpha?: number; beta?: number; gamma?: number; } +interface DoubleRange { + max?: number; + min?: number; +} + interface EventInit { bubbles?: boolean; cancelable?: boolean; } +interface EventModifierInit extends UIEventInit { + ctrlKey?: boolean; + shiftKey?: boolean; + altKey?: boolean; + metaKey?: boolean; + modifierAltGraph?: boolean; + modifierCapsLock?: boolean; + modifierFn?: boolean; + modifierFnLock?: boolean; + modifierHyper?: boolean; + modifierNumLock?: boolean; + modifierOS?: boolean; + modifierScrollLock?: boolean; + modifierSuper?: boolean; + modifierSymbol?: boolean; + modifierSymbolLock?: boolean; +} + interface ExceptionInformation { domain?: string; } @@ -64,17 +111,415 @@ interface HashChangeEventInit extends EventInit { oldURL?: string; } +interface IDBIndexParameters { + multiEntry?: boolean; + unique?: boolean; +} + +interface IDBObjectStoreParameters { + autoIncrement?: boolean; + keyPath?: IDBKeyPath; +} + interface KeyAlgorithm { name?: string; } -interface KeyboardEventInit extends SharedKeyboardAndMouseEventInit { +interface KeyboardEventInit extends EventModifierInit { key?: string; location?: number; repeat?: boolean; } -interface MouseEventInit extends SharedKeyboardAndMouseEventInit { +interface LongRange { + max?: number; + min?: number; +} + +interface MSAccountInfo { + rpDisplayName?: string; + userDisplayName?: string; + accountName?: string; + userId?: string; + accountImageUri?: string; +} + +interface MSAudioLocalClientEvent extends MSLocalClientEventBase { + networkSendQualityEventRatio?: number; + networkDelayEventRatio?: number; + cpuInsufficientEventRatio?: number; + deviceHalfDuplexAECEventRatio?: number; + deviceRenderNotFunctioningEventRatio?: number; + deviceCaptureNotFunctioningEventRatio?: number; + deviceGlitchesEventRatio?: number; + deviceLowSNREventRatio?: number; + deviceLowSpeechLevelEventRatio?: number; + deviceClippingEventRatio?: number; + deviceEchoEventRatio?: number; + deviceNearEndToEchoRatioEventRatio?: number; + deviceRenderZeroVolumeEventRatio?: number; + deviceRenderMuteEventRatio?: number; + deviceMultipleEndpointsEventCount?: number; + deviceHowlingEventCount?: number; +} + +interface MSAudioRecvPayload extends MSPayloadBase { + samplingRate?: number; + signal?: MSAudioRecvSignal; + packetReorderRatio?: number; + packetReorderDepthAvg?: number; + packetReorderDepthMax?: number; + burstLossLength1?: number; + burstLossLength2?: number; + burstLossLength3?: number; + burstLossLength4?: number; + burstLossLength5?: number; + burstLossLength6?: number; + burstLossLength7?: number; + burstLossLength8OrHigher?: number; + fecRecvDistance1?: number; + fecRecvDistance2?: number; + fecRecvDistance3?: number; + ratioConcealedSamplesAvg?: number; + ratioStretchedSamplesAvg?: number; + ratioCompressedSamplesAvg?: number; +} + +interface MSAudioRecvSignal { + initialSignalLevelRMS?: number; + recvSignalLevelCh1?: number; + recvNoiseLevelCh1?: number; + renderSignalLevel?: number; + renderNoiseLevel?: number; + renderLoopbackSignalLevel?: number; +} + +interface MSAudioSendPayload extends MSPayloadBase { + samplingRate?: number; + signal?: MSAudioSendSignal; + audioFECUsed?: boolean; + sendMutePercent?: number; +} + +interface MSAudioSendSignal { + noiseLevel?: number; + sendSignalLevelCh1?: number; + sendNoiseLevelCh1?: number; +} + +interface MSConnectivity { + iceType?: string; + iceWarningFlags?: MSIceWarningFlags; + relayAddress?: MSRelayAddress; +} + +interface MSCredentialFilter { + accept?: MSCredentialSpec[]; +} + +interface MSCredentialParameters { + type?: string; +} + +interface MSCredentialSpec { + type?: string; + id?: string; +} + +interface MSDelay { + roundTrip?: number; + roundTripMax?: number; +} + +interface MSDescription extends RTCStats { + connectivity?: MSConnectivity; + transport?: string; + networkconnectivity?: MSNetworkConnectivityInfo; + localAddr?: MSIPAddressInfo; + remoteAddr?: MSIPAddressInfo; + deviceDevName?: string; + reflexiveLocalIPAddr?: MSIPAddressInfo; +} + +interface MSFIDOCredentialParameters extends MSCredentialParameters { + algorithm?: string | Algorithm; + authenticators?: AAGUID[]; +} + +interface MSIPAddressInfo { + ipAddr?: string; + port?: number; + manufacturerMacAddrMask?: string; +} + +interface MSIceWarningFlags { + turnTcpTimedOut?: boolean; + turnUdpAllocateFailed?: boolean; + turnUdpSendFailed?: boolean; + turnTcpAllocateFailed?: boolean; + turnTcpSendFailed?: boolean; + udpLocalConnectivityFailed?: boolean; + udpNatConnectivityFailed?: boolean; + udpRelayConnectivityFailed?: boolean; + tcpNatConnectivityFailed?: boolean; + tcpRelayConnectivityFailed?: boolean; + connCheckMessageIntegrityFailed?: boolean; + allocationMessageIntegrityFailed?: boolean; + connCheckOtherError?: boolean; + turnAuthUnknownUsernameError?: boolean; + noRelayServersConfigured?: boolean; + multipleRelayServersAttempted?: boolean; + portRangeExhausted?: boolean; + alternateServerReceived?: boolean; + pseudoTLSFailure?: boolean; + turnTurnTcpConnectivityFailed?: boolean; + useCandidateChecksFailed?: boolean; + fipsAllocationFailure?: boolean; +} + +interface MSJitter { + interArrival?: number; + interArrivalMax?: number; + interArrivalSD?: number; +} + +interface MSLocalClientEventBase extends RTCStats { + networkReceiveQualityEventRatio?: number; + networkBandwidthLowEventRatio?: number; +} + +interface MSNetwork extends RTCStats { + jitter?: MSJitter; + delay?: MSDelay; + packetLoss?: MSPacketLoss; + utilization?: MSUtilization; +} + +interface MSNetworkConnectivityInfo { + vpn?: boolean; + linkspeed?: number; + networkConnectionDetails?: string; +} + +interface MSNetworkInterfaceType { + interfaceTypeEthernet?: boolean; + interfaceTypeWireless?: boolean; + interfaceTypePPP?: boolean; + interfaceTypeTunnel?: boolean; + interfaceTypeWWAN?: boolean; +} + +interface MSOutboundNetwork extends MSNetwork { + appliedBandwidthLimit?: number; +} + +interface MSPacketLoss { + lossRate?: number; + lossRateMax?: number; +} + +interface MSPayloadBase extends RTCStats { + payloadDescription?: string; +} + +interface MSRelayAddress { + relayAddress?: string; + port?: number; +} + +interface MSSignatureParameters { + userPrompt?: string; +} + +interface MSTransportDiagnosticsStats extends RTCStats { + baseAddress?: string; + localAddress?: string; + localSite?: string; + networkName?: string; + remoteAddress?: string; + remoteSite?: string; + localMR?: string; + remoteMR?: string; + iceWarningFlags?: MSIceWarningFlags; + portRangeMin?: number; + portRangeMax?: number; + localMRTCPPort?: number; + remoteMRTCPPort?: number; + stunVer?: number; + numConsentReqSent?: number; + numConsentReqReceived?: number; + numConsentRespSent?: number; + numConsentRespReceived?: number; + interfaces?: MSNetworkInterfaceType; + baseInterface?: MSNetworkInterfaceType; + protocol?: string; + localInterface?: MSNetworkInterfaceType; + localAddrType?: string; + remoteAddrType?: string; + iceRole?: string; + rtpRtcpMux?: boolean; + allocationTimeInMs?: number; + msRtcEngineVersion?: string; +} + +interface MSUtilization { + packets?: number; + bandwidthEstimation?: number; + bandwidthEstimationMin?: number; + bandwidthEstimationMax?: number; + bandwidthEstimationStdDev?: number; + bandwidthEstimationAvg?: number; +} + +interface MSVideoPayload extends MSPayloadBase { + resoluton?: string; + videoBitRateAvg?: number; + videoBitRateMax?: number; + videoFrameRateAvg?: number; + videoPacketLossRate?: number; + durationSeconds?: number; +} + +interface MSVideoRecvPayload extends MSVideoPayload { + videoFrameLossRate?: number; + recvCodecType?: string; + recvResolutionWidth?: number; + recvResolutionHeight?: number; + videoResolutions?: MSVideoResolutionDistribution; + recvFrameRateAverage?: number; + recvBitRateMaximum?: number; + recvBitRateAverage?: number; + recvVideoStreamsMax?: number; + recvVideoStreamsMin?: number; + recvVideoStreamsMode?: number; + videoPostFECPLR?: number; + lowBitRateCallPercent?: number; + lowFrameRateCallPercent?: number; + reorderBufferTotalPackets?: number; + recvReorderBufferReorderedPackets?: number; + recvReorderBufferPacketsDroppedDueToBufferExhaustion?: number; + recvReorderBufferMaxSuccessfullyOrderedExtent?: number; + recvReorderBufferMaxSuccessfullyOrderedLateTime?: number; + recvReorderBufferPacketsDroppedDueToTimeout?: number; + recvFpsHarmonicAverage?: number; + recvNumResSwitches?: number; +} + +interface MSVideoResolutionDistribution { + cifQuality?: number; + vgaQuality?: number; + h720Quality?: number; + h1080Quality?: number; + h1440Quality?: number; + h2160Quality?: number; +} + +interface MSVideoSendPayload extends MSVideoPayload { + sendFrameRateAverage?: number; + sendBitRateMaximum?: number; + sendBitRateAverage?: number; + sendVideoStreamsMax?: number; + sendResolutionWidth?: number; + sendResolutionHeight?: number; +} + +interface MediaEncryptedEventInit extends EventInit { + initDataType?: string; + initData?: ArrayBuffer; +} + +interface MediaKeyMessageEventInit extends EventInit { + messageType?: string; + message?: ArrayBuffer; +} + +interface MediaKeySystemConfiguration { + initDataTypes?: string[]; + audioCapabilities?: MediaKeySystemMediaCapability[]; + videoCapabilities?: MediaKeySystemMediaCapability[]; + distinctiveIdentifier?: string; + persistentState?: string; +} + +interface MediaKeySystemMediaCapability { + contentType?: string; + robustness?: string; +} + +interface MediaStreamConstraints { + video?: boolean | MediaTrackConstraints; + audio?: boolean | MediaTrackConstraints; +} + +interface MediaStreamErrorEventInit extends EventInit { + error?: MediaStreamError; +} + +interface MediaStreamTrackEventInit extends EventInit { + track?: MediaStreamTrack; +} + +interface MediaTrackCapabilities { + width?: number | LongRange; + height?: number | LongRange; + aspectRatio?: number | DoubleRange; + frameRate?: number | DoubleRange; + facingMode?: string; + volume?: number | DoubleRange; + sampleRate?: number | LongRange; + sampleSize?: number | LongRange; + echoCancellation?: boolean[]; + deviceId?: string; + groupId?: string; +} + +interface MediaTrackConstraintSet { + width?: number | ConstrainLongRange; + height?: number | ConstrainLongRange; + aspectRatio?: number | ConstrainDoubleRange; + frameRate?: number | ConstrainDoubleRange; + facingMode?: string | string[] | ConstrainDOMStringParameters; + volume?: number | ConstrainDoubleRange; + sampleRate?: number | ConstrainLongRange; + sampleSize?: number | ConstrainLongRange; + echoCancelation?: boolean | ConstrainBooleanParameters; + deviceId?: string | string[] | ConstrainDOMStringParameters; + groupId?: string | string[] | ConstrainDOMStringParameters; +} + +interface MediaTrackConstraints extends MediaTrackConstraintSet { + advanced?: MediaTrackConstraintSet[]; +} + +interface MediaTrackSettings { + width?: number; + height?: number; + aspectRatio?: number; + frameRate?: number; + facingMode?: string; + volume?: number; + sampleRate?: number; + sampleSize?: number; + echoCancellation?: boolean; + deviceId?: string; + groupId?: string; +} + +interface MediaTrackSupportedConstraints { + width?: boolean; + height?: boolean; + aspectRatio?: boolean; + frameRate?: boolean; + facingMode?: boolean; + volume?: boolean; + sampleRate?: boolean; + sampleSize?: boolean; + echoCancellation?: boolean; + deviceId?: boolean; + groupId?: boolean; +} + +interface MouseEventInit extends EventModifierInit { screenX?: number; screenY?: number; clientX?: number; @@ -107,6 +552,10 @@ interface ObjectURLOptions { oneTimeOnly?: boolean; } +interface PeriodicWaveConstraints { + disableNormalization?: boolean; +} + interface PointerEventInit extends MouseEventInit { pointerId?: number; width?: number; @@ -124,22 +573,266 @@ interface PositionOptions { maximumAge?: number; } -interface SharedKeyboardAndMouseEventInit extends UIEventInit { - ctrlKey?: boolean; - shiftKey?: boolean; - altKey?: boolean; - metaKey?: boolean; - keyModifierStateAltGraph?: boolean; - keyModifierStateCapsLock?: boolean; - keyModifierStateFn?: boolean; - keyModifierStateFnLock?: boolean; - keyModifierStateHyper?: boolean; - keyModifierStateNumLock?: boolean; - keyModifierStateOS?: boolean; - keyModifierStateScrollLock?: boolean; - keyModifierStateSuper?: boolean; - keyModifierStateSymbol?: boolean; - keyModifierStateSymbolLock?: boolean; +interface RTCDTMFToneChangeEventInit extends EventInit { + tone?: string; +} + +interface RTCDtlsFingerprint { + algorithm?: string; + value?: string; +} + +interface RTCDtlsParameters { + role?: string; + fingerprints?: RTCDtlsFingerprint[]; +} + +interface RTCIceCandidate { + foundation?: string; + priority?: number; + ip?: string; + protocol?: string; + port?: number; + type?: string; + tcpType?: string; + relatedAddress?: string; + relatedPort?: number; +} + +interface RTCIceCandidateAttributes extends RTCStats { + ipAddress?: string; + portNumber?: number; + transport?: string; + candidateType?: string; + priority?: number; + addressSourceUrl?: string; +} + +interface RTCIceCandidateComplete { +} + +interface RTCIceCandidatePair { + local?: RTCIceCandidate; + remote?: RTCIceCandidate; +} + +interface RTCIceCandidatePairStats extends RTCStats { + transportId?: string; + localCandidateId?: string; + remoteCandidateId?: string; + state?: string; + priority?: number; + nominated?: boolean; + writable?: boolean; + readable?: boolean; + bytesSent?: number; + bytesReceived?: number; + roundTripTime?: number; + availableOutgoingBitrate?: number; + availableIncomingBitrate?: number; +} + +interface RTCIceGatherOptions { + gatherPolicy?: string; + iceservers?: RTCIceServer[]; +} + +interface RTCIceParameters { + usernameFragment?: string; + password?: string; +} + +interface RTCIceServer { + urls?: any; + username?: string; + credential?: string; +} + +interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { + packetsReceived?: number; + bytesReceived?: number; + packetsLost?: number; + jitter?: number; + fractionLost?: number; +} + +interface RTCMediaStreamTrackStats extends RTCStats { + trackIdentifier?: string; + remoteSource?: boolean; + ssrcIds?: string[]; + frameWidth?: number; + frameHeight?: number; + framesPerSecond?: number; + framesSent?: number; + framesReceived?: number; + framesDecoded?: number; + framesDropped?: number; + framesCorrupted?: number; + audioLevel?: number; + echoReturnLoss?: number; + echoReturnLossEnhancement?: number; +} + +interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { + packetsSent?: number; + bytesSent?: number; + targetBitrate?: number; + roundTripTime?: number; +} + +interface RTCRTPStreamStats extends RTCStats { + ssrc?: string; + associateStatsId?: string; + isRemote?: boolean; + mediaTrackId?: string; + transportId?: string; + codecId?: string; + firCount?: number; + pliCount?: number; + nackCount?: number; + sliCount?: number; +} + +interface RTCRtcpFeedback { + type?: string; + parameter?: string; +} + +interface RTCRtcpParameters { + ssrc?: number; + cname?: string; + reducedSize?: boolean; + mux?: boolean; +} + +interface RTCRtpCapabilities { + codecs?: RTCRtpCodecCapability[]; + headerExtensions?: RTCRtpHeaderExtension[]; + fecMechanisms?: string[]; +} + +interface RTCRtpCodecCapability { + name?: string; + kind?: string; + clockRate?: number; + preferredPayloadType?: number; + maxptime?: number; + numChannels?: number; + rtcpFeedback?: RTCRtcpFeedback[]; + parameters?: any; + options?: any; + maxTemporalLayers?: number; + maxSpatialLayers?: number; + svcMultiStreamSupport?: boolean; +} + +interface RTCRtpCodecParameters { + name?: string; + payloadType?: any; + clockRate?: number; + maxptime?: number; + numChannels?: number; + rtcpFeedback?: RTCRtcpFeedback[]; + parameters?: any; +} + +interface RTCRtpContributingSource { + timestamp?: number; + csrc?: number; + audioLevel?: number; +} + +interface RTCRtpEncodingParameters { + ssrc?: number; + codecPayloadType?: number; + fec?: RTCRtpFecParameters; + rtx?: RTCRtpRtxParameters; + priority?: number; + maxBitrate?: number; + minQuality?: number; + framerateBias?: number; + resolutionScale?: number; + framerateScale?: number; + active?: boolean; + encodingId?: string; + dependencyEncodingIds?: string[]; + ssrcRange?: RTCSsrcRange; +} + +interface RTCRtpFecParameters { + ssrc?: number; + mechanism?: string; +} + +interface RTCRtpHeaderExtension { + kind?: string; + uri?: string; + preferredId?: number; + preferredEncrypt?: boolean; +} + +interface RTCRtpHeaderExtensionParameters { + uri?: string; + id?: number; + encrypt?: boolean; +} + +interface RTCRtpParameters { + muxId?: string; + codecs?: RTCRtpCodecParameters[]; + headerExtensions?: RTCRtpHeaderExtensionParameters[]; + encodings?: RTCRtpEncodingParameters[]; + rtcp?: RTCRtcpParameters; +} + +interface RTCRtpRtxParameters { + ssrc?: number; +} + +interface RTCRtpUnhandled { + ssrc?: number; + payloadType?: number; + muxId?: string; +} + +interface RTCSrtpKeyParam { + keyMethod?: string; + keySalt?: string; + lifetime?: string; + mkiValue?: number; + mkiLength?: number; +} + +interface RTCSrtpSdesParameters { + tag?: number; + cryptoSuite?: string; + keyParams?: RTCSrtpKeyParam[]; + sessionParams?: string[]; +} + +interface RTCSsrcRange { + min?: number; + max?: number; +} + +interface RTCStats { + timestamp?: number; + type?: string; + id?: string; + msType?: string; +} + +interface RTCStatsReport { +} + +interface RTCTransportStats extends RTCStats { + bytesSent?: number; + bytesReceived?: number; + rtcpTransportStatsId?: string; + activeConnection?: boolean; + selectedCandidatePairId?: string; + localCertificateId?: string; + remoteCertificateId?: string; } interface StoreExceptionsInformation extends ExceptionInformation { @@ -276,6 +969,7 @@ declare var AriaRequestEvent: { interface Attr extends Node { name: string; ownerElement: Element; + prefix: string; specified: boolean; value: string; } @@ -290,6 +984,8 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; + copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void; + copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void; getChannelData(channel: number): Float32Array; } @@ -300,14 +996,15 @@ declare var AudioBuffer: { interface AudioBufferSourceNode extends AudioNode { buffer: AudioBuffer; + detune: AudioParam; loop: boolean; loopEnd: number; loopStart: number; - onended: (ev: Event) => any; + onended: (ev: MediaStreamErrorEvent) => any; playbackRate: AudioParam; start(when?: number, offset?: number, duration?: number): void; stop(when?: number): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -333,13 +1030,14 @@ interface AudioContext extends EventTarget { createDynamicsCompressor(): DynamicsCompressorNode; createGain(): GainNode; createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; + createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array, constraints?: PeriodicWaveConstraints): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; - decodeAudioData(audioData: ArrayBuffer, successCallback: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): void; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): PromiseLike; } declare var AudioContext: { @@ -525,8 +1223,8 @@ declare var CSSFontFaceRule: { interface CSSGroupingRule extends CSSRule { cssRules: CSSRuleList; - deleteRule(index?: number): void; - insertRule(rule: string, index?: number): number; + deleteRule(index: number): void; + insertRule(rule: string, index: number): number; } declare var CSSGroupingRule: { @@ -881,7 +1579,6 @@ interface CSSStyleDeclaration { textAlignLast: string; textAnchor: string; textDecoration: string; - textFillColor: string; textIndent: string; textJustify: string; textKashida: string; @@ -917,25 +1614,12 @@ interface CSSStyleDeclaration { webkitAnimationTimingFunction: string; webkitAppearance: string; webkitBackfaceVisibility: string; - webkitBackground: string; - webkitBackgroundAttachment: string; webkitBackgroundClip: string; - webkitBackgroundColor: string; - webkitBackgroundImage: string; webkitBackgroundOrigin: string; - webkitBackgroundPosition: string; - webkitBackgroundPositionX: string; - webkitBackgroundPositionY: string; - webkitBackgroundRepeat: string; webkitBackgroundSize: string; webkitBorderBottomLeftRadius: string; webkitBorderBottomRightRadius: string; webkitBorderImage: string; - webkitBorderImageOutset: string; - webkitBorderImageRepeat: string; - webkitBorderImageSlice: string; - webkitBorderImageSource: string; - webkitBorderImageWidth: string; webkitBorderRadius: string; webkitBorderTopLeftRadius: string; webkitBorderTopRightRadius: string; @@ -981,6 +1665,7 @@ interface CSSStyleDeclaration { webkitTransitionDuration: string; webkitTransitionProperty: string; webkitTransitionTimingFunction: string; + webkitUserModify: string; webkitUserSelect: string; webkitWritingMode: string; whiteSpace: string; @@ -1068,7 +1753,7 @@ declare var CanvasPattern: { new(): CanvasPattern; } -interface CanvasRenderingContext2D { +interface CanvasRenderingContext2D extends Object, CanvasPathMethods { canvas: HTMLCanvasElement; fillStyle: string | CanvasGradient | CanvasPattern; font: string; @@ -1088,13 +1773,9 @@ interface CanvasRenderingContext2D { strokeStyle: string | CanvasGradient | CanvasPattern; textAlign: string; textBaseline: string; - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; beginPath(): void; - bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; clearRect(x: number, y: number, w: number, h: number): void; clip(fillRule?: string): void; - closePath(): void; createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; @@ -1106,12 +1787,8 @@ interface CanvasRenderingContext2D { getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; getLineDash(): number[]; isPointInPath(x: number, y: number, fillRule?: string): boolean; - lineTo(x: number, y: number): void; measureText(text: string): TextMetrics; - moveTo(x: number, y: number): void; putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; - quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; - rect(x: number, y: number, w: number, h: number): void; restore(): void; rotate(angle: number): void; save(): void; @@ -1246,6 +1923,7 @@ interface Console { dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; + exception(message?: string, ...optionalParams: any[]): void; group(groupTitle?: string): void; groupCollapsed(groupTitle?: string): void; groupEnd(): void; @@ -1255,6 +1933,7 @@ interface Console { profile(reportName?: string): void; profileEnd(): void; select(element: Element): void; + table(...data: any[]): void; time(timerName?: string): void; timeEnd(timerName?: string): void; trace(message?: any, ...optionalParams: any[]): void; @@ -1559,6 +2238,15 @@ declare var DeviceAcceleration: { new(): DeviceAcceleration; } +interface DeviceLightEvent extends Event { + value: number; +} + +declare var DeviceLightEvent: { + prototype: DeviceLightEvent; + new(type: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; +} + interface DeviceMotionEvent extends Event { acceleration: DeviceAcceleration; accelerationIncludingGravity: DeviceAcceleration; @@ -1616,7 +2304,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven /** * Returns a reference to the collection of elements contained by the object. */ - all: HTMLCollection; + all: HTMLAllCollection; /** * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. */ @@ -1643,6 +2331,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ compatMode: string; cookie: string; + currentScript: HTMLScriptElement | SVGScriptElement; /** * Gets the default character set from the current regional language settings. */ @@ -1712,11 +2401,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Contains information about the current URL. */ location: Location; - media: string; msCSSOMElementFloatMetrics: boolean; msCapsLockWarningOff: boolean; - msHidden: boolean; - msVisibilityState: string; /** * Fires when the user aborts the download. * @param ev The event. @@ -1818,7 +2504,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Occurs when the end of playback is reached. * @param ev The event */ - onended: (ev: Event) => any; + onended: (ev: MediaStreamErrorEvent) => any; /** * Fires when an error occurs during object loading. * @param ev The event. @@ -1832,6 +2518,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven onfullscreenchange: (ev: Event) => any; onfullscreenerror: (ev: Event) => any; oninput: (ev: Event) => any; + oninvalid: (ev: Event) => any; /** * Fires when the user presses a key. * @param ev The keyboard event @@ -1896,7 +2583,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Fires when the wheel button is rotated. * @param ev The mouse event */ - onmousewheel: (ev: MouseWheelEvent) => any; + onmousewheel: (ev: WheelEvent) => any; onmscontentzoom: (ev: UIEvent) => any; onmsgesturechange: (ev: MSGestureEvent) => any; onmsgesturedoubletap: (ev: MSGestureEvent) => any; @@ -1981,6 +2668,11 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param ev The event. */ onselect: (ev: UIEvent) => any; + /** + * Fires when the selection state of a document changes. + * @param ev The event. + */ + onselectionchange: (ev: Event) => any; onselectstart: (ev: Event) => any; /** * Occurs when the download has stopped. @@ -2037,7 +2729,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Retrieves a collection of all script objects in the document. */ scripts: HTMLCollection; - security: string; + scrollingElement: Element; /** * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. */ @@ -2061,9 +2753,9 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Gets or sets the version attribute specified in the declaration of an XML document. */ xmlVersion: string; - currentScript: HTMLScriptElement; adoptNode(source: Node): Node; captureEvents(): void; + caretRangeFromPoint(x: number, y: number): Range; clear(): void; /** * Closes an output stream and forces the sent data to display. @@ -2090,37 +2782,24 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param tagName The name of an element. */ createElement(tagName: "a"): HTMLAnchorElement; - createElement(tagName: "abbr"): HTMLPhraseElement; - createElement(tagName: "acronym"): HTMLPhraseElement; - createElement(tagName: "address"): HTMLBlockElement; createElement(tagName: "applet"): HTMLAppletElement; createElement(tagName: "area"): HTMLAreaElement; createElement(tagName: "audio"): HTMLAudioElement; - createElement(tagName: "b"): HTMLPhraseElement; createElement(tagName: "base"): HTMLBaseElement; createElement(tagName: "basefont"): HTMLBaseFontElement; - createElement(tagName: "bdo"): HTMLPhraseElement; - createElement(tagName: "big"): HTMLPhraseElement; - createElement(tagName: "blockquote"): HTMLBlockElement; + createElement(tagName: "blockquote"): HTMLQuoteElement; createElement(tagName: "body"): HTMLBodyElement; createElement(tagName: "br"): HTMLBRElement; createElement(tagName: "button"): HTMLButtonElement; createElement(tagName: "canvas"): HTMLCanvasElement; createElement(tagName: "caption"): HTMLTableCaptionElement; - createElement(tagName: "center"): HTMLBlockElement; - createElement(tagName: "cite"): HTMLPhraseElement; - createElement(tagName: "code"): HTMLPhraseElement; createElement(tagName: "col"): HTMLTableColElement; createElement(tagName: "colgroup"): HTMLTableColElement; createElement(tagName: "datalist"): HTMLDataListElement; - createElement(tagName: "dd"): HTMLDDElement; createElement(tagName: "del"): HTMLModElement; - createElement(tagName: "dfn"): HTMLPhraseElement; createElement(tagName: "dir"): HTMLDirectoryElement; createElement(tagName: "div"): HTMLDivElement; createElement(tagName: "dl"): HTMLDListElement; - createElement(tagName: "dt"): HTMLDTElement; - createElement(tagName: "em"): HTMLPhraseElement; createElement(tagName: "embed"): HTMLEmbedElement; createElement(tagName: "fieldset"): HTMLFieldSetElement; createElement(tagName: "font"): HTMLFontElement; @@ -2136,52 +2815,41 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createElement(tagName: "head"): HTMLHeadElement; createElement(tagName: "hr"): HTMLHRElement; createElement(tagName: "html"): HTMLHtmlElement; - createElement(tagName: "i"): HTMLPhraseElement; createElement(tagName: "iframe"): HTMLIFrameElement; createElement(tagName: "img"): HTMLImageElement; createElement(tagName: "input"): HTMLInputElement; createElement(tagName: "ins"): HTMLModElement; - createElement(tagName: "isindex"): HTMLIsIndexElement; - createElement(tagName: "kbd"): HTMLPhraseElement; - createElement(tagName: "keygen"): HTMLBlockElement; + createElement(tagName: "isindex"): HTMLUnknownElement; createElement(tagName: "label"): HTMLLabelElement; createElement(tagName: "legend"): HTMLLegendElement; createElement(tagName: "li"): HTMLLIElement; createElement(tagName: "link"): HTMLLinkElement; - createElement(tagName: "listing"): HTMLBlockElement; + createElement(tagName: "listing"): HTMLPreElement; createElement(tagName: "map"): HTMLMapElement; createElement(tagName: "marquee"): HTMLMarqueeElement; createElement(tagName: "menu"): HTMLMenuElement; createElement(tagName: "meta"): HTMLMetaElement; - createElement(tagName: "nextid"): HTMLNextIdElement; - createElement(tagName: "nobr"): HTMLPhraseElement; + createElement(tagName: "meter"): HTMLMeterElement; + createElement(tagName: "nextid"): HTMLUnknownElement; createElement(tagName: "object"): HTMLObjectElement; createElement(tagName: "ol"): HTMLOListElement; createElement(tagName: "optgroup"): HTMLOptGroupElement; createElement(tagName: "option"): HTMLOptionElement; createElement(tagName: "p"): HTMLParagraphElement; createElement(tagName: "param"): HTMLParamElement; - createElement(tagName: "plaintext"): HTMLBlockElement; + createElement(tagName: "picture"): HTMLPictureElement; createElement(tagName: "pre"): HTMLPreElement; createElement(tagName: "progress"): HTMLProgressElement; createElement(tagName: "q"): HTMLQuoteElement; - createElement(tagName: "rt"): HTMLPhraseElement; - createElement(tagName: "ruby"): HTMLPhraseElement; - createElement(tagName: "s"): HTMLPhraseElement; - createElement(tagName: "samp"): HTMLPhraseElement; createElement(tagName: "script"): HTMLScriptElement; createElement(tagName: "select"): HTMLSelectElement; - createElement(tagName: "small"): HTMLPhraseElement; createElement(tagName: "source"): HTMLSourceElement; createElement(tagName: "span"): HTMLSpanElement; - createElement(tagName: "strike"): HTMLPhraseElement; - createElement(tagName: "strong"): HTMLPhraseElement; createElement(tagName: "style"): HTMLStyleElement; - createElement(tagName: "sub"): HTMLPhraseElement; - createElement(tagName: "sup"): HTMLPhraseElement; createElement(tagName: "table"): HTMLTableElement; createElement(tagName: "tbody"): HTMLTableSectionElement; createElement(tagName: "td"): HTMLTableDataCellElement; + createElement(tagName: "template"): HTMLTemplateElement; createElement(tagName: "textarea"): HTMLTextAreaElement; createElement(tagName: "tfoot"): HTMLTableSectionElement; createElement(tagName: "th"): HTMLTableHeaderCellElement; @@ -2189,13 +2857,10 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createElement(tagName: "title"): HTMLTitleElement; createElement(tagName: "tr"): HTMLTableRowElement; createElement(tagName: "track"): HTMLTrackElement; - createElement(tagName: "tt"): HTMLPhraseElement; - createElement(tagName: "u"): HTMLPhraseElement; createElement(tagName: "ul"): HTMLUListElement; - createElement(tagName: "var"): HTMLPhraseElement; createElement(tagName: "video"): HTMLVideoElement; createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; - createElement(tagName: "xmp"): HTMLBlockElement; + createElement(tagName: "xmp"): HTMLPreElement; createElement(tagName: string): HTMLElement; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement @@ -2280,7 +2945,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param data String that specifies the nodeValue property of the text node. */ createTextNode(data: string): Text; - createTouch(view: any, target: EventTarget, identifier: number, pageX: number, pageY: number, screenX: number, screenY: number): Touch; + createTouch(view: Window, target: EventTarget, identifier: number, pageX: number, pageY: number, screenX: number, screenY: number): Touch; createTouchList(...touches: Touch[]): TouchList; /** * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. @@ -2331,44 +2996,44 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param name Specifies the name of an element. */ getElementsByTagName(tagname: "a"): NodeListOf; - getElementsByTagName(tagname: "abbr"): NodeListOf; - getElementsByTagName(tagname: "acronym"): NodeListOf; - getElementsByTagName(tagname: "address"): NodeListOf; + getElementsByTagName(tagname: "abbr"): NodeListOf; + getElementsByTagName(tagname: "acronym"): NodeListOf; + getElementsByTagName(tagname: "address"): NodeListOf; getElementsByTagName(tagname: "applet"): NodeListOf; getElementsByTagName(tagname: "area"): NodeListOf; getElementsByTagName(tagname: "article"): NodeListOf; getElementsByTagName(tagname: "aside"): NodeListOf; getElementsByTagName(tagname: "audio"): NodeListOf; - getElementsByTagName(tagname: "b"): NodeListOf; + getElementsByTagName(tagname: "b"): NodeListOf; getElementsByTagName(tagname: "base"): NodeListOf; getElementsByTagName(tagname: "basefont"): NodeListOf; - getElementsByTagName(tagname: "bdo"): NodeListOf; - getElementsByTagName(tagname: "big"): NodeListOf; - getElementsByTagName(tagname: "blockquote"): NodeListOf; + getElementsByTagName(tagname: "bdo"): NodeListOf; + getElementsByTagName(tagname: "big"): NodeListOf; + getElementsByTagName(tagname: "blockquote"): NodeListOf; getElementsByTagName(tagname: "body"): NodeListOf; getElementsByTagName(tagname: "br"): NodeListOf; getElementsByTagName(tagname: "button"): NodeListOf; getElementsByTagName(tagname: "canvas"): NodeListOf; getElementsByTagName(tagname: "caption"): NodeListOf; - getElementsByTagName(tagname: "center"): NodeListOf; + getElementsByTagName(tagname: "center"): NodeListOf; getElementsByTagName(tagname: "circle"): NodeListOf; - getElementsByTagName(tagname: "cite"): NodeListOf; + getElementsByTagName(tagname: "cite"): NodeListOf; getElementsByTagName(tagname: "clippath"): NodeListOf; - getElementsByTagName(tagname: "code"): NodeListOf; + getElementsByTagName(tagname: "code"): NodeListOf; getElementsByTagName(tagname: "col"): NodeListOf; getElementsByTagName(tagname: "colgroup"): NodeListOf; getElementsByTagName(tagname: "datalist"): NodeListOf; - getElementsByTagName(tagname: "dd"): NodeListOf; + getElementsByTagName(tagname: "dd"): NodeListOf; getElementsByTagName(tagname: "defs"): NodeListOf; getElementsByTagName(tagname: "del"): NodeListOf; getElementsByTagName(tagname: "desc"): NodeListOf; - getElementsByTagName(tagname: "dfn"): NodeListOf; + getElementsByTagName(tagname: "dfn"): NodeListOf; getElementsByTagName(tagname: "dir"): NodeListOf; getElementsByTagName(tagname: "div"): NodeListOf; getElementsByTagName(tagname: "dl"): NodeListOf; - getElementsByTagName(tagname: "dt"): NodeListOf; + getElementsByTagName(tagname: "dt"): NodeListOf; getElementsByTagName(tagname: "ellipse"): NodeListOf; - getElementsByTagName(tagname: "em"): NodeListOf; + getElementsByTagName(tagname: "em"): NodeListOf; getElementsByTagName(tagname: "embed"): NodeListOf; getElementsByTagName(tagname: "feblend"): NodeListOf; getElementsByTagName(tagname: "fecolormatrix"): NodeListOf; @@ -2416,22 +3081,22 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "hgroup"): NodeListOf; getElementsByTagName(tagname: "hr"): NodeListOf; getElementsByTagName(tagname: "html"): NodeListOf; - getElementsByTagName(tagname: "i"): NodeListOf; + getElementsByTagName(tagname: "i"): NodeListOf; getElementsByTagName(tagname: "iframe"): NodeListOf; getElementsByTagName(tagname: "image"): NodeListOf; getElementsByTagName(tagname: "img"): NodeListOf; getElementsByTagName(tagname: "input"): NodeListOf; getElementsByTagName(tagname: "ins"): NodeListOf; - getElementsByTagName(tagname: "isindex"): NodeListOf; - getElementsByTagName(tagname: "kbd"): NodeListOf; - getElementsByTagName(tagname: "keygen"): NodeListOf; + getElementsByTagName(tagname: "isindex"): NodeListOf; + getElementsByTagName(tagname: "kbd"): NodeListOf; + getElementsByTagName(tagname: "keygen"): NodeListOf; getElementsByTagName(tagname: "label"): NodeListOf; getElementsByTagName(tagname: "legend"): NodeListOf; getElementsByTagName(tagname: "li"): NodeListOf; getElementsByTagName(tagname: "line"): NodeListOf; getElementsByTagName(tagname: "lineargradient"): NodeListOf; getElementsByTagName(tagname: "link"): NodeListOf; - getElementsByTagName(tagname: "listing"): NodeListOf; + getElementsByTagName(tagname: "listing"): NodeListOf; getElementsByTagName(tagname: "map"): NodeListOf; getElementsByTagName(tagname: "mark"): NodeListOf; getElementsByTagName(tagname: "marker"): NodeListOf; @@ -2440,9 +3105,10 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "menu"): NodeListOf; getElementsByTagName(tagname: "meta"): NodeListOf; getElementsByTagName(tagname: "metadata"): NodeListOf; + getElementsByTagName(tagname: "meter"): NodeListOf; getElementsByTagName(tagname: "nav"): NodeListOf; - getElementsByTagName(tagname: "nextid"): NodeListOf; - getElementsByTagName(tagname: "nobr"): NodeListOf; + getElementsByTagName(tagname: "nextid"): NodeListOf; + getElementsByTagName(tagname: "nobr"): NodeListOf; getElementsByTagName(tagname: "noframes"): NodeListOf; getElementsByTagName(tagname: "noscript"): NodeListOf; getElementsByTagName(tagname: "object"): NodeListOf; @@ -2453,7 +3119,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "param"): NodeListOf; getElementsByTagName(tagname: "path"): NodeListOf; getElementsByTagName(tagname: "pattern"): NodeListOf; - getElementsByTagName(tagname: "plaintext"): NodeListOf; + getElementsByTagName(tagname: "picture"): NodeListOf; + getElementsByTagName(tagname: "plaintext"): NodeListOf; getElementsByTagName(tagname: "polygon"): NodeListOf; getElementsByTagName(tagname: "polyline"): NodeListOf; getElementsByTagName(tagname: "pre"): NodeListOf; @@ -2461,28 +3128,29 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "q"): NodeListOf; getElementsByTagName(tagname: "radialgradient"): NodeListOf; getElementsByTagName(tagname: "rect"): NodeListOf; - getElementsByTagName(tagname: "rt"): NodeListOf; - getElementsByTagName(tagname: "ruby"): NodeListOf; - getElementsByTagName(tagname: "s"): NodeListOf; - getElementsByTagName(tagname: "samp"): NodeListOf; + getElementsByTagName(tagname: "rt"): NodeListOf; + getElementsByTagName(tagname: "ruby"): NodeListOf; + getElementsByTagName(tagname: "s"): NodeListOf; + getElementsByTagName(tagname: "samp"): NodeListOf; getElementsByTagName(tagname: "script"): NodeListOf; getElementsByTagName(tagname: "section"): NodeListOf; getElementsByTagName(tagname: "select"): NodeListOf; - getElementsByTagName(tagname: "small"): NodeListOf; + getElementsByTagName(tagname: "small"): NodeListOf; getElementsByTagName(tagname: "source"): NodeListOf; getElementsByTagName(tagname: "span"): NodeListOf; getElementsByTagName(tagname: "stop"): NodeListOf; - getElementsByTagName(tagname: "strike"): NodeListOf; - getElementsByTagName(tagname: "strong"): NodeListOf; + getElementsByTagName(tagname: "strike"): NodeListOf; + getElementsByTagName(tagname: "strong"): NodeListOf; getElementsByTagName(tagname: "style"): NodeListOf; - getElementsByTagName(tagname: "sub"): NodeListOf; - getElementsByTagName(tagname: "sup"): NodeListOf; + getElementsByTagName(tagname: "sub"): NodeListOf; + getElementsByTagName(tagname: "sup"): NodeListOf; getElementsByTagName(tagname: "svg"): NodeListOf; getElementsByTagName(tagname: "switch"): NodeListOf; getElementsByTagName(tagname: "symbol"): NodeListOf; getElementsByTagName(tagname: "table"): NodeListOf; getElementsByTagName(tagname: "tbody"): NodeListOf; getElementsByTagName(tagname: "td"): NodeListOf; + getElementsByTagName(tagname: "template"): NodeListOf; getElementsByTagName(tagname: "text"): NodeListOf; getElementsByTagName(tagname: "textpath"): NodeListOf; getElementsByTagName(tagname: "textarea"): NodeListOf; @@ -2493,16 +3161,16 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "tr"): NodeListOf; getElementsByTagName(tagname: "track"): NodeListOf; getElementsByTagName(tagname: "tspan"): NodeListOf; - getElementsByTagName(tagname: "tt"): NodeListOf; - getElementsByTagName(tagname: "u"): NodeListOf; + getElementsByTagName(tagname: "tt"): NodeListOf; + getElementsByTagName(tagname: "u"): NodeListOf; getElementsByTagName(tagname: "ul"): NodeListOf; getElementsByTagName(tagname: "use"): NodeListOf; - getElementsByTagName(tagname: "var"): NodeListOf; + getElementsByTagName(tagname: "var"): NodeListOf; getElementsByTagName(tagname: "video"): NodeListOf; getElementsByTagName(tagname: "view"): NodeListOf; getElementsByTagName(tagname: "wbr"): NodeListOf; getElementsByTagName(tagname: "x-ms-webview"): NodeListOf; - getElementsByTagName(tagname: "xmp"): NodeListOf; + getElementsByTagName(tagname: "xmp"): NodeListOf; getElementsByTagName(tagname: string): NodeListOf; getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; /** @@ -2611,12 +3279,13 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "fullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "fullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -2629,7 +3298,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -2653,6 +3322,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectionchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -2725,6 +3395,14 @@ declare var DynamicsCompressorNode: { new(): DynamicsCompressorNode; } +interface EXT_frag_depth { +} + +declare var EXT_frag_depth: { + prototype: EXT_frag_depth; + new(): EXT_frag_depth; +} + interface EXT_texture_filter_anisotropic { MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; TEXTURE_MAX_ANISOTROPY_EXT: number; @@ -2739,10 +3417,12 @@ declare var EXT_texture_filter_anisotropic: { interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode { classList: DOMTokenList; + className: string; clientHeight: number; clientLeft: number; clientTop: number; clientWidth: number; + id: string; msContentZoomFactor: number; msRegionOverflow: string; onariarequest: (ev: AriaRequestEvent) => any; @@ -2772,13 +3452,12 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (ev: Event) => any; onwebkitfullscreenerror: (ev: Event) => any; + prefix: string; scrollHeight: number; scrollLeft: number; scrollTop: number; scrollWidth: number; tagName: string; - id: string; - className: string; innerHTML: string; getAttribute(name?: string): string; getAttributeNS(namespaceURI: string, localName: string): string; @@ -2787,44 +3466,44 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getBoundingClientRect(): ClientRect; getClientRects(): ClientRectList; getElementsByTagName(name: "a"): NodeListOf; - getElementsByTagName(name: "abbr"): NodeListOf; - getElementsByTagName(name: "acronym"): NodeListOf; - getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "acronym"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; getElementsByTagName(name: "applet"): NodeListOf; getElementsByTagName(name: "area"): NodeListOf; getElementsByTagName(name: "article"): NodeListOf; getElementsByTagName(name: "aside"): NodeListOf; getElementsByTagName(name: "audio"): NodeListOf; - getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; getElementsByTagName(name: "base"): NodeListOf; getElementsByTagName(name: "basefont"): NodeListOf; - getElementsByTagName(name: "bdo"): NodeListOf; - getElementsByTagName(name: "big"): NodeListOf; - getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "big"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; getElementsByTagName(name: "body"): NodeListOf; getElementsByTagName(name: "br"): NodeListOf; getElementsByTagName(name: "button"): NodeListOf; getElementsByTagName(name: "canvas"): NodeListOf; getElementsByTagName(name: "caption"): NodeListOf; - getElementsByTagName(name: "center"): NodeListOf; + getElementsByTagName(name: "center"): NodeListOf; getElementsByTagName(name: "circle"): NodeListOf; - getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; getElementsByTagName(name: "clippath"): NodeListOf; - getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; getElementsByTagName(name: "col"): NodeListOf; getElementsByTagName(name: "colgroup"): NodeListOf; getElementsByTagName(name: "datalist"): NodeListOf; - getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; getElementsByTagName(name: "defs"): NodeListOf; getElementsByTagName(name: "del"): NodeListOf; getElementsByTagName(name: "desc"): NodeListOf; - getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; getElementsByTagName(name: "dir"): NodeListOf; getElementsByTagName(name: "div"): NodeListOf; getElementsByTagName(name: "dl"): NodeListOf; - getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; getElementsByTagName(name: "ellipse"): NodeListOf; - getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; getElementsByTagName(name: "embed"): NodeListOf; getElementsByTagName(name: "feblend"): NodeListOf; getElementsByTagName(name: "fecolormatrix"): NodeListOf; @@ -2872,22 +3551,22 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "hgroup"): NodeListOf; getElementsByTagName(name: "hr"): NodeListOf; getElementsByTagName(name: "html"): NodeListOf; - getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; getElementsByTagName(name: "iframe"): NodeListOf; getElementsByTagName(name: "image"): NodeListOf; getElementsByTagName(name: "img"): NodeListOf; getElementsByTagName(name: "input"): NodeListOf; getElementsByTagName(name: "ins"): NodeListOf; - getElementsByTagName(name: "isindex"): NodeListOf; - getElementsByTagName(name: "kbd"): NodeListOf; - getElementsByTagName(name: "keygen"): NodeListOf; + getElementsByTagName(name: "isindex"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "keygen"): NodeListOf; getElementsByTagName(name: "label"): NodeListOf; getElementsByTagName(name: "legend"): NodeListOf; getElementsByTagName(name: "li"): NodeListOf; getElementsByTagName(name: "line"): NodeListOf; getElementsByTagName(name: "lineargradient"): NodeListOf; getElementsByTagName(name: "link"): NodeListOf; - getElementsByTagName(name: "listing"): NodeListOf; + getElementsByTagName(name: "listing"): NodeListOf; getElementsByTagName(name: "map"): NodeListOf; getElementsByTagName(name: "mark"): NodeListOf; getElementsByTagName(name: "marker"): NodeListOf; @@ -2896,9 +3575,10 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "menu"): NodeListOf; getElementsByTagName(name: "meta"): NodeListOf; getElementsByTagName(name: "metadata"): NodeListOf; + getElementsByTagName(name: "meter"): NodeListOf; getElementsByTagName(name: "nav"): NodeListOf; - getElementsByTagName(name: "nextid"): NodeListOf; - getElementsByTagName(name: "nobr"): NodeListOf; + getElementsByTagName(name: "nextid"): NodeListOf; + getElementsByTagName(name: "nobr"): NodeListOf; getElementsByTagName(name: "noframes"): NodeListOf; getElementsByTagName(name: "noscript"): NodeListOf; getElementsByTagName(name: "object"): NodeListOf; @@ -2909,7 +3589,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "param"): NodeListOf; getElementsByTagName(name: "path"): NodeListOf; getElementsByTagName(name: "pattern"): NodeListOf; - getElementsByTagName(name: "plaintext"): NodeListOf; + getElementsByTagName(name: "picture"): NodeListOf; + getElementsByTagName(name: "plaintext"): NodeListOf; getElementsByTagName(name: "polygon"): NodeListOf; getElementsByTagName(name: "polyline"): NodeListOf; getElementsByTagName(name: "pre"): NodeListOf; @@ -2917,28 +3598,29 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "q"): NodeListOf; getElementsByTagName(name: "radialgradient"): NodeListOf; getElementsByTagName(name: "rect"): NodeListOf; - getElementsByTagName(name: "rt"): NodeListOf; - getElementsByTagName(name: "ruby"): NodeListOf; - getElementsByTagName(name: "s"): NodeListOf; - getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; getElementsByTagName(name: "script"): NodeListOf; getElementsByTagName(name: "section"): NodeListOf; getElementsByTagName(name: "select"): NodeListOf; - getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; getElementsByTagName(name: "source"): NodeListOf; getElementsByTagName(name: "span"): NodeListOf; getElementsByTagName(name: "stop"): NodeListOf; - getElementsByTagName(name: "strike"): NodeListOf; - getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "strike"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; getElementsByTagName(name: "style"): NodeListOf; - getElementsByTagName(name: "sub"): NodeListOf; - getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; getElementsByTagName(name: "svg"): NodeListOf; getElementsByTagName(name: "switch"): NodeListOf; getElementsByTagName(name: "symbol"): NodeListOf; getElementsByTagName(name: "table"): NodeListOf; getElementsByTagName(name: "tbody"): NodeListOf; getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "template"): NodeListOf; getElementsByTagName(name: "text"): NodeListOf; getElementsByTagName(name: "textpath"): NodeListOf; getElementsByTagName(name: "textarea"): NodeListOf; @@ -2949,16 +3631,16 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "tr"): NodeListOf; getElementsByTagName(name: "track"): NodeListOf; getElementsByTagName(name: "tspan"): NodeListOf; - getElementsByTagName(name: "tt"): NodeListOf; - getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "tt"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; getElementsByTagName(name: "ul"): NodeListOf; getElementsByTagName(name: "use"): NodeListOf; - getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; getElementsByTagName(name: "video"): NodeListOf; getElementsByTagName(name: "view"): NodeListOf; getElementsByTagName(name: "wbr"): NodeListOf; getElementsByTagName(name: "x-ms-webview"): NodeListOf; - getElementsByTagName(name: "xmp"): NodeListOf; + getElementsByTagName(name: "xmp"): NodeListOf; getElementsByTagName(name: string): NodeListOf; getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; hasAttribute(name: string): boolean; @@ -3075,9 +3757,9 @@ declare var Event: { } interface EventTarget { - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; dispatchEvent(evt: Event): boolean; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var EventTarget: { @@ -3096,6 +3778,7 @@ declare var External: { interface File extends Blob { lastModifiedDate: any; name: string; + webkitRelativePath: string; } declare var File: { @@ -3220,6 +3903,7 @@ interface HTMLAnchorElement extends HTMLElement { * Sets or retrieves the coordinates of the object. */ coords: string; + download: string; /** * Contains the anchor portion of the URL including the hash sign (#). */ @@ -3377,6 +4061,7 @@ interface HTMLAreaElement extends HTMLElement { * Sets or retrieves the coordinates of the object. */ coords: string; + download: string; /** * Sets or retrieves the subsection of the href property that follows the number sign (#). */ @@ -3502,23 +4187,6 @@ declare var HTMLBaseFontElement: { new(): HTMLBaseFontElement; } -interface HTMLBlockElement extends HTMLElement { - /** - * Sets or retrieves reference information about the object. - */ - cite: string; - clear: string; - /** - * Sets or retrieves the width of the object. - */ - width: number; -} - -declare var HTMLBlockElement: { - prototype: HTMLBlockElement; - new(): HTMLBlockElement; -} - interface HTMLBodyElement extends HTMLElement { aLink: any; background: string; @@ -3546,7 +4214,6 @@ interface HTMLBodyElement extends HTMLElement { onunload: (ev: Event) => any; text: any; vLink: any; - createTextRange(): TextRange; 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; @@ -3571,10 +4238,10 @@ interface HTMLBodyElement extends HTMLElement { addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; @@ -3585,9 +4252,9 @@ interface HTMLBodyElement extends HTMLElement { addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -3599,7 +4266,7 @@ interface HTMLBodyElement extends HTMLElement { addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; @@ -3607,6 +4274,7 @@ interface HTMLBodyElement extends HTMLElement { addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -3624,13 +4292,13 @@ interface HTMLBodyElement extends HTMLElement { addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -3734,10 +4402,6 @@ interface HTMLButtonElement extends HTMLElement { * Returns whether a form will validate when it is submitted, without having to submit it. */ checkValidity(): boolean; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; /** * Sets a custom error message that is displayed when a form is submitted. * @param error Sets a custom error message that is displayed when a form is submitted. @@ -3804,18 +4468,6 @@ declare var HTMLCollection: { new(): HTMLCollection; } -interface HTMLDDElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} - -declare var HTMLDDElement: { - prototype: HTMLDDElement; - new(): HTMLDDElement; -} - interface HTMLDListElement extends HTMLElement { compact: boolean; } @@ -3825,18 +4477,6 @@ declare var HTMLDListElement: { new(): HTMLDListElement; } -interface HTMLDTElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} - -declare var HTMLDTElement: { - prototype: HTMLDTElement; - new(): HTMLDTElement; -} - interface HTMLDataListElement extends HTMLElement { options: HTMLCollection; } @@ -3900,19 +4540,19 @@ interface HTMLElement extends Element { onabort: (ev: Event) => any; onactivate: (ev: UIEvent) => any; onbeforeactivate: (ev: UIEvent) => any; - onbeforecopy: (ev: DragEvent) => any; - onbeforecut: (ev: DragEvent) => any; + onbeforecopy: (ev: ClipboardEvent) => any; + onbeforecut: (ev: ClipboardEvent) => any; onbeforedeactivate: (ev: UIEvent) => any; - onbeforepaste: (ev: DragEvent) => any; + onbeforepaste: (ev: ClipboardEvent) => any; onblur: (ev: FocusEvent) => any; oncanplay: (ev: Event) => any; oncanplaythrough: (ev: Event) => any; onchange: (ev: Event) => any; onclick: (ev: MouseEvent) => any; oncontextmenu: (ev: PointerEvent) => any; - oncopy: (ev: DragEvent) => any; + oncopy: (ev: ClipboardEvent) => any; oncuechange: (ev: Event) => any; - oncut: (ev: DragEvent) => any; + oncut: (ev: ClipboardEvent) => any; ondblclick: (ev: MouseEvent) => any; ondeactivate: (ev: UIEvent) => any; ondrag: (ev: DragEvent) => any; @@ -3924,10 +4564,11 @@ interface HTMLElement extends Element { ondrop: (ev: DragEvent) => any; ondurationchange: (ev: Event) => any; onemptied: (ev: Event) => any; - onended: (ev: Event) => any; + onended: (ev: MediaStreamErrorEvent) => any; onerror: (ev: Event) => any; onfocus: (ev: FocusEvent) => any; oninput: (ev: Event) => any; + oninvalid: (ev: Event) => any; onkeydown: (ev: KeyboardEvent) => any; onkeypress: (ev: KeyboardEvent) => any; onkeyup: (ev: KeyboardEvent) => any; @@ -3942,10 +4583,10 @@ interface HTMLElement extends Element { onmouseout: (ev: MouseEvent) => any; onmouseover: (ev: MouseEvent) => any; onmouseup: (ev: MouseEvent) => any; - onmousewheel: (ev: MouseWheelEvent) => any; + onmousewheel: (ev: WheelEvent) => any; onmscontentzoom: (ev: UIEvent) => any; onmsmanipulationstatechanged: (ev: MSManipulationEvent) => any; - onpaste: (ev: DragEvent) => any; + onpaste: (ev: ClipboardEvent) => any; onpause: (ev: Event) => any; onplay: (ev: Event) => any; onplaying: (ev: Event) => any; @@ -4002,10 +4643,10 @@ interface HTMLElement extends Element { addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -4013,9 +4654,9 @@ interface HTMLElement extends Element { addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -4027,11 +4668,12 @@ interface HTMLElement extends Element { addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -4047,8 +4689,8 @@ interface HTMLElement extends Element { addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -4327,10 +4969,6 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument { * Sets or retrieves whether the frame can be scrolled. */ scrolling: string; - /** - * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. - */ - security: any; /** * Sets or retrieves a URL to be loaded by the object. */ @@ -4362,10 +5000,10 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument { addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -4373,9 +5011,9 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument { addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -4387,11 +5025,12 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument { addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -4408,8 +5047,8 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument { addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -4519,10 +5158,10 @@ interface HTMLFrameSetElement extends HTMLElement { addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; @@ -4533,9 +5172,9 @@ interface HTMLFrameSetElement extends HTMLElement { addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -4547,7 +5186,7 @@ interface HTMLFrameSetElement extends HTMLElement { addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; @@ -4555,6 +5194,7 @@ interface HTMLFrameSetElement extends HTMLElement { addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -4572,13 +5212,13 @@ interface HTMLFrameSetElement extends HTMLElement { addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -4657,7 +5297,6 @@ interface HTMLHeadingElement extends HTMLElement { * Sets or retrieves a value that indicates the table alignment. */ align: string; - clear: string; } declare var HTMLHeadingElement: { @@ -4740,10 +5379,6 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { * Sets or retrieves whether the frame can be scrolled. */ scrolling: string; - /** - * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. - */ - security: any; /** * Sets or retrieves a URL to be loaded by the object. */ @@ -4779,10 +5414,10 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -4790,9 +5425,9 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -4804,11 +5439,12 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -4825,8 +5461,8 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -4902,6 +5538,7 @@ interface HTMLImageElement extends HTMLElement { * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. */ longDesc: string; + lowsrc: string; /** * Gets or sets whether the DLNA PlayTo device is available. */ @@ -4927,6 +5564,7 @@ interface HTMLImageElement extends HTMLElement { * The original width of the image resource before sizing. */ naturalWidth: number; + sizes: string; /** * The address or URL of the a media resource that is to be considered. */ @@ -5071,6 +5709,7 @@ interface HTMLInputElement extends HTMLElement { * When present, marks an element that can't be submitted without a value. */ required: boolean; + selectionDirection: string; /** * Gets or sets the end position or offset of a text selection. */ @@ -5118,6 +5757,7 @@ interface HTMLInputElement extends HTMLElement { * Sets or retrieves the vertical margin for the object. */ vspace: number; + webkitdirectory: boolean; /** * Sets or retrieves the width of the object. */ @@ -5126,14 +5766,11 @@ interface HTMLInputElement extends HTMLElement { * Returns whether an element will successfully validate based on forms validation rules and constraints. */ willValidate: boolean; + minLength: number; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ checkValidity(): boolean; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; /** * Makes the selection equal to the current object. */ @@ -5148,7 +5785,7 @@ interface HTMLInputElement extends HTMLElement { * @param start The offset into the text field for the start of the selection. * @param end The offset into the text field for the end of the selection. */ - setSelectionRange(start: number, end: number): void; + setSelectionRange(start?: number, end?: number, direction?: string): void; /** * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. * @param n Value to decrement the value by. @@ -5166,23 +5803,6 @@ declare var HTMLInputElement: { new(): HTMLInputElement; } -interface HTMLIsIndexElement extends HTMLElement { - /** - * Sets or retrieves the URL to which the form content is sent for processing. - */ - action: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - prompt: string; -} - -declare var HTMLIsIndexElement: { - prototype: HTMLIsIndexElement; - new(): HTMLIsIndexElement; -} - interface HTMLLIElement extends HTMLElement { type: string; /** @@ -5262,6 +5882,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { * Sets or retrieves the MIME type of the object. */ type: string; + import?: Document; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5326,10 +5947,10 @@ interface HTMLMarqueeElement extends HTMLElement { addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -5338,9 +5959,9 @@ interface HTMLMarqueeElement extends HTMLElement { addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -5352,12 +5973,13 @@ interface HTMLMarqueeElement extends HTMLElement { addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -5373,8 +5995,8 @@ interface HTMLMarqueeElement extends HTMLElement { addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -5433,6 +6055,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). */ controls: boolean; + crossOrigin: string; /** * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. */ @@ -5462,6 +6085,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets or sets a flag to specify whether playback should restart after it completes. */ loop: boolean; + mediaKeys: MediaKeys; /** * Specifies the purpose of the audio or video media, such as background audio or alerts. */ @@ -5503,6 +6127,7 @@ interface HTMLMediaElement extends HTMLElement { * Gets the current network activity for the element. */ networkState: number; + onencrypted: (ev: MediaEncryptedEvent) => any; onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; /** * Gets a flag that specifies whether playback is paused. @@ -5533,6 +6158,7 @@ interface HTMLMediaElement extends HTMLElement { * The address or URL of the a media resource that is to be considered. */ src: string; + srcObject: MediaStream; textTracks: TextTrackList; videoTracks: VideoTrackList; /** @@ -5570,6 +6196,7 @@ interface HTMLMediaElement extends HTMLElement { * Loads and starts playback of a media resource. */ play(): void; + setMediaKeys(mediaKeys: MediaKeys): PromiseLike; HAVE_CURRENT_DATA: number; HAVE_ENOUGH_DATA: number; HAVE_FUTURE_DATA: number; @@ -5602,10 +6229,10 @@ interface HTMLMediaElement extends HTMLElement { addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -5613,9 +6240,9 @@ interface HTMLMediaElement extends HTMLElement { addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -5627,11 +6254,13 @@ interface HTMLMediaElement extends HTMLElement { addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "encrypted", listener: (ev: MediaEncryptedEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -5647,9 +6276,9 @@ interface HTMLMediaElement extends HTMLElement { addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -5741,6 +6370,20 @@ declare var HTMLMetaElement: { new(): HTMLMetaElement; } +interface HTMLMeterElement extends HTMLElement { + high: number; + low: number; + max: number; + min: number; + optimum: number; + value: number; +} + +declare var HTMLMeterElement: { + prototype: HTMLMeterElement; + new(): HTMLMeterElement; +} + interface HTMLModElement extends HTMLElement { /** * Sets or retrieves reference information about the object. @@ -5757,15 +6400,6 @@ declare var HTMLModElement: { new(): HTMLModElement; } -interface HTMLNextIdElement extends HTMLElement { - n: string; -} - -declare var HTMLNextIdElement: { - prototype: HTMLNextIdElement; - new(): HTMLNextIdElement; -} - interface HTMLOListElement extends HTMLElement { compact: boolean; /** @@ -5975,6 +6609,18 @@ declare var HTMLOptionElement: { create(): HTMLOptionElement; } +interface HTMLOptionsCollection extends HTMLCollection { + length: number; + selectedIndex: number; + add(element: HTMLOptionElement | HTMLOptGroupElement, before?: HTMLElement | number): void; + remove(index: number): void; +} + +declare var HTMLOptionsCollection: { + prototype: HTMLOptionsCollection; + new(): HTMLOptionsCollection; +} + interface HTMLParagraphElement extends HTMLElement { /** * Sets or retrieves how the object is aligned with adjacent text. @@ -6012,28 +6658,15 @@ declare var HTMLParamElement: { new(): HTMLParamElement; } -interface HTMLPhraseElement extends HTMLElement { - /** - * Sets or retrieves reference information about the object. - */ - cite: string; - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; +interface HTMLPictureElement extends HTMLElement { } -declare var HTMLPhraseElement: { - prototype: HTMLPhraseElement; - new(): HTMLPhraseElement; +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; } interface HTMLPreElement extends HTMLElement { - /** - * Indicates a citation by rendering text in italic type. - */ - cite: string; - clear: string; /** * Sets or gets a value that you can use to implement your own width functionality for the object. */ @@ -6074,10 +6707,6 @@ interface HTMLQuoteElement extends HTMLElement { * Sets or retrieves reference information about the object. */ cite: string; - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; } declare var HTMLQuoteElement: { @@ -6153,6 +6782,7 @@ interface HTMLSelectElement extends HTMLElement { * Sets or retrieves the index of the selected option in a select object. */ selectedIndex: number; + selectedOptions: HTMLCollection; /** * Sets or retrieves the number of rows in the list box. */ @@ -6177,7 +6807,6 @@ interface HTMLSelectElement extends HTMLElement { * Returns whether an element will successfully validate based on forms validation rules and constraints. */ willValidate: boolean; - selectedOptions: HTMLCollection; /** * Adds an element to the areas, controlRange, or options collection. * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. @@ -6223,10 +6852,12 @@ interface HTMLSourceElement extends HTMLElement { */ media: string; msKeySystem: string; + sizes: string; /** * The address or URL of the a media resource that is to be considered. */ src: string; + srcset: string; /** * Gets or sets the MIME type of a media resource. */ @@ -6247,6 +6878,7 @@ declare var HTMLSpanElement: { } interface HTMLStyleElement extends HTMLElement, LinkStyle { + disabled: boolean; /** * Sets or retrieves the media type. */ @@ -6552,6 +7184,15 @@ declare var HTMLTableSectionElement: { new(): HTMLTableSectionElement; } +interface HTMLTemplateElement extends HTMLElement { + content: DocumentFragment; +} + +declare var HTMLTemplateElement: { + prototype: HTMLTemplateElement; + new(): HTMLTemplateElement; +} + interface HTMLTextAreaElement extends HTMLElement { /** * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. @@ -6630,14 +7271,11 @@ interface HTMLTextAreaElement extends HTMLElement { * Sets or retrieves how to handle wordwrapping in the object. */ wrap: string; + minLength: number; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ checkValidity(): boolean; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; /** * Highlights the input area of a form element. */ @@ -6779,10 +7417,10 @@ interface HTMLVideoElement extends HTMLMediaElement { addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -6790,9 +7428,9 @@ interface HTMLVideoElement extends HTMLMediaElement { addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -6804,11 +7442,13 @@ interface HTMLVideoElement extends HTMLMediaElement { addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "encrypted", listener: (ev: MediaEncryptedEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -6824,9 +7464,9 @@ interface HTMLVideoElement extends HTMLMediaElement { addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: ClipboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -6894,11 +7534,11 @@ declare var History: { interface IDBCursor { direction: string; - key: any; + key: IDBKeyRange | IDBValidKey; primaryKey: any; source: IDBObjectStore | IDBIndex; advance(count: number): void; - continue(key?: any): void; + continue(key?: IDBKeyRange | IDBValidKey): void; delete(): IDBRequest; update(value: any): IDBRequest; NEXT: string; @@ -6931,10 +7571,12 @@ interface IDBDatabase extends EventTarget { onabort: (ev: Event) => any; onerror: (ev: Event) => any; version: number; + onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: string | string[], mode?: string): IDBTransaction; + addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -6962,11 +7604,11 @@ interface IDBIndex { objectStore: IDBObjectStore; unique: boolean; multiEntry: boolean; - count(key?: any): IDBRequest; - get(key: any): IDBRequest; - getKey(key: any): IDBRequest; - openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; - openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; + get(key: IDBKeyRange | IDBValidKey): IDBRequest; + getKey(key: IDBKeyRange | IDBValidKey): IDBRequest; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + openKeyCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; } declare var IDBIndex: { @@ -6985,9 +7627,9 @@ declare var IDBKeyRange: { prototype: IDBKeyRange; new(): IDBKeyRange; bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; - lowerBound(bound: any, open?: boolean): IDBKeyRange; + lowerBound(lower: any, open?: boolean): IDBKeyRange; only(value: any): IDBKeyRange; - upperBound(bound: any, open?: boolean): IDBKeyRange; + upperBound(upper: any, open?: boolean): IDBKeyRange; } interface IDBObjectStore { @@ -6996,16 +7638,16 @@ interface IDBObjectStore { name: string; transaction: IDBTransaction; autoIncrement: boolean; - add(value: any, key?: any): IDBRequest; + add(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; clear(): IDBRequest; - count(key?: any): IDBRequest; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex; - delete(key: any): IDBRequest; + delete(key: IDBKeyRange | IDBValidKey): IDBRequest; deleteIndex(indexName: string): void; get(key: any): IDBRequest; index(name: string): IDBIndex; - openCursor(range?: any, direction?: string): IDBRequest; - put(value: any, key?: any): IDBRequest; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + put(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; } declare var IDBObjectStore: { @@ -7128,6 +7770,16 @@ declare var KeyboardEvent: { DOM_KEY_LOCATION_STANDARD: number; } +interface ListeningStateChangedEvent extends Event { + label: string; + state: string; +} + +declare var ListeningStateChangedEvent: { + prototype: ListeningStateChangedEvent; + new(): ListeningStateChangedEvent; +} + interface Location { hash: string; host: string; @@ -7169,7 +7821,7 @@ interface MSApp { execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): any; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; getViewId(view: any): any; isTaskScheduledAtPriorityOrHigher(priority: string): boolean; pageHandlesAllApplicationActivations(enabled: boolean): void; @@ -7205,6 +7857,16 @@ declare var MSAppAsyncOperation: { STARTED: number; } +interface MSAssertion { + id: string; + type: string; +} + +declare var MSAssertion: { + prototype: MSAssertion; + new(): MSAssertion; +} + interface MSBlobBuilder { append(data: any, endings?: string): void; getBlob(contentType?: string): Blob; @@ -7215,44 +7877,46 @@ declare var MSBlobBuilder: { new(): MSBlobBuilder; } -interface MSCSSMatrix { - a: number; - b: number; - c: number; - d: number; - e: number; - f: number; - m11: number; - m12: number; - m13: number; - m14: number; - m21: number; - m22: number; - m23: number; - m24: number; - m31: number; - m32: number; - m33: number; - m34: number; - m41: number; - m42: number; - m43: number; - m44: number; - inverse(): MSCSSMatrix; - multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; - rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; - rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; - scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; - setMatrixValue(value: string): void; - skewX(angle: number): MSCSSMatrix; - skewY(angle: number): MSCSSMatrix; - toString(): string; - translate(x: number, y: number, z?: number): MSCSSMatrix; +interface MSCredentials { + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): PromiseLike; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): PromiseLike; } -declare var MSCSSMatrix: { - prototype: MSCSSMatrix; - new(text?: string): MSCSSMatrix; +declare var MSCredentials: { + prototype: MSCredentials; + new(): MSCredentials; +} + +interface MSFIDOCredentialAssertion extends MSAssertion { + algorithm: string | Algorithm; + attestation: any; + publicKey: string; + transportHints: string[]; +} + +declare var MSFIDOCredentialAssertion: { + prototype: MSFIDOCredentialAssertion; + new(): MSFIDOCredentialAssertion; +} + +interface MSFIDOSignature { + authnrData: string; + clientData: string; + signature: string; +} + +declare var MSFIDOSignature: { + prototype: MSFIDOSignature; + new(): MSFIDOSignature; +} + +interface MSFIDOSignatureAssertion extends MSAssertion { + signature: MSFIDOSignature; +} + +declare var MSFIDOSignatureAssertion: { + prototype: MSFIDOSignatureAssertion; + new(): MSFIDOSignatureAssertion; } interface MSGesture { @@ -7457,25 +8121,7 @@ declare var MSMediaKeys: { prototype: MSMediaKeys; new(keySystem: string): MSMediaKeys; isTypeSupported(keySystem: string, type?: string): boolean; -} - -interface MSMimeTypesCollection { - length: number; -} - -declare var MSMimeTypesCollection: { - prototype: MSMimeTypesCollection; - new(): MSMimeTypesCollection; -} - -interface MSPluginsCollection { - length: number; - refresh(reload?: boolean): void; -} - -declare var MSPluginsCollection: { - prototype: MSPluginsCollection; - new(): MSPluginsCollection; + isTypeSupportedWithFeatures(keySystem: string, type?: string): string; } interface MSPointerEvent extends MouseEvent { @@ -7589,6 +8235,32 @@ declare var MSWebViewSettings: { new(): MSWebViewSettings; } +interface MediaDeviceInfo { + deviceId: string; + groupId: string; + kind: string; + label: string; +} + +declare var MediaDeviceInfo: { + prototype: MediaDeviceInfo; + new(): MediaDeviceInfo; +} + +interface MediaDevices extends EventTarget { + ondevicechange: (ev: Event) => any; + enumerateDevices(): any; + getSupportedConstraints(): MediaTrackSupportedConstraints; + getUserMedia(constraints: MediaStreamConstraints): PromiseLike; + addEventListener(type: "devicechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaDevices: { + prototype: MediaDevices; + new(): MediaDevices; +} + interface MediaElementAudioSourceNode extends AudioNode { } @@ -7597,6 +8269,16 @@ declare var MediaElementAudioSourceNode: { new(): MediaElementAudioSourceNode; } +interface MediaEncryptedEvent extends Event { + initData: ArrayBuffer; + initDataType: string; +} + +declare var MediaEncryptedEvent: { + prototype: MediaEncryptedEvent; + new(type: string, eventInitDict?: MediaEncryptedEventInit): MediaEncryptedEvent; +} + interface MediaError { code: number; msExtendedCode: number; @@ -7617,6 +8299,66 @@ declare var MediaError: { MS_MEDIA_ERR_ENCRYPTED: number; } +interface MediaKeyMessageEvent extends Event { + message: ArrayBuffer; + messageType: string; +} + +declare var MediaKeyMessageEvent: { + prototype: MediaKeyMessageEvent; + new(type: string, eventInitDict?: MediaKeyMessageEventInit): MediaKeyMessageEvent; +} + +interface MediaKeySession extends EventTarget { + closed: PromiseLike; + expiration: number; + keyStatuses: MediaKeyStatusMap; + sessionId: string; + close(): PromiseLike; + generateRequest(initDataType: string, initData: any): PromiseLike; + load(sessionId: string): PromiseLike; + remove(): PromiseLike; + update(response: any): PromiseLike; +} + +declare var MediaKeySession: { + prototype: MediaKeySession; + new(): MediaKeySession; +} + +interface MediaKeyStatusMap { + size: number; + forEach(callback: ForEachCallback): void; + get(keyId: any): string; + has(keyId: any): boolean; +} + +declare var MediaKeyStatusMap: { + prototype: MediaKeyStatusMap; + new(): MediaKeyStatusMap; +} + +interface MediaKeySystemAccess { + keySystem: string; + createMediaKeys(): PromiseLike; + getConfiguration(): MediaKeySystemConfiguration; +} + +declare var MediaKeySystemAccess: { + prototype: MediaKeySystemAccess; + new(): MediaKeySystemAccess; +} + +interface MediaKeys { + createSession(sessionType?: string): MediaKeySession; + setServerCertificate(serverCertificate: any): PromiseLike; +} + +declare var MediaKeys: { + prototype: MediaKeys; + new(): MediaKeys; +} + interface MediaList { length: number; mediaText: string; @@ -7660,6 +8402,101 @@ declare var MediaSource: { isTypeSupported(type: string): boolean; } +interface MediaStream extends EventTarget { + active: boolean; + id: string; + onactive: (ev: Event) => any; + onaddtrack: (ev: TrackEvent) => any; + oninactive: (ev: Event) => any; + onremovetrack: (ev: TrackEvent) => any; + addTrack(track: MediaStreamTrack): void; + clone(): MediaStream; + getAudioTracks(): MediaStreamTrack[]; + getTrackById(trackId: string): MediaStreamTrack; + getTracks(): MediaStreamTrack[]; + getVideoTracks(): MediaStreamTrack[]; + removeTrack(track: MediaStreamTrack): void; + stop(): void; + addEventListener(type: "active", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "inactive", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaStream: { + prototype: MediaStream; + new(streamOrTracks?: MediaStream | MediaStreamTrack[]): MediaStream; +} + +interface MediaStreamAudioSourceNode extends AudioNode { +} + +declare var MediaStreamAudioSourceNode: { + prototype: MediaStreamAudioSourceNode; + new(): MediaStreamAudioSourceNode; +} + +interface MediaStreamError { + constraintName: string; + message: string; + name: string; +} + +declare var MediaStreamError: { + prototype: MediaStreamError; + new(): MediaStreamError; +} + +interface MediaStreamErrorEvent extends Event { + error: MediaStreamError; +} + +declare var MediaStreamErrorEvent: { + prototype: MediaStreamErrorEvent; + new(type: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamTrack extends EventTarget { + enabled: boolean; + id: string; + kind: string; + label: string; + muted: boolean; + onended: (ev: MediaStreamErrorEvent) => any; + onmute: (ev: Event) => any; + onoverconstrained: (ev: MediaStreamErrorEvent) => any; + onunmute: (ev: Event) => any; + readonly: boolean; + readyState: string; + remote: boolean; + applyConstraints(constraints: MediaTrackConstraints): PromiseLike; + clone(): MediaStreamTrack; + getCapabilities(): MediaTrackCapabilities; + getConstraints(): MediaTrackConstraints; + getSettings(): MediaTrackSettings; + stop(): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mute", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "overconstrained", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unmute", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaStreamTrack: { + prototype: MediaStreamTrack; + new(): MediaStreamTrack; +} + +interface MediaStreamTrackEvent extends Event { + track: MediaStreamTrack; +} + +declare var MediaStreamTrackEvent: { + prototype: MediaStreamTrackEvent; + new(type: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; +} + interface MessageChannel { port1: MessagePort; port2: MessagePort; @@ -7755,18 +8592,6 @@ declare var MouseEvent: { new(typeArg: string, eventInitDict?: MouseEventInit): MouseEvent; } -interface MouseWheelEvent extends MouseEvent { - wheelDelta: number; - wheelDeltaX: number; - wheelDeltaY: number; - initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; -} - -declare var MouseWheelEvent: { - prototype: MouseWheelEvent; - new(): MouseWheelEvent; -} - interface MutationEvent extends Event { attrChange: number; attrName: string; @@ -7860,27 +8685,22 @@ declare var NavigationEventWithReferrer: { new(): NavigationEventWithReferrer; } -interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver { +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorUserMedia { appCodeName: string; - appMinorVersion: string; - browserLanguage: string; - connectionSpeed: number; cookieEnabled: boolean; - cpuClass: string; language: string; maxTouchPoints: number; - mimeTypes: MSMimeTypesCollection; + mimeTypes: MimeTypeArray; msManipulationViewsEnabled: boolean; msMaxTouchPoints: number; msPointerEnabled: boolean; - plugins: MSPluginsCollection; + plugins: PluginArray; pointerEnabled: boolean; - systemLanguage: string; - userLanguage: string; webdriver: boolean; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): PromiseLike; vibrate(pattern: number | number[]): boolean; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7905,12 +8725,12 @@ interface Node extends EventTarget { ownerDocument: Document; parentElement: HTMLElement; parentNode: Node; - prefix: string; previousSibling: Node; textContent: string; 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; @@ -8060,7 +8880,7 @@ declare var OfflineAudioCompletionEvent: { interface OfflineAudioContext extends AudioContext { oncomplete: (ev: Event) => any; - startRendering(): void; + startRendering(): PromiseLike; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8073,12 +8893,12 @@ declare var OfflineAudioContext: { interface OscillatorNode extends AudioNode { detune: AudioParam; frequency: AudioParam; - onended: (ev: Event) => any; + onended: (ev: MediaStreamErrorEvent) => any; type: string; setPeriodicWave(periodicWave: PeriodicWave): void; start(when?: number): void; stop(when?: number): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -8087,6 +8907,23 @@ declare var OscillatorNode: { new(): OscillatorNode; } +interface OverflowEvent extends UIEvent { + horizontalOverflow: boolean; + orient: number; + verticalOverflow: boolean; + BOTH: number; + HORIZONTAL: number; + VERTICAL: number; +} + +declare var OverflowEvent: { + prototype: OverflowEvent; + new(): OverflowEvent; + BOTH: number; + HORIZONTAL: number; + VERTICAL: number; +} + interface PageTransitionEvent extends Event { persisted: boolean; } @@ -8430,6 +9267,203 @@ declare var ProgressEvent: { new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } +interface RTCDTMFToneChangeEvent extends Event { + tone: string; +} + +declare var RTCDTMFToneChangeEvent: { + prototype: RTCDTMFToneChangeEvent; + new(type: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; +} + +interface RTCDtlsTransport extends RTCStatsProvider { + ondtlsstatechange: (ev: RTCDtlsTransportStateChangedEvent) => any; + onerror: (ev: Event) => any; + state: string; + transport: RTCIceTransport; + getLocalParameters(): RTCDtlsParameters; + getRemoteCertificates(): ArrayBuffer[]; + getRemoteParameters(): RTCDtlsParameters; + start(remoteParameters: RTCDtlsParameters): void; + stop(): void; + addEventListener(type: "dtlsstatechange", listener: (ev: RTCDtlsTransportStateChangedEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCDtlsTransport: { + prototype: RTCDtlsTransport; + new(transport: RTCIceTransport): RTCDtlsTransport; +} + +interface RTCDtlsTransportStateChangedEvent extends Event { + state: string; +} + +declare var RTCDtlsTransportStateChangedEvent: { + prototype: RTCDtlsTransportStateChangedEvent; + new(): RTCDtlsTransportStateChangedEvent; +} + +interface RTCDtmfSender extends EventTarget { + canInsertDTMF: boolean; + duration: number; + interToneGap: number; + ontonechange: (ev: RTCDTMFToneChangeEvent) => any; + sender: RTCRtpSender; + toneBuffer: string; + insertDTMF(tones: string, duration?: number, interToneGap?: number): void; + addEventListener(type: "tonechange", listener: (ev: RTCDTMFToneChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCDtmfSender: { + prototype: RTCDtmfSender; + new(sender: RTCRtpSender): RTCDtmfSender; +} + +interface RTCIceCandidatePairChangedEvent extends Event { + pair: RTCIceCandidatePair; +} + +declare var RTCIceCandidatePairChangedEvent: { + prototype: RTCIceCandidatePairChangedEvent; + new(): RTCIceCandidatePairChangedEvent; +} + +interface RTCIceGatherer extends RTCStatsProvider { + component: string; + onerror: (ev: Event) => any; + onlocalcandidate: (ev: RTCIceGathererEvent) => any; + createAssociatedGatherer(): RTCIceGatherer; + getLocalCandidates(): RTCIceCandidate[]; + getLocalParameters(): RTCIceParameters; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "localcandidate", listener: (ev: RTCIceGathererEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCIceGatherer: { + prototype: RTCIceGatherer; + new(options: RTCIceGatherOptions): RTCIceGatherer; +} + +interface RTCIceGathererEvent extends Event { + candidate: RTCIceCandidate | RTCIceCandidateComplete; +} + +declare var RTCIceGathererEvent: { + prototype: RTCIceGathererEvent; + new(): RTCIceGathererEvent; +} + +interface RTCIceTransport extends RTCStatsProvider { + component: string; + iceGatherer: RTCIceGatherer; + oncandidatepairchange: (ev: RTCIceCandidatePairChangedEvent) => any; + onicestatechange: (ev: RTCIceTransportStateChangedEvent) => any; + role: string; + state: string; + addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; + createAssociatedTransport(): RTCIceTransport; + getNominatedCandidatePair(): RTCIceCandidatePair; + getRemoteCandidates(): RTCIceCandidate[]; + getRemoteParameters(): RTCIceParameters; + setRemoteCandidates(remoteCandidates: RTCIceCandidate[]): void; + start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; + stop(): void; + addEventListener(type: "candidatepairchange", listener: (ev: RTCIceCandidatePairChangedEvent) => any, useCapture?: boolean): void; + addEventListener(type: "icestatechange", listener: (ev: RTCIceTransportStateChangedEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCIceTransport: { + prototype: RTCIceTransport; + new(): RTCIceTransport; +} + +interface RTCIceTransportStateChangedEvent extends Event { + state: string; +} + +declare var RTCIceTransportStateChangedEvent: { + prototype: RTCIceTransportStateChangedEvent; + new(): RTCIceTransportStateChangedEvent; +} + +interface RTCRtpReceiver extends RTCStatsProvider { + onerror: (ev: Event) => any; + rtcpTransport: RTCDtlsTransport; + track: MediaStreamTrack; + transport: RTCDtlsTransport | RTCSrtpSdesTransport; + getContributingSources(): RTCRtpContributingSource[]; + receive(parameters: RTCRtpParameters): void; + requestSendCSRC(csrc: number): void; + setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; + stop(): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCRtpReceiver: { + prototype: RTCRtpReceiver; + new(transport: RTCDtlsTransport | RTCSrtpSdesTransport, kind: string, rtcpTransport?: RTCDtlsTransport): RTCRtpReceiver; + getCapabilities(kind?: string): RTCRtpCapabilities; +} + +interface RTCRtpSender extends RTCStatsProvider { + onerror: (ev: Event) => any; + onssrcconflict: (ev: RTCSsrcConflictEvent) => any; + rtcpTransport: RTCDtlsTransport; + track: MediaStreamTrack; + transport: RTCDtlsTransport | RTCSrtpSdesTransport; + send(parameters: RTCRtpParameters): void; + setTrack(track: MediaStreamTrack): void; + setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; + stop(): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ssrcconflict", listener: (ev: RTCSsrcConflictEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCRtpSender: { + prototype: RTCRtpSender; + new(track: MediaStreamTrack, transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): RTCRtpSender; + getCapabilities(kind?: string): RTCRtpCapabilities; +} + +interface RTCSrtpSdesTransport extends EventTarget { + onerror: (ev: Event) => any; + transport: RTCIceTransport; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCSrtpSdesTransport: { + prototype: RTCSrtpSdesTransport; + new(transport: RTCIceTransport, encryptParameters: RTCSrtpSdesParameters, decryptParameters: RTCSrtpSdesParameters): RTCSrtpSdesTransport; + getLocalParameters(): RTCSrtpSdesParameters[]; +} + +interface RTCSsrcConflictEvent extends Event { + ssrc: number; +} + +declare var RTCSsrcConflictEvent: { + prototype: RTCSsrcConflictEvent; + new(): RTCSsrcConflictEvent; +} + +interface RTCStatsProvider extends EventTarget { + getStats(): PromiseLike; + msGetStats(): PromiseLike; +} + +declare var RTCStatsProvider: { + prototype: RTCStatsProvider; + new(): RTCStatsProvider; +} + interface Range { collapsed: boolean; commonAncestorContainer: Node; @@ -8696,7 +9730,6 @@ declare var SVGDescElement: { } interface SVGElement extends Element { - id: string; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -10021,6 +11054,7 @@ declare var SVGStringList: { } interface SVGStyleElement extends SVGElement, SVGLangSpace { + disabled: boolean; media: string; title: string; type: string; @@ -10365,7 +11399,7 @@ declare var StereoPannerNode: { interface Storage { length: number; clear(): void; - getItem(key: string): any; + getItem(key: string): string; key(index: number): string; removeItem(key: string): void; setItem(key: string, data: string): void; @@ -10439,18 +11473,18 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; - deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any; - deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string | Algorithm, data: ArrayBufferView): any; - encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; - exportKey(format: string, key: CryptoKey): any; - generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any; + decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): PromiseLike; + deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): PromiseLike; + deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): PromiseLike; + digest(algorithm: string | Algorithm, data: ArrayBufferView): PromiseLike; + 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; + 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; + verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): PromiseLike; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): PromiseLike; } declare var SubtleCrypto: { @@ -10460,7 +11494,6 @@ declare var SubtleCrypto: { interface Text extends CharacterData { wholeText: string; - replaceWholeText(content: string): Text; splitText(offset: number): Text; } @@ -10510,62 +11543,6 @@ declare var TextMetrics: { new(): TextMetrics; } -interface TextRange { - boundingHeight: number; - boundingLeft: number; - boundingTop: number; - boundingWidth: number; - htmlText: string; - offsetLeft: number; - offsetTop: number; - text: string; - collapse(start?: boolean): void; - compareEndPoints(how: string, sourceRange: TextRange): number; - duplicate(): TextRange; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - execCommandShowHelp(cmdID: string): boolean; - expand(Unit: string): boolean; - findText(string: string, count?: number, flags?: number): boolean; - getBookmark(): string; - getBoundingClientRect(): ClientRect; - getClientRects(): ClientRectList; - inRange(range: TextRange): boolean; - isEqual(range: TextRange): boolean; - move(unit: string, count?: number): number; - moveEnd(unit: string, count?: number): number; - moveStart(unit: string, count?: number): number; - moveToBookmark(bookmark: string): boolean; - moveToElementText(element: Element): void; - moveToPoint(x: number, y: number): void; - parentElement(): Element; - pasteHTML(html: string): void; - queryCommandEnabled(cmdID: string): boolean; - queryCommandIndeterm(cmdID: string): boolean; - queryCommandState(cmdID: string): boolean; - queryCommandSupported(cmdID: string): boolean; - queryCommandText(cmdID: string): string; - queryCommandValue(cmdID: string): any; - scrollIntoView(fStart?: boolean): void; - select(): void; - setEndPoint(how: string, SourceRange: TextRange): void; -} - -declare var TextRange: { - prototype: TextRange; - new(): TextRange; -} - -interface TextRangeCollection { - length: number; - item(index: number): TextRange; - [index: number]: TextRange; -} - -declare var TextRangeCollection: { - prototype: TextRangeCollection; - new(): TextRangeCollection; -} - interface TextTrack extends EventTarget { activeCues: TextTrackCueList; cues: TextTrackCueList; @@ -10756,10 +11733,26 @@ declare var UIEvent: { } interface URL { + hash: string; + host: string; + hostname: string; + href: string; + origin: string; + password: string; + pathname: string; + port: string; + protocol: string; + search: string; + username: string; + toString(): string; +} + +declare var URL: { + prototype: URL; + new(url: string, base?: string): URL; createObjectURL(object: any, options?: ObjectURLOptions): string; revokeObjectURL(url: string): void; } -declare var URL: URL; interface UnviewableContentIdentifiedEvent extends NavigationEventWithReferrer { mediaType: string; @@ -10908,7 +11901,7 @@ interface WebGLContextEvent extends Event { declare var WebGLContextEvent: { prototype: WebGLContextEvent; - new(): WebGLContextEvent; + new(type: string, eventInitDict?: WebGLContextEventInit): WebGLContextEvent; } interface WebGLFramebuffer extends WebGLObject { @@ -11815,6 +12808,9 @@ interface WheelEvent extends MouseEvent { deltaX: number; deltaY: number; deltaZ: number; + wheelDelta: number; + wheelDeltaX: number; + wheelDeltaY: number; getCurrentPoint(element: Element): void; initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; DOM_DELTA_LINE: number; @@ -11831,7 +12827,6 @@ declare var WheelEvent: { } interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { - animationStartTime: number; applicationCache: ApplicationCache; clientInformation: Navigator; closed: boolean; @@ -11851,7 +12846,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window location: Location; locationbar: BarProp; menubar: BarProp; - msAnimationStartTime: number; + msCredentials: MSCredentials; name: string; navigator: Navigator; offscreenBuffering: string | boolean; @@ -11867,6 +12862,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window oncompassneedscalibration: (ev: Event) => any; oncontextmenu: (ev: PointerEvent) => any; ondblclick: (ev: MouseEvent) => any; + ondevicelight: (ev: DeviceLightEvent) => any; ondevicemotion: (ev: DeviceMotionEvent) => any; ondeviceorientation: (ev: DeviceOrientationEvent) => any; ondrag: (ev: DragEvent) => any; @@ -11878,11 +12874,12 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window ondrop: (ev: DragEvent) => any; ondurationchange: (ev: Event) => any; onemptied: (ev: Event) => any; - onended: (ev: Event) => any; + onended: (ev: MediaStreamErrorEvent) => any; onerror: ErrorEventHandler; onfocus: (ev: FocusEvent) => any; onhashchange: (ev: HashChangeEvent) => any; oninput: (ev: Event) => any; + oninvalid: (ev: Event) => any; onkeydown: (ev: KeyboardEvent) => any; onkeypress: (ev: KeyboardEvent) => any; onkeyup: (ev: KeyboardEvent) => any; @@ -11898,7 +12895,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onmouseout: (ev: MouseEvent) => any; onmouseover: (ev: MouseEvent) => any; onmouseup: (ev: MouseEvent) => any; - onmousewheel: (ev: MouseWheelEvent) => any; + onmousewheel: (ev: WheelEvent) => any; onmsgesturechange: (ev: MSGestureEvent) => any; onmsgesturedoubletap: (ev: MSGestureEvent) => any; onmsgestureend: (ev: MSGestureEvent) => any; @@ -11937,10 +12934,10 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onsubmit: (ev: Event) => any; onsuspend: (ev: Event) => any; ontimeupdate: (ev: Event) => any; - ontouchcancel: any; - ontouchend: any; - ontouchmove: any; - ontouchstart: any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; onunload: (ev: Event) => any; onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; @@ -11968,7 +12965,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window toolbar: BarProp; top: Window; window: Window; - URL: URL; + URL: typeof URL; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; @@ -11982,12 +12979,9 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window matchMedia(mediaQuery: string): MediaQueryList; moveBy(x?: number, y?: number): void; moveTo(x?: number, y?: number): void; - msCancelRequestAnimationFrame(handle: number): void; - msMatchMedia(mediaQuery: string): MediaQueryList; - msRequestAnimationFrame(callback: FrameRequestCallback): number; msWriteProfilerMark(profilerMarkName: string): void; open(url?: string, target?: string, features?: string, replace?: boolean): Window; - postMessage(message: any, targetOrigin: string, ports?: any): void; + postMessage(message: any, targetOrigin: string, transfer?: any[]): void; print(): void; prompt(message?: string, _default?: string): string; releaseEvents(): void; @@ -11997,8 +12991,10 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window scroll(x?: number, y?: number): void; scrollBy(x?: number, y?: number): void; scrollTo(x?: number, y?: number): void; + webkitCancelAnimationFrame(handle: number): void; webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; + webkitRequestAnimationFrame(callback: FrameRequestCallback): number; 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; @@ -12026,6 +13022,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window addEventListener(type: "compassneedscalibration", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "devicelight", listener: (ev: DeviceLightEvent) => any, useCapture?: boolean): void; addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -12037,10 +13034,11 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -12056,7 +13054,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -12128,7 +13126,6 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { onreadystatechange: (ev: ProgressEvent) => any; readyState: number; response: any; - responseBody: any; responseText: string; responseType: string; responseXML: any; @@ -12280,6 +13277,18 @@ interface AbstractWorker { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface CanvasPathMethods { + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + closePath(): void; + ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + lineTo(x: number, y: number): void; + moveTo(x: number, y: number): void; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + rect(x: number, y: number, w: number, h: number): void; +} + interface ChildNode { remove(): void; } @@ -12302,6 +13311,7 @@ interface DocumentEvent { createEvent(eventInterface:"CommandEvent"): CommandEvent; createEvent(eventInterface:"CompositionEvent"): CompositionEvent; createEvent(eventInterface:"CustomEvent"): CustomEvent; + createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface:"DragEvent"): DragEvent; @@ -12313,6 +13323,7 @@ interface DocumentEvent { createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; createEvent(eventInterface:"KeyboardEvent"): KeyboardEvent; + createEvent(eventInterface:"ListeningStateChangedEvent"): ListeningStateChangedEvent; createEvent(eventInterface:"LongRunningScriptDetectedEvent"): LongRunningScriptDetectedEvent; createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; createEvent(eventInterface:"MSManipulationEvent"): MSManipulationEvent; @@ -12320,21 +13331,31 @@ interface DocumentEvent { createEvent(eventInterface:"MSMediaKeyNeededEvent"): MSMediaKeyNeededEvent; createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; createEvent(eventInterface:"MSSiteModeEvent"): MSSiteModeEvent; + createEvent(eventInterface:"MediaEncryptedEvent"): MediaEncryptedEvent; + createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; + createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; createEvent(eventInterface:"MessageEvent"): MessageEvent; createEvent(eventInterface:"MouseEvent"): MouseEvent; createEvent(eventInterface:"MouseEvents"): MouseEvent; - createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; createEvent(eventInterface:"MutationEvent"): MutationEvent; createEvent(eventInterface:"MutationEvents"): MutationEvent; createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; createEvent(eventInterface:"NavigationEvent"): NavigationEvent; createEvent(eventInterface:"NavigationEventWithReferrer"): NavigationEventWithReferrer; createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; + createEvent(eventInterface:"OverflowEvent"): OverflowEvent; createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface:"PointerEvent"): PointerEvent; createEvent(eventInterface:"PopStateEvent"): PopStateEvent; createEvent(eventInterface:"ProgressEvent"): ProgressEvent; + createEvent(eventInterface:"RTCDTMFToneChangeEvent"): RTCDTMFToneChangeEvent; + createEvent(eventInterface:"RTCDtlsTransportStateChangedEvent"): RTCDtlsTransportStateChangedEvent; + createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; + createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; + createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; @@ -12402,7 +13423,6 @@ interface HTMLTableAlignment { interface IDBEnvironment { indexedDB: IDBFactory; - msIndexedDB: IDBFactory; } interface LinkStyle { @@ -12470,6 +13490,11 @@ interface NavigatorOnLine { interface NavigatorStorageUtils { } +interface NavigatorUserMedia { + mediaDevices: MediaDevices; + getUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; +} + interface NodeSelector { querySelector(selectors: string): Element; querySelectorAll(selectors: string): NodeListOf; @@ -12565,8 +13590,6 @@ interface WindowTimers extends Object, WindowTimersExtension { interface WindowTimersExtension { clearImmediate(handle: number): void; - msClearImmediate(handle: number): void; - msSetImmediate(expression: any, ...args: any[]): number; setImmediate(expression: any, ...args: any[]): number; } @@ -12596,16 +13619,6 @@ interface StorageEventInit extends EventInit { storageArea?: Storage; } -interface IDBObjectStoreParameters { - keyPath?: string | string[]; - autoIncrement?: boolean; -} - -interface IDBIndexParameters { - unique?: boolean; - multiEntry?: boolean; -} - interface NodeListOf extends NodeList { length: number; item(index: number): TNode; @@ -12641,15 +13654,6 @@ interface ProgressEventInit extends EventInit { total?: number; } -interface HTMLTemplateElement extends HTMLElement { - content: DocumentFragment; -} - -declare var HTMLTemplateElement: { - prototype: HTMLTemplateElement; - new(): HTMLTemplateElement; -} - interface HTMLPictureElement extends HTMLElement { } @@ -12658,6 +13662,14 @@ declare var HTMLPictureElement: { new(): HTMLPictureElement; } +interface ClipboardEventInit extends EventInit { + data?: string; + dataType?: string; +} + +interface IDBArrayKey extends Array { +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -12696,10 +13708,18 @@ interface DecodeErrorCallback { interface FunctionStringCallback { (data: string): void; } +interface NavigatorUserMediaSuccessCallback { + (stream: MediaStream): void; +} +interface NavigatorUserMediaErrorCallback { + (error: MediaStreamError): void; +} +interface ForEachCallback { + (keyId: any, status: string): void; +} declare var Audio: {new(src?: string): HTMLAudioElement; }; declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; -declare var animationStartTime: number; declare var applicationCache: ApplicationCache; declare var clientInformation: Navigator; declare var closed: boolean; @@ -12719,7 +13739,7 @@ declare var length: number; declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; -declare var msAnimationStartTime: number; +declare var msCredentials: MSCredentials; declare var name: string; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; @@ -12735,6 +13755,7 @@ declare var onclick: (ev: MouseEvent) => any; declare var oncompassneedscalibration: (ev: Event) => any; declare var oncontextmenu: (ev: PointerEvent) => any; declare var ondblclick: (ev: MouseEvent) => any; +declare var ondevicelight: (ev: DeviceLightEvent) => any; declare var ondevicemotion: (ev: DeviceMotionEvent) => any; declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; declare var ondrag: (ev: DragEvent) => any; @@ -12746,11 +13767,12 @@ declare var ondragstart: (ev: DragEvent) => any; declare var ondrop: (ev: DragEvent) => any; declare var ondurationchange: (ev: Event) => any; declare var onemptied: (ev: Event) => any; -declare var onended: (ev: Event) => any; +declare var onended: (ev: MediaStreamErrorEvent) => any; declare var onerror: ErrorEventHandler; declare var onfocus: (ev: FocusEvent) => any; declare var onhashchange: (ev: HashChangeEvent) => any; declare var oninput: (ev: Event) => any; +declare var oninvalid: (ev: Event) => any; declare var onkeydown: (ev: KeyboardEvent) => any; declare var onkeypress: (ev: KeyboardEvent) => any; declare var onkeyup: (ev: KeyboardEvent) => any; @@ -12766,7 +13788,7 @@ declare var onmousemove: (ev: MouseEvent) => any; declare var onmouseout: (ev: MouseEvent) => any; declare var onmouseover: (ev: MouseEvent) => any; declare var onmouseup: (ev: MouseEvent) => any; -declare var onmousewheel: (ev: MouseWheelEvent) => any; +declare var onmousewheel: (ev: WheelEvent) => any; declare var onmsgesturechange: (ev: MSGestureEvent) => any; declare var onmsgesturedoubletap: (ev: MSGestureEvent) => any; declare var onmsgestureend: (ev: MSGestureEvent) => any; @@ -12805,10 +13827,10 @@ declare var onstorage: (ev: StorageEvent) => any; declare var onsubmit: (ev: Event) => any; declare var onsuspend: (ev: Event) => any; declare var ontimeupdate: (ev: Event) => any; -declare var ontouchcancel: any; -declare var ontouchend: any; -declare var ontouchmove: any; -declare var ontouchstart: any; +declare var ontouchcancel: (ev: TouchEvent) => any; +declare var ontouchend: (ev: TouchEvent) => any; +declare var ontouchmove: (ev: TouchEvent) => any; +declare var ontouchstart: (ev: TouchEvent) => any; declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; @@ -12836,7 +13858,6 @@ declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; -declare var URL: URL; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; @@ -12850,12 +13871,9 @@ declare function getSelection(): Selection; declare function matchMedia(mediaQuery: string): MediaQueryList; declare function moveBy(x?: number, y?: number): void; declare function moveTo(x?: number, y?: number): void; -declare function msCancelRequestAnimationFrame(handle: number): void; -declare function msMatchMedia(mediaQuery: string): MediaQueryList; -declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; 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, ports?: any): void; +declare function postMessage(message: any, targetOrigin: string, transfer?: any[]): void; declare function print(): void; declare function prompt(message?: string, _default?: string): string; declare function releaseEvents(): void; @@ -12865,19 +13883,19 @@ declare function resizeTo(x?: number, y?: number): void; declare function scroll(x?: number, y?: number): void; declare function scrollBy(x?: number, y?: number): void; declare function scrollTo(x?: number, y?: number): void; +declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; +declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; declare function toString(): string; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare function dispatchEvent(evt: Event): boolean; -declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare function clearInterval(handle: number): void; declare function clearTimeout(handle: number): void; declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; declare function clearImmediate(handle: number): void; -declare function msClearImmediate(handle: number): void; -declare function msSetImmediate(expression: any, ...args: any[]): number; declare function setImmediate(expression: any, ...args: any[]): number; declare var sessionStorage: Storage; declare var localStorage: Storage; @@ -12892,7 +13910,6 @@ declare var onpointerover: (ev: PointerEvent) => any; declare var onpointerup: (ev: PointerEvent) => any; declare var onwheel: (ev: WheelEvent) => any; declare var indexedDB: IDBFactory; -declare var msIndexedDB: IDBFactory; declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; declare function addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -12922,6 +13939,7 @@ declare function addEventListener(type: "click", listener: (ev: MouseEvent) => a declare function addEventListener(type: "compassneedscalibration", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "devicelight", listener: (ev: DeviceLightEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; @@ -12933,10 +13951,11 @@ declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) = declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "invalid", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; @@ -12952,7 +13971,7 @@ declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousewheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -12988,4 +14007,36 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +type AAGUID = string; +type AlgorithmIdentifier = string | Algorithm; +type ConstrainBoolean = boolean | ConstrainBooleanParameters; +type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; +type ConstrainDouble = number | ConstrainDoubleRange; +type ConstrainLong = number | ConstrainLongRange; +type CryptoOperationData = ArrayBufferView; +type GLbitfield = number; +type GLboolean = boolean; +type GLbyte = number; +type GLclampf = number; +type GLenum = number; +type GLfloat = number; +type GLint = number; +type GLintptr = number; +type GLshort = number; +type GLsizei = number; +type GLsizeiptr = number; +type GLubyte = number; +type GLuint = number; +type GLushort = number; +type IDBKeyPath = string; +type KeyFormat = string; +type KeyType = string; +type KeyUsage = string; +type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; +type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; +type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; +type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; +type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type payloadtype = number; +type IDBValidKey = number | string | Date | IDBArrayKey; \ No newline at end of file diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index cd49a565f12..b342c88a9fd 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -17,6 +17,8 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; + copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void; + copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void; getChannelData(channel: number): Float32Array; } @@ -58,6 +60,7 @@ interface Console { dir(value?: any, ...optionalParams: any[]): void; dirxml(value: any): void; error(message?: any, ...optionalParams: any[]): void; + exception(message?: string, ...optionalParams: any[]): void; group(groupTitle?: string): void; groupCollapsed(groupTitle?: string): void; groupEnd(): void; @@ -67,6 +70,7 @@ interface Console { profile(reportName?: string): void; profileEnd(): void; select(element: any): void; + table(...data: any[]): void; time(timerName?: string): void; timeEnd(timerName?: string): void; trace(message?: any, ...optionalParams: any[]): void; @@ -226,9 +230,9 @@ declare var Event: { } interface EventTarget { - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; dispatchEvent(evt: Event): boolean; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var EventTarget: { @@ -239,6 +243,7 @@ declare var EventTarget: { interface File extends Blob { lastModifiedDate: any; name: string; + webkitRelativePath: string; } declare var File: { @@ -273,11 +278,11 @@ declare var FileReader: { interface IDBCursor { direction: string; - key: any; + key: IDBKeyRange | IDBValidKey; primaryKey: any; source: IDBObjectStore | IDBIndex; advance(count: number): void; - continue(key?: any): void; + continue(key?: IDBKeyRange | IDBValidKey): void; delete(): IDBRequest; update(value: any): IDBRequest; NEXT: string; @@ -310,10 +315,12 @@ interface IDBDatabase extends EventTarget { onabort: (ev: Event) => any; onerror: (ev: Event) => any; version: number; + onversionchange: (ev: IDBVersionChangeEvent) => any; close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: string | string[], mode?: string): IDBTransaction; + addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -341,11 +348,11 @@ interface IDBIndex { objectStore: IDBObjectStore; unique: boolean; multiEntry: boolean; - count(key?: any): IDBRequest; - get(key: any): IDBRequest; - getKey(key: any): IDBRequest; - openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; - openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; + get(key: IDBKeyRange | IDBValidKey): IDBRequest; + getKey(key: IDBKeyRange | IDBValidKey): IDBRequest; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + openKeyCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; } declare var IDBIndex: { @@ -364,9 +371,9 @@ declare var IDBKeyRange: { prototype: IDBKeyRange; new(): IDBKeyRange; bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; - lowerBound(bound: any, open?: boolean): IDBKeyRange; + lowerBound(lower: any, open?: boolean): IDBKeyRange; only(value: any): IDBKeyRange; - upperBound(bound: any, open?: boolean): IDBKeyRange; + upperBound(upper: any, open?: boolean): IDBKeyRange; } interface IDBObjectStore { @@ -375,16 +382,16 @@ interface IDBObjectStore { name: string; transaction: IDBTransaction; autoIncrement: boolean; - add(value: any, key?: any): IDBRequest; + add(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; clear(): IDBRequest; - count(key?: any): IDBRequest; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex; - delete(key: any): IDBRequest; + delete(key: IDBKeyRange | IDBValidKey): IDBRequest; deleteIndex(indexName: string): void; get(key: any): IDBRequest; index(name: string): IDBIndex; - openCursor(range?: any, direction?: string): IDBRequest; - put(value: any, key?: any): IDBRequest; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + put(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; } declare var IDBObjectStore: { @@ -483,7 +490,7 @@ interface MSApp { execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; getCurrentPriority(): string; - getHtmlPrintDocumentSourceAsync(htmlDoc: any): any; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): PromiseLike; getViewId(view: any): any; isTaskScheduledAtPriorityOrHigher(priority: string): boolean; pageHandlesAllApplicationActivations(enabled: boolean): void; @@ -695,7 +702,6 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { onreadystatechange: (ev: ProgressEvent) => any; readyState: number; response: any; - responseBody: any; responseText: string; responseType: string; responseXML: any; @@ -894,16 +900,6 @@ interface WorkerUtils extends Object, WindowBase64 { setTimeout(handler: any, timeout?: any, ...args: any[]): number; } -interface IDBObjectStoreParameters { - keyPath?: string | string[]; - autoIncrement?: boolean; -} - -interface IDBIndexParameters { - unique?: boolean; - multiEntry?: boolean; -} - interface BlobPropertyBag { type?: string; endings?: string; @@ -933,6 +929,9 @@ interface ProgressEventInit extends EventInit { total?: number; } +interface IDBArrayKey extends Array { +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -971,9 +970,9 @@ declare var self: WorkerGlobalScope; declare function close(): void; declare function msWriteProfilerMark(profilerMarkName: string): void; declare function toString(): string; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare function dispatchEvent(evt: Event): boolean; -declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare var indexedDB: IDBFactory; declare var msIndexedDB: IDBFactory; declare var navigator: WorkerNavigator; @@ -991,4 +990,5 @@ declare function postMessage(data: any): void; 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; \ No newline at end of file +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +type IDBValidKey = number | string | Date | IDBArrayKey; \ No newline at end of file From c9f5f3d67e3783a4a0f4099ecfbd2d213de18548 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 25 Mar 2016 15:41:37 -0700 Subject: [PATCH 30/48] Remove --strictThisChecks --- src/compiler/binder.ts | 3 - src/compiler/checker.ts | 16 - src/compiler/commandLineParser.ts | 4 - src/compiler/types.ts | 1 - .../reference/thisTypeInFunctions.js | 87 +- .../reference/thisTypeInFunctions.symbols | 976 ++++++++---------- .../reference/thisTypeInFunctions.types | 302 ++---- .../thisTypeInFunctionsNegative.errors.txt | 229 ++-- .../reference/thisTypeInFunctionsNegative.js | 78 +- .../reference/unionThisTypeInFunctions.js | 4 +- .../unionThisTypeInFunctions.symbols | 14 +- .../reference/unionThisTypeInFunctions.types | 8 +- .../types/thisType/thisTypeInFunctions.ts | 46 +- .../thisType/thisTypeInFunctionsNegative.ts | 41 +- .../thisType/unionThisTypeInFunctions.ts | 5 +- .../fourslash/memberListOnExplicitThis.ts | 5 +- tests/cases/fourslash/quickInfoOnThis.ts | 13 +- 17 files changed, 714 insertions(+), 1118 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7ae21a6338e..9363a8796ee 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1307,9 +1307,6 @@ namespace ts { // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - if (options.strictThisChecks) { - seenThisKeyword = true; - } return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); case SyntaxKind.FunctionDeclaration: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5017f0dcd2c..51fad3e7f33 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3520,7 +3520,6 @@ namespace ts { return isIndependentVariableLikeDeclaration(declaration); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - return compilerOptions.strictThisChecks ? false : isIndependentFunctionLikeDeclaration(declaration); case SyntaxKind.Constructor: return isIndependentFunctionLikeDeclaration(declaration); } @@ -4234,21 +4233,6 @@ namespace ts { if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); } - if (!hasThisParameter && compilerOptions.strictThisChecks) { - if (declaration.kind === SyntaxKind.FunctionDeclaration || - declaration.kind === SyntaxKind.CallSignature || - declaration.kind == SyntaxKind.FunctionExpression || - declaration.kind === SyntaxKind.FunctionType) { - thisType = voidType; - } - else if ((declaration.kind === SyntaxKind.MethodDeclaration || declaration.kind === SyntaxKind.MethodSignature) - && (isClassLike(declaration.parent) || declaration.parent.kind === SyntaxKind.InterfaceDeclaration)) { - thisType = declaration.flags & NodeFlags.Static ? - getTypeOfSymbol(getSymbolOfNode(declaration.parent)) : - getThisType(declaration.name); - Debug.assert(!!thisType, "couldn't find implicit this type"); - } - } if (isJSConstructSignature) { minArgumentCount--; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f6e1d9b48d7..cf55f030c33 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -137,10 +137,6 @@ namespace ts { name: "skipDefaultLibCheck", type: "boolean", }, - { - name: "strictThisChecks", - type: "boolean", - }, { name: "out", type: "string", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index dfa1b54e428..5965a39a79e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2407,7 +2407,6 @@ namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; - strictThisChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index e963dad60f7..74eba32082b 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -8,9 +8,6 @@ class C { explicitThis(this: this, m: number): number { return this.n + m; } - implicitThis(m: number): number { - return this.n + m; - } explicitC(this: C, m: number): number { return this.n + m; } @@ -29,8 +26,6 @@ interface I { explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; - implicitMethod(): number; - implicitFunction: () => number; } function explicitStructural(this: { y: number }, x: number): number { return x + this.y; @@ -39,7 +34,7 @@ function justThis(this: { y: number }): number { return this.y; } function implicitThis(n: number): number { - return 12; + return this.m + n + 12; } let impl: I = { a: 12, @@ -54,10 +49,6 @@ let impl: I = { explicitThis() { return this.a; }, - implicitMethod() { - return this.a; - }, - implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) } impl.explicitVoid1 = function () { return 12; }; impl.explicitVoid2 = () => 12; @@ -66,9 +57,6 @@ impl.explicitInterface = function() { return this.a; }; impl.explicitStructural = () => 12; impl.explicitInterface = () => 12; impl.explicitThis = function () { return this.a; }; -impl.implicitMethod = function () { return this.a; }; -impl.implicitMethod = () => 12; -impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) // parameter checking let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; @@ -82,29 +70,26 @@ let ripped = c.explicitC; c.explicitC(12); c.explicitProperty(12); c.explicitThis(12); -c.implicitThis(12); d.explicitC(12); d.explicitProperty(12); d.explicitThis(12); -d.implicitThis(12); let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid }; +reconstructed.explicitThis(10); reconstructed.explicitProperty(11); -reconstructed.implicitThis(11); - +let explicitVoid = reconstructed.explicitVoid; +explicitVoid(12); // assignment checking let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; @@ -143,8 +128,6 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; c.explicitC = function(m) { return this.n + m }; c.explicitProperty = function(m) { return this.n + m }; c.explicitThis = function(m) { return this.n + m }; -c.implicitThis = function(m) { return this.n + m }; -c.implicitThis = reconstructed.implicitThis; c.explicitC = function(this: B, m: number) { return this.n + m }; @@ -154,19 +137,17 @@ c.explicitVoid = n => n; // class-based assignability class Base1 { x: number; - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.y; } static explicitStatic(this: typeof Base1): number { return this.y; } static y: number; - } class Derived1 extends Base1 { y: number } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -176,14 +157,14 @@ let b1 = new Base1(); let b2 = new Base2(); let d1 = new Derived1(); let d2 = new Derived2(); -d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) -d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) +d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } +d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } // bivariance-allowed cases -d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) -d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) -b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) -b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } +d2.polymorphic = d1.explicit // ok, 'y' in { x, y } +b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } ////// use this-type for construction with new //// function InterfaceThis(this: I) { @@ -206,7 +187,7 @@ declare var f: { }; let n: number = f.call(12); -function missingTypeIsImplicitAny(this, a: number) { return a; } +function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } //// [thisTypeInFunctions.js] @@ -228,9 +209,6 @@ var C = (function () { C.prototype.explicitThis = function (m) { return this.n + m; }; - C.prototype.implicitThis = function (m) { - return this.n + m; - }; C.prototype.explicitC = function (m) { return this.n + m; }; @@ -256,7 +234,7 @@ function justThis() { return this.y; } function implicitThis(n) { - return 12; + return this.m + n + 12; } var impl = { a: 12, @@ -270,11 +248,7 @@ var impl = { }, explicitThis: function () { return this.a; - }, - implicitMethod: function () { - return this.a; - }, - implicitFunction: function () { return _this.a; } + } }; impl.explicitVoid1 = function () { return 12; }; impl.explicitVoid2 = function () { return 12; }; @@ -283,9 +257,6 @@ impl.explicitInterface = function () { return this.a; }; impl.explicitStructural = function () { return 12; }; impl.explicitInterface = function () { return 12; }; impl.explicitThis = function () { return this.a; }; -impl.implicitMethod = function () { return this.a; }; -impl.implicitMethod = function () { return 12; }; -impl.implicitFunction = function () { return _this.a; }; // ok, this: any because it refers to some outer object (window?) // parameter checking var ok = { y: 12, f: explicitStructural }; var implicitAnyOk = { notSpecified: 12, f: implicitThis }; @@ -298,21 +269,20 @@ var ripped = c.explicitC; c.explicitC(12); c.explicitProperty(12); c.explicitThis(12); -c.implicitThis(12); d.explicitC(12); d.explicitProperty(12); d.explicitThis(12); -d.implicitThis(12); var reconstructed = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid }; +reconstructed.explicitThis(10); reconstructed.explicitProperty(11); -reconstructed.implicitThis(11); +var explicitVoid = reconstructed.explicitVoid; +explicitVoid(12); // assignment checking var unboundToSpecified = function (x) { return x + _this.y; }; // ok, this:any var specifiedToSpecified = explicitStructural; @@ -344,8 +314,6 @@ c.explicitThis = function (m) { return this.n + m; }; c.explicitC = function (m) { return this.n + m; }; c.explicitProperty = function (m) { return this.n + m; }; c.explicitThis = function (m) { return this.n + m; }; -c.implicitThis = function (m) { return this.n + m; }; -c.implicitThis = reconstructed.implicitThis; c.explicitC = function (m) { return this.n + m; }; // this:void compatibility c.explicitVoid = function (n) { return n; }; @@ -353,9 +321,8 @@ c.explicitVoid = function (n) { return n; }; var Base1 = (function () { function Base1() { } - Base1.prototype.implicit = function () { return this.x; }; + Base1.prototype.polymorphic = function () { return this.x; }; Base1.prototype.explicit = function () { return this.x; }; - Base1.implicitStatic = function () { return this.y; }; Base1.explicitStatic = function () { return this.y; }; return Base1; }()); @@ -369,7 +336,7 @@ var Derived1 = (function (_super) { var Base2 = (function () { function Base2() { } - Base2.prototype.implicit = function () { return this.y; }; + Base2.prototype.polymorphic = function () { return this.y; }; Base2.prototype.explicit = function () { return this.x; }; return Base2; }()); @@ -384,13 +351,13 @@ var b1 = new Base1(); var b2 = new Base2(); var d1 = new Derived1(); var d2 = new Derived2(); -d2.implicit = d1.implicit; // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) -d1.implicit = d2.implicit; // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) +d2.polymorphic = d1.polymorphic; // ok, 'x' and 'y' in { x, y } +d1.polymorphic = d2.polymorphic; // ok, 'x' and 'y' in { x, y } // bivariance-allowed cases -d1.implicit = b2.implicit; // ok, 'y' in D: { x, y } (d assignable e) -d2.implicit = d1.explicit; // ok, 'y' in { x, y } (c assignable to f) -b1.implicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) -b1.explicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) +d1.polymorphic = b2.polymorphic; // ok, 'y' in D: { x, y } +d2.polymorphic = d1.explicit; // ok, 'y' in { x, y } +b1.polymorphic = d2.polymorphic; // ok, 'x' and 'y' not in Base1: { x } +b1.explicit = d2.polymorphic; // ok, 'x' and 'y' not in Base1: { x } ////// use this-type for construction with new //// function InterfaceThis() { this.a = 12; @@ -405,4 +372,4 @@ var interfaceThis = new InterfaceThis(); var literalTypeThis = new LiteralTypeThis(); var anyThis = new AnyThis(); var n = f.call(12); -function missingTypeIsImplicitAny(a) { return a; } +function missingTypeIsImplicitAny(a) { return this.anything + a; } diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 9cd1915fc94..1d51f4aaca0 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -22,841 +22,763 @@ class C { >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 28)) - } - implicitThis(m: number): number { ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 17)) - - return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 17)) } explicitC(this: C, m: number): number { ->explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 14)) +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 9, 14)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 22)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) return this.n + m; >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 22)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) } explicitProperty(this: {n: number}, m: number): number { ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 15, 21)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 39)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 21)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 15, 26)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 39)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) } explicitVoid(this: void, m: number): number { ->explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 18, 17)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 18, 28)) +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 15, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 28)) return m + 1; ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 18, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 28)) } } class D extends C { } ->D : Symbol(D, Decl(thisTypeInFunctions.ts, 21, 1)) +>D : Symbol(D, Decl(thisTypeInFunctions.ts, 18, 1)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) interface I { ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) a: number; ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 23, 13)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 20, 13)) explicitVoid1(this: void): number; ->explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 24, 14)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 18)) +>explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 21, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 22, 18)) explicitVoid2(this: void): number; ->explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 25, 38)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 18)) +>explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 22, 38)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 23, 18)) explicitStructural(this: {a: number}): number; ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 27, 23)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 24, 23)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) explicitInterface(this: I): number; ->explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 28, 22)) ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) +>explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 22)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) explicitThis(this: this): number; ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 29, 17)) - - implicitMethod(): number; ->implicitMethod : Symbol(implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) - - implicitFunction: () => number; ->implicitFunction : Symbol(implicitFunction, Decl(thisTypeInFunctions.ts, 30, 29)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 17)) } function explicitStructural(this: { y: number }, x: number): number { ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 32, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 33, 28)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 33, 35)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 33, 48)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 27, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 28, 28)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 28, 35)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 28, 48)) return x + this.y; ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 33, 48)) ->this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 33, 35)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 33, 33)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 33, 35)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 28, 48)) +>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 28, 35)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 28, 33)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 28, 35)) } function justThis(this: { y: number }): number { ->justThis : Symbol(justThis, Decl(thisTypeInFunctions.ts, 35, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 36, 18)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 36, 25)) +>justThis : Symbol(justThis, Decl(thisTypeInFunctions.ts, 30, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 31, 18)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 31, 25)) return this.y; ->this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 36, 25)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 36, 23)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 36, 25)) +>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 31, 25)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 31, 23)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 31, 25)) } function implicitThis(n: number): number { ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 38, 1)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 39, 22)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 33, 1)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 34, 22)) - return 12; + return this.m + n + 12; +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 34, 22)) } let impl: I = { ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) a: 12, ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 42, 15)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 37, 15)) explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) ->explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 43, 10)) +>explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 38, 10)) explicitVoid1() { return 12; }, ->explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 44, 32)) +>explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 39, 32)) explicitStructural() { ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 45, 35)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 40, 35)) return this.a; ->this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 27, 28)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) +>this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 24, 28)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) }, explicitInterface() { ->explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 48, 6)) +>explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 43, 6)) return this.a; ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) }, explicitThis() { ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 51, 6)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 46, 6)) return this.a; ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) }, - implicitMethod() { ->implicitMethod : Symbol(implicitMethod, Decl(thisTypeInFunctions.ts, 54, 6)) - - return this.a; ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) - - }, - implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) ->implicitFunction : Symbol(implicitFunction, Decl(thisTypeInFunctions.ts, 57, 6)) } impl.explicitVoid1 = function () { return 12; }; ->impl.explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 24, 14)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 24, 14)) +>impl.explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 21, 14)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 21, 14)) impl.explicitVoid2 = () => 12; ->impl.explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 25, 38)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 25, 38)) +>impl.explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 22, 38)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 22, 38)) impl.explicitStructural = function() { return this.a; }; ->impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) ->this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 27, 28)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) +>impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) +>this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 24, 28)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) impl.explicitInterface = function() { return this.a; }; ->impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) impl.explicitStructural = () => 12; ->impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) +>impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) impl.explicitInterface = () => 12; ->impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) +>impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) impl.explicitThis = function () { return this.a; }; ->impl.explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) - -impl.implicitMethod = function () { return this.a; }; ->impl.implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) - -impl.implicitMethod = () => 12; ->impl.implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) - -impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) ->impl.implicitFunction : Symbol(I.implicitFunction, Decl(thisTypeInFunctions.ts, 30, 29)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->implicitFunction : Symbol(I.implicitFunction, Decl(thisTypeInFunctions.ts, 30, 29)) +>impl.explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) // parameter checking let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; ->ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 71, 3)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 71, 9)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 19)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 71, 24)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 71, 31)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 71, 44)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 71, 70)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 77)) ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 32, 1)) +>ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 59, 3)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 59, 9)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 59, 19)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 59, 24)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 59, 31)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 59, 44)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 59, 70)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 59, 77)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 27, 1)) let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; ->implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 72, 3)) ->notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 72, 20)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 41)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 72, 46)) ->notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 72, 71)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 89)) ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 38, 1)) +>implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 60, 3)) +>notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 60, 20)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 60, 41)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 60, 46)) +>notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 60, 71)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 60, 89)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 33, 1)) ok.f(13); ->ok.f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 19)) ->ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 71, 3)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 19)) +>ok.f : Symbol(f, Decl(thisTypeInFunctions.ts, 59, 19)) +>ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 59, 3)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 59, 19)) implicitThis(12); ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 38, 1)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 33, 1)) implicitAnyOk.f(12); ->implicitAnyOk.f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 41)) ->implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 72, 3)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 41)) +>implicitAnyOk.f : Symbol(f, Decl(thisTypeInFunctions.ts, 60, 41)) +>implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 60, 3)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 60, 41)) let c = new C(); ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) let d = new D(); ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->D : Symbol(D, Decl(thisTypeInFunctions.ts, 21, 1)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 66, 3)) +>D : Symbol(D, Decl(thisTypeInFunctions.ts, 18, 1)) let ripped = c.explicitC; ->ripped : Symbol(ripped, Decl(thisTypeInFunctions.ts, 79, 3)) ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) +>ripped : Symbol(ripped, Decl(thisTypeInFunctions.ts, 67, 3)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) c.explicitC(12); ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) c.explicitProperty(12); ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) c.explicitThis(12); >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) -c.implicitThis(12); ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) - d.explicitC(12); ->d.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) +>d.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 66, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) d.explicitProperty(12); ->d.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) +>d.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 66, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) d.explicitThis(12); >d.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 66, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) -d.implicitThis(12); ->d.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) - let reconstructed: { ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) n: number, ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 88, 20)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 74, 20)) explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 89, 14)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 90, 17)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 75, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 76, 17)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 90, 25)) - - implicitThis(m: number): number, ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 91, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 76, 25)) explicitC(this: C, m: number): number, ->explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 91, 36)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 92, 14)) +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 76, 45)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 77, 14)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 92, 22)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 77, 22)) explicitProperty: (this: {n : number}, m: number) => number, ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 93, 23)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 93, 30)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 93, 42)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 78, 23)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 78, 30)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 78, 42)) explicitVoid(this: void, m: number): number, ->explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 93, 64)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 94, 17)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 94, 28)) +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 78, 64)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 79, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 79, 28)) } = { n: 12, ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 95, 5)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 80, 5)) explicitThis: c.explicitThis, ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 96, 10)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 81, 10)) >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) - implicitThis: c.implicitThis, ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 97, 33)) ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) - explicitC: c.explicitC, ->explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 98, 33)) ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 82, 33)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) explicitProperty: c.explicitProperty, ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 99, 27)) ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 83, 27)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) explicitVoid: c.explicitVoid ->explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 100, 41)) ->c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 84, 41)) +>c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) }; -reconstructed.explicitProperty(11); ->reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) +reconstructed.explicitThis(10); +>reconstructed.explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 75, 14)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 75, 14)) -reconstructed.implicitThis(11); ->reconstructed.implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) +reconstructed.explicitProperty(11); +>reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) + +let explicitVoid = reconstructed.explicitVoid; +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 89, 3)) +>reconstructed.explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 78, 64)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 78, 64)) + +explicitVoid(12); +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 89, 3)) // assignment checking let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any ->unboundToSpecified : Symbol(unboundToSpecified, Decl(thisTypeInFunctions.ts, 107, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 107, 25)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 107, 32)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 107, 45)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 107, 68)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 107, 68)) +>unboundToSpecified : Symbol(unboundToSpecified, Decl(thisTypeInFunctions.ts, 92, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 92, 25)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 92, 32)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 45)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; ->specifiedToSpecified : Symbol(specifiedToSpecified, Decl(thisTypeInFunctions.ts, 108, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 108, 27)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 108, 34)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 108, 45)) ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 32, 1)) +>specifiedToSpecified : Symbol(specifiedToSpecified, Decl(thisTypeInFunctions.ts, 93, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 93, 27)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 93, 34)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 93, 45)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 27, 1)) let anyToSpecified: (this: { y: number }, x: number) => number = function(x: number): number { return x + 12; }; ->anyToSpecified : Symbol(anyToSpecified, Decl(thisTypeInFunctions.ts, 109, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 109, 21)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 109, 28)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 109, 41)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 109, 74)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 109, 74)) +>anyToSpecified : Symbol(anyToSpecified, Decl(thisTypeInFunctions.ts, 94, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 94, 21)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 94, 28)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 94, 41)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 94, 74)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 94, 74)) let unspecifiedLambda: (x: number) => number = x => x + 12; ->unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 111, 3)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 111, 24)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 111, 46)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 111, 46)) +>unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 96, 3)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 96, 24)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 96, 46)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 96, 46)) let specifiedLambda: (this: void, x: number) => number = x => x + 12; ->specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 112, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 112, 22)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 112, 33)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 112, 56)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 112, 56)) +>specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 97, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 97, 22)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 97, 33)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 97, 56)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 97, 56)) let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = unspecifiedLambda; ->unspecifiedLambdaToSpecified : Symbol(unspecifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 113, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 113, 35)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 113, 42)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 113, 53)) ->unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 111, 3)) +>unspecifiedLambdaToSpecified : Symbol(unspecifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 98, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 98, 35)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 98, 42)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 98, 53)) +>unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 96, 3)) let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; ->specifiedLambdaToSpecified : Symbol(specifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 114, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 114, 33)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 114, 40)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 114, 51)) ->specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 112, 3)) +>specifiedLambdaToSpecified : Symbol(specifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 99, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 99, 33)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 99, 40)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 99, 51)) +>specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 97, 3)) let explicitCFunction: (this: C, m: number) => number; ->explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 117, 24)) +>explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 102, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 102, 24)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 32)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 102, 32)) let explicitPropertyFunction: (this: {n: number}, m: number) => number; ->explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 118, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 118, 31)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 118, 38)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 49)) +>explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 103, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 103, 31)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 103, 38)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 103, 49)) c.explicitC = explicitCFunction; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 102, 3)) c.explicitC = function(this: C, m: number) { return this.n + m }; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 120, 23)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 105, 23)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 120, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 105, 31)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 120, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 105, 31)) c.explicitProperty = explicitPropertyFunction; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 118, 3)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 103, 3)) c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m }; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 122, 30)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 122, 48)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 122, 35)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 122, 48)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 107, 30)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 107, 37)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 107, 48)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 107, 37)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 107, 35)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 107, 37)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 107, 48)) c.explicitProperty = reconstructed.explicitProperty; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) // lambdas are assignable to anything c.explicitC = m => m; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 13)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 13)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 111, 13)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 111, 13)) c.explicitThis = m => m; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 16)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 112, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 112, 16)) c.explicitProperty = m => m; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 20)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 20)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 113, 20)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 113, 20)) // this inside lambdas refer to outer scope // the outer-scoped lambda at top-level is still just `any` c.explicitC = m => m + this.n; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 132, 13)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 132, 13)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) c.explicitThis = m => m + this.n; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 133, 16)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 133, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) c.explicitProperty = m => m + this.n; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 20)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 20)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) //NOTE: this=C here, I guess? c.explicitThis = explicitCFunction; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) +>explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 102, 3)) c.explicitThis = function(this: C, m: number) { return this.n + m }; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 138, 26)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 123, 26)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 138, 34)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 123, 34)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 138, 34)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 123, 34)) // this:any compatibility c.explicitC = function(m) { return this.n + m }; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 141, 23)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 23)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 141, 23)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 23)) c.explicitProperty = function(m) { return this.n + m }; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 142, 30)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 15, 26)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 142, 30)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 30)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 30)) c.explicitThis = function(m) { return this.n + m }; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 143, 26)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 26)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 143, 26)) - -c.implicitThis = function(m) { return this.n + m }; ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 144, 26)) ->this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 144, 26)) - -c.implicitThis = reconstructed.implicitThis; ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->reconstructed.implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 26)) c.explicitC = function(this: B, m: number) { return this.n + m }; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 147, 23)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 130, 23)) >B : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 147, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 130, 31)) >this.n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9)) >this : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) >n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 147, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 130, 31)) // this:void compatibility c.explicitVoid = n => n; ->c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 150, 16)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 150, 16)) +>c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 133, 16)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 133, 16)) // class-based assignability class Base1 { ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) x: number; ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) - public implicit(): number { return this.x; } ->implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) + public polymorphic(this: this): number { return this.x; } +>polymorphic : Symbol(polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 138, 23)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) explicit(this: Base1): number { return this.x; } ->explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 155, 48)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 156, 13)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) - - static implicitStatic(): number { return this.y; } ->implicitStatic : Symbol(Base1.implicitStatic, Decl(thisTypeInFunctions.ts, 156, 52)) ->this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) +>explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 139, 13)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) static explicitStatic(this: typeof Base1): number { return this.y; } ->explicitStatic : Symbol(Base1.explicitStatic, Decl(thisTypeInFunctions.ts, 157, 54)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 158, 26)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) +>explicitStatic : Symbol(Base1.explicitStatic, Decl(thisTypeInFunctions.ts, 139, 52)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 140, 26)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 140, 72)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 140, 72)) static y: number; ->y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) - +>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 140, 72)) } class Derived1 extends Base1 { ->Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 161, 1)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 142, 1)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) y: number ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 162, 30)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 143, 30)) } class Base2 { ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) y: number ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 165, 13)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 146, 13)) - implicit(): number { return this.y; } ->implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 165, 13)) ->this : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 165, 13)) + polymorphic(this: this): number { return this.y; } +>polymorphic : Symbol(polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 148, 16)) +>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 146, 13)) +>this : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 146, 13)) explicit(this: Base1): number { return this.x; } ->explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 167, 41)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 168, 13)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 153, 13)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 153, 13)) +>explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 148, 54)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 149, 13)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) } class Derived2 extends Base2 { ->Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 169, 1)) ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) +>Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 150, 1)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) x: number ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 170, 30)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 151, 30)) } let b1 = new Base1(); ->b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 173, 3)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) let b2 = new Base2(); ->b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 174, 3)) ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) +>b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 155, 3)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) let d1 = new Derived1(); ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 161, 1)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 142, 1)) let d2 = new Derived2(); ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 169, 1)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 150, 1)) -d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) -d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) ->d1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } +>d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) // bivariance-allowed cases -d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) ->d1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->b2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 174, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } +>d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>b2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 155, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) -d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) +d2.polymorphic = d1.explicit // ok, 'y' in { x, y } +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) -b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) ->b1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 173, 3)) ->implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +>b1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) -b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) ->b1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) ->b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 173, 3)) ->explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +>b1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ////// use this-type for construction with new //// function InterfaceThis(this: I) { ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 187, 23)) ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 165, 28)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 168, 23)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) this.a = 12; ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) } function LiteralTypeThis(this: {x: string}) { ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 190, 25)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 170, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 171, 25)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 171, 32)) this.x = "ok"; ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 190, 30)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 171, 32)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 171, 30)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 171, 32)) } function AnyThis(this: any) { ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 193, 17)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 173, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 174, 17)) this.x = "ok"; } let interfaceThis = new InterfaceThis(); ->interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 196, 3)) ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) +>interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 177, 3)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 165, 28)) let literalTypeThis = new LiteralTypeThis(); ->literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 197, 3)) ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) +>literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 178, 3)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 170, 1)) let anyThis = new AnyThis(); ->anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 198, 3)) ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) +>anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 179, 3)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 173, 1)) //// type parameter inference //// declare var f: { ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 182, 11)) (this: void, x: number): number, ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 202, 5)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 202, 16)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 183, 5)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 183, 16)) call(this: (...argArray: any[]) => U, ...argArray: any[]): U; ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 203, 12)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 19)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 44)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 183, 36)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 184, 9)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 184, 12)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 184, 19)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 184, 9)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 184, 44)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 184, 9)) }; let n: number = f.call(12); ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 205, 3)) ->f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 186, 3)) +>f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 183, 36)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 182, 11)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 183, 36)) -function missingTypeIsImplicitAny(this, a: number) { return a; } ->missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 205, 27)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 207, 34)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) +function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } +>missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 186, 27)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 188, 34)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 188, 39)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 188, 39)) diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 3922e454c3f..48186eee2d0 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -22,17 +22,6 @@ class C { >this.n : number >this : this >n : number ->m : number - } - implicitThis(m: number): number { ->implicitThis : (this: this, m: number) => number ->m : number - - return this.n + m; ->this.n + m : number ->this.n : number ->this : this ->n : number >m : number } explicitC(this: C, m: number): number { @@ -103,12 +92,6 @@ interface I { explicitThis(this: this): number; >explicitThis : (this: this) => number >this : this - - implicitMethod(): number; ->implicitMethod : (this: this) => number - - implicitFunction: () => number; ->implicitFunction : (this: void) => number } function explicitStructural(this: { y: number }, x: number): number { >explicitStructural : (this: { y: number; }, x: number) => number @@ -134,16 +117,22 @@ function justThis(this: { y: number }): number { >y : number } function implicitThis(n: number): number { ->implicitThis : (this: void, n: number) => number +>implicitThis : (n: number) => number >n : number - return 12; + return this.m + n + 12; +>this.m + n + 12 : any +>this.m + n : any +>this.m : any +>this : any +>m : any +>n : number >12 : number } let impl: I = { >impl : I >I : I ->{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; }, implicitMethod() { return this.a; }, implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?)} : { a: number; explicitVoid2: () => any; explicitVoid1(): number; explicitStructural(): number; explicitInterface(): number; explicitThis(): number; implicitMethod(): number; implicitFunction: () => any; } +>{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; },} : { a: number; explicitVoid2: () => any; explicitVoid1(): number; explicitStructural(): number; explicitInterface(): number; explicitThis(): number; } a: 12, >a : number @@ -187,28 +176,13 @@ let impl: I = { >a : number }, - implicitMethod() { ->implicitMethod : () => number - - return this.a; ->this.a : number ->this : I ->a : number - - }, - implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) ->implicitFunction : () => any ->() => this.a : () => any ->this.a : any ->this : any ->a : any } impl.explicitVoid1 = function () { return 12; }; ->impl.explicitVoid1 = function () { return 12; } : (this: void) => number +>impl.explicitVoid1 = function () { return 12; } : () => number >impl.explicitVoid1 : (this: void) => number >impl : I >explicitVoid1 : (this: void) => number ->function () { return 12; } : (this: void) => number +>function () { return 12; } : () => number >12 : number impl.explicitVoid2 = () => 12; @@ -220,21 +194,21 @@ impl.explicitVoid2 = () => 12; >12 : number impl.explicitStructural = function() { return this.a; }; ->impl.explicitStructural = function() { return this.a; } : (this: void) => number +>impl.explicitStructural = function() { return this.a; } : () => number >impl.explicitStructural : (this: { a: number; }) => number >impl : I >explicitStructural : (this: { a: number; }) => number ->function() { return this.a; } : (this: void) => number +>function() { return this.a; } : () => number >this.a : number >this : { a: number; } >a : number impl.explicitInterface = function() { return this.a; }; ->impl.explicitInterface = function() { return this.a; } : (this: void) => number +>impl.explicitInterface = function() { return this.a; } : () => number >impl.explicitInterface : (this: I) => number >impl : I >explicitInterface : (this: I) => number ->function() { return this.a; } : (this: void) => number +>function() { return this.a; } : () => number >this.a : number >this : I >a : number @@ -256,43 +230,15 @@ impl.explicitInterface = () => 12; >12 : number impl.explicitThis = function () { return this.a; }; ->impl.explicitThis = function () { return this.a; } : (this: void) => number +>impl.explicitThis = function () { return this.a; } : () => number >impl.explicitThis : (this: I) => number >impl : I >explicitThis : (this: I) => number ->function () { return this.a; } : (this: void) => number +>function () { return this.a; } : () => number >this.a : number >this : I >a : number -impl.implicitMethod = function () { return this.a; }; ->impl.implicitMethod = function () { return this.a; } : (this: void) => number ->impl.implicitMethod : (this: I) => number ->impl : I ->implicitMethod : (this: I) => number ->function () { return this.a; } : (this: void) => number ->this.a : number ->this : I ->a : number - -impl.implicitMethod = () => 12; ->impl.implicitMethod = () => 12 : () => number ->impl.implicitMethod : (this: I) => number ->impl : I ->implicitMethod : (this: I) => number ->() => 12 : () => number ->12 : number - -impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) ->impl.implicitFunction = () => this.a : () => any ->impl.implicitFunction : (this: void) => number ->impl : I ->implicitFunction : (this: void) => number ->() => this.a : () => any ->this.a : any ->this : any ->a : any - // parameter checking let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; >ok : { y: number; f: (this: { y: number; }, x: number) => number; } @@ -308,15 +254,15 @@ let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: >explicitStructural : (this: { y: number; }, x: number) => number let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; ->implicitAnyOk : { notSpecified: number; f: (this: void, x: number) => number; } +>implicitAnyOk : { notSpecified: number; f: (x: number) => number; } >notSpecified : number ->f : (this: void, x: number) => number +>f : (x: number) => number >x : number ->{ notSpecified: 12, f: implicitThis } : { notSpecified: number; f: (this: void, n: number) => number; } +>{ notSpecified: 12, f: implicitThis } : { notSpecified: number; f: (n: number) => number; } >notSpecified : number >12 : number ->f : (this: void, n: number) => number ->implicitThis : (this: void, n: number) => number +>f : (n: number) => number +>implicitThis : (n: number) => number ok.f(13); >ok.f(13) : number @@ -327,14 +273,14 @@ ok.f(13); implicitThis(12); >implicitThis(12) : number ->implicitThis : (this: void, n: number) => number +>implicitThis : (n: number) => number >12 : number implicitAnyOk.f(12); >implicitAnyOk.f(12) : number ->implicitAnyOk.f : (this: void, x: number) => number ->implicitAnyOk : { notSpecified: number; f: (this: void, x: number) => number; } ->f : (this: void, x: number) => number +>implicitAnyOk.f : (x: number) => number +>implicitAnyOk : { notSpecified: number; f: (x: number) => number; } +>f : (x: number) => number >12 : number let c = new C(); @@ -374,13 +320,6 @@ c.explicitThis(12); >explicitThis : (this: C, m: number) => number >12 : number -c.implicitThis(12); ->c.implicitThis(12) : number ->c.implicitThis : (this: C, m: number) => number ->c : C ->implicitThis : (this: C, m: number) => number ->12 : number - d.explicitC(12); >d.explicitC(12) : number >d.explicitC : (this: C, m: number) => number @@ -402,15 +341,8 @@ d.explicitThis(12); >explicitThis : (this: D, m: number) => number >12 : number -d.implicitThis(12); ->d.implicitThis(12) : number ->d.implicitThis : (this: D, m: number) => number ->d : D ->implicitThis : (this: D, m: number) => number ->12 : number - let reconstructed: { ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } n: number, >n : number @@ -419,10 +351,6 @@ let reconstructed: { >explicitThis : (this: C, m: number) => number >this : C >C : C ->m : number - - implicitThis(m: number): number, ->implicitThis : (m: number) => number >m : number explicitC(this: C, m: number): number, @@ -443,7 +371,7 @@ let reconstructed: { >m : number } = { ->{ n: 12, explicitThis: c.explicitThis, implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid} : { n: number; explicitThis: (this: C, m: number) => number; implicitThis: (this: C, m: number) => number; explicitC: (this: C, m: number) => number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid: (this: void, m: number) => number; } +>{ n: 12, explicitThis: c.explicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid} : { n: number; explicitThis: (this: C, m: number) => number; explicitC: (this: C, m: number) => number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid: (this: void, m: number) => number; } n: 12, >n : number @@ -455,12 +383,6 @@ let reconstructed: { >c : C >explicitThis : (this: C, m: number) => number - implicitThis: c.implicitThis, ->implicitThis : (this: C, m: number) => number ->c.implicitThis : (this: C, m: number) => number ->c : C ->implicitThis : (this: C, m: number) => number - explicitC: c.explicitC, >explicitC : (this: C, m: number) => number >c.explicitC : (this: C, m: number) => number @@ -480,19 +402,30 @@ let reconstructed: { >explicitVoid : (this: void, m: number) => number }; +reconstructed.explicitThis(10); +>reconstructed.explicitThis(10) : number +>reconstructed.explicitThis : (this: C, m: number) => number +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>explicitThis : (this: C, m: number) => number +>10 : number + reconstructed.explicitProperty(11); >reconstructed.explicitProperty(11) : number >reconstructed.explicitProperty : (this: { n: number; }, m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >explicitProperty : (this: { n: number; }, m: number) => number >11 : number -reconstructed.implicitThis(11); ->reconstructed.implicitThis(11) : number ->reconstructed.implicitThis : (m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } ->implicitThis : (m: number) => number ->11 : number +let explicitVoid = reconstructed.explicitVoid; +>explicitVoid : (this: void, m: number) => number +>reconstructed.explicitVoid : (this: void, m: number) => number +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>explicitVoid : (this: void, m: number) => number + +explicitVoid(12); +>explicitVoid(12) : number +>explicitVoid : (this: void, m: number) => number +>12 : number // assignment checking let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any @@ -520,14 +453,14 @@ let anyToSpecified: (this: { y: number }, x: number) => number = function(x: num >this : { y: number; } >y : number >x : number ->function(x: number): number { return x + 12; } : (this: void, x: number) => number +>function(x: number): number { return x + 12; } : (x: number) => number >x : number >x + 12 : number >x : number >12 : number let unspecifiedLambda: (x: number) => number = x => x + 12; ->unspecifiedLambda : (this: void, x: number) => number +>unspecifiedLambda : (x: number) => number >x : number >x => x + 12 : (x: number) => number >x : number @@ -550,7 +483,7 @@ let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = uns >this : { y: number; } >y : number >x : number ->unspecifiedLambda : (this: void, x: number) => number +>unspecifiedLambda : (x: number) => number let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; >specifiedLambdaToSpecified : (this: { y: number; }, x: number) => number @@ -622,7 +555,7 @@ c.explicitProperty = reconstructed.explicitProperty; >c : C >explicitProperty : (this: { n: number; }, m: number) => number >reconstructed.explicitProperty : (this: { n: number; }, m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >explicitProperty : (this: { n: number; }, m: number) => number // lambdas are assignable to anything @@ -719,11 +652,11 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; // this:any compatibility c.explicitC = function(m) { return this.n + m }; ->c.explicitC = function(m) { return this.n + m } : (this: void, m: number) => number +>c.explicitC = function(m) { return this.n + m } : (m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->function(m) { return this.n + m } : (this: void, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number @@ -732,11 +665,11 @@ c.explicitC = function(m) { return this.n + m }; >m : number c.explicitProperty = function(m) { return this.n + m }; ->c.explicitProperty = function(m) { return this.n + m } : (this: void, m: number) => number +>c.explicitProperty = function(m) { return this.n + m } : (m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->function(m) { return this.n + m } : (this: void, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number @@ -745,11 +678,11 @@ c.explicitProperty = function(m) { return this.n + m }; >m : number c.explicitThis = function(m) { return this.n + m }; ->c.explicitThis = function(m) { return this.n + m } : (this: void, m: number) => number +>c.explicitThis = function(m) { return this.n + m } : (m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (this: void, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number @@ -757,28 +690,6 @@ c.explicitThis = function(m) { return this.n + m }; >n : number >m : number -c.implicitThis = function(m) { return this.n + m }; ->c.implicitThis = function(m) { return this.n + m } : (this: void, m: number) => number ->c.implicitThis : (this: C, m: number) => number ->c : C ->implicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (this: void, m: number) => number ->m : number ->this.n + m : number ->this.n : number ->this : C ->n : number ->m : number - -c.implicitThis = reconstructed.implicitThis; ->c.implicitThis = reconstructed.implicitThis : (m: number) => number ->c.implicitThis : (this: C, m: number) => number ->c : C ->implicitThis : (this: C, m: number) => number ->reconstructed.implicitThis : (m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } ->implicitThis : (m: number) => number - c.explicitC = function(this: B, m: number) { return this.n + m }; >c.explicitC = function(this: B, m: number) { return this.n + m } : (this: B, m: number) => number >c.explicitC : (this: C, m: number) => number @@ -811,8 +722,9 @@ class Base1 { x: number; >x : number - public implicit(): number { return this.x; } ->implicit : (this: this) => number + public polymorphic(this: this): number { return this.x; } +>polymorphic : (this: this) => number +>this : this >this.x : number >this : this >x : number @@ -825,12 +737,6 @@ class Base1 { >this : Base1 >x : number - static implicitStatic(): number { return this.y; } ->implicitStatic : (this: typeof Base1) => number ->this.y : number ->this : typeof Base1 ->y : number - static explicitStatic(this: typeof Base1): number { return this.y; } >explicitStatic : (this: typeof Base1) => number >this : typeof Base1 @@ -841,7 +747,6 @@ class Base1 { static y: number; >y : number - } class Derived1 extends Base1 { >Derived1 : Derived1 @@ -856,8 +761,9 @@ class Base2 { y: number >y : number - implicit(): number { return this.y; } ->implicit : (this: this) => number + polymorphic(this: this): number { return this.y; } +>polymorphic : (this: this) => number +>this : this >this.y : number >this : this >y : number @@ -897,60 +803,60 @@ let d2 = new Derived2(); >new Derived2() : Derived2 >Derived2 : typeof Derived2 -d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) ->d2.implicit = d1.implicit : (this: Derived1) => number ->d2.implicit : (this: Derived2) => number +d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } +>d2.polymorphic = d1.polymorphic : (this: Derived1) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number ->d1.implicit : (this: Derived1) => number +>polymorphic : (this: Derived2) => number +>d1.polymorphic : (this: Derived1) => number >d1 : Derived1 ->implicit : (this: Derived1) => number +>polymorphic : (this: Derived1) => number -d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) ->d1.implicit = d2.implicit : (this: Derived2) => number ->d1.implicit : (this: Derived1) => number +d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } +>d1.polymorphic = d2.polymorphic : (this: Derived2) => number +>d1.polymorphic : (this: Derived1) => number >d1 : Derived1 ->implicit : (this: Derived1) => number ->d2.implicit : (this: Derived2) => number +>polymorphic : (this: Derived1) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number +>polymorphic : (this: Derived2) => number // bivariance-allowed cases -d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) ->d1.implicit = b2.implicit : (this: Base2) => number ->d1.implicit : (this: Derived1) => number +d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } +>d1.polymorphic = b2.polymorphic : (this: Base2) => number +>d1.polymorphic : (this: Derived1) => number >d1 : Derived1 ->implicit : (this: Derived1) => number ->b2.implicit : (this: Base2) => number +>polymorphic : (this: Derived1) => number +>b2.polymorphic : (this: Base2) => number >b2 : Base2 ->implicit : (this: Base2) => number +>polymorphic : (this: Base2) => number -d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) ->d2.implicit = d1.explicit : (this: Base1) => number ->d2.implicit : (this: Derived2) => number +d2.polymorphic = d1.explicit // ok, 'y' in { x, y } +>d2.polymorphic = d1.explicit : (this: Base1) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number +>polymorphic : (this: Derived2) => number >d1.explicit : (this: Base1) => number >d1 : Derived1 >explicit : (this: Base1) => number -b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) ->b1.implicit = d2.implicit : (this: Derived2) => number ->b1.implicit : (this: Base1) => number +b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +>b1.polymorphic = d2.polymorphic : (this: Derived2) => number +>b1.polymorphic : (this: Base1) => number >b1 : Base1 ->implicit : (this: Base1) => number ->d2.implicit : (this: Derived2) => number +>polymorphic : (this: Base1) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number +>polymorphic : (this: Derived2) => number -b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) ->b1.explicit = d2.implicit : (this: Derived2) => number +b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +>b1.explicit = d2.polymorphic : (this: Derived2) => number >b1.explicit : (this: Base1) => number >b1 : Base1 >explicit : (this: Base1) => number ->d2.implicit : (this: Derived2) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number +>polymorphic : (this: Derived2) => number ////// use this-type for construction with new //// function InterfaceThis(this: I) { @@ -1005,16 +911,16 @@ let anyThis = new AnyThis(); //// type parameter inference //// declare var f: { ->f : { (this: void, x: number): number; call(this: (this: void, ...argArray: any[]) => U, ...argArray: any[]): U; } +>f : { (this: void, x: number): number; call(this: (...argArray: any[]) => U, ...argArray: any[]): U; } (this: void, x: number): number, >this : void >x : number call(this: (...argArray: any[]) => U, ...argArray: any[]): U; ->call : (this: (this: void, ...argArray: any[]) => U, ...argArray: any[]) => U +>call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U >U : U ->this : (this: void, ...argArray: any[]) => U +>this : (...argArray: any[]) => U >argArray : any[] >U : U >argArray : any[] @@ -1024,14 +930,18 @@ declare var f: { let n: number = f.call(12); >n : number >f.call(12) : number ->f.call : (this: (this: void, ...argArray: any[]) => U, ...argArray: any[]) => U ->f : { (this: void, x: number): number; call(this: (this: void, ...argArray: any[]) => U, ...argArray: any[]): U; } ->call : (this: (this: void, ...argArray: any[]) => U, ...argArray: any[]) => U +>f.call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U +>f : { (this: void, x: number): number; call(this: (...argArray: any[]) => U, ...argArray: any[]): U; } +>call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U >12 : number -function missingTypeIsImplicitAny(this, a: number) { return a; } ->missingTypeIsImplicitAny : (this: any, a: number) => number +function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } +>missingTypeIsImplicitAny : (this: any, a: number) => any >this : any >a : number +>this.anything + a : any +>this.anything : any +>this : any +>anything : any >a : number diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index c48ea11b3b0..c888f4e5ecb 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -1,126 +1,103 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(16,15): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(44,21): error TS2339: Property 'a' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(55,49): error TS2339: Property 'a' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(58,1): error TS2345: Argument of type 'void' is not assignable to parameter of type '{ a: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(60,1): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(62,1): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(70,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(74,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(76,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(39,21): error TS2339: Property 'a' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2345: Argument of type 'void' is not assignable to parameter of type '{ a: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(56,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(59,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(61,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(77,97): error TS2322: Type '{ y: string; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(62,97): error TS2322: Type '{ y: string; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(78,110): error TS2322: Type '{ wrongName: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(63,110): error TS2322: Type '{ wrongName: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(80,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(82,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(83,1): error TS2345: Argument of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(65,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(66,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2345: Argument of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. Types of property 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(84,1): error TS2345: Argument of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2345: Argument of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(87,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(88,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(89,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(90,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(91,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(92,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(93,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(94,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(95,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(96,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(97,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(98,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(101,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(73,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(74,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(75,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(76,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(77,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(78,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(79,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(80,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(82,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(83,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(86,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type '{ y: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(124,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(107,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. Property 'x' is missing in type 'C'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(125,1): error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(108,1): error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type '{ n: number; }' is not assignable to type '{ x: number; }'. Property 'x' is missing in type '{ n: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(127,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(110,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(128,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(111,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(129,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(112,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(130,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(113,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(131,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(132,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(133,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(114,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type '{ n: number; }' is not assignable to type 'D'. Property 'x' is missing in type '{ n: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(134,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type '{ n: number; }' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(135,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(136,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(115,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(116,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(137,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(117,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(138,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type 'void' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,51): error TS2339: Property 'x' does not exist on type 'typeof Base1'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(147,69): error TS2339: Property 'x' does not exist on type 'typeof Base1'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(125,69): error TS2339: Property 'x' does not exist on type 'typeof Base1'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(145,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'Base1' is not assignable to type 'Base2'. Property 'y' is missing in type 'Base1'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'Base1' is not assignable to type 'Base2'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type 'Base1' is not assignable to type 'Base2'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(179,16): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(180,24): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,17): error TS2680: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,30): error TS2679: 'this' parameter must be the first parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,61): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,26): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,57): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,20): error TS2370: A rest parameter must be of an array type. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,23): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,27): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,54): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,23): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,24): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(193,28): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(193,32): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(193,59): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,32): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,39): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,40): error TS1128: Declaration or statement expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,42): error TS2304: Cannot find name 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,49): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,1): error TS7027: Unreachable code detected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,29): error TS2304: Cannot find name 'm'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,32): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(148,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2680: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(161,30): error TS2679: 'this' parameter must be the first parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,26): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,20): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,23): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,27): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,23): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,24): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,28): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,32): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,32): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,39): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,40): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,42): error TS2304: Cannot find name 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,49): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,1): error TS7027: Unreachable code detected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,29): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,32): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,35): error TS2304: Cannot find name 'm'. -==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (76 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (63 errors) ==== class C { n: number; explicitThis(this: this, m: number): number { @@ -149,9 +126,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e explicitD(this: D, m: number): number { return this.x + m; } - implicitD(m: number): number { - return this.x + m; - } } interface I { a: number; @@ -160,8 +134,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; // TODO: Allow `this` types for interfaces - implicitMethod(): number; - implicitFunction: () => number; } let impl: I = { a: 12, @@ -176,12 +148,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e explicitThis() { return this.a; }, - implicitMethod() { - return this.a; // ok, I.a: number - }, - implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' - ~ -!!! error TS2339: Property 'a' does not exist on type 'void'. } let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' @@ -190,10 +156,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. - let implImplicitMethod = impl.implicitMethod; - implImplicitMethod(); // error, no 'a' in 'void' - ~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. function explicitStructural(this: { y: number }, x: number): number { return x + this.y; @@ -206,12 +168,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e function voidThisSpecified(this: void, x: number): number { return x + this.notSpecified; ~~~~~~~~~~~~ -!!! error TS2339: Property 'notSpecified' does not exist on type 'void'. - } - function noThisSpecified(x: number): number { - // this:void unless loose-this is on - return x + this.notSpecified; - ~~~~~~~~~~~~ !!! error TS2339: Property 'notSpecified' does not exist on type 'void'. } let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, explicitStructural }; @@ -285,8 +241,8 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. - let specifiedToImplicitVoid: (x: number) => number = explicitStructural; - ~~~~~~~~~~~~~~~~~~~~~~~ + let specifiedToVoid: (this: void, x: number) => number = explicitStructural; + ~~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type '{ y: number; }'. @@ -294,14 +250,12 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, // error not assignable -- c.this:c not assignable to this:void. explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid @@ -325,11 +279,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS2322: Type '{ n: number; }' is not assignable to type '{ x: number; }'. !!! error TS2322: Property 'x' is missing in type '{ n: number; }'. - c.explicitC = d.implicitD; - ~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitC = d.explicitD; ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. @@ -339,11 +288,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type 'C' is not assignable to type 'D'. - c.explicitThis = d.implicitD; - ~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitThis = d.explicitD; ~~~~~~~~~~~~~~ @@ -361,19 +305,9 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type '{ n: number; }' is not assignable to type 'D'. !!! error TS2322: Property 'x' is missing in type '{ n: number; }'. - c.explicitProperty = d.implicitD; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type '{ n: number; }' is not assignable to type 'D'. c.explicitThis = d.explicitThis; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - c.explicitVoid = d.implicitD; - ~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type 'void' is not assignable to type 'D'. c.explicitVoid = d.explicitD; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. @@ -385,15 +319,12 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'D'. - /// class-based implicit assignability (with inheritance!) /// + /// class-based polymorphic assignability (with inheritance!) /// class Base1 { x: number - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.x; } - ~ -!!! error TS2339: Property 'x' does not exist on type 'typeof Base1'. static explicitStatic(this: typeof Base1): number { return this.x; } ~ !!! error TS2339: Property 'x' does not exist on type 'typeof Base1'. @@ -403,7 +334,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -416,37 +347,29 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e let b2 = new Base2(); let d2 = new Derived2(); - b1.implicit = b2.implicit // error, 'this.y' not in C: { x } (c assignable to e) - ~~~~~~~~~~~ + b1.polymorphic = b2.polymorphic // error, 'this.y' not in Base1: { x } + ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. !!! error TS2322: Property 'y' is missing in type 'Base1'. - b1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + b1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. - d1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + d1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. ////// use this-type for construction with new //// function VoidThis(this: void) { - } - function ImplicitVoidThis() { - } let voidThis = new VoidThis(); ~~~~~~~~~~~~~~ !!! error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. - let implicitVoidThis = new ImplicitVoidThis(); - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. ///// syntax-ish errors ///// class ThisConstructor { @@ -458,8 +381,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ !!! error TS2679: 'this' parameter must be the first parameter. - ~ -!!! error TS2339: Property 'n' does not exist on type 'void'. ///// parse errors ///// function modifiers(async this: C): number { return this.n; } @@ -467,8 +388,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS1003: Identifier expected. ~ !!! error TS1005: ',' expected. - ~ -!!! error TS2339: Property 'n' does not exist on type 'void'. function restParam(...this: C): number { return this.n; } ~~~~~~~ !!! error TS2370: A rest parameter must be of an array type. @@ -476,8 +395,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS1003: Identifier expected. ~ !!! error TS1005: ',' expected. - ~ -!!! error TS2339: Property 'n' does not exist on type 'void'. function optional(this?: C): number { return this.n; } ~ !!! error TS1005: ',' expected. @@ -488,8 +405,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS1003: Identifier expected. ~ !!! error TS1005: ',' expected. - ~ -!!! error TS2339: Property 'n' does not exist on type 'void'. function initializer(this: C = new C()): number { return this.n; } ~ !!! error TS1005: ',' expected. diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index c0892d9e4c8..8fa5aba6ad2 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -25,9 +25,6 @@ class D { explicitD(this: D, m: number): number { return this.x + m; } - implicitD(m: number): number { - return this.x + m; - } } interface I { a: number; @@ -36,8 +33,6 @@ interface I { explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; // TODO: Allow `this` types for interfaces - implicitMethod(): number; - implicitFunction: () => number; } let impl: I = { a: 12, @@ -50,17 +45,11 @@ let impl: I = { explicitThis() { return this.a; }, - implicitMethod() { - return this.a; // ok, I.a: number - }, - implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' } let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' -let implImplicitMethod = impl.implicitMethod; -implImplicitMethod(); // error, no 'a' in 'void' function explicitStructural(this: { y: number }, x: number): number { return x + this.y; } @@ -70,10 +59,6 @@ function propertyName(this: { y: number }, x: number): number { function voidThisSpecified(this: void, x: number): number { return x + this.notSpecified; } -function noThisSpecified(x: number): number { - // this:void unless loose-this is on - return x + this.notSpecified; -} let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, explicitStructural }; let wrongPropertyType: {y: string, f: (this: { y: number }, x: number) => number} = { y: 'foo', explicitStructural }; let wrongPropertyName: {wrongName: number, f: (this: { y: number }, x: number) => number} = { wrongName: 12, explicitStructural }; @@ -99,19 +84,17 @@ c.explicitProperty('wrong type 3'); c.explicitProperty(15, 'too many arguments 3'); // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. -let specifiedToImplicitVoid: (x: number) => number = explicitStructural; +let specifiedToVoid: (this: void, x: number) => number = explicitStructural; let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, // error not assignable -- c.this:c not assignable to this:void. explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid @@ -125,26 +108,21 @@ let explicitXProperty: (this: { x: number }, m: number) => number; c.explicitC = function(this: D, m: number) { return this.x + m }; c.explicitProperty = explicitXProperty; -c.explicitC = d.implicitD; c.explicitC = d.explicitD; c.explicitC = d.explicitThis; -c.explicitThis = d.implicitD; c.explicitThis = d.explicitD; c.explicitThis = d.explicitThis; c.explicitProperty = d.explicitD; -c.explicitProperty = d.implicitD; c.explicitThis = d.explicitThis; -c.explicitVoid = d.implicitD; c.explicitVoid = d.explicitD; c.explicitVoid = d.explicitThis; -/// class-based implicit assignability (with inheritance!) /// +/// class-based polymorphic assignability (with inheritance!) /// class Base1 { x: number - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.x; } static explicitStatic(this: typeof Base1): number { return this.x; } } class Derived1 extends Base1 { @@ -152,7 +130,7 @@ class Derived1 extends Base1 { } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -165,20 +143,16 @@ let d1 = new Derived1(); let b2 = new Base2(); let d2 = new Derived2(); -b1.implicit = b2.implicit // error, 'this.y' not in C: { x } (c assignable to e) -b1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) +b1.polymorphic = b2.polymorphic // error, 'this.y' not in Base1: { x } +b1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } -d1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) +d1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ////// use this-type for construction with new //// function VoidThis(this: void) { -} -function ImplicitVoidThis() { - } let voidThis = new VoidThis(); -let implicitVoidThis = new ImplicitVoidThis(); ///// syntax-ish errors ///// class ThisConstructor { @@ -234,9 +208,6 @@ var D = (function () { D.prototype.explicitD = function (m) { return this.x + m; }; - D.prototype.implicitD = function (m) { - return this.x + m; - }; return D; }()); var impl = { @@ -249,18 +220,12 @@ var impl = { explicitInterface: function () { return 12; }, explicitThis: function () { return this.a; - }, - implicitMethod: function () { - return this.a; // ok, I.a: number - }, - implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' + } }; var implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' var implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' -var implImplicitMethod = impl.implicitMethod; -implImplicitMethod(); // error, no 'a' in 'void' function explicitStructural(x) { return x + this.y; } @@ -270,10 +235,6 @@ function propertyName(x) { function voidThisSpecified(x) { return x + this.notSpecified; } -function noThisSpecified(x) { - // this:void unless loose-this is on - return x + this.notSpecified; -} var ok = { y: 12, explicitStructural: explicitStructural }; var wrongPropertyType = { y: 'foo', explicitStructural: explicitStructural }; var wrongPropertyName = { wrongName: 12, explicitStructural: explicitStructural }; @@ -296,11 +257,10 @@ c.explicitProperty(); // not enough arguments c.explicitProperty('wrong type 3'); c.explicitProperty(15, 'too many arguments 3'); // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. -var specifiedToImplicitVoid = explicitStructural; +var specifiedToVoid = explicitStructural; var reconstructed = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid @@ -312,25 +272,20 @@ var explicitXProperty; // from differing object types c.explicitC = function (m) { return this.x + m; }; c.explicitProperty = explicitXProperty; -c.explicitC = d.implicitD; c.explicitC = d.explicitD; c.explicitC = d.explicitThis; -c.explicitThis = d.implicitD; c.explicitThis = d.explicitD; c.explicitThis = d.explicitThis; c.explicitProperty = d.explicitD; -c.explicitProperty = d.implicitD; c.explicitThis = d.explicitThis; -c.explicitVoid = d.implicitD; c.explicitVoid = d.explicitD; c.explicitVoid = d.explicitThis; -/// class-based implicit assignability (with inheritance!) /// +/// class-based polymorphic assignability (with inheritance!) /// var Base1 = (function () { function Base1() { } - Base1.prototype.implicit = function () { return this.x; }; + Base1.prototype.polymorphic = function () { return this.x; }; Base1.prototype.explicit = function () { return this.x; }; - Base1.implicitStatic = function () { return this.x; }; Base1.explicitStatic = function () { return this.x; }; return Base1; }()); @@ -344,7 +299,7 @@ var Derived1 = (function (_super) { var Base2 = (function () { function Base2() { } - Base2.prototype.implicit = function () { return this.y; }; + Base2.prototype.polymorphic = function () { return this.y; }; Base2.prototype.explicit = function () { return this.x; }; return Base2; }()); @@ -359,16 +314,13 @@ var b1 = new Base1(); var d1 = new Derived1(); var b2 = new Base2(); var d2 = new Derived2(); -b1.implicit = b2.implicit; // error, 'this.y' not in C: { x } (c assignable to e) -b1.explicit = b2.implicit; // error, 'y' not in C: { x } (c assignable to e) -d1.explicit = b2.implicit; // error, 'y' not in C: { x } (c assignable to e) +b1.polymorphic = b2.polymorphic; // error, 'this.y' not in Base1: { x } +b1.explicit = b2.polymorphic; // error, 'y' not in Base1: { x } +d1.explicit = b2.polymorphic; // error, 'y' not in Base1: { x } ////// use this-type for construction with new //// function VoidThis() { } -function ImplicitVoidThis() { -} var voidThis = new VoidThis(); -var implicitVoidThis = new ImplicitVoidThis(); ///// syntax-ish errors ///// var ThisConstructor = (function () { function ThisConstructor(n) { diff --git a/tests/baselines/reference/unionThisTypeInFunctions.js b/tests/baselines/reference/unionThisTypeInFunctions.js index 31ff266087b..0d4b535ff8b 100644 --- a/tests/baselines/reference/unionThisTypeInFunctions.js +++ b/tests/baselines/reference/unionThisTypeInFunctions.js @@ -1,10 +1,10 @@ //// [unionThisTypeInFunctions.ts] interface Real { - method(n: number): void; + method(this: this, n: number): void; data: string; } interface Fake { - method(n: number): void; + method(this: this, n: number): void; data: number; } function test(r: Real | Fake) { diff --git a/tests/baselines/reference/unionThisTypeInFunctions.symbols b/tests/baselines/reference/unionThisTypeInFunctions.symbols index 8b5f2af01e0..d18fb3475bb 100644 --- a/tests/baselines/reference/unionThisTypeInFunctions.symbols +++ b/tests/baselines/reference/unionThisTypeInFunctions.symbols @@ -2,22 +2,24 @@ interface Real { >Real : Symbol(Real, Decl(unionThisTypeInFunctions.ts, 0, 0)) - method(n: number): void; + method(this: this, n: number): void; >method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 0, 16)) ->n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 1, 11)) +>this : Symbol(this, Decl(unionThisTypeInFunctions.ts, 1, 11)) +>n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 1, 22)) data: string; ->data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 1, 28)) +>data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 1, 40)) } interface Fake { >Fake : Symbol(Fake, Decl(unionThisTypeInFunctions.ts, 3, 1)) - method(n: number): void; + method(this: this, n: number): void; >method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 4, 16)) ->n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 5, 11)) +>this : Symbol(this, Decl(unionThisTypeInFunctions.ts, 5, 11)) +>n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 5, 22)) data: number; ->data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 5, 28)) +>data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 5, 40)) } function test(r: Real | Fake) { >test : Symbol(test, Decl(unionThisTypeInFunctions.ts, 7, 1)) diff --git a/tests/baselines/reference/unionThisTypeInFunctions.types b/tests/baselines/reference/unionThisTypeInFunctions.types index f2c4f7ee4ec..3c5181166b6 100644 --- a/tests/baselines/reference/unionThisTypeInFunctions.types +++ b/tests/baselines/reference/unionThisTypeInFunctions.types @@ -2,8 +2,9 @@ interface Real { >Real : Real - method(n: number): void; + method(this: this, n: number): void; >method : (this: this, n: number) => void +>this : this >n : number data: string; @@ -12,15 +13,16 @@ interface Real { interface Fake { >Fake : Fake - method(n: number): void; + method(this: this, n: number): void; >method : (this: this, n: number) => void +>this : this >n : number data: number; >data : number } function test(r: Real | Fake) { ->test : (this: void, r: Real | Fake) => void +>test : (r: Real | Fake) => void >r : Real | Fake >Real : Real >Fake : Fake diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts index 3a1de178eea..80f5fce9a97 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts @@ -1,4 +1,3 @@ -// @strictThisChecks: true // body checking class B { n: number; @@ -8,9 +7,6 @@ class C { explicitThis(this: this, m: number): number { return this.n + m; } - implicitThis(m: number): number { - return this.n + m; - } explicitC(this: C, m: number): number { return this.n + m; } @@ -29,8 +25,6 @@ interface I { explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; - implicitMethod(): number; - implicitFunction: () => number; } function explicitStructural(this: { y: number }, x: number): number { return x + this.y; @@ -39,7 +33,7 @@ function justThis(this: { y: number }): number { return this.y; } function implicitThis(n: number): number { - return 12; + return this.m + n + 12; } let impl: I = { a: 12, @@ -54,10 +48,6 @@ let impl: I = { explicitThis() { return this.a; }, - implicitMethod() { - return this.a; - }, - implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) } impl.explicitVoid1 = function () { return 12; }; impl.explicitVoid2 = () => 12; @@ -66,9 +56,6 @@ impl.explicitInterface = function() { return this.a; }; impl.explicitStructural = () => 12; impl.explicitInterface = () => 12; impl.explicitThis = function () { return this.a; }; -impl.implicitMethod = function () { return this.a; }; -impl.implicitMethod = () => 12; -impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) // parameter checking let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; @@ -82,29 +69,26 @@ let ripped = c.explicitC; c.explicitC(12); c.explicitProperty(12); c.explicitThis(12); -c.implicitThis(12); d.explicitC(12); d.explicitProperty(12); d.explicitThis(12); -d.implicitThis(12); let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid }; +reconstructed.explicitThis(10); reconstructed.explicitProperty(11); -reconstructed.implicitThis(11); - +let explicitVoid = reconstructed.explicitVoid; +explicitVoid(12); // assignment checking let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; @@ -143,8 +127,6 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; c.explicitC = function(m) { return this.n + m }; c.explicitProperty = function(m) { return this.n + m }; c.explicitThis = function(m) { return this.n + m }; -c.implicitThis = function(m) { return this.n + m }; -c.implicitThis = reconstructed.implicitThis; c.explicitC = function(this: B, m: number) { return this.n + m }; @@ -154,19 +136,17 @@ c.explicitVoid = n => n; // class-based assignability class Base1 { x: number; - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.y; } static explicitStatic(this: typeof Base1): number { return this.y; } static y: number; - } class Derived1 extends Base1 { y: number } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -176,14 +156,14 @@ let b1 = new Base1(); let b2 = new Base2(); let d1 = new Derived1(); let d2 = new Derived2(); -d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) -d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) +d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } +d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } // bivariance-allowed cases -d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) -d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) -b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) -b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } +d2.polymorphic = d1.explicit // ok, 'y' in { x, y } +b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } ////// use this-type for construction with new //// function InterfaceThis(this: I) { @@ -206,4 +186,4 @@ declare var f: { }; let n: number = f.call(12); -function missingTypeIsImplicitAny(this, a: number) { return a; } +function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts index bec0b9ab434..394b1867490 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts @@ -1,4 +1,3 @@ -// @strictThisChecks: true class C { n: number; explicitThis(this: this, m: number): number { @@ -25,9 +24,6 @@ class D { explicitD(this: D, m: number): number { return this.x + m; } - implicitD(m: number): number { - return this.x + m; - } } interface I { a: number; @@ -36,8 +32,6 @@ interface I { explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; // TODO: Allow `this` types for interfaces - implicitMethod(): number; - implicitFunction: () => number; } let impl: I = { a: 12, @@ -50,17 +44,11 @@ let impl: I = { explicitThis() { return this.a; }, - implicitMethod() { - return this.a; // ok, I.a: number - }, - implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' } let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' -let implImplicitMethod = impl.implicitMethod; -implImplicitMethod(); // error, no 'a' in 'void' function explicitStructural(this: { y: number }, x: number): number { return x + this.y; } @@ -70,10 +58,6 @@ function propertyName(this: { y: number }, x: number): number { function voidThisSpecified(this: void, x: number): number { return x + this.notSpecified; } -function noThisSpecified(x: number): number { - // this:void unless loose-this is on - return x + this.notSpecified; -} let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, explicitStructural }; let wrongPropertyType: {y: string, f: (this: { y: number }, x: number) => number} = { y: 'foo', explicitStructural }; let wrongPropertyName: {wrongName: number, f: (this: { y: number }, x: number) => number} = { wrongName: 12, explicitStructural }; @@ -99,19 +83,17 @@ c.explicitProperty('wrong type 3'); c.explicitProperty(15, 'too many arguments 3'); // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. -let specifiedToImplicitVoid: (x: number) => number = explicitStructural; +let specifiedToVoid: (this: void, x: number) => number = explicitStructural; let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, // error not assignable -- c.this:c not assignable to this:void. explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid @@ -125,26 +107,21 @@ let explicitXProperty: (this: { x: number }, m: number) => number; c.explicitC = function(this: D, m: number) { return this.x + m }; c.explicitProperty = explicitXProperty; -c.explicitC = d.implicitD; c.explicitC = d.explicitD; c.explicitC = d.explicitThis; -c.explicitThis = d.implicitD; c.explicitThis = d.explicitD; c.explicitThis = d.explicitThis; c.explicitProperty = d.explicitD; -c.explicitProperty = d.implicitD; c.explicitThis = d.explicitThis; -c.explicitVoid = d.implicitD; c.explicitVoid = d.explicitD; c.explicitVoid = d.explicitThis; -/// class-based implicit assignability (with inheritance!) /// +/// class-based polymorphic assignability (with inheritance!) /// class Base1 { x: number - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.x; } static explicitStatic(this: typeof Base1): number { return this.x; } } class Derived1 extends Base1 { @@ -152,7 +129,7 @@ class Derived1 extends Base1 { } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -165,20 +142,16 @@ let d1 = new Derived1(); let b2 = new Base2(); let d2 = new Derived2(); -b1.implicit = b2.implicit // error, 'this.y' not in C: { x } (c assignable to e) -b1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) +b1.polymorphic = b2.polymorphic // error, 'this.y' not in Base1: { x } +b1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } -d1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) +d1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ////// use this-type for construction with new //// function VoidThis(this: void) { -} -function ImplicitVoidThis() { - } let voidThis = new VoidThis(); -let implicitVoidThis = new ImplicitVoidThis(); ///// syntax-ish errors ///// class ThisConstructor { diff --git a/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts index c0a55f138ce..4f74058cc48 100644 --- a/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts @@ -1,10 +1,9 @@ -// @strictThisChecks: true interface Real { - method(n: number): void; + method(this: this, n: number): void; data: string; } interface Fake { - method(n: number): void; + method(this: this, n: number): void; data: number; } function test(r: Real | Fake) { diff --git a/tests/cases/fourslash/memberListOnExplicitThis.ts b/tests/cases/fourslash/memberListOnExplicitThis.ts index 207ec8796fa..b776a7c0641 100644 --- a/tests/cases/fourslash/memberListOnExplicitThis.ts +++ b/tests/cases/fourslash/memberListOnExplicitThis.ts @@ -1,4 +1,3 @@ -// @strictThisChecks: true /// ////interface Restricted { @@ -7,10 +6,10 @@ ////class C1 implements Restricted { //// n: number; //// m: number; -//// f() {this./*1*/} // test on 'this.' +//// f(this: this) {this./*1*/} // test on 'this.' //// g(this: Restricted) {this./*2*/} ////} -////function f() {this./*3*/} +////function f(this: void) {this./*3*/} ////function g(this: Restricted) {this./*4*/} goTo.marker('1'); diff --git a/tests/cases/fourslash/quickInfoOnThis.ts b/tests/cases/fourslash/quickInfoOnThis.ts index bfed13ea89c..91083d41e6b 100644 --- a/tests/cases/fourslash/quickInfoOnThis.ts +++ b/tests/cases/fourslash/quickInfoOnThis.ts @@ -1,4 +1,3 @@ -// @strictThisChecks: true /// ////interface Restricted { //// n: number; @@ -6,9 +5,9 @@ ////function wrapper(wrapped: { (): void; }) { } ////class Foo { //// n: number; -//// public implicitThis() { +//// public explicitThis(this: this) { //// wrapper( -//// function implicitVoid() { +//// function explicitVoid(this: void) { //// console.log(th/*1*/is); //// } //// ) @@ -22,15 +21,15 @@ //// } ////} ////class Bar { -//// public implicitThis() { +//// public explicitThis(this: this) { //// console.log(th/*7*/is); //// } -//// public explicitThis(this: Bar) { +//// public explicitClass(this: Bar) { //// console.log(thi/*8*/s); //// } ////} //// -////function implicitVoid(x: number): void { +////function implicitAny(x: number): void { //// return th/*9*/is; ////} ////function explicitVoid(th/*10*/is: void, x: number): void { @@ -75,7 +74,7 @@ verify.quickInfoIs('this: this'); goTo.marker('8'); verify.quickInfoIs('this: Bar'); goTo.marker('9'); -verify.quickInfoIs('void'); +verify.quickInfoIs('any'); goTo.marker('10'); verify.quickInfoIs('(parameter) this: void'); goTo.marker('11'); From a91cdccfc509e0878a8b8993e10aaa3a65246673 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 25 Mar 2016 16:37:28 -0700 Subject: [PATCH 31/48] Add --noImplicitThis flag It's basically another --noImplicitAny error, but one that would break large amount of JavaScript-style code. --- src/compiler/checker.ts | 4 ++ src/compiler/commandLineParser.ts | 4 ++ src/compiler/diagnosticMessages.json | 6 ++- src/compiler/types.ts | 1 + .../noImplicitThisFunctions.errors.txt | 25 +++++++++++++ .../reference/noImplicitThisFunctions.js | 37 +++++++++++++++++++ .../cases/compiler/noImplicitThisFunctions.ts | 19 ++++++++++ 7 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/noImplicitThisFunctions.errors.txt create mode 100644 tests/baselines/reference/noImplicitThisFunctions.js create mode 100644 tests/cases/compiler/noImplicitThisFunctions.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 51fad3e7f33..0f9287f9c52 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7707,6 +7707,10 @@ namespace ts { } } + if (compilerOptions.noImplicitThis && isFunctionLike(container)) { + // With noImplicitThis, functions may not reference 'this' if it has type 'any' + error(node, Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); + } return anyType; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index cf55f030c33..363a3fdfc8f 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -125,6 +125,10 @@ namespace ts { type: "boolean", description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, + { + name: "noImplicitThis", + type: "boolean", + }, { name: "noLib", type: "boolean", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5ea860f00af..53d0bcc07b8 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1863,7 +1863,11 @@ "category": "Error", "code": 2680 }, - "Import declaration '{0}' is using private name '{1}'.": { + "'this' implicitly has type 'any' because it does not have a type annotation.": { + "category": "Error", + "code": 2681 + }, + "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5965a39a79e..e4c376b7b25 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2395,6 +2395,7 @@ namespace ts { noEmitOnError?: boolean; noErrorTruncation?: boolean; noImplicitAny?: boolean; + noImplicitThis?: boolean; noLib?: boolean; noResolve?: boolean; out?: string; diff --git a/tests/baselines/reference/noImplicitThisFunctions.errors.txt b/tests/baselines/reference/noImplicitThisFunctions.errors.txt new file mode 100644 index 00000000000..b00949d5086 --- /dev/null +++ b/tests/baselines/reference/noImplicitThisFunctions.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/noImplicitThisFunctions.ts(14,12): error TS2681: 'this' implicitly has type 'any' because it does not have a type annotation. + + +==== tests/cases/compiler/noImplicitThisFunctions.ts (1 errors) ==== + + function f1(x) { + // implicit any is still allowed + return x + 1; + } + + function f2(y: number) { + // ok: no reference to this + return y + 1; + } + + function f3(z: number): number { + // error: this is implicitly any + return this.a + z; + ~~~~ +!!! error TS2681: 'this' implicitly has type 'any' because it does not have a type annotation. + } + + // ok, arrow functions don't even bind `this`, so `this` is just `window` + let f4: (b: number) => number = b => this.c + b; + \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitThisFunctions.js b/tests/baselines/reference/noImplicitThisFunctions.js new file mode 100644 index 00000000000..e256df2d77f --- /dev/null +++ b/tests/baselines/reference/noImplicitThisFunctions.js @@ -0,0 +1,37 @@ +//// [noImplicitThisFunctions.ts] + +function f1(x) { + // implicit any is still allowed + return x + 1; +} + +function f2(y: number) { + // ok: no reference to this + return y + 1; +} + +function f3(z: number): number { + // error: this is implicitly any + return this.a + z; +} + +// ok, arrow functions don't even bind `this`, so `this` is just `window` +let f4: (b: number) => number = b => this.c + b; + + +//// [noImplicitThisFunctions.js] +var _this = this; +function f1(x) { + // implicit any is still allowed + return x + 1; +} +function f2(y) { + // ok: no reference to this + return y + 1; +} +function f3(z) { + // error: this is implicitly any + return this.a + z; +} +// ok, arrow functions don't even bind `this`, so `this` is just `window` +var f4 = function (b) { return _this.c + b; }; diff --git a/tests/cases/compiler/noImplicitThisFunctions.ts b/tests/cases/compiler/noImplicitThisFunctions.ts new file mode 100644 index 00000000000..1e0aa0c4da0 --- /dev/null +++ b/tests/cases/compiler/noImplicitThisFunctions.ts @@ -0,0 +1,19 @@ +// @noImplicitThis: true + +function f1(x) { + // implicit any is still allowed + return x + 1; +} + +function f2(y: number) { + // ok: no reference to this + return y + 1; +} + +function f3(z: number): number { + // error: this is implicitly any + return this.a + z; +} + +// ok, arrow functions don't even bind `this`, so `this` is just `window` +let f4: (b: number) => number = b => this.c + b; From f64110aa0f6f3ffced6142a6465d6038b128bfd9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 28 Mar 2016 10:37:39 -0700 Subject: [PATCH 32/48] Update baselines after merging from master --- .../reference/thisTypeInFunctions.symbols | 60 +++++++++---------- .../unionThisTypeInFunctions.symbols | 8 +-- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 1d51f4aaca0..0d7c8263206 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -4,39 +4,39 @@ class B { >B : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) n: number; ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 1, 9)) +>n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9)) } class C { >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) n: number; ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) explicitThis(this: this, m: number): number { ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 6, 17)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 28)) return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 28)) } explicitC(this: C, m: number): number { ->explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 9, 14)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) } explicitProperty(this: {n: number}, m: number): number { ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 21)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) @@ -48,7 +48,7 @@ class C { >m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) } explicitVoid(this: void, m: number): number { ->explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 15, 17)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 28)) @@ -64,28 +64,28 @@ interface I { >I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) a: number; ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 20, 13)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) explicitVoid1(this: void): number; ->explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 21, 14)) +>explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 21, 14)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 22, 18)) explicitVoid2(this: void): number; ->explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 22, 38)) +>explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 22, 38)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 23, 18)) explicitStructural(this: {a: number}): number; ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) +>explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 24, 23)) >a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) explicitInterface(this: I): number; ->explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) +>explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 22)) >I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) explicitThis(this: this): number; ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) +>explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 17)) } function explicitStructural(this: { y: number }, x: number): number { @@ -585,22 +585,22 @@ class Base1 { >Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) x: number; ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) public polymorphic(this: this): number { return this.x; } ->polymorphic : Symbol(polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 138, 23)) ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) +>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) >this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) explicit(this: Base1): number { return this.x; } ->explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 139, 13)) >Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) +>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) >this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) static explicitStatic(this: typeof Base1): number { return this.y; } >explicitStatic : Symbol(Base1.explicitStatic, Decl(thisTypeInFunctions.ts, 139, 52)) @@ -618,23 +618,23 @@ class Derived1 extends Base1 { >Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) y: number ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 143, 30)) +>y : Symbol(Derived1.y, Decl(thisTypeInFunctions.ts, 143, 30)) } class Base2 { >Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) y: number ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 146, 13)) +>y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 146, 13)) polymorphic(this: this): number { return this.y; } ->polymorphic : Symbol(polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 148, 16)) ->this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 146, 13)) +>this.y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 146, 13)) >this : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 146, 13)) +>y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 146, 13)) explicit(this: Base1): number { return this.x; } ->explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 148, 54)) +>explicit : Symbol(Base2.explicit, Decl(thisTypeInFunctions.ts, 148, 54)) >this : Symbol(this, Decl(thisTypeInFunctions.ts, 149, 13)) >Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) >this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) @@ -646,7 +646,7 @@ class Derived2 extends Base2 { >Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) x: number ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 151, 30)) +>x : Symbol(Derived2.x, Decl(thisTypeInFunctions.ts, 151, 30)) } let b1 = new Base1(); >b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) diff --git a/tests/baselines/reference/unionThisTypeInFunctions.symbols b/tests/baselines/reference/unionThisTypeInFunctions.symbols index d18fb3475bb..eada1231750 100644 --- a/tests/baselines/reference/unionThisTypeInFunctions.symbols +++ b/tests/baselines/reference/unionThisTypeInFunctions.symbols @@ -3,23 +3,23 @@ interface Real { >Real : Symbol(Real, Decl(unionThisTypeInFunctions.ts, 0, 0)) method(this: this, n: number): void; ->method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 0, 16)) +>method : Symbol(Real.method, Decl(unionThisTypeInFunctions.ts, 0, 16)) >this : Symbol(this, Decl(unionThisTypeInFunctions.ts, 1, 11)) >n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 1, 22)) data: string; ->data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 1, 40)) +>data : Symbol(Real.data, Decl(unionThisTypeInFunctions.ts, 1, 40)) } interface Fake { >Fake : Symbol(Fake, Decl(unionThisTypeInFunctions.ts, 3, 1)) method(this: this, n: number): void; ->method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 4, 16)) +>method : Symbol(Fake.method, Decl(unionThisTypeInFunctions.ts, 4, 16)) >this : Symbol(this, Decl(unionThisTypeInFunctions.ts, 5, 11)) >n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 5, 22)) data: number; ->data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 5, 40)) +>data : Symbol(Fake.data, Decl(unionThisTypeInFunctions.ts, 5, 40)) } function test(r: Real | Fake) { >test : Symbol(test, Decl(unionThisTypeInFunctions.ts, 7, 1)) From 0113ad525069ca77e69d7b98fd429e5a5f178d22 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 30 Mar 2016 13:31:10 -0700 Subject: [PATCH 33/48] Error on all uses of this that are implicitly any Previously it was only an error inside an function. --- src/compiler/checker.ts | 2 +- .../baselines/reference/noImplicitThisFunctions.errors.txt | 7 +++++-- tests/baselines/reference/noImplicitThisFunctions.js | 4 ++-- tests/cases/compiler/noImplicitThisFunctions.ts | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 272dbb12b97..9a2a6e1f8e7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8110,7 +8110,7 @@ namespace ts { } } - if (compilerOptions.noImplicitThis && isFunctionLike(container)) { + if (compilerOptions.noImplicitThis) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' error(node, Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); } diff --git a/tests/baselines/reference/noImplicitThisFunctions.errors.txt b/tests/baselines/reference/noImplicitThisFunctions.errors.txt index b00949d5086..f1742bc758a 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.errors.txt +++ b/tests/baselines/reference/noImplicitThisFunctions.errors.txt @@ -1,7 +1,8 @@ tests/cases/compiler/noImplicitThisFunctions.ts(14,12): error TS2681: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2681: 'this' implicitly has type 'any' because it does not have a type annotation. -==== tests/cases/compiler/noImplicitThisFunctions.ts (1 errors) ==== +==== tests/cases/compiler/noImplicitThisFunctions.ts (2 errors) ==== function f1(x) { // implicit any is still allowed @@ -20,6 +21,8 @@ tests/cases/compiler/noImplicitThisFunctions.ts(14,12): error TS2681: 'this' imp !!! error TS2681: 'this' implicitly has type 'any' because it does not have a type annotation. } - // ok, arrow functions don't even bind `this`, so `this` is just `window` + // error: `this` is `window`, but is still of type `any` let f4: (b: number) => number = b => this.c + b; + ~~~~ +!!! error TS2681: '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/noImplicitThisFunctions.js b/tests/baselines/reference/noImplicitThisFunctions.js index e256df2d77f..80ceccbe751 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.js +++ b/tests/baselines/reference/noImplicitThisFunctions.js @@ -15,7 +15,7 @@ function f3(z: number): number { return this.a + z; } -// ok, arrow functions don't even bind `this`, so `this` is just `window` +// error: `this` is `window`, but is still of type `any` let f4: (b: number) => number = b => this.c + b; @@ -33,5 +33,5 @@ function f3(z) { // error: this is implicitly any return this.a + z; } -// ok, arrow functions don't even bind `this`, so `this` is just `window` +// error: `this` is `window`, but is still of type `any` var f4 = function (b) { return _this.c + b; }; diff --git a/tests/cases/compiler/noImplicitThisFunctions.ts b/tests/cases/compiler/noImplicitThisFunctions.ts index 1e0aa0c4da0..45f0e5a1eb9 100644 --- a/tests/cases/compiler/noImplicitThisFunctions.ts +++ b/tests/cases/compiler/noImplicitThisFunctions.ts @@ -15,5 +15,5 @@ function f3(z: number): number { return this.a + z; } -// ok, arrow functions don't even bind `this`, so `this` is just `window` +// error: `this` is `window`, but is still of type `any` let f4: (b: number) => number = b => this.c + b; From e4ed7f904e43424ea9fac3e2e8f3ac6435949daf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 30 Mar 2016 15:01:16 -0700 Subject: [PATCH 34/48] Address PR comments --- src/compiler/checker.ts | 28 +++++----- src/compiler/commandLineParser.ts | 1 + src/compiler/diagnosticMessages.json | 10 +++- .../noImplicitThisFunctions.errors.txt | 8 +-- .../thisTypeInFunctionsNegative.errors.txt | 53 +++++++++++-------- .../reference/thisTypeInFunctionsNegative.js | 11 ++++ .../thisType/thisTypeInFunctionsNegative.ts | 5 ++ 7 files changed, 76 insertions(+), 40 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9a2a6e1f8e7..e5a57cd96a9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5379,11 +5379,8 @@ namespace ts { function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration) { const areAllParametersUntyped = !forEach(node.parameters, p => p.type); - if (node.kind === SyntaxKind.ArrowFunction) { - return !node.typeParameters && node.parameters.length && areAllParametersUntyped; - } - const hasThisType = node.parameters.length && (node.parameters[0].name).text === "this" && node.parameters[0].type; - return !node.typeParameters && areAllParametersUntyped && !hasThisType; + const isNullaryArrow = node.kind === SyntaxKind.ArrowFunction && !node.parameters.length; + return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; } function getTypeWithoutSignatures(type: Type): Type { @@ -8072,20 +8069,20 @@ 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); } - 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 (isInJavaScriptFile(node)) { const type = getTypeForThisExpressionFromJSDoc(container); @@ -12401,9 +12398,12 @@ namespace ts { if (indexOf(func.parameters, node) !== 0) { error(node, Diagnostics.this_parameter_must_be_the_first_parameter); } - if (func.kind === SyntaxKind.Constructor) { + if (func.kind === SyntaxKind.Constructor || func.kind === SyntaxKind.ConstructSignature) { error(node, Diagnostics.A_constructor_cannot_have_a_this_parameter); } + if (func.kind === SyntaxKind.SetAccessor) { + error(node, Diagnostics.A_setter_cannot_have_a_this_parameter); + } } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e418a529386..81d5d190fc7 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -125,6 +125,7 @@ namespace ts { { name: "noImplicitThis", type: "boolean", + description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noLib", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f0df9c4f9cb..0da7cb72932 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1887,10 +1887,14 @@ "category": "Error", "code": 2680 }, - "'this' implicitly has type 'any' because it does not have a type annotation.": { + "A setter cannot have a 'this' parameter.": { "category": "Error", "code": 2681 }, + "'this' implicitly has type 'any' because it does not have a type annotation.": { + "category": "Error", + "code": 2682 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -2636,6 +2640,10 @@ "category": "Message", "code": 6113 }, + "Raise error on 'this' expressions with an implied 'any' type.": { + "category": "Message", + "code": 6114 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/tests/baselines/reference/noImplicitThisFunctions.errors.txt b/tests/baselines/reference/noImplicitThisFunctions.errors.txt index f1742bc758a..c80552c6b37 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.errors.txt +++ b/tests/baselines/reference/noImplicitThisFunctions.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/noImplicitThisFunctions.ts(14,12): error TS2681: 'this' implicitly has type 'any' because it does not have a type annotation. -tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2681: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisFunctions.ts(14,12): error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. ==== tests/cases/compiler/noImplicitThisFunctions.ts (2 errors) ==== @@ -18,11 +18,11 @@ tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2681: 'this' imp // error: this is implicitly any return this.a + z; ~~~~ -!!! error TS2681: 'this' implicitly has type 'any' because it does not have a type annotation. +!!! error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. } // error: `this` is `window`, but is still of type `any` let f4: (b: number) => number = b => this.c + b; ~~~~ -!!! error TS2681: 'this' implicitly has type 'any' because it does not have a type annotation. +!!! error TS2682: '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/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index c888f4e5ecb..305208ac7d7 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -75,29 +75,31 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,1): er tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(148,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2680: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(161,30): error TS2679: 'this' parameter must be the first parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,26): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,20): error TS2370: A rest parameter must be of an array type. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,23): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,27): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,23): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,24): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,28): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,32): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,32): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,39): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,40): error TS1128: Declaration or statement expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,42): error TS2304: Cannot find name 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,49): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,1): error TS7027: Unreachable code detected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,29): error TS2304: Cannot find name 'm'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,32): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,35): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(160,11): error TS2681: A setter cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,9): error TS2680: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,30): error TS2679: 'this' parameter must be the first parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,26): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,20): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,23): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,27): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,23): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,24): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,28): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,32): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,32): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,39): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,40): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,42): error TS2304: Cannot find name 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,49): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,1): error TS7027: Unreachable code detected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,29): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,32): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): error TS2304: Cannot find name 'm'. -==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (63 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (65 errors) ==== class C { n: number; explicitThis(this: this, m: number): number { @@ -377,6 +379,15 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,35): e ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2680: A constructor cannot have a 'this' parameter. } + set p(this: void) { + ~~~~~~~~~~ +!!! error TS2681: A setter cannot have a 'this' parameter. + } + } + interface ThisConstructorInterface { + new(this: ThisConstructor, n: number); + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2680: A constructor cannot have a 'this' parameter. } function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index 8fa5aba6ad2..1cfb38bb100 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -158,6 +158,11 @@ let voidThis = new VoidThis(); class ThisConstructor { constructor(this: ThisConstructor, private n: number) { } + set p(this: void) { + } +} +interface ThisConstructorInterface { + new(this: ThisConstructor, n: number); } function notFirst(a: number, this: C): number { return this.n; } @@ -326,6 +331,12 @@ var ThisConstructor = (function () { function ThisConstructor(n) { this.n = n; } + Object.defineProperty(ThisConstructor.prototype, "p", { + set: function () { + }, + enumerable: true, + configurable: true + }); return ThisConstructor; }()); function notFirst(a, this) { return this.n; } diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts index 394b1867490..1b049aeec50 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts @@ -157,6 +157,11 @@ let voidThis = new VoidThis(); class ThisConstructor { constructor(this: ThisConstructor, private n: number) { } + set p(this: void) { + } +} +interface ThisConstructorInterface { + new(this: ThisConstructor, n: number); } function notFirst(a: number, this: C): number { return this.n; } From 0060b4d66332adb2fc5eb99b84f3e2095d176d58 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 31 Mar 2016 09:32:34 -0700 Subject: [PATCH 35/48] Test that signature help doesn't show 'this' --- tests/cases/fourslash/signatureHelpThis.ts | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/cases/fourslash/signatureHelpThis.ts diff --git a/tests/cases/fourslash/signatureHelpThis.ts b/tests/cases/fourslash/signatureHelpThis.ts new file mode 100644 index 00000000000..2ac19c823c0 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpThis.ts @@ -0,0 +1,43 @@ +/// +////class Foo { +//// public implicitAny(n: number) { +//// } +//// public explicitThis(this: this, n: number) { +//// console.log(this); +//// } +//// public explicitClass(this: Foo, n: number) { +//// console.log(this); +//// } +////} +//// +////function implicitAny(x: number): void { +//// return this; +////} +////function explicitVoid(this: void, x: number): void { +//// return this; +////} +////function explicitLiteral(this: { n: number }, x: number): void { +//// console.log(this); +////} +////let foo = new Foo(); +////foo.implicitAny(/*1*/); +////foo.explicitThis(/*2*/); +////foo.explicitClass(/*3*/); +////implicitAny(/*4*/12); +////explicitVoid(/*5*/13); +////let o = { n: 14, m: explicitLiteral }; +////o.m(/*6*/); + + +goTo.marker('1'); +verify.currentParameterHelpArgumentNameIs("n"); +goTo.marker('2'); +verify.currentParameterHelpArgumentNameIs("n"); +goTo.marker('3'); +verify.currentParameterHelpArgumentNameIs("n"); +goTo.marker('4'); +verify.currentParameterHelpArgumentNameIs("x"); +goTo.marker('5'); +verify.currentParameterHelpArgumentNameIs("x"); +goTo.marker('6'); +verify.currentParameterHelpArgumentNameIs("x"); From da982587032f50d9d4a6ca7e7969487690d3c395 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 31 Mar 2016 10:28:06 -0700 Subject: [PATCH 36/48] Improve error messages and code style --- src/compiler/checker.ts | 32 +++++++++---------- src/compiler/diagnosticMessages.json | 6 +++- .../looseThisTypeInFunctions.errors.txt | 4 +-- .../thisTypeInFunctionsNegative.errors.txt | 26 +++++++-------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e5a57cd96a9..4ce7f6cd0a8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5465,21 +5465,17 @@ namespace ts { target = getErasedSignature(target); let result = Ternary.True; - if (source.thisType && target.thisType) { - if (source.thisType !== voidType) { - // void sources are assignable to anything. - let related = compareTypes(target.thisType, source.thisType, reportErrors); - if (!related) { - related = compareTypes(source.thisType, target.thisType, /*reportErrors*/ false); - if (!related) { - if (reportErrors) { - errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, "this", "this"); - } - return Ternary.False; - } + if (source.thisType && target.thisType && source.thisType !== voidType) { + // void sources are assignable to anything. + const related = compareTypes(source.thisType, target.thisType, /*reportErrors*/ false) + || compareTypes(target.thisType, source.thisType, reportErrors); + if (!related) { + if (reportErrors) { + errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, "this", "this"); } - result &= related; + return Ternary.False; } + result &= related; } const sourceMax = getNumNonRestParameters(source); @@ -10199,18 +10195,20 @@ namespace ts { } function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map, excludeArgument: boolean[], reportErrors: boolean) { - const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + if (signature.thisType && signature.thisType !== voidType && node.kind !== SyntaxKind.NewExpression) { - // If the source's this is not of the form `x.f` or `x[f]`, then sourceType = voidType - // If the target's this is voidType, then the check is skipped -- anything is compatible. + // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType + // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. const thisArgumentNode = getThisArgumentOfCall(node); const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; const errorNode = reportErrors ? (thisArgumentNode || node) : undefined; + const headMessage = Diagnostics.this_context_of_type_0_is_not_assignable_to_method_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage)) { return false; } } + const headMessage = Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; const argCount = getEffectiveArgumentCount(node, args, signature); for (let i = 0; i < argCount; i++) { const arg = getEffectiveArgument(node, args, i); @@ -12396,7 +12394,7 @@ namespace ts { } if ((node.name).text === "this") { if (indexOf(func.parameters, node) !== 0) { - error(node, Diagnostics.this_parameter_must_be_the_first_parameter); + error(node, Diagnostics.A_this_parameter_must_be_the_first_parameter); } if (func.kind === SyntaxKind.Constructor || func.kind === SyntaxKind.ConstructSignature) { error(node, Diagnostics.A_constructor_cannot_have_a_this_parameter); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0da7cb72932..1f282b10fd8 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1879,7 +1879,7 @@ "category": "Error", "code": 2678 }, - "'this' parameter must be the first parameter.": { + "A 'this' parameter must be the first parameter.": { "category": "Error", "code": 2679 }, @@ -1895,6 +1895,10 @@ "category": "Error", "code": 2682 }, + "'this' context of type '{0}' is not assignable to method 'this' of type '{1}'.": { + "category": "Error", + "code": 2683 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index caaf7afb09c..4531797586c 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'C'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,28): error TS2339: Property 'length' does not exist on type 'number'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error TS2339: Property 'length' does not exist on type 'number'. @@ -51,7 +51,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error let x = i.explicitThis; let n = x(12); // callee:void doesn't match this:I ~~~~~ -!!! error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +!!! error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. let u: Unused; let y = u.implicitNoThis; n = y(12); // ok, callee:void matches this:any diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 305208ac7d7..3c25b31e0a8 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(16,15): error TS2339: Property 'n' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(39,21): error TS2339: Property 'a' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2345: Argument of type 'void' is not assignable to parameter of type '{ a: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(56,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(59,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(61,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. @@ -13,10 +13,10 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(63,110): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(65,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(66,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2345: Argument of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2683: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. Types of property 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2345: Argument of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2683: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(73,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. @@ -77,7 +77,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2680: A constructor cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(160,11): error TS2681: A setter cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,9): error TS2680: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,30): error TS2679: 'this' parameter must be the first parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,30): error TS2679: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,26): error TS1003: Identifier expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,30): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,20): error TS2370: A rest parameter must be of an array type. @@ -154,11 +154,11 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'void' is not assignable to parameter of type '{ a: number; }'. +!!! error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +!!! error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. function explicitStructural(this: { y: number }, x: number): number { return x + this.y; } @@ -196,13 +196,13 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. wrongPropertyType.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. -!!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. +!!! error TS2683: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +!!! error TS2683: Types of property 'y' are incompatible. +!!! error TS2683: Type 'string' is not assignable to type 'number'. wrongPropertyName.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. -!!! error TS2345: Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. +!!! error TS2683: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +!!! error TS2683: Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. let c = new C(); c.explicitC(); // not enough arguments @@ -391,7 +391,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e } function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ -!!! error TS2679: 'this' parameter must be the first parameter. +!!! error TS2679: A 'this' parameter must be the first parameter. ///// parse errors ///// function modifiers(async this: C): number { return this.n; } From 81f0d86634255f12bcff789047b546a0200399d2 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 31 Mar 2016 10:58:59 -0700 Subject: [PATCH 37/48] Fix up baselines and missing , after merge --- src/compiler/diagnosticMessages.json | 2 +- ...ArrowFunctionCapturesArguments_es6.symbols | 4 +- ...declarationEmitThisPredicates02.errors.txt | 4 +- ...ThisPredicatesWithPrivateName02.errors.txt | 4 +- .../looseThisTypeInFunctions.errors.txt | 4 +- .../noImplicitThisFunctions.errors.txt | 8 ++-- .../thisTypeInFunctionsNegative.errors.txt | 42 +++++++++---------- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c1910fa9e05..1fa9151d500 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2659,7 +2659,7 @@ "Raise error on 'this' expressions with an implied 'any' type.": { "category": "Message", "code": 6115 - } + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols index 4b312fd4646..06999513192 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, --, --)) +>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) ->apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt index 8cf85d4f764..d3597ad2507 100644 --- a/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicates02.errors.txt @@ -1,5 +1,5 @@ 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: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +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; }'. @@ -17,7 +17,7 @@ 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: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +!!! 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; } diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt index 0c0661023f5..7a4716a92e0 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt @@ -1,6 +1,6 @@ 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: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +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; }'. @@ -20,7 +20,7 @@ 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: Neither type '{ m(): this is Foo; }' nor type 'Foo' is assignable to the other. +!!! 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; } diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index 4531797586c..69e9493b24a 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'C'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,28): error TS2339: Property 'length' does not exist on type 'number'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error TS2339: Property 'length' does not exist on type 'number'. @@ -51,7 +51,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error let x = i.explicitThis; let n = x(12); // callee:void doesn't match this:I ~~~~~ -!!! error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +!!! error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. let u: Unused; let y = u.implicitNoThis; n = y(12); // ok, callee:void matches this:any diff --git a/tests/baselines/reference/noImplicitThisFunctions.errors.txt b/tests/baselines/reference/noImplicitThisFunctions.errors.txt index c80552c6b37..5f66ac3553f 100644 --- a/tests/baselines/reference/noImplicitThisFunctions.errors.txt +++ b/tests/baselines/reference/noImplicitThisFunctions.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/noImplicitThisFunctions.ts(14,12): error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. -tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisFunctions.ts(14,12): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. ==== tests/cases/compiler/noImplicitThisFunctions.ts (2 errors) ==== @@ -18,11 +18,11 @@ tests/cases/compiler/noImplicitThisFunctions.ts(18,38): error TS2682: 'this' imp // error: this is implicitly any return this.a + z; ~~~~ -!!! error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. } // error: `this` is `window`, but is still of type `any` let f4: (b: number) => number = b => this.c + b; ~~~~ -!!! error TS2682: 'this' implicitly has type 'any' because it does not have a type annotation. +!!! 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/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 3c25b31e0a8..41711b526c7 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(16,15): error TS2339: Property 'n' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(39,21): error TS2339: Property 'a' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(56,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(59,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(61,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. @@ -13,10 +13,10 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(63,110): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(65,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(66,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2683: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. Types of property 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2683: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(73,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. @@ -73,11 +73,11 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,1): er Types of parameters 'this' and 'this' are incompatible. Type 'Base1' is not assignable to type 'Base2'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(148,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2680: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(160,11): error TS2681: A setter cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,9): error TS2680: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,30): error TS2679: A 'this' parameter must be the first parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2679: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2681: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(160,11): error TS2682: A setter cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,9): error TS2681: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,30): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,26): error TS1003: Identifier expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,30): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,20): error TS2370: A rest parameter must be of an array type. @@ -154,11 +154,11 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. +!!! error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2683: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +!!! error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. function explicitStructural(this: { y: number }, x: number): number { return x + this.y; } @@ -196,13 +196,13 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. wrongPropertyType.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2683: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. -!!! error TS2683: Types of property 'y' are incompatible. -!!! error TS2683: Type 'string' is not assignable to type 'number'. +!!! error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +!!! error TS2684: Types of property 'y' are incompatible. +!!! error TS2684: Type 'string' is not assignable to type 'number'. wrongPropertyName.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2683: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. -!!! error TS2683: Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. +!!! error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +!!! error TS2684: Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. let c = new C(); c.explicitC(); // not enough arguments @@ -371,27 +371,27 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e } let voidThis = new VoidThis(); ~~~~~~~~~~~~~~ -!!! error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +!!! error TS2679: A function that is called with the 'new' keyword cannot have a 'this' type that is void. ///// syntax-ish errors ///// class ThisConstructor { constructor(this: ThisConstructor, private n: number) { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2680: A constructor cannot have a 'this' parameter. +!!! error TS2681: A constructor cannot have a 'this' parameter. } set p(this: void) { ~~~~~~~~~~ -!!! error TS2681: A setter cannot have a 'this' parameter. +!!! error TS2682: A setter cannot have a 'this' parameter. } } interface ThisConstructorInterface { new(this: ThisConstructor, n: number); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2680: A constructor cannot have a 'this' parameter. +!!! error TS2681: A constructor cannot have a 'this' parameter. } function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ -!!! error TS2679: A 'this' parameter must be the first parameter. +!!! error TS2680: A 'this' parameter must be the first parameter. ///// parse errors ///// function modifiers(async this: C): number { return this.n; } From 4197a30f0caffaf8bfdd4c5f57cba12353417d0b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 31 Mar 2016 14:32:56 -0700 Subject: [PATCH 38/48] Improve error messages and always return any from newed functions Previously, functions that specified a type for `this` would return that type. Now they return `any`. This helps prevent unintentional use of this feature when --noImplicitAny is turned on. The type of `this` is still checked in the body of these functions. --- src/compiler/checker.ts | 10 +-- src/compiler/diagnosticMessages.json | 8 ++- .../looseThisTypeInFunctions.errors.txt | 8 +-- .../reference/thisTypeInFunctions.types | 8 +-- .../thisTypeInFunctionsNegative.errors.txt | 68 +++++++++---------- 5 files changed, 53 insertions(+), 49 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 45ec89086f6..37f714a6e09 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5480,7 +5480,7 @@ namespace ts { || compareTypes(target.thisType, source.thisType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, "this", "this"); + errorReporter(Diagnostics.this_types_of_each_signature_are_incompatible); } return Ternary.False; } @@ -10223,7 +10223,7 @@ namespace ts { const thisArgumentNode = getThisArgumentOfCall(node); const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; const errorNode = reportErrors ? (thisArgumentNode || node) : undefined; - const headMessage = Diagnostics.this_context_of_type_0_is_not_assignable_to_method_this_of_type_1; + const headMessage = Diagnostics.this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage)) { return false; } @@ -10929,7 +10929,7 @@ namespace ts { // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the - // operation is the function's this type. It is an error to have a Void this type. + // operation is Any. It is an error to have a Void this type. const callSignatures = getSignaturesOfType(expressionType, SignatureKind.Call); if (callSignatures.length) { const signature = resolveCall(node, callSignatures, candidatesOutArray); @@ -11117,10 +11117,10 @@ namespace ts { if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function)) { return getInferredClassType(funcSymbol); } - else if (compilerOptions.noImplicitAny && !signature.thisType) { + else if (compilerOptions.noImplicitAny) { error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } - return signature.thisType || anyType; + return anyType; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 1fa9151d500..fcca93b92dc 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1879,7 +1879,7 @@ "category": "Error", "code": 2678 }, - "A function that is called with the 'new' keyword cannot have a 'this' type that is void.": { + "A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'.": { "category": "Error", "code": 2679 }, @@ -1899,10 +1899,14 @@ "category": "Error", "code": 2683 }, - "'this' context of type '{0}' is not assignable to method 'this' of type '{1}'.": { + "'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'.": { "category": "Error", "code": 2684 }, + "'this' types of each signature are incompatible.": { + "category": "Error", + "code": 2685 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index 69e9493b24a..c290ad2d833 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'void' is not assignable to type 'C'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,28): error TS2339: Property 'length' does not exist on type 'number'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error TS2339: Property 'length' does not exist on type 'number'. @@ -30,7 +30,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error c.explicitVoid = c.explicitThis; // error, 'void' is missing everything ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'C'. let o = { n: 101, @@ -51,7 +51,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error let x = i.explicitThis; let n = x(12); // callee:void doesn't match this:I ~~~~~ -!!! error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +!!! error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. let u: Unused; let y = u.implicitNoThis; n = y(12); // ok, callee:void matches this:any diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 48186eee2d0..24d3bf9f178 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -895,13 +895,13 @@ function AnyThis(this: any) { >"ok" : string } let interfaceThis = new InterfaceThis(); ->interfaceThis : I ->new InterfaceThis() : I +>interfaceThis : any +>new InterfaceThis() : any >InterfaceThis : (this: I) => void let literalTypeThis = new LiteralTypeThis(); ->literalTypeThis : { x: string; } ->new LiteralTypeThis() : { x: string; } +>literalTypeThis : any +>new LiteralTypeThis() : any >LiteralTypeThis : (this: { x: string; }) => void let anyThis = new AnyThis(); diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 41711b526c7..955469f9bf3 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(16,15): error TS2339: Property 'n' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(39,21): error TS2339: Property 'a' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type '{ a: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(56,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(59,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(61,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. @@ -13,10 +13,10 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(63,110): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(65,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(66,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. Types of property 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(73,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. @@ -31,49 +31,49 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,1): err tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(82,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(83,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(86,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'void' is not assignable to type '{ y: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(107,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. Property 'x' is missing in type 'C'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(108,1): error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type '{ n: number; }' is not assignable to type '{ x: number; }'. Property 'x' is missing in type '{ n: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(110,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(111,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(112,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(113,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(114,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type '{ n: number; }' is not assignable to type 'D'. Property 'x' is missing in type '{ n: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(115,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(116,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'void' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(117,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'void' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(125,69): error TS2339: Property 'x' does not exist on type 'typeof Base1'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(145,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'Base1' is not assignable to type 'Base2'. Property 'y' is missing in type 'Base1'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. - Types of parameters 'this' and 'this' are incompatible. + 'this' types of each signature are incompatible. Type 'Base1' is not assignable to type 'Base2'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(148,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2679: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2679: A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2681: A constructor cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(160,11): error TS2682: A setter cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,9): error TS2681: A constructor cannot have a 'this' parameter. @@ -154,11 +154,11 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type '{ a: number; }'. +!!! error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type '{ a: number; }'. let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2684: 'this' context of type 'void' is not assignable to method 'this' of type 'I'. +!!! error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. function explicitStructural(this: { y: number }, x: number): number { return x + this.y; } @@ -196,12 +196,12 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. wrongPropertyType.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +!!! error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. !!! error TS2684: Types of property 'y' are incompatible. !!! error TS2684: Type 'string' is not assignable to type 'number'. wrongPropertyName.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method 'this' of type '{ y: number; }'. +!!! error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. !!! error TS2684: Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. let c = new C(); @@ -246,7 +246,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e let specifiedToVoid: (this: void, x: number) => number = explicitStructural; ~~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'void' is not assignable to type '{ y: number; }'. let reconstructed: { @@ -271,40 +271,40 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e c.explicitC = function(this: D, m: number) { return this.x + m }; ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. !!! error TS2322: Property 'x' is missing in type 'C'. c.explicitProperty = explicitXProperty; ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type '{ n: number; }' is not assignable to type '{ x: number; }'. !!! error TS2322: Property 'x' is missing in type '{ n: number; }'. c.explicitC = d.explicitD; ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitC = d.explicitThis; ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitThis = d.explicitD; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitThis = d.explicitThis; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitProperty = d.explicitD; ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type '{ n: number; }' is not assignable to type 'D'. !!! error TS2322: Property 'x' is missing in type '{ n: number; }'. c.explicitThis = d.explicitThis; @@ -313,12 +313,12 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e c.explicitVoid = d.explicitD; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'D'. c.explicitVoid = d.explicitThis; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'D'. /// class-based polymorphic assignability (with inheritance!) /// @@ -352,13 +352,13 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e b1.polymorphic = b2.polymorphic // error, 'this.y' not in Base1: { x } ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. !!! error TS2322: Property 'y' is missing in type 'Base1'. b1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. +!!! error TS2322: 'this' types of each signature are incompatible. !!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. d1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } @@ -371,7 +371,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e } let voidThis = new VoidThis(); ~~~~~~~~~~~~~~ -!!! error TS2679: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +!!! error TS2679: A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'. ///// syntax-ish errors ///// class ThisConstructor { From 9e5fba6036544f3bc22c85cc3b2edc47c9a63c98 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 1 Apr 2016 11:33:33 -0700 Subject: [PATCH 39/48] Prepend 'the' to a couple of ambiguous messages. Based on feedback from @DanielRosenwasser @Arnavion and @RichiCoder1 --- src/compiler/checker.ts | 4 +- src/compiler/diagnosticMessages.json | 4 +- .../looseThisTypeInFunctions.errors.txt | 8 +-- .../thisTypeInFunctionsNegative.errors.txt | 64 +++++++++---------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 37f714a6e09..bbc22e1b88b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5480,7 +5480,7 @@ namespace ts { || compareTypes(target.thisType, source.thisType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(Diagnostics.this_types_of_each_signature_are_incompatible); + errorReporter(Diagnostics.The_this_types_of_each_signature_are_incompatible); } return Ternary.False; } @@ -10223,7 +10223,7 @@ namespace ts { const thisArgumentNode = getThisArgumentOfCall(node); const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; const errorNode = reportErrors ? (thisArgumentNode || node) : undefined; - const headMessage = Diagnostics.this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; + const headMessage = Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, signature.thisType, relation, errorNode, headMessage)) { return false; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fcca93b92dc..6134f1e82b2 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1899,11 +1899,11 @@ "category": "Error", "code": 2683 }, - "'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'.": { + "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'.": { "category": "Error", "code": 2684 }, - "'this' types of each signature are incompatible.": { + "The 'this' types of each signature are incompatible.": { "category": "Error", "code": 2685 }, diff --git a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt index c290ad2d833..b7a36b99ad4 100644 --- a/tests/baselines/reference/looseThisTypeInFunctions.errors.txt +++ b/tests/baselines/reference/looseThisTypeInFunctions.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(21,1): error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'void' is not assignable to type 'C'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(33,28): error TS2339: Property 'length' does not exist on type 'number'. -tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. +tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(37,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error TS2339: Property 'length' does not exist on type 'number'. @@ -30,7 +30,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error c.explicitVoid = c.explicitThis; // error, 'void' is missing everything ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: C, m: number) => number' is not assignable to type '(this: void, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'C'. let o = { n: 101, @@ -51,7 +51,7 @@ tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts(46,20): error let x = i.explicitThis; let n = x(12); // callee:void doesn't match this:I ~~~~~ -!!! error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. +!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. let u: Unused; let y = u.implicitNoThis; n = y(12); // ok, callee:void matches this:any diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 955469f9bf3..e4891fe322d 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(16,15): error TS2339: Property 'n' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(39,21): error TS2339: Property 'a' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type '{ a: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type '{ a: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(56,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(59,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(61,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. @@ -13,10 +13,10 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(63,110): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(65,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(66,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2684: The 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. Types of property 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2684: The 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(73,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. @@ -31,46 +31,46 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,1): err tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(82,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(83,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(86,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'void' is not assignable to type '{ y: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(107,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. Property 'x' is missing in type 'C'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(108,1): error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type '{ n: number; }' is not assignable to type '{ x: number; }'. Property 'x' is missing in type '{ n: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(110,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(111,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(112,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(113,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'C' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(114,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type '{ n: number; }' is not assignable to type 'D'. Property 'x' is missing in type '{ n: number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(115,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(116,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'void' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(117,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'void' is not assignable to type 'D'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(125,69): error TS2339: Property 'x' does not exist on type 'typeof Base1'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(145,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'Base1' is not assignable to type 'Base2'. Property 'y' is missing in type 'Base1'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. - 'this' types of each signature are incompatible. + The 'this' types of each signature are incompatible. Type 'Base1' is not assignable to type 'Base2'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(148,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2679: A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'. @@ -154,11 +154,11 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type '{ a: number; }'. +!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type '{ a: number; }'. let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2684: 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. +!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'I'. function explicitStructural(this: { y: number }, x: number): number { return x + this.y; } @@ -196,12 +196,12 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. wrongPropertyType.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2684: 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. +!!! error TS2684: The 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. !!! error TS2684: Types of property 'y' are incompatible. !!! error TS2684: Type 'string' is not assignable to type 'number'. wrongPropertyName.f(13); ~~~~~~~~~~~~~~~~~ -!!! error TS2684: 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. +!!! error TS2684: The 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. !!! error TS2684: Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. let c = new C(); @@ -246,7 +246,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e let specifiedToVoid: (this: void, x: number) => number = explicitStructural; ~~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'void' is not assignable to type '{ y: number; }'. let reconstructed: { @@ -271,40 +271,40 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e c.explicitC = function(this: D, m: number) { return this.x + m }; ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. !!! error TS2322: Property 'x' is missing in type 'C'. c.explicitProperty = explicitXProperty; ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type '{ n: number; }' is not assignable to type '{ x: number; }'. !!! error TS2322: Property 'x' is missing in type '{ n: number; }'. c.explicitC = d.explicitD; ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitC = d.explicitThis; ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitThis = d.explicitD; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitThis = d.explicitThis; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitProperty = d.explicitD; ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type '{ n: number; }' is not assignable to type 'D'. !!! error TS2322: Property 'x' is missing in type '{ n: number; }'. c.explicitThis = d.explicitThis; @@ -313,12 +313,12 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e c.explicitVoid = d.explicitD; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'D'. c.explicitVoid = d.explicitThis; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'D'. /// class-based polymorphic assignability (with inheritance!) /// @@ -352,13 +352,13 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e b1.polymorphic = b2.polymorphic // error, 'this.y' not in Base1: { x } ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. !!! error TS2322: Property 'y' is missing in type 'Base1'. b1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. -!!! error TS2322: 'this' types of each signature are incompatible. +!!! error TS2322: The 'this' types of each signature are incompatible. !!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. d1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } From 2a9f39b1320849b84b869f3aad59fb278110cdaf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 1 Apr 2016 13:06:55 -0700 Subject: [PATCH 40/48] Forbid ConstructType as part of 'no this in constructors' --- src/compiler/checker.ts | 2 +- .../thisTypeInFunctionsNegative.errors.txt | 46 ++++++++++--------- .../reference/thisTypeInFunctionsNegative.js | 2 + .../thisType/thisTypeInFunctionsNegative.ts | 1 + 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bbc22e1b88b..8178025c7ae 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12416,7 +12416,7 @@ namespace ts { if (indexOf(func.parameters, node) !== 0) { error(node, Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === SyntaxKind.Constructor || func.kind === SyntaxKind.ConstructSignature) { + if (func.kind === SyntaxKind.Constructor || func.kind === SyntaxKind.ConstructSignature || func.kind === SyntaxKind.ConstructorType) { error(node, Diagnostics.A_constructor_cannot_have_a_this_parameter); } if (func.kind === SyntaxKind.SetAccessor) { diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index e4891fe322d..017550dcecd 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -77,29 +77,30 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): e tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2681: A constructor cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(160,11): error TS2682: A setter cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,9): error TS2681: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,30): error TS2680: A 'this' parameter must be the first parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,26): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,20): error TS2370: A rest parameter must be of an array type. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,23): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,27): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,23): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,24): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,28): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,32): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,32): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,39): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,40): error TS1128: Declaration or statement expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,42): error TS2304: Cannot find name 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,49): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,1): error TS7027: Unreachable code detected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,29): error TS2304: Cannot find name 'm'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,32): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,31): error TS2681: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,30): error TS2680: A 'this' parameter must be the first parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,26): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,20): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,23): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,27): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,23): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,24): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,28): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(173,32): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(174,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(174,32): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(174,39): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(174,40): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(174,42): error TS2304: Cannot find name 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(174,49): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(177,1): error TS7027: Unreachable code detected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(177,29): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(177,32): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(177,35): error TS2304: Cannot find name 'm'. -==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (65 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (66 errors) ==== class C { n: number; explicitThis(this: this, m: number): number { @@ -389,6 +390,9 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(176,35): e ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2681: A constructor cannot have a 'this' parameter. } + var thisConstructorType: new (this: number) => number; + ~~~~~~~~~~~~ +!!! error TS2681: A constructor cannot have a 'this' parameter. function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ !!! error TS2680: A 'this' parameter must be the first parameter. diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index 1cfb38bb100..124a7c88013 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -164,6 +164,7 @@ class ThisConstructor { interface ThisConstructorInterface { new(this: ThisConstructor, n: number); } +var thisConstructorType: new (this: number) => number; function notFirst(a: number, this: C): number { return this.n; } ///// parse errors ///// @@ -339,6 +340,7 @@ var ThisConstructor = (function () { }); return ThisConstructor; }()); +var thisConstructorType; function notFirst(a, this) { return this.n; } ///// parse errors ///// function modifiers(, C) { diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts index 1b049aeec50..597fe5a836e 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts @@ -163,6 +163,7 @@ class ThisConstructor { interface ThisConstructorInterface { new(this: ThisConstructor, n: number); } +var thisConstructorType: new (this: number) => number; function notFirst(a: number, this: C): number { return this.n; } ///// parse errors ///// From 921d5f83e9b8cee0765cbccc4dd749df3335d376 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 1 Apr 2016 16:13:57 -0700 Subject: [PATCH 41/48] Fix == typo and add object literal 'this' test --- src/compiler/checker.ts | 2 +- .../reference/thisTypeInObjectLiterals.js | 40 +++++++++ .../thisTypeInObjectLiterals.symbols | 73 ++++++++++++++++ .../reference/thisTypeInObjectLiterals.types | 83 +++++++++++++++++++ .../thisType/thisTypeInObjectLiterals.ts | 23 +++++ 5 files changed, 220 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8178025c7ae..a357a2e0f71 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4252,7 +4252,7 @@ namespace ts { const resolvedSymbol = resolveName(param, paramSymbol.name, SymbolFlags.Value, undefined, undefined); paramSymbol = resolvedSymbol; } - if (i == 0 && paramSymbol.name === "this") { + if (i === 0 && paramSymbol.name === "this") { hasThisParameter = true; thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType; } diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.js b/tests/baselines/reference/thisTypeInObjectLiterals.js index 78854bf2388..5af13a41af8 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.js +++ b/tests/baselines/reference/thisTypeInObjectLiterals.js @@ -5,6 +5,29 @@ let o = { return this.d.length; } } +let mutuallyRecursive = { + 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; + } +} +var i: number = mutuallyRecursive.start(); +interface I { + a: number; + start(): number; + passthrough(n: number): number; + sub1(n: number): number; +} +var impl: I = mutuallyRecursive; //// [thisTypeInObjectLiterals.js] @@ -14,3 +37,20 @@ var o = { return this.d.length; } }; +var mutuallyRecursive = { + a: 100, + start: function () { + return this.passthrough(this.a); + }, + passthrough: function (n) { + return this.sub1(n); + }, + sub1: function (n) { + if (n > 0) { + return this.passthrough(n - 1); + } + return n; + } +}; +var i = mutuallyRecursive.start(); +var impl = mutuallyRecursive; diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.symbols b/tests/baselines/reference/thisTypeInObjectLiterals.symbols index 6bea6d88c58..9ae4a990d5b 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.symbols +++ b/tests/baselines/reference/thisTypeInObjectLiterals.symbols @@ -16,4 +16,77 @@ let o = { >length : Symbol(String.length, Decl(lib.d.ts, --, --)) } } +let mutuallyRecursive = { +>mutuallyRecursive : Symbol(mutuallyRecursive, Decl(thisTypeInObjectLiterals.ts, 6, 3)) + + a: 100, +>a : Symbol(a, Decl(thisTypeInObjectLiterals.ts, 6, 25)) + + start() { +>start : Symbol(start, Decl(thisTypeInObjectLiterals.ts, 7, 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)) + + 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)) + + }, + sub1(n: number): number { +>sub1 : Symbol(sub1, Decl(thisTypeInObjectLiterals.ts, 13, 6)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 14, 9)) + + if (n > 0) { +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 14, 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)) + } + return n; +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 14, 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)) + +interface I { +>I : Symbol(I, Decl(thisTypeInObjectLiterals.ts, 21, 42)) + + a: number; +>a : Symbol(I.a, Decl(thisTypeInObjectLiterals.ts, 22, 13)) + + start(): number; +>start : Symbol(I.start, Decl(thisTypeInObjectLiterals.ts, 23, 14)) + + passthrough(n: number): number; +>passthrough : Symbol(I.passthrough, Decl(thisTypeInObjectLiterals.ts, 24, 20)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 25, 16)) + + sub1(n: number): number; +>sub1 : Symbol(I.sub1, Decl(thisTypeInObjectLiterals.ts, 25, 35)) +>n : Symbol(n, Decl(thisTypeInObjectLiterals.ts, 26, 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)) diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.types b/tests/baselines/reference/thisTypeInObjectLiterals.types index 824b0b00f4c..0b164209219 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.types +++ b/tests/baselines/reference/thisTypeInObjectLiterals.types @@ -18,4 +18,87 @@ let o = { >length : number } } +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; } + + a: 100, +>a : number +>100 : number + + start() { +>start : () => number + + 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 + + }, + passthrough(n: number) { +>passthrough : (n: number) => number +>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 +>n : number + + }, + sub1(n: number): number { +>sub1 : (n: number) => number +>n : number + + if (n > 0) { +>n > 0 : boolean +>n : number +>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 +>n - 1 : number +>n : number +>1 : number + } + return n; +>n : number + } +} +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 + +interface I { +>I : I + + a: number; +>a : number + + start(): number; +>start : () => number + + passthrough(n: number): number; +>passthrough : (n: number) => number +>n : number + + sub1(n: number): number; +>sub1 : (n: number) => number +>n : number +} +var impl: I = mutuallyRecursive; +>impl : I +>I : I +>mutuallyRecursive : { a: number; start(): number; passthrough(n: number): number; sub1(n: number): number; } diff --git a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts index 11c6b58d710..cfdb0883fed 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInObjectLiterals.ts @@ -4,3 +4,26 @@ let o = { return this.d.length; } } +let mutuallyRecursive = { + 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; + } +} +var i: number = mutuallyRecursive.start(); +interface I { + a: number; + start(): number; + passthrough(n: number): number; + sub1(n: number): number; +} +var impl: I = mutuallyRecursive; From 3e78ff0b3c67dba94e4ca8733294e5f77bd43e39 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Wed, 6 Apr 2016 22:17:14 -0700 Subject: [PATCH 42/48] Sync with TSJS repo --- src/lib/dom.generated.d.ts | 4906 +++++++++++++++--------------- src/lib/webworker.generated.d.ts | 470 +-- 2 files changed, 2691 insertions(+), 2685 deletions(-) diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 59cd2675e7a..ca303aeb079 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -878,18 +878,18 @@ interface ANGLE_instanced_arrays { drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; vertexAttribDivisorANGLE(index: number, divisor: number): void; - VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; } declare var ANGLE_instanced_arrays: { prototype: ANGLE_instanced_arrays; new(): ANGLE_instanced_arrays; - VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; } interface AnalyserNode extends AudioNode { fftSize: number; - frequencyBinCount: number; + readonly frequencyBinCount: number; maxDecibels: number; minDecibels: number; smoothingTimeConstant: number; @@ -905,8 +905,8 @@ declare var AnalyserNode: { } interface AnimationEvent extends Event { - animationName: string; - elapsedTime: number; + readonly animationName: string; + readonly elapsedTime: number; initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; } @@ -924,16 +924,16 @@ interface ApplicationCache extends EventTarget { onobsolete: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; onupdateready: (ev: Event) => any; - status: number; + readonly status: number; abort(): void; swapCache(): void; update(): void; - CHECKING: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; - UNCACHED: number; - UPDATEREADY: number; + readonly CHECKING: number; + readonly DOWNLOADING: number; + readonly IDLE: number; + readonly OBSOLETE: number; + readonly UNCACHED: number; + readonly UPDATEREADY: number; addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -948,16 +948,16 @@ interface ApplicationCache extends EventTarget { declare var ApplicationCache: { prototype: ApplicationCache; new(): ApplicationCache; - CHECKING: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; - UNCACHED: number; - UPDATEREADY: number; + readonly CHECKING: number; + readonly DOWNLOADING: number; + readonly IDLE: number; + readonly OBSOLETE: number; + readonly UNCACHED: number; + readonly UPDATEREADY: number; } interface AriaRequestEvent extends Event { - attributeName: string; + readonly attributeName: string; attributeValue: string; } @@ -967,10 +967,10 @@ declare var AriaRequestEvent: { } interface Attr extends Node { - name: string; - ownerElement: Element; - prefix: string; - specified: boolean; + readonly name: string; + readonly ownerElement: Element; + readonly prefix: string; + readonly specified: boolean; value: string; } @@ -980,10 +980,10 @@ declare var Attr: { } interface AudioBuffer { - duration: number; - length: number; - numberOfChannels: number; - sampleRate: number; + readonly duration: number; + readonly length: number; + readonly numberOfChannels: number; + readonly sampleRate: number; copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void; copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void; getChannelData(channel: number): Float32Array; @@ -996,12 +996,12 @@ declare var AudioBuffer: { interface AudioBufferSourceNode extends AudioNode { buffer: AudioBuffer; - detune: AudioParam; + readonly detune: AudioParam; loop: boolean; loopEnd: number; loopStart: number; onended: (ev: MediaStreamErrorEvent) => any; - playbackRate: AudioParam; + readonly playbackRate: AudioParam; start(when?: number, offset?: number, duration?: number): void; stop(when?: number): void; addEventListener(type: "ended", listener: (ev: MediaStreamErrorEvent) => any, useCapture?: boolean): void; @@ -1014,10 +1014,10 @@ declare var AudioBufferSourceNode: { } interface AudioContext extends EventTarget { - currentTime: number; - destination: AudioDestinationNode; - listener: AudioListener; - sampleRate: number; + readonly currentTime: number; + readonly destination: AudioDestinationNode; + readonly listener: AudioListener; + readonly sampleRate: number; state: string; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; @@ -1046,7 +1046,7 @@ declare var AudioContext: { } interface AudioDestinationNode extends AudioNode { - maxChannelCount: number; + readonly maxChannelCount: number; } declare var AudioDestinationNode: { @@ -1071,9 +1071,9 @@ interface AudioNode extends EventTarget { channelCount: number; channelCountMode: string; channelInterpretation: string; - context: AudioContext; - numberOfInputs: number; - numberOfOutputs: number; + readonly context: AudioContext; + readonly numberOfInputs: number; + readonly numberOfOutputs: number; connect(destination: AudioNode, output?: number, input?: number): void; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; @@ -1086,7 +1086,7 @@ declare var AudioNode: { } interface AudioParam { - defaultValue: number; + readonly defaultValue: number; value: number; cancelScheduledValues(startTime: number): void; exponentialRampToValueAtTime(value: number, endTime: number): void; @@ -1102,9 +1102,9 @@ declare var AudioParam: { } interface AudioProcessingEvent extends Event { - inputBuffer: AudioBuffer; - outputBuffer: AudioBuffer; - playbackTime: number; + readonly inputBuffer: AudioBuffer; + readonly outputBuffer: AudioBuffer; + readonly playbackTime: number; } declare var AudioProcessingEvent: { @@ -1114,11 +1114,11 @@ declare var AudioProcessingEvent: { interface AudioTrack { enabled: boolean; - id: string; + readonly id: string; kind: string; - label: string; + readonly label: string; language: string; - sourceBuffer: SourceBuffer; + readonly sourceBuffer: SourceBuffer; } declare var AudioTrack: { @@ -1127,7 +1127,7 @@ declare var AudioTrack: { } interface AudioTrackList extends EventTarget { - length: number; + readonly length: number; onaddtrack: (ev: TrackEvent) => any; onchange: (ev: Event) => any; onremovetrack: (ev: TrackEvent) => any; @@ -1146,7 +1146,7 @@ declare var AudioTrackList: { } interface BarProp { - visible: boolean; + readonly visible: boolean; } declare var BarProp: { @@ -1164,10 +1164,10 @@ declare var BeforeUnloadEvent: { } interface BiquadFilterNode extends AudioNode { - Q: AudioParam; - detune: AudioParam; - frequency: AudioParam; - gain: AudioParam; + readonly Q: AudioParam; + readonly detune: AudioParam; + readonly frequency: AudioParam; + readonly gain: AudioParam; type: string; getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } @@ -1178,8 +1178,8 @@ declare var BiquadFilterNode: { } interface Blob { - size: number; - type: string; + readonly size: number; + readonly type: string; msClose(): void; msDetachStream(): any; slice(start?: number, end?: number, contentType?: string): Blob; @@ -1213,7 +1213,7 @@ declare var CSSConditionRule: { } interface CSSFontFaceRule extends CSSRule { - style: CSSStyleDeclaration; + readonly style: CSSStyleDeclaration; } declare var CSSFontFaceRule: { @@ -1222,7 +1222,7 @@ declare var CSSFontFaceRule: { } interface CSSGroupingRule extends CSSRule { - cssRules: CSSRuleList; + readonly cssRules: CSSRuleList; deleteRule(index: number): void; insertRule(rule: string, index: number): number; } @@ -1233,9 +1233,9 @@ declare var CSSGroupingRule: { } interface CSSImportRule extends CSSRule { - href: string; - media: MediaList; - styleSheet: CSSStyleSheet; + readonly href: string; + readonly media: MediaList; + readonly styleSheet: CSSStyleSheet; } declare var CSSImportRule: { @@ -1245,7 +1245,7 @@ declare var CSSImportRule: { interface CSSKeyframeRule extends CSSRule { keyText: string; - style: CSSStyleDeclaration; + readonly style: CSSStyleDeclaration; } declare var CSSKeyframeRule: { @@ -1254,7 +1254,7 @@ declare var CSSKeyframeRule: { } interface CSSKeyframesRule extends CSSRule { - cssRules: CSSRuleList; + readonly cssRules: CSSRuleList; name: string; appendRule(rule: string): void; deleteRule(rule: string): void; @@ -1267,7 +1267,7 @@ declare var CSSKeyframesRule: { } interface CSSMediaRule extends CSSConditionRule { - media: MediaList; + readonly media: MediaList; } declare var CSSMediaRule: { @@ -1276,8 +1276,8 @@ declare var CSSMediaRule: { } interface CSSNamespaceRule extends CSSRule { - namespaceURI: string; - prefix: string; + readonly namespaceURI: string; + readonly prefix: string; } declare var CSSNamespaceRule: { @@ -1286,10 +1286,10 @@ declare var CSSNamespaceRule: { } interface CSSPageRule extends CSSRule { - pseudoClass: string; - selector: string; + readonly pseudoClass: string; + readonly selector: string; selectorText: string; - style: CSSStyleDeclaration; + readonly style: CSSStyleDeclaration; } declare var CSSPageRule: { @@ -1299,42 +1299,42 @@ declare var CSSPageRule: { interface CSSRule { cssText: string; - parentRule: CSSRule; - parentStyleSheet: CSSStyleSheet; - type: number; - CHARSET_RULE: number; - FONT_FACE_RULE: number; - IMPORT_RULE: number; - KEYFRAMES_RULE: number; - KEYFRAME_RULE: number; - MEDIA_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - STYLE_RULE: number; - SUPPORTS_RULE: number; - UNKNOWN_RULE: number; - VIEWPORT_RULE: number; + readonly parentRule: CSSRule; + readonly parentStyleSheet: CSSStyleSheet; + readonly type: number; + readonly CHARSET_RULE: number; + readonly FONT_FACE_RULE: number; + readonly IMPORT_RULE: number; + readonly KEYFRAMES_RULE: number; + readonly KEYFRAME_RULE: number; + readonly MEDIA_RULE: number; + readonly NAMESPACE_RULE: number; + readonly PAGE_RULE: number; + readonly STYLE_RULE: number; + readonly SUPPORTS_RULE: number; + readonly UNKNOWN_RULE: number; + readonly VIEWPORT_RULE: number; } declare var CSSRule: { prototype: CSSRule; new(): CSSRule; - CHARSET_RULE: number; - FONT_FACE_RULE: number; - IMPORT_RULE: number; - KEYFRAMES_RULE: number; - KEYFRAME_RULE: number; - MEDIA_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - STYLE_RULE: number; - SUPPORTS_RULE: number; - UNKNOWN_RULE: number; - VIEWPORT_RULE: number; + readonly CHARSET_RULE: number; + readonly FONT_FACE_RULE: number; + readonly IMPORT_RULE: number; + readonly KEYFRAMES_RULE: number; + readonly KEYFRAME_RULE: number; + readonly MEDIA_RULE: number; + readonly NAMESPACE_RULE: number; + readonly PAGE_RULE: number; + readonly STYLE_RULE: number; + readonly SUPPORTS_RULE: number; + readonly UNKNOWN_RULE: number; + readonly VIEWPORT_RULE: number; } interface CSSRuleList { - length: number; + readonly length: number; item(index: number): CSSRule; [index: number]: CSSRule; } @@ -1467,7 +1467,7 @@ interface CSSStyleDeclaration { justifyContent: string; kerning: string; left: string; - length: number; + readonly length: number; letterSpacing: string; lightingColor: string; lineHeight: string; @@ -1554,7 +1554,7 @@ interface CSSStyleDeclaration { pageBreakAfter: string; pageBreakBefore: string; pageBreakInside: string; - parentRule: CSSRule; + readonly parentRule: CSSRule; perspective: string; perspectiveOrigin: string; pointerEvents: string; @@ -1691,9 +1691,9 @@ declare var CSSStyleDeclaration: { } interface CSSStyleRule extends CSSRule { - readOnly: boolean; + readonly readOnly: boolean; selectorText: string; - style: CSSStyleDeclaration; + readonly style: CSSStyleDeclaration; } declare var CSSStyleRule: { @@ -1702,18 +1702,18 @@ declare var CSSStyleRule: { } interface CSSStyleSheet extends StyleSheet { - cssRules: CSSRuleList; + readonly cssRules: CSSRuleList; cssText: string; - href: string; - id: string; - imports: StyleSheetList; - isAlternate: boolean; - isPrefAlternate: boolean; - ownerRule: CSSRule; - owningElement: Element; - pages: StyleSheetPageList; - readOnly: boolean; - rules: CSSRuleList; + readonly href: string; + readonly id: string; + readonly imports: StyleSheetList; + readonly isAlternate: boolean; + readonly isPrefAlternate: boolean; + readonly ownerRule: CSSRule; + readonly owningElement: Element; + readonly pages: StyleSheetPageList; + readonly readOnly: boolean; + readonly rules: CSSRuleList; addImport(bstrURL: string, lIndex?: number): number; addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; @@ -1754,7 +1754,7 @@ declare var CanvasPattern: { } interface CanvasRenderingContext2D extends Object, CanvasPathMethods { - canvas: HTMLCanvasElement; + readonly canvas: HTMLCanvasElement; fillStyle: string | CanvasGradient | CanvasPattern; font: string; globalAlpha: number; @@ -1825,7 +1825,7 @@ declare var ChannelSplitterNode: { interface CharacterData extends Node, ChildNode { data: string; - length: number; + readonly length: number; appendData(arg: string): void; deleteData(offset: number, count: number): void; insertData(offset: number, arg: string): void; @@ -1841,11 +1841,11 @@ declare var CharacterData: { interface ClientRect { bottom: number; - height: number; + readonly height: number; left: number; right: number; top: number; - width: number; + readonly width: number; } declare var ClientRect: { @@ -1854,7 +1854,7 @@ declare var ClientRect: { } interface ClientRectList { - length: number; + readonly length: number; item(index: number): ClientRect; [index: number]: ClientRect; } @@ -1865,7 +1865,7 @@ declare var ClientRectList: { } interface ClipboardEvent extends Event { - clipboardData: DataTransfer; + readonly clipboardData: DataTransfer; } declare var ClipboardEvent: { @@ -1874,9 +1874,9 @@ declare var ClipboardEvent: { } interface CloseEvent extends Event { - code: number; - reason: string; - wasClean: boolean; + readonly code: number; + readonly reason: string; + readonly wasClean: boolean; initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; } @@ -1886,8 +1886,8 @@ declare var CloseEvent: { } interface CommandEvent extends Event { - commandName: string; - detail: string; + readonly commandName: string; + readonly detail: string; } declare var CommandEvent: { @@ -1905,8 +1905,8 @@ declare var Comment: { } interface CompositionEvent extends UIEvent { - data: string; - locale: string; + readonly data: string; + readonly locale: string; initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; } @@ -1956,13 +1956,13 @@ declare var ConvolverNode: { } interface Coordinates { - accuracy: number; - altitude: number; - altitudeAccuracy: number; - heading: number; - latitude: number; - longitude: number; - speed: number; + readonly accuracy: number; + readonly altitude: number; + readonly altitudeAccuracy: number; + readonly heading: number; + readonly latitude: number; + readonly longitude: number; + readonly speed: number; } declare var Coordinates: { @@ -1971,7 +1971,7 @@ declare var Coordinates: { } interface Crypto extends Object, RandomSource { - subtle: SubtleCrypto; + readonly subtle: SubtleCrypto; } declare var Crypto: { @@ -1980,10 +1980,10 @@ declare var Crypto: { } interface CryptoKey { - algorithm: KeyAlgorithm; - extractable: boolean; - type: string; - usages: string[]; + readonly algorithm: KeyAlgorithm; + readonly extractable: boolean; + readonly type: string; + readonly usages: string[]; } declare var CryptoKey: { @@ -2002,7 +2002,7 @@ declare var CryptoKeyPair: { } interface CustomEvent extends Event { - detail: any; + readonly detail: any; initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; } @@ -2012,7 +2012,7 @@ declare var CustomEvent: { } interface DOMError { - name: string; + readonly name: string; toString(): string; } @@ -2022,69 +2022,69 @@ declare var DOMError: { } interface DOMException { - code: number; - message: string; - name: string; + readonly code: number; + readonly message: string; + readonly name: string; toString(): string; - ABORT_ERR: number; - DATA_CLONE_ERR: number; - DOMSTRING_SIZE_ERR: number; - HIERARCHY_REQUEST_ERR: number; - INDEX_SIZE_ERR: number; - INUSE_ATTRIBUTE_ERR: number; - INVALID_ACCESS_ERR: number; - INVALID_CHARACTER_ERR: number; - INVALID_MODIFICATION_ERR: number; - INVALID_NODE_TYPE_ERR: number; - INVALID_STATE_ERR: number; - NAMESPACE_ERR: number; - NETWORK_ERR: number; - NOT_FOUND_ERR: number; - NOT_SUPPORTED_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - PARSE_ERR: number; - QUOTA_EXCEEDED_ERR: number; - SECURITY_ERR: number; - SERIALIZE_ERR: number; - SYNTAX_ERR: number; - TIMEOUT_ERR: number; - TYPE_MISMATCH_ERR: number; - URL_MISMATCH_ERR: number; - VALIDATION_ERR: number; - WRONG_DOCUMENT_ERR: number; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; } declare var DOMException: { prototype: DOMException; new(): DOMException; - ABORT_ERR: number; - DATA_CLONE_ERR: number; - DOMSTRING_SIZE_ERR: number; - HIERARCHY_REQUEST_ERR: number; - INDEX_SIZE_ERR: number; - INUSE_ATTRIBUTE_ERR: number; - INVALID_ACCESS_ERR: number; - INVALID_CHARACTER_ERR: number; - INVALID_MODIFICATION_ERR: number; - INVALID_NODE_TYPE_ERR: number; - INVALID_STATE_ERR: number; - NAMESPACE_ERR: number; - NETWORK_ERR: number; - NOT_FOUND_ERR: number; - NOT_SUPPORTED_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - PARSE_ERR: number; - QUOTA_EXCEEDED_ERR: number; - SECURITY_ERR: number; - SERIALIZE_ERR: number; - SYNTAX_ERR: number; - TIMEOUT_ERR: number; - TYPE_MISMATCH_ERR: number; - URL_MISMATCH_ERR: number; - VALIDATION_ERR: number; - WRONG_DOCUMENT_ERR: number; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; } interface DOMImplementation { @@ -2118,7 +2118,7 @@ declare var DOMSettableTokenList: { } interface DOMStringList { - length: number; + readonly length: number; contains(str: string): boolean; item(index: number): string; [index: number]: string; @@ -2139,7 +2139,7 @@ declare var DOMStringMap: { } interface DOMTokenList { - length: number; + readonly length: number; add(...token: string[]): void; contains(token: string): boolean; item(index: number): string; @@ -2166,9 +2166,9 @@ declare var DataCue: { interface DataTransfer { dropEffect: string; effectAllowed: string; - files: FileList; - items: DataTransferItemList; - types: DOMStringList; + readonly files: FileList; + readonly items: DataTransferItemList; + readonly types: DOMStringList; clearData(format?: string): boolean; getData(format: string): string; setData(format: string, data: string): boolean; @@ -2180,8 +2180,8 @@ declare var DataTransfer: { } interface DataTransferItem { - kind: string; - type: string; + readonly kind: string; + readonly type: string; getAsFile(): File; getAsString(_callback: FunctionStringCallback): void; } @@ -2192,7 +2192,7 @@ declare var DataTransferItem: { } interface DataTransferItemList { - length: number; + readonly length: number; add(data: File): DataTransferItem; clear(): void; item(index: number): DataTransferItem; @@ -2206,9 +2206,9 @@ declare var DataTransferItemList: { } interface DeferredPermissionRequest { - id: number; - type: string; - uri: string; + readonly id: number; + readonly type: string; + readonly uri: string; allow(): void; deny(): void; } @@ -2219,7 +2219,7 @@ declare var DeferredPermissionRequest: { } interface DelayNode extends AudioNode { - delayTime: AudioParam; + readonly delayTime: AudioParam; } declare var DelayNode: { @@ -2228,9 +2228,9 @@ declare var DelayNode: { } interface DeviceAcceleration { - x: number; - y: number; - z: number; + readonly x: number; + readonly y: number; + readonly z: number; } declare var DeviceAcceleration: { @@ -2239,7 +2239,7 @@ declare var DeviceAcceleration: { } interface DeviceLightEvent extends Event { - value: number; + readonly value: number; } declare var DeviceLightEvent: { @@ -2248,10 +2248,10 @@ declare var DeviceLightEvent: { } interface DeviceMotionEvent extends Event { - acceleration: DeviceAcceleration; - accelerationIncludingGravity: DeviceAcceleration; - interval: number; - rotationRate: DeviceRotationRate; + 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; } @@ -2261,10 +2261,10 @@ declare var DeviceMotionEvent: { } interface DeviceOrientationEvent extends Event { - absolute: boolean; - alpha: number; - beta: number; - gamma: number; + 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; } @@ -2274,9 +2274,9 @@ declare var DeviceOrientationEvent: { } interface DeviceRotationRate { - alpha: number; - beta: number; - gamma: number; + readonly alpha: number; + readonly beta: number; + readonly gamma: number; } declare var DeviceRotationRate: { @@ -2288,15 +2288,15 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven /** * Sets or gets the URL for the current document. */ - URL: string; + readonly URL: string; /** * Gets the URL for the document, stripped of any character encoding. */ - URLUnencoded: string; + readonly URLUnencoded: string; /** * Gets the object that has the focus when the parent document has focus. */ - activeElement: Element; + readonly activeElement: Element; /** * Sets or gets the color of all active links in the document. */ @@ -2304,15 +2304,15 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven /** * Returns a reference to the collection of elements contained by the object. */ - all: HTMLAllCollection; + readonly all: HTMLAllCollection; /** * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. */ - anchors: HTMLCollection; + anchors: HTMLCollectionOf; /** * Retrieves a collection of all applet objects in the document. */ - applets: HTMLCollection; + applets: HTMLCollectionOf; /** * Deprecated. Sets or retrieves a value that indicates the background color behind the object. */ @@ -2321,7 +2321,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Specifies the beginning and end of the document body. */ body: HTMLElement; - characterSet: string; + readonly characterSet: string; /** * Gets or sets the character set used to encode the object. */ @@ -2329,14 +2329,14 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven /** * Gets a value that indicates whether standards-compliant mode is switched on for the object. */ - compatMode: string; + readonly compatMode: string; cookie: string; - currentScript: HTMLScriptElement | SVGScriptElement; + readonly currentScript: HTMLScriptElement | SVGScriptElement; /** * Gets the default character set from the current regional language settings. */ - defaultCharset: string; - defaultView: Window; + readonly defaultCharset: string; + readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. */ @@ -2348,7 +2348,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven /** * Gets an object representing the document type declaration associated with the current document. */ - doctype: DocumentType; + readonly doctype: DocumentType; /** * Gets a reference to the root node of the document. */ @@ -2360,7 +2360,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven /** * Retrieves a collection of all embed objects in the document. */ - embeds: HTMLCollection; + embeds: HTMLCollectionOf; /** * Sets or gets the foreground (text) color of the document. */ @@ -2368,27 +2368,27 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven /** * Retrieves a collection, in source order, of all form objects in the document. */ - forms: HTMLCollection; - fullscreenElement: Element; - fullscreenEnabled: boolean; - head: HTMLHeadElement; - hidden: boolean; + forms: HTMLCollectionOf; + readonly fullscreenElement: Element; + readonly fullscreenEnabled: boolean; + readonly head: HTMLHeadElement; + readonly hidden: boolean; /** * Retrieves a collection, in source order, of img objects in the document. */ - images: HTMLCollection; + images: HTMLCollectionOf; /** * Gets the implementation object of the current document. */ - implementation: DOMImplementation; + readonly implementation: DOMImplementation; /** * Returns the character encoding used to create the webpage that is loaded into the document object. */ - inputEncoding: string; + readonly inputEncoding: string; /** * Gets the date that the page was last modified, if the page supplies one. */ - lastModified: string; + readonly lastModified: string; /** * Sets or gets the color of the document links. */ @@ -2396,11 +2396,11 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven /** * Retrieves a collection of all a objects that specify the href property and all area objects in the document. */ - links: HTMLCollection; + links: HTMLCollectionOf; /** * Contains information about the current URL. */ - location: Location; + readonly location: Location; msCSSOMElementFloatMetrics: boolean; msCapsLockWarningOff: boolean; /** @@ -2711,43 +2711,43 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven onwaiting: (ev: Event) => any; onwebkitfullscreenchange: (ev: Event) => any; onwebkitfullscreenerror: (ev: Event) => any; - plugins: HTMLCollection; - pointerLockElement: Element; + plugins: HTMLCollectionOf; + readonly pointerLockElement: Element; /** * Retrieves a value that indicates the current state of the object. */ - readyState: string; + readonly readyState: string; /** * Gets the URL of the location that referred the user to the current page. */ - referrer: string; + readonly referrer: string; /** * Gets the root svg element in the document hierarchy. */ - rootElement: SVGSVGElement; + readonly rootElement: SVGSVGElement; /** * Retrieves a collection of all script objects in the document. */ - scripts: HTMLCollection; - scrollingElement: Element; + scripts: HTMLCollectionOf; + readonly scrollingElement: Element; /** * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. */ - styleSheets: StyleSheetList; + readonly styleSheets: StyleSheetList; /** * Contains the title of the document. */ title: string; - visibilityState: string; + readonly visibilityState: string; /** * Sets or gets the color of the links that the user has visited. */ vlinkColor: string; - webkitCurrentFullScreenElement: Element; - webkitFullscreenElement: Element; - webkitFullscreenEnabled: boolean; - webkitIsFullScreen: boolean; - xmlEncoding: string; + readonly webkitCurrentFullScreenElement: Element; + readonly webkitFullscreenElement: Element; + readonly webkitFullscreenEnabled: boolean; + readonly webkitIsFullScreen: boolean; + readonly xmlEncoding: string; xmlStandalone: boolean; /** * Gets or sets the version attribute specified in the declaration of an XML document. @@ -3182,8 +3182,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ hasFocus(): boolean; importNode(importedNode: Node, deep: boolean): Node; - msElementsFromPoint(x: number, y: number): NodeList; - msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; + msElementsFromPoint(x: number, y: number): NodeListOf; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeListOf; /** * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. * @param url Specifies a MIME type for the document. @@ -3356,12 +3356,12 @@ declare var DocumentFragment: { } interface DocumentType extends Node, ChildNode { - entities: NamedNodeMap; - internalSubset: string; - name: string; - notations: NamedNodeMap; - publicId: string; - systemId: string; + readonly entities: NamedNodeMap; + readonly internalSubset: string; + readonly name: string; + readonly notations: NamedNodeMap; + readonly publicId: string; + readonly systemId: string; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3371,7 +3371,7 @@ declare var DocumentType: { } interface DragEvent extends MouseEvent { - dataTransfer: DataTransfer; + readonly dataTransfer: DataTransfer; initDragEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, dataTransferArg: DataTransfer): void; msConvertURL(file: File, targetType: string, targetURL?: string): void; } @@ -3382,12 +3382,12 @@ declare var DragEvent: { } interface DynamicsCompressorNode extends AudioNode { - attack: AudioParam; - knee: AudioParam; - ratio: AudioParam; - reduction: AudioParam; - release: AudioParam; - threshold: AudioParam; + readonly attack: AudioParam; + readonly knee: AudioParam; + readonly ratio: AudioParam; + readonly reduction: AudioParam; + readonly release: AudioParam; + readonly threshold: AudioParam; } declare var DynamicsCompressorNode: { @@ -3404,27 +3404,27 @@ declare var EXT_frag_depth: { } interface EXT_texture_filter_anisotropic { - MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; - TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly TEXTURE_MAX_ANISOTROPY_EXT: number; } declare var EXT_texture_filter_anisotropic: { prototype: EXT_texture_filter_anisotropic; new(): EXT_texture_filter_anisotropic; - MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; - TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly TEXTURE_MAX_ANISOTROPY_EXT: number; } interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode { - classList: DOMTokenList; + readonly classList: DOMTokenList; className: string; - clientHeight: number; - clientLeft: number; - clientTop: number; - clientWidth: number; + readonly clientHeight: number; + readonly clientLeft: number; + readonly clientTop: number; + readonly clientWidth: number; id: string; msContentZoomFactor: number; - msRegionOverflow: string; + readonly msRegionOverflow: string; onariarequest: (ev: AriaRequestEvent) => any; oncommand: (ev: CommandEvent) => any; ongotpointercapture: (ev: PointerEvent) => any; @@ -3452,12 +3452,12 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec ontouchstart: (ev: TouchEvent) => any; onwebkitfullscreenchange: (ev: Event) => any; onwebkitfullscreenerror: (ev: Event) => any; - prefix: string; - scrollHeight: number; + readonly prefix: string; + readonly scrollHeight: number; scrollLeft: number; scrollTop: number; - scrollWidth: number; - tagName: string; + readonly scrollWidth: number; + readonly tagName: string; innerHTML: string; getAttribute(name?: string): string; getAttributeNS(namespaceURI: string, localName: string): string; @@ -3713,11 +3713,11 @@ declare var Element: { } interface ErrorEvent extends Event { - colno: number; - error: any; - filename: string; - lineno: number; - message: string; + readonly colno: number; + readonly error: any; + readonly filename: string; + readonly lineno: number; + readonly message: string; initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; } @@ -3727,33 +3727,33 @@ declare var ErrorEvent: { } interface Event { - bubbles: boolean; + readonly bubbles: boolean; cancelBubble: boolean; - cancelable: boolean; - currentTarget: EventTarget; - defaultPrevented: boolean; - eventPhase: number; - isTrusted: boolean; + readonly cancelable: boolean; + readonly currentTarget: EventTarget; + readonly defaultPrevented: boolean; + readonly eventPhase: number; + readonly isTrusted: boolean; returnValue: boolean; - srcElement: Element; - target: EventTarget; - timeStamp: number; - type: string; + readonly srcElement: Element; + readonly target: EventTarget; + readonly timeStamp: number; + readonly type: string; initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; preventDefault(): void; stopImmediatePropagation(): void; stopPropagation(): void; - AT_TARGET: number; - BUBBLING_PHASE: number; - CAPTURING_PHASE: number; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; } declare var Event: { prototype: Event; new(type: string, eventInitDict?: EventInit): Event; - AT_TARGET: number; - BUBBLING_PHASE: number; - CAPTURING_PHASE: number; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; } interface EventTarget { @@ -3776,9 +3776,9 @@ declare var External: { } interface File extends Blob { - lastModifiedDate: any; - name: string; - webkitRelativePath: string; + readonly lastModifiedDate: any; + readonly name: string; + readonly webkitRelativePath: string; } declare var File: { @@ -3787,7 +3787,7 @@ declare var File: { } interface FileList { - length: number; + readonly length: number; item(index: number): File; [index: number]: File; } @@ -3798,7 +3798,7 @@ declare var FileList: { } interface FileReader extends EventTarget, MSBaseReader { - error: DOMError; + readonly error: DOMError; readAsArrayBuffer(blob: Blob): void; readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; @@ -3812,7 +3812,7 @@ declare var FileReader: { } interface FocusEvent extends UIEvent { - relatedTarget: EventTarget; + readonly relatedTarget: EventTarget; initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; } @@ -3831,7 +3831,7 @@ declare var FormData: { } interface GainNode extends AudioNode { - gain: AudioParam; + readonly gain: AudioParam; } declare var GainNode: { @@ -3840,13 +3840,13 @@ declare var GainNode: { } interface Gamepad { - axes: number[]; - buttons: GamepadButton[]; - connected: boolean; - id: string; - index: number; - mapping: string; - timestamp: number; + readonly axes: number[]; + readonly buttons: GamepadButton[]; + readonly connected: boolean; + readonly id: string; + readonly index: number; + readonly mapping: string; + readonly timestamp: number; } declare var Gamepad: { @@ -3855,8 +3855,8 @@ declare var Gamepad: { } interface GamepadButton { - pressed: boolean; - value: number; + readonly pressed: boolean; + readonly value: number; } declare var GamepadButton: { @@ -3865,7 +3865,7 @@ declare var GamepadButton: { } interface GamepadEvent extends Event { - gamepad: Gamepad; + readonly gamepad: Gamepad; } declare var GamepadEvent: { @@ -3924,12 +3924,12 @@ interface HTMLAnchorElement extends HTMLElement { * Sets or retrieves the language code of the object. */ hreflang: string; - mimeType: string; + readonly mimeType: string; /** * Sets or retrieves the shape of the object. */ name: string; - nameProp: string; + readonly nameProp: string; /** * Contains the pathname of the URL. */ @@ -3942,7 +3942,7 @@ interface HTMLAnchorElement extends HTMLElement { * Contains the protocol of the URL. */ protocol: string; - protocolLong: string; + readonly protocolLong: string; /** * Sets or retrieves the relationship between the object and the destination of the link. */ @@ -3984,7 +3984,7 @@ interface HTMLAppletElement extends HTMLElement { /** * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. */ - BaseHref: string; + readonly BaseHref: string; align: string; /** * Sets or retrieves a text alternative to the graphic. @@ -4011,7 +4011,7 @@ interface HTMLAppletElement extends HTMLElement { /** * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. */ - contentDocument: Document; + readonly contentDocument: Document; /** * Sets or retrieves the URL that references the data of the object. */ @@ -4020,7 +4020,7 @@ interface HTMLAppletElement extends HTMLElement { * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. */ declare: boolean; - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Sets or retrieves the height of the object. */ @@ -4352,7 +4352,7 @@ interface HTMLButtonElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -4385,11 +4385,11 @@ interface HTMLButtonElement extends HTMLElement { /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ - validationMessage: string; + readonly validationMessage: string; /** * Returns a ValidityState object that represents the validity states of an element. */ - validity: ValidityState; + readonly validity: ValidityState; /** * Sets or retrieves the default or selected value of the control. */ @@ -4397,7 +4397,7 @@ interface HTMLButtonElement extends HTMLElement { /** * Returns whether an element will successfully validate based on forms validation rules and constraints. */ - willValidate: boolean; + readonly willValidate: boolean; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ @@ -4451,11 +4451,11 @@ interface HTMLCollection { /** * Sets or retrieves the number of objects in a collection. */ - length: number; + readonly length: number; /** * Retrieves an object from various collections. */ - item(nameOrIndex?: any, optionalIndex?: any): Element; + item(index: number): Element; /** * Retrieves a select object or an object from an options collection. */ @@ -4478,7 +4478,7 @@ declare var HTMLDListElement: { } interface HTMLDataListElement extends HTMLElement { - options: HTMLCollection; + options: HTMLCollectionOf; } declare var HTMLDataListElement: { @@ -4521,22 +4521,22 @@ declare var HTMLDocument: { interface HTMLElement extends Element { accessKey: string; - children: HTMLCollection; + readonly children: HTMLCollection; contentEditable: string; - dataset: DOMStringMap; + readonly dataset: DOMStringMap; dir: string; draggable: boolean; hidden: boolean; hideFocus: boolean; innerHTML: string; innerText: string; - isContentEditable: boolean; + readonly isContentEditable: boolean; lang: string; - offsetHeight: number; - offsetLeft: number; - offsetParent: Element; - offsetTop: number; - offsetWidth: number; + readonly offsetHeight: number; + readonly offsetLeft: number; + readonly offsetParent: Element; + readonly offsetTop: number; + readonly offsetWidth: number; onabort: (ev: Event) => any; onactivate: (ev: UIEvent) => any; onbeforeactivate: (ev: UIEvent) => any; @@ -4607,7 +4607,7 @@ interface HTMLElement extends Element { outerHTML: string; outerText: string; spellcheck: boolean; - style: CSSStyleDeclaration; + readonly style: CSSStyleDeclaration; tabIndex: number; title: string; blur(): void; @@ -4752,7 +4752,7 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { /** * Gets the source associated with the media element for use by the PlayToManager. */ - msPlayToSource: any; + readonly msPlayToSource: any; /** * Sets or retrieves the name of the object. */ @@ -4760,12 +4760,12 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { /** * Retrieves the palette used for the embedded document. */ - palette: string; + readonly palette: string; /** * Retrieves the URL of the plug-in used to view an embedded document. */ - pluginspage: string; - readyState: string; + readonly pluginspage: string; + readonly readyState: string; /** * Sets or retrieves a URL to be loaded by the object. */ @@ -4795,19 +4795,19 @@ interface HTMLFieldSetElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ - validationMessage: string; + readonly validationMessage: string; /** * Returns a ValidityState object that represents the validity states of an element. */ - validity: ValidityState; + readonly validity: ValidityState; /** * Returns whether an element will successfully validate based on forms validation rules and constraints. */ - willValidate: boolean; + readonly willValidate: boolean; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ @@ -4853,7 +4853,7 @@ interface HTMLFormElement extends HTMLElement { /** * Retrieves a collection, in source order, of all controls in a given form. */ - elements: HTMLCollection; + readonly elements: HTMLCollection; /** * Sets or retrieves the MIME encoding for the form. */ @@ -4865,7 +4865,7 @@ interface HTMLFormElement extends HTMLElement { /** * Sets or retrieves the number of objects in a collection. */ - length: number; + readonly length: number; /** * Sets or retrieves how to send the form data to the server. */ @@ -4924,11 +4924,11 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument { /** * Retrieves the document object of the page or frame. */ - contentDocument: Document; + readonly contentDocument: Document; /** * Retrieves the object of the specified. */ - contentWindow: Window; + readonly contentWindow: Window; /** * Sets or retrieves whether to display a border for the frame. */ @@ -5329,11 +5329,11 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { /** * Retrieves the document object of the page or frame. */ - contentDocument: Document; + readonly contentDocument: Document; /** * Retrieves the object of the specified. */ - contentWindow: Window; + readonly contentWindow: Window; /** * Sets or retrieves whether to display a border for the frame. */ @@ -5374,7 +5374,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { * Raised when the object has been completely received from the server. */ onload: (ev: Event) => any; - sandbox: DOMSettableTokenList; + readonly sandbox: DOMSettableTokenList; /** * Sets or retrieves whether the frame can be scrolled. */ @@ -5519,9 +5519,9 @@ interface HTMLImageElement extends HTMLElement { /** * Retrieves whether the object is fully loaded. */ - complete: boolean; + readonly complete: boolean; crossOrigin: string; - currentSrc: string; + readonly currentSrc: string; /** * Sets or retrieves the height of the object. */ @@ -5551,7 +5551,7 @@ interface HTMLImageElement extends HTMLElement { /** * Gets the source associated with the media element for use by the PlayToManager. */ - msPlayToSource: any; + readonly msPlayToSource: any; /** * Sets or retrieves the name of the object. */ @@ -5559,11 +5559,11 @@ interface HTMLImageElement extends HTMLElement { /** * The original height of the image resource before sizing. */ - naturalHeight: number; + readonly naturalHeight: number; /** * The original width of the image resource before sizing. */ - naturalWidth: number; + readonly naturalWidth: number; sizes: string; /** * The address or URL of the a media resource that is to be considered. @@ -5582,8 +5582,8 @@ interface HTMLImageElement extends HTMLElement { * Sets or retrieves the width of the object. */ width: number; - x: number; - y: number; + readonly x: number; + readonly y: number; msGetAsCastingSource(): any; } @@ -5625,7 +5625,7 @@ interface HTMLInputElement extends HTMLElement { /** * Retrieves whether the object is fully loaded. */ - complete: boolean; + readonly complete: boolean; /** * Sets or retrieves the state of the check box or radio button. */ @@ -5638,11 +5638,11 @@ interface HTMLInputElement extends HTMLElement { /** * Returns a FileList object on a file type input object. */ - files: FileList; + readonly files: FileList; /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -5675,7 +5675,7 @@ interface HTMLInputElement extends HTMLElement { /** * Specifies the ID of a pre-defined datalist of options for an input element. */ - list: HTMLElement; + readonly list: HTMLElement; /** * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. */ @@ -5739,11 +5739,11 @@ interface HTMLInputElement extends HTMLElement { /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ - validationMessage: string; + readonly validationMessage: string; /** * Returns a ValidityState object that represents the validity states of an element. */ - validity: ValidityState; + readonly validity: ValidityState; /** * Returns the value of the data at the cursor's current position. */ @@ -5765,7 +5765,7 @@ interface HTMLInputElement extends HTMLElement { /** * Returns whether an element will successfully validate based on forms validation rules and constraints. */ - willValidate: boolean; + readonly willValidate: boolean; minLength: number; /** * Returns whether a form will validate when it is submitted, without having to submit it. @@ -5820,7 +5820,7 @@ interface HTMLLabelElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Sets or retrieves the object to which the given label object is assigned. */ @@ -5840,7 +5840,7 @@ interface HTMLLegendElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; } declare var HTMLLegendElement: { @@ -5895,7 +5895,7 @@ interface HTMLMapElement extends HTMLElement { /** * Retrieves a collection of the area objects defined for the given map object. */ - areas: HTMLAreasCollection; + readonly areas: HTMLAreasCollection; /** * Sets or retrieves the name of the object. */ @@ -6042,7 +6042,7 @@ interface HTMLMediaElement extends HTMLElement { /** * Returns an AudioTrackList object with the audio tracks for a given video element. */ - audioTracks: AudioTrackList; + readonly audioTracks: AudioTrackList; /** * Gets or sets a value that indicates whether to start playing the media automatically. */ @@ -6050,7 +6050,7 @@ interface HTMLMediaElement extends HTMLElement { /** * Gets a collection of buffered time ranges. */ - buffered: TimeRanges; + readonly buffered: TimeRanges; /** * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). */ @@ -6059,7 +6059,7 @@ interface HTMLMediaElement extends HTMLElement { /** * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. */ - currentSrc: string; + readonly currentSrc: string; /** * Gets or sets the current playback position, in seconds. */ @@ -6072,20 +6072,20 @@ interface HTMLMediaElement extends HTMLElement { /** * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. */ - duration: number; + readonly duration: number; /** * Gets information about whether the playback has ended or not. */ - ended: boolean; + readonly ended: boolean; /** * Returns an object representing the current error state of the audio or video element. */ - error: MediaError; + readonly error: MediaError; /** * Gets or sets a flag to specify whether playback should restart after it completes. */ loop: boolean; - mediaKeys: MediaKeys; + readonly mediaKeys: MediaKeys; /** * Specifies the purpose of the audio or video media, such as background audio or alerts. */ @@ -6094,11 +6094,11 @@ interface HTMLMediaElement extends HTMLElement { * Specifies the output device id that the audio will be sent to. */ msAudioDeviceType: string; - msGraphicsTrustStatus: MSGraphicsTrust; + readonly msGraphicsTrustStatus: MSGraphicsTrust; /** * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. */ - msKeys: MSMediaKeys; + readonly msKeys: MSMediaKeys; /** * Gets or sets whether the DLNA PlayTo device is available. */ @@ -6114,7 +6114,7 @@ interface HTMLMediaElement extends HTMLElement { /** * Gets the source associated with the media element for use by the PlayToManager. */ - msPlayToSource: any; + readonly msPlayToSource: any; /** * Specifies whether or not to enable low-latency playback on the media element. */ @@ -6126,13 +6126,13 @@ interface HTMLMediaElement extends HTMLElement { /** * Gets the current network activity for the element. */ - networkState: number; + readonly networkState: number; onencrypted: (ev: MediaEncryptedEvent) => any; onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; /** * Gets a flag that specifies whether playback is paused. */ - paused: boolean; + readonly paused: boolean; /** * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. */ @@ -6140,7 +6140,7 @@ interface HTMLMediaElement extends HTMLElement { /** * Gets TimeRanges for the current media resource that has been played. */ - played: TimeRanges; + readonly played: TimeRanges; /** * Gets or sets the current playback position, in seconds. */ @@ -6149,18 +6149,18 @@ interface HTMLMediaElement extends HTMLElement { /** * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. */ - seekable: TimeRanges; + readonly seekable: TimeRanges; /** * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. */ - seeking: boolean; + readonly seeking: boolean; /** * The address or URL of the a media resource that is to be considered. */ src: string; srcObject: MediaStream; - textTracks: TextTrackList; - videoTracks: VideoTrackList; + readonly textTracks: TextTrackList; + readonly videoTracks: VideoTrackList; /** * Gets or sets the volume level for audio portions of the media element. */ @@ -6197,15 +6197,15 @@ interface HTMLMediaElement extends HTMLElement { */ play(): void; setMediaKeys(mediaKeys: MediaKeys): PromiseLike; - HAVE_CURRENT_DATA: number; - HAVE_ENOUGH_DATA: number; - HAVE_FUTURE_DATA: number; - HAVE_METADATA: number; - HAVE_NOTHING: number; - NETWORK_EMPTY: number; - NETWORK_IDLE: number; - NETWORK_LOADING: number; - NETWORK_NO_SOURCE: number; + readonly HAVE_CURRENT_DATA: number; + readonly HAVE_ENOUGH_DATA: number; + readonly HAVE_FUTURE_DATA: number; + readonly HAVE_METADATA: number; + readonly HAVE_NOTHING: number; + readonly NETWORK_EMPTY: number; + readonly NETWORK_IDLE: number; + readonly NETWORK_LOADING: number; + readonly NETWORK_NO_SOURCE: number; 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; @@ -6317,15 +6317,15 @@ interface HTMLMediaElement extends HTMLElement { declare var HTMLMediaElement: { prototype: HTMLMediaElement; new(): HTMLMediaElement; - HAVE_CURRENT_DATA: number; - HAVE_ENOUGH_DATA: number; - HAVE_FUTURE_DATA: number; - HAVE_METADATA: number; - HAVE_NOTHING: number; - NETWORK_EMPTY: number; - NETWORK_IDLE: number; - NETWORK_LOADING: number; - NETWORK_NO_SOURCE: number; + readonly HAVE_CURRENT_DATA: number; + readonly HAVE_ENOUGH_DATA: number; + readonly HAVE_FUTURE_DATA: number; + readonly HAVE_METADATA: number; + readonly HAVE_NOTHING: number; + readonly NETWORK_EMPTY: number; + readonly NETWORK_IDLE: number; + readonly NETWORK_LOADING: number; + readonly NETWORK_NO_SOURCE: number; } interface HTMLMenuElement extends HTMLElement { @@ -6418,7 +6418,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. */ - BaseHref: string; + readonly BaseHref: string; align: string; /** * Sets or retrieves a text alternative to the graphic. @@ -6448,7 +6448,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves the document object of the page or frame. */ - contentDocument: Document; + readonly contentDocument: Document; /** * Sets or retrieves the URL that references the data of the object. */ @@ -6457,7 +6457,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Sets or retrieves the height of the object. */ @@ -6478,7 +6478,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Gets the source associated with the media element for use by the PlayToManager. */ - msPlayToSource: any; + readonly msPlayToSource: any; /** * Sets or retrieves the name of the object. */ @@ -6486,8 +6486,8 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves the contained object. */ - object: any; - readyState: number; + readonly object: any; + readonly readyState: number; /** * Sets or retrieves a message to be displayed while an object is loading. */ @@ -6503,11 +6503,11 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ - validationMessage: string; + readonly validationMessage: string; /** * Returns a ValidityState object that represents the validity states of an element. */ - validity: ValidityState; + readonly validity: ValidityState; vspace: number; /** * Sets or retrieves the width of the object. @@ -6516,7 +6516,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Returns whether an element will successfully validate based on forms validation rules and constraints. */ - willValidate: boolean; + readonly willValidate: boolean; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ @@ -6543,11 +6543,11 @@ interface HTMLOptGroupElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Sets or retrieves the ordinal position of an option in a list box. */ - index: number; + readonly index: number; /** * Sets or retrieves a value that you can use to implement your own label functionality for the object. */ @@ -6559,7 +6559,7 @@ interface HTMLOptGroupElement extends HTMLElement { /** * Sets or retrieves the text string specified by the option tag. */ - text: string; + readonly text: string; /** * Sets or retrieves the value which is returned to the server when the form control is submitted. */ @@ -6580,11 +6580,11 @@ interface HTMLOptionElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Sets or retrieves the ordinal position of an option in a list box. */ - index: number; + readonly index: number; /** * Sets or retrieves a value that you can use to implement your own label functionality for the object. */ @@ -6682,7 +6682,7 @@ interface HTMLProgressElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Defines the maximum, or "done" value for a progress element. */ @@ -6690,7 +6690,7 @@ interface HTMLProgressElement extends HTMLElement { /** * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). */ - position: number; + readonly position: number; /** * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. */ @@ -6760,7 +6760,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Sets or retrieves the number of objects in a collection. */ @@ -6773,7 +6773,7 @@ interface HTMLSelectElement extends HTMLElement { * Sets or retrieves the name of the object. */ name: string; - options: HTMLCollection; + options: HTMLCollectionOf; /** * When present, marks an element that can't be submitted without a value. */ @@ -6782,7 +6782,7 @@ interface HTMLSelectElement extends HTMLElement { * Sets or retrieves the index of the selected option in a select object. */ selectedIndex: number; - selectedOptions: HTMLCollection; + selectedOptions: HTMLCollectionOf; /** * Sets or retrieves the number of rows in the list box. */ @@ -6790,15 +6790,15 @@ interface HTMLSelectElement extends HTMLElement { /** * Retrieves the type of select control based on the value of the MULTIPLE attribute. */ - type: string; + readonly type: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ - validationMessage: string; + readonly validationMessage: string; /** * Returns a ValidityState object that represents the validity states of an element. */ - validity: ValidityState; + readonly validity: ValidityState; /** * Sets or retrieves the value which is returned to the server when the form control is submitted. */ @@ -6806,7 +6806,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Returns whether an element will successfully validate based on forms validation rules and constraints. */ - willValidate: boolean; + readonly willValidate: boolean; /** * Adds an element to the areas, controlRange, or options collection. * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. @@ -6928,7 +6928,7 @@ interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { /** * Retrieves the position of the object in the cells collection of a row. */ - cellIndex: number; + readonly cellIndex: number; /** * Sets or retrieves the number columns in the table that the object should span. */ @@ -7035,7 +7035,7 @@ interface HTMLTableElement extends HTMLElement { /** * Sets or retrieves the number of horizontal rows contained in the object. */ - rows: HTMLCollection; + rows: HTMLCollectionOf; /** * Sets or retrieves which dividing lines (inner borders) are displayed. */ @@ -7047,7 +7047,7 @@ interface HTMLTableElement extends HTMLElement { /** * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. */ - tBodies: HTMLCollection; + tBodies: HTMLCollectionOf; /** * Retrieves the tFoot object of the table. */ @@ -7126,7 +7126,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { /** * Retrieves a collection of all cells in the table row. */ - cells: HTMLCollection; + cells: HTMLCollectionOf; /** * Sets or retrieves the height of the object. */ @@ -7134,11 +7134,11 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { /** * Retrieves the position of the object in the rows collection for the table. */ - rowIndex: number; + readonly rowIndex: number; /** * Retrieves the position of the object in the collection. */ - sectionRowIndex: number; + readonly sectionRowIndex: number; /** * Removes the specified cell from the table row, as well as from the cells collection. * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. @@ -7148,7 +7148,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { * Creates a new cell in the table row, and adds the cell to the cells collection. * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. */ - insertCell(index?: number): HTMLTableCellElement; + insertCell(index?: number): HTMLTableDataCellElement; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7165,7 +7165,7 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { /** * Sets or retrieves the number of horizontal rows contained in the object. */ - rows: HTMLCollection; + rows: HTMLCollectionOf; /** * Removes the specified row (tr) from the element and from the rows collection. * @param index Number that specifies the zero-based position in the rows collection of the row to remove. @@ -7185,7 +7185,7 @@ declare var HTMLTableSectionElement: { } interface HTMLTemplateElement extends HTMLElement { - content: DocumentFragment; + readonly content: DocumentFragment; } declare var HTMLTemplateElement: { @@ -7210,7 +7210,7 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - form: HTMLFormElement; + readonly form: HTMLFormElement; /** * Sets or retrieves the maximum number of characters that the user can enter in a text control. */ @@ -7250,15 +7250,15 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Retrieves the type of control. */ - type: string; + readonly type: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. */ - validationMessage: string; + readonly validationMessage: string; /** * Returns a ValidityState object that represents the validity states of an element. */ - validity: ValidityState; + readonly validity: ValidityState; /** * Retrieves or sets the text in the entry field of the textArea element. */ @@ -7266,7 +7266,7 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Returns whether an element will successfully validate based on forms validation rules and constraints. */ - willValidate: boolean; + readonly willValidate: boolean; /** * Sets or retrieves how to handle wordwrapping in the object. */ @@ -7314,23 +7314,23 @@ interface HTMLTrackElement extends HTMLElement { default: boolean; kind: string; label: string; - readyState: number; + readonly readyState: number; src: string; srclang: string; - track: TextTrack; - ERROR: number; - LOADED: number; - LOADING: number; - NONE: number; + readonly track: TextTrack; + readonly ERROR: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; } declare var HTMLTrackElement: { prototype: HTMLTrackElement; new(): HTMLTrackElement; - ERROR: number; - LOADED: number; - LOADING: number; - NONE: number; + readonly ERROR: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; } interface HTMLUListElement extends HTMLElement { @@ -7357,8 +7357,8 @@ interface HTMLVideoElement extends HTMLMediaElement { */ height: number; msHorizontalMirror: boolean; - msIsLayoutOptimalForPlayback: boolean; - msIsStereo3D: boolean; + readonly msIsLayoutOptimalForPlayback: boolean; + readonly msIsStereo3D: boolean; msStereo3DPackingMode: string; msStereo3DRenderMode: string; msZoom: boolean; @@ -7372,13 +7372,13 @@ interface HTMLVideoElement extends HTMLMediaElement { /** * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. */ - videoHeight: number; + readonly videoHeight: number; /** * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. */ - videoWidth: number; - webkitDisplayingFullscreen: boolean; - webkitSupportsFullscreen: boolean; + readonly videoWidth: number; + readonly webkitDisplayingFullscreen: boolean; + readonly webkitSupportsFullscreen: boolean; /** * Gets or sets the width of the video element. */ @@ -7508,8 +7508,8 @@ declare var HTMLVideoElement: { } interface HashChangeEvent extends Event { - newURL: string; - oldURL: string; + readonly newURL: string; + readonly oldURL: string; } declare var HashChangeEvent: { @@ -7518,8 +7518,8 @@ declare var HashChangeEvent: { } interface History { - length: number; - state: any; + readonly length: number; + readonly state: any; back(distance?: any): void; forward(distance?: any): void; go(delta?: any): void; @@ -7533,31 +7533,31 @@ declare var History: { } interface IDBCursor { - direction: string; + readonly direction: string; key: IDBKeyRange | IDBValidKey; - primaryKey: any; + readonly primaryKey: any; source: IDBObjectStore | IDBIndex; advance(count: number): void; continue(key?: IDBKeyRange | IDBValidKey): void; delete(): IDBRequest; update(value: any): IDBRequest; - NEXT: string; - NEXT_NO_DUPLICATE: string; - PREV: string; - PREV_NO_DUPLICATE: string; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; } declare var IDBCursor: { prototype: IDBCursor; new(): IDBCursor; - NEXT: string; - NEXT_NO_DUPLICATE: string; - PREV: string; - PREV_NO_DUPLICATE: string; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; } interface IDBCursorWithValue extends IDBCursor { - value: any; + readonly value: any; } declare var IDBCursorWithValue: { @@ -7566,8 +7566,8 @@ declare var IDBCursorWithValue: { } interface IDBDatabase extends EventTarget { - name: string; - objectStoreNames: DOMStringList; + readonly name: string; + readonly objectStoreNames: DOMStringList; onabort: (ev: Event) => any; onerror: (ev: Event) => any; version: number; @@ -7600,9 +7600,9 @@ declare var IDBFactory: { interface IDBIndex { keyPath: string | string[]; - name: string; - objectStore: IDBObjectStore; - unique: boolean; + readonly name: string; + readonly objectStore: IDBObjectStore; + readonly unique: boolean; multiEntry: boolean; count(key?: IDBKeyRange | IDBValidKey): IDBRequest; get(key: IDBKeyRange | IDBValidKey): IDBRequest; @@ -7617,10 +7617,10 @@ declare var IDBIndex: { } interface IDBKeyRange { - lower: any; - lowerOpen: boolean; - upper: any; - upperOpen: boolean; + readonly lower: any; + readonly lowerOpen: boolean; + readonly upper: any; + readonly upperOpen: boolean; } declare var IDBKeyRange: { @@ -7633,10 +7633,10 @@ declare var IDBKeyRange: { } interface IDBObjectStore { - indexNames: DOMStringList; + readonly indexNames: DOMStringList; keyPath: string | string[]; - name: string; - transaction: IDBTransaction; + readonly name: string; + readonly transaction: IDBTransaction; autoIncrement: boolean; add(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; clear(): IDBRequest; @@ -7671,13 +7671,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequest extends EventTarget { - error: DOMError; + readonly error: DOMError; onerror: (ev: Event) => any; onsuccess: (ev: Event) => any; - readyState: string; - result: any; + readonly readyState: string; + readonly result: any; source: IDBObjectStore | IDBIndex | IDBCursor; - transaction: IDBTransaction; + readonly transaction: IDBTransaction; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -7689,17 +7689,17 @@ declare var IDBRequest: { } interface IDBTransaction extends EventTarget { - db: IDBDatabase; - error: DOMError; - mode: string; + readonly db: IDBDatabase; + readonly error: DOMError; + readonly mode: string; onabort: (ev: Event) => any; oncomplete: (ev: Event) => any; onerror: (ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; - READ_ONLY: string; - READ_WRITE: string; - VERSION_CHANGE: string; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; @@ -7709,14 +7709,14 @@ interface IDBTransaction extends EventTarget { declare var IDBTransaction: { prototype: IDBTransaction; new(): IDBTransaction; - READ_ONLY: string; - READ_WRITE: string; - VERSION_CHANGE: string; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; } interface IDBVersionChangeEvent extends Event { - newVersion: number; - oldVersion: number; + readonly newVersion: number; + readonly oldVersion: number; } declare var IDBVersionChangeEvent: { @@ -7726,8 +7726,8 @@ declare var IDBVersionChangeEvent: { interface ImageData { data: Uint8ClampedArray; - height: number; - width: number; + readonly height: number; + readonly width: number; } declare var ImageData: { @@ -7737,42 +7737,42 @@ declare var ImageData: { } interface KeyboardEvent extends UIEvent { - altKey: boolean; - char: string; - charCode: number; - ctrlKey: boolean; - key: string; - keyCode: number; - locale: string; - location: number; - metaKey: boolean; - repeat: boolean; - shiftKey: boolean; - which: number; + readonly altKey: boolean; + readonly char: string; + readonly charCode: number; + readonly ctrlKey: boolean; + readonly key: string; + readonly keyCode: number; + readonly locale: string; + readonly location: number; + readonly metaKey: boolean; + readonly repeat: boolean; + readonly shiftKey: boolean; + readonly which: number; getModifierState(keyArg: string): boolean; initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_MOBILE: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; + readonly DOM_KEY_LOCATION_JOYSTICK: number; + readonly DOM_KEY_LOCATION_LEFT: number; + readonly DOM_KEY_LOCATION_MOBILE: number; + readonly DOM_KEY_LOCATION_NUMPAD: number; + readonly DOM_KEY_LOCATION_RIGHT: number; + readonly DOM_KEY_LOCATION_STANDARD: number; } declare var KeyboardEvent: { prototype: KeyboardEvent; new(typeArg: string, eventInitDict?: KeyboardEventInit): KeyboardEvent; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_MOBILE: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; + readonly DOM_KEY_LOCATION_JOYSTICK: number; + readonly DOM_KEY_LOCATION_LEFT: number; + readonly DOM_KEY_LOCATION_MOBILE: number; + readonly DOM_KEY_LOCATION_NUMPAD: number; + readonly DOM_KEY_LOCATION_RIGHT: number; + readonly DOM_KEY_LOCATION_STANDARD: number; } interface ListeningStateChangedEvent extends Event { - label: string; - state: string; + readonly label: string; + readonly state: string; } declare var ListeningStateChangedEvent: { @@ -7785,7 +7785,7 @@ interface Location { host: string; hostname: string; href: string; - origin: string; + readonly origin: string; pathname: string; port: string; protocol: string; @@ -7802,7 +7802,7 @@ declare var Location: { } interface LongRunningScriptDetectedEvent extends Event { - executionTime: number; + readonly executionTime: number; stopPageScriptExecution: boolean; } @@ -7827,23 +7827,23 @@ interface MSApp { pageHandlesAllApplicationActivations(enabled: boolean): void; suppressSubdownloadCredentialPrompts(suppress: boolean): void; terminateApp(exceptionObject: any): void; - CURRENT: string; - HIGH: string; - IDLE: string; - NORMAL: string; + readonly CURRENT: string; + readonly HIGH: string; + readonly IDLE: string; + readonly NORMAL: string; } declare var MSApp: MSApp; interface MSAppAsyncOperation extends EventTarget { - error: DOMError; + readonly error: DOMError; oncomplete: (ev: Event) => any; onerror: (ev: Event) => any; - readyState: number; - result: any; + readonly readyState: number; + readonly result: any; start(): void; - COMPLETED: number; - ERROR: number; - STARTED: number; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -7852,14 +7852,14 @@ interface MSAppAsyncOperation extends EventTarget { declare var MSAppAsyncOperation: { prototype: MSAppAsyncOperation; new(): MSAppAsyncOperation; - COMPLETED: number; - ERROR: number; - STARTED: number; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; } interface MSAssertion { - id: string; - type: string; + readonly id: string; + readonly type: string; } declare var MSAssertion: { @@ -7888,10 +7888,10 @@ declare var MSCredentials: { } interface MSFIDOCredentialAssertion extends MSAssertion { - algorithm: string | Algorithm; - attestation: any; - publicKey: string; - transportHints: string[]; + readonly algorithm: string | Algorithm; + readonly attestation: any; + readonly publicKey: string; + readonly transportHints: string[]; } declare var MSFIDOCredentialAssertion: { @@ -7900,9 +7900,9 @@ declare var MSFIDOCredentialAssertion: { } interface MSFIDOSignature { - authnrData: string; - clientData: string; - signature: string; + readonly authnrData: string; + readonly clientData: string; + readonly signature: string; } declare var MSFIDOSignature: { @@ -7911,7 +7911,7 @@ declare var MSFIDOSignature: { } interface MSFIDOSignatureAssertion extends MSAssertion { - signature: MSFIDOSignature; + readonly signature: MSFIDOSignature; } declare var MSFIDOSignatureAssertion: { @@ -7931,44 +7931,44 @@ declare var MSGesture: { } interface MSGestureEvent extends UIEvent { - clientX: number; - clientY: number; - expansion: number; - gestureObject: any; - hwTimestamp: number; - offsetX: number; - offsetY: number; - rotation: number; - scale: number; - screenX: number; - screenY: number; - translationX: number; - translationY: number; - velocityAngular: number; - velocityExpansion: number; - velocityX: number; - velocityY: number; + readonly clientX: number; + readonly clientY: number; + readonly expansion: number; + readonly gestureObject: any; + readonly hwTimestamp: number; + readonly offsetX: number; + readonly offsetY: number; + readonly rotation: number; + readonly scale: number; + readonly screenX: number; + readonly screenY: number; + readonly translationX: number; + readonly translationY: number; + readonly velocityAngular: number; + readonly velocityExpansion: number; + readonly velocityX: number; + readonly velocityY: number; initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; + readonly MSGESTURE_FLAG_BEGIN: number; + readonly MSGESTURE_FLAG_CANCEL: number; + readonly MSGESTURE_FLAG_END: number; + readonly MSGESTURE_FLAG_INERTIA: number; + readonly MSGESTURE_FLAG_NONE: number; } declare var MSGestureEvent: { prototype: MSGestureEvent; new(): MSGestureEvent; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; + readonly MSGESTURE_FLAG_BEGIN: number; + readonly MSGESTURE_FLAG_CANCEL: number; + readonly MSGESTURE_FLAG_END: number; + readonly MSGESTURE_FLAG_INERTIA: number; + readonly MSGESTURE_FLAG_NONE: number; } interface MSGraphicsTrust { - constrictionActive: boolean; - status: string; + readonly constrictionActive: boolean; + readonly status: string; } declare var MSGraphicsTrust: { @@ -7977,12 +7977,12 @@ declare var MSGraphicsTrust: { } interface MSHTMLWebViewElement extends HTMLElement { - canGoBack: boolean; - canGoForward: boolean; - containsFullScreenElement: boolean; - documentTitle: string; + readonly canGoBack: boolean; + readonly canGoForward: boolean; + readonly containsFullScreenElement: boolean; + readonly documentTitle: string; height: number; - settings: MSWebViewSettings; + readonly settings: MSWebViewSettings; src: string; width: number; addWebAllowedObject(name: string, applicationObject: any): void; @@ -8008,12 +8008,12 @@ declare var MSHTMLWebViewElement: { } interface MSInputMethodContext extends EventTarget { - compositionEndOffset: number; - compositionStartOffset: number; + readonly compositionEndOffset: number; + readonly compositionStartOffset: number; oncandidatewindowhide: (ev: Event) => any; oncandidatewindowshow: (ev: Event) => any; oncandidatewindowupdate: (ev: Event) => any; - target: HTMLElement; + readonly target: HTMLElement; getCandidateWindowClientRect(): ClientRect; getCompositionAlternatives(): string[]; hasComposition(): boolean; @@ -8030,59 +8030,59 @@ declare var MSInputMethodContext: { } interface MSManipulationEvent extends UIEvent { - currentState: number; - inertiaDestinationX: number; - inertiaDestinationY: number; - lastState: number; + readonly currentState: number; + readonly inertiaDestinationX: number; + readonly inertiaDestinationY: number; + readonly lastState: number; initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_CANCELLED: number; - MS_MANIPULATION_STATE_COMMITTED: number; - MS_MANIPULATION_STATE_DRAGGING: number; - MS_MANIPULATION_STATE_INERTIA: number; - MS_MANIPULATION_STATE_PRESELECT: number; - MS_MANIPULATION_STATE_SELECTING: number; - MS_MANIPULATION_STATE_STOPPED: number; + readonly MS_MANIPULATION_STATE_ACTIVE: number; + readonly MS_MANIPULATION_STATE_CANCELLED: number; + readonly MS_MANIPULATION_STATE_COMMITTED: number; + readonly MS_MANIPULATION_STATE_DRAGGING: number; + readonly MS_MANIPULATION_STATE_INERTIA: number; + readonly MS_MANIPULATION_STATE_PRESELECT: number; + readonly MS_MANIPULATION_STATE_SELECTING: number; + readonly MS_MANIPULATION_STATE_STOPPED: number; } declare var MSManipulationEvent: { prototype: MSManipulationEvent; new(): MSManipulationEvent; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_CANCELLED: number; - MS_MANIPULATION_STATE_COMMITTED: number; - MS_MANIPULATION_STATE_DRAGGING: number; - MS_MANIPULATION_STATE_INERTIA: number; - MS_MANIPULATION_STATE_PRESELECT: number; - MS_MANIPULATION_STATE_SELECTING: number; - MS_MANIPULATION_STATE_STOPPED: number; + readonly MS_MANIPULATION_STATE_ACTIVE: number; + readonly MS_MANIPULATION_STATE_CANCELLED: number; + readonly MS_MANIPULATION_STATE_COMMITTED: number; + readonly MS_MANIPULATION_STATE_DRAGGING: number; + readonly MS_MANIPULATION_STATE_INERTIA: number; + readonly MS_MANIPULATION_STATE_PRESELECT: number; + readonly MS_MANIPULATION_STATE_SELECTING: number; + readonly MS_MANIPULATION_STATE_STOPPED: number; } interface MSMediaKeyError { - code: number; - systemCode: number; - MS_MEDIA_KEYERR_CLIENT: number; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_HARDWARECHANGE: number; - MS_MEDIA_KEYERR_OUTPUT: number; - MS_MEDIA_KEYERR_SERVICE: number; - MS_MEDIA_KEYERR_UNKNOWN: number; + readonly code: number; + readonly systemCode: number; + readonly MS_MEDIA_KEYERR_CLIENT: number; + readonly MS_MEDIA_KEYERR_DOMAIN: number; + readonly MS_MEDIA_KEYERR_HARDWARECHANGE: number; + readonly MS_MEDIA_KEYERR_OUTPUT: number; + readonly MS_MEDIA_KEYERR_SERVICE: number; + readonly MS_MEDIA_KEYERR_UNKNOWN: number; } declare var MSMediaKeyError: { prototype: MSMediaKeyError; new(): MSMediaKeyError; - MS_MEDIA_KEYERR_CLIENT: number; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_HARDWARECHANGE: number; - MS_MEDIA_KEYERR_OUTPUT: number; - MS_MEDIA_KEYERR_SERVICE: number; - MS_MEDIA_KEYERR_UNKNOWN: number; + readonly MS_MEDIA_KEYERR_CLIENT: number; + readonly MS_MEDIA_KEYERR_DOMAIN: number; + readonly MS_MEDIA_KEYERR_HARDWARECHANGE: number; + readonly MS_MEDIA_KEYERR_OUTPUT: number; + readonly MS_MEDIA_KEYERR_SERVICE: number; + readonly MS_MEDIA_KEYERR_UNKNOWN: number; } interface MSMediaKeyMessageEvent extends Event { - destinationURL: string; - message: Uint8Array; + readonly destinationURL: string; + readonly message: Uint8Array; } declare var MSMediaKeyMessageEvent: { @@ -8091,7 +8091,7 @@ declare var MSMediaKeyMessageEvent: { } interface MSMediaKeyNeededEvent extends Event { - initData: Uint8Array; + readonly initData: Uint8Array; } declare var MSMediaKeyNeededEvent: { @@ -8100,9 +8100,9 @@ declare var MSMediaKeyNeededEvent: { } interface MSMediaKeySession extends EventTarget { - error: MSMediaKeyError; - keySystem: string; - sessionId: string; + readonly error: MSMediaKeyError; + readonly keySystem: string; + readonly sessionId: string; close(): void; update(key: Uint8Array): void; } @@ -8113,7 +8113,7 @@ declare var MSMediaKeySession: { } interface MSMediaKeys { - keySystem: string; + readonly keySystem: string; createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; } @@ -8125,18 +8125,18 @@ declare var MSMediaKeys: { } interface MSPointerEvent extends MouseEvent { - currentPoint: any; - height: number; - hwTimestamp: number; - intermediatePoints: any; - isPrimary: boolean; - pointerId: number; - pointerType: any; - pressure: number; - rotation: number; - tiltX: number; - tiltY: number; - width: number; + readonly currentPoint: any; + readonly height: number; + readonly hwTimestamp: number; + readonly intermediatePoints: any; + readonly isPrimary: boolean; + readonly pointerId: number; + readonly pointerType: any; + readonly pressure: number; + readonly rotation: number; + readonly tiltX: number; + readonly tiltY: number; + readonly width: number; getCurrentPoint(element: Element): void; getIntermediatePoints(element: Element): void; initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; @@ -8148,7 +8148,7 @@ declare var MSPointerEvent: { } interface MSRangeCollection { - length: number; + readonly length: number; item(index: number): Range; [index: number]: Range; } @@ -8159,8 +8159,8 @@ declare var MSRangeCollection: { } interface MSSiteModeEvent extends Event { - actionURL: string; - buttonID: number; + readonly actionURL: string; + readonly buttonID: number; } declare var MSSiteModeEvent: { @@ -8169,7 +8169,7 @@ declare var MSSiteModeEvent: { } interface MSStream { - type: string; + readonly type: string; msClose(): void; msDetachStream(): any; } @@ -8180,7 +8180,7 @@ declare var MSStream: { } interface MSStreamReader extends EventTarget, MSBaseReader { - error: DOMError; + readonly error: DOMError; readAsArrayBuffer(stream: MSStream, size?: number): void; readAsBinaryString(stream: MSStream, size?: number): void; readAsBlob(stream: MSStream, size?: number): void; @@ -8195,20 +8195,20 @@ declare var MSStreamReader: { } interface MSWebViewAsyncOperation extends EventTarget { - error: DOMError; + readonly error: DOMError; oncomplete: (ev: Event) => any; onerror: (ev: Event) => any; - readyState: number; - result: any; - target: MSHTMLWebViewElement; - type: number; + readonly readyState: number; + readonly result: any; + readonly target: MSHTMLWebViewElement; + readonly type: number; start(): void; - COMPLETED: number; - ERROR: number; - STARTED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; - TYPE_INVOKE_SCRIPT: number; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + readonly TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + readonly TYPE_INVOKE_SCRIPT: number; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -8217,12 +8217,12 @@ interface MSWebViewAsyncOperation extends EventTarget { declare var MSWebViewAsyncOperation: { prototype: MSWebViewAsyncOperation; new(): MSWebViewAsyncOperation; - COMPLETED: number; - ERROR: number; - STARTED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; - TYPE_INVOKE_SCRIPT: number; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + readonly TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + readonly TYPE_INVOKE_SCRIPT: number; } interface MSWebViewSettings { @@ -8236,10 +8236,10 @@ declare var MSWebViewSettings: { } interface MediaDeviceInfo { - deviceId: string; - groupId: string; - kind: string; - label: string; + readonly deviceId: string; + readonly groupId: string; + readonly kind: string; + readonly label: string; } declare var MediaDeviceInfo: { @@ -8270,8 +8270,8 @@ declare var MediaElementAudioSourceNode: { } interface MediaEncryptedEvent extends Event { - initData: ArrayBuffer; - initDataType: string; + readonly initData: ArrayBuffer; + readonly initDataType: string; } declare var MediaEncryptedEvent: { @@ -8280,28 +8280,28 @@ declare var MediaEncryptedEvent: { } interface MediaError { - code: number; - msExtendedCode: number; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_DECODE: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MS_MEDIA_ERR_ENCRYPTED: number; + readonly code: number; + readonly msExtendedCode: number; + readonly MEDIA_ERR_ABORTED: number; + readonly MEDIA_ERR_DECODE: number; + readonly MEDIA_ERR_NETWORK: number; + readonly MEDIA_ERR_SRC_NOT_SUPPORTED: number; + readonly MS_MEDIA_ERR_ENCRYPTED: number; } declare var MediaError: { prototype: MediaError; new(): MediaError; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_DECODE: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MS_MEDIA_ERR_ENCRYPTED: number; + readonly MEDIA_ERR_ABORTED: number; + readonly MEDIA_ERR_DECODE: number; + readonly MEDIA_ERR_NETWORK: number; + readonly MEDIA_ERR_SRC_NOT_SUPPORTED: number; + readonly MS_MEDIA_ERR_ENCRYPTED: number; } interface MediaKeyMessageEvent extends Event { - message: ArrayBuffer; - messageType: string; + readonly message: ArrayBuffer; + readonly messageType: string; } declare var MediaKeyMessageEvent: { @@ -8310,10 +8310,10 @@ declare var MediaKeyMessageEvent: { } interface MediaKeySession extends EventTarget { - closed: PromiseLike; - expiration: number; - keyStatuses: MediaKeyStatusMap; - sessionId: string; + readonly closed: PromiseLike; + readonly expiration: number; + readonly keyStatuses: MediaKeyStatusMap; + readonly sessionId: string; close(): PromiseLike; generateRequest(initDataType: string, initData: any): PromiseLike; load(sessionId: string): PromiseLike; @@ -8327,7 +8327,7 @@ declare var MediaKeySession: { } interface MediaKeyStatusMap { - size: number; + readonly size: number; forEach(callback: ForEachCallback): void; get(keyId: any): string; has(keyId: any): boolean; @@ -8339,7 +8339,7 @@ declare var MediaKeyStatusMap: { } interface MediaKeySystemAccess { - keySystem: string; + readonly keySystem: string; createMediaKeys(): PromiseLike; getConfiguration(): MediaKeySystemConfiguration; } @@ -8360,7 +8360,7 @@ declare var MediaKeys: { } interface MediaList { - length: number; + readonly length: number; mediaText: string; appendMedium(newMedium: string): void; deleteMedium(oldMedium: string): void; @@ -8375,8 +8375,8 @@ declare var MediaList: { } interface MediaQueryList { - matches: boolean; - media: string; + readonly matches: boolean; + readonly media: string; addListener(listener: MediaQueryListListener): void; removeListener(listener: MediaQueryListListener): void; } @@ -8387,10 +8387,10 @@ declare var MediaQueryList: { } interface MediaSource extends EventTarget { - activeSourceBuffers: SourceBufferList; + readonly activeSourceBuffers: SourceBufferList; duration: number; - readyState: string; - sourceBuffers: SourceBufferList; + readonly readyState: string; + readonly sourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; endOfStream(error?: number): void; removeSourceBuffer(sourceBuffer: SourceBuffer): void; @@ -8403,8 +8403,8 @@ declare var MediaSource: { } interface MediaStream extends EventTarget { - active: boolean; - id: string; + readonly active: boolean; + readonly id: string; onactive: (ev: Event) => any; onaddtrack: (ev: TrackEvent) => any; oninactive: (ev: Event) => any; @@ -8438,9 +8438,9 @@ declare var MediaStreamAudioSourceNode: { } interface MediaStreamError { - constraintName: string; - message: string; - name: string; + readonly constraintName: string; + readonly message: string; + readonly name: string; } declare var MediaStreamError: { @@ -8449,7 +8449,7 @@ declare var MediaStreamError: { } interface MediaStreamErrorEvent extends Event { - error: MediaStreamError; + readonly error: MediaStreamError; } declare var MediaStreamErrorEvent: { @@ -8459,17 +8459,17 @@ declare var MediaStreamErrorEvent: { interface MediaStreamTrack extends EventTarget { enabled: boolean; - id: string; - kind: string; - label: string; - muted: boolean; + readonly id: string; + readonly kind: string; + readonly label: string; + readonly muted: boolean; onended: (ev: MediaStreamErrorEvent) => any; onmute: (ev: Event) => any; onoverconstrained: (ev: MediaStreamErrorEvent) => any; onunmute: (ev: Event) => any; - readonly: boolean; - readyState: string; - remote: boolean; + readonly readonly: boolean; + readonly readyState: string; + readonly remote: boolean; applyConstraints(constraints: MediaTrackConstraints): PromiseLike; clone(): MediaStreamTrack; getCapabilities(): MediaTrackCapabilities; @@ -8489,7 +8489,7 @@ declare var MediaStreamTrack: { } interface MediaStreamTrackEvent extends Event { - track: MediaStreamTrack; + readonly track: MediaStreamTrack; } declare var MediaStreamTrackEvent: { @@ -8498,8 +8498,8 @@ declare var MediaStreamTrackEvent: { } interface MessageChannel { - port1: MessagePort; - port2: MessagePort; + readonly port1: MessagePort; + readonly port2: MessagePort; } declare var MessageChannel: { @@ -8508,10 +8508,10 @@ declare var MessageChannel: { } interface MessageEvent extends Event { - data: any; - origin: string; - ports: any; - source: Window; + readonly data: any; + readonly origin: string; + readonly ports: any; + readonly source: Window; initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; } @@ -8535,10 +8535,10 @@ declare var MessagePort: { } interface MimeType { - description: string; - enabledPlugin: Plugin; - suffixes: string; - type: string; + readonly description: string; + readonly enabledPlugin: Plugin; + readonly suffixes: string; + readonly type: string; } declare var MimeType: { @@ -8547,7 +8547,7 @@ declare var MimeType: { } interface MimeTypeArray { - length: number; + readonly length: number; item(index: number): Plugin; namedItem(type: string): Plugin; [index: number]: Plugin; @@ -8559,30 +8559,30 @@ declare var MimeTypeArray: { } interface MouseEvent extends UIEvent { - altKey: boolean; - button: number; - buttons: number; - clientX: number; - clientY: number; - ctrlKey: boolean; - fromElement: Element; - layerX: number; - layerY: number; - metaKey: boolean; - movementX: number; - movementY: number; - offsetX: number; - offsetY: number; - pageX: number; - pageY: number; - relatedTarget: EventTarget; - screenX: number; - screenY: number; - shiftKey: boolean; - toElement: Element; - which: number; - x: number; - y: number; + readonly altKey: boolean; + readonly button: number; + readonly buttons: number; + readonly clientX: number; + readonly clientY: number; + readonly ctrlKey: boolean; + readonly fromElement: Element; + readonly layerX: number; + readonly layerY: number; + readonly metaKey: boolean; + readonly movementX: number; + readonly movementY: number; + readonly offsetX: number; + readonly offsetY: number; + readonly pageX: number; + readonly pageY: number; + readonly relatedTarget: EventTarget; + readonly screenX: number; + readonly screenY: number; + readonly shiftKey: boolean; + readonly toElement: Element; + readonly which: number; + readonly x: number; + readonly y: number; getModifierState(keyArg: string): boolean; initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; } @@ -8593,23 +8593,23 @@ declare var MouseEvent: { } interface MutationEvent extends Event { - attrChange: number; - attrName: string; - newValue: string; - prevValue: string; - relatedNode: Node; + readonly attrChange: number; + readonly attrName: string; + readonly newValue: string; + readonly prevValue: string; + readonly relatedNode: Node; initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; - ADDITION: number; - MODIFICATION: number; - REMOVAL: number; + readonly ADDITION: number; + readonly MODIFICATION: number; + readonly REMOVAL: number; } declare var MutationEvent: { prototype: MutationEvent; new(): MutationEvent; - ADDITION: number; - MODIFICATION: number; - REMOVAL: number; + readonly ADDITION: number; + readonly MODIFICATION: number; + readonly REMOVAL: number; } interface MutationObserver { @@ -8624,15 +8624,15 @@ declare var MutationObserver: { } interface MutationRecord { - addedNodes: NodeList; - attributeName: string; - attributeNamespace: string; - nextSibling: Node; - oldValue: string; - previousSibling: Node; - removedNodes: NodeList; - target: Node; - type: string; + readonly addedNodes: NodeList; + readonly attributeName: string; + readonly attributeNamespace: string; + readonly nextSibling: Node; + readonly oldValue: string; + readonly previousSibling: Node; + readonly removedNodes: NodeList; + readonly target: Node; + readonly type: string; } declare var MutationRecord: { @@ -8641,7 +8641,7 @@ declare var MutationRecord: { } interface NamedNodeMap { - length: number; + readonly length: number; getNamedItem(name: string): Attr; getNamedItemNS(namespaceURI: string, localName: string): Attr; item(index: number): Attr; @@ -8658,8 +8658,8 @@ declare var NamedNodeMap: { } interface NavigationCompletedEvent extends NavigationEvent { - isSuccess: boolean; - webErrorStatus: number; + readonly isSuccess: boolean; + readonly webErrorStatus: number; } declare var NavigationCompletedEvent: { @@ -8668,7 +8668,7 @@ declare var NavigationCompletedEvent: { } interface NavigationEvent extends Event { - uri: string; + readonly uri: string; } declare var NavigationEvent: { @@ -8677,7 +8677,7 @@ declare var NavigationEvent: { } interface NavigationEventWithReferrer extends NavigationEvent { - referer: string; + readonly referer: string; } declare var NavigationEventWithReferrer: { @@ -8686,17 +8686,17 @@ declare var NavigationEventWithReferrer: { } interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorUserMedia { - appCodeName: string; - cookieEnabled: boolean; - language: string; - maxTouchPoints: number; - mimeTypes: MimeTypeArray; - msManipulationViewsEnabled: boolean; - msMaxTouchPoints: number; - msPointerEnabled: boolean; - plugins: PluginArray; - pointerEnabled: boolean; - webdriver: boolean; + readonly appCodeName: string; + readonly cookieEnabled: boolean; + readonly language: string; + readonly maxTouchPoints: number; + readonly mimeTypes: MimeTypeArray; + readonly msManipulationViewsEnabled: boolean; + readonly msMaxTouchPoints: number; + readonly msPointerEnabled: boolean; + readonly plugins: PluginArray; + readonly pointerEnabled: boolean; + readonly webdriver: boolean; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; @@ -8711,21 +8711,21 @@ declare var Navigator: { } interface Node extends EventTarget { - attributes: NamedNodeMap; - baseURI: string; - childNodes: NodeList; - firstChild: Node; - lastChild: Node; - localName: string; - namespaceURI: string; - nextSibling: Node; - nodeName: string; - nodeType: number; + readonly attributes: NamedNodeMap; + readonly baseURI: string; + readonly childNodes: NodeList; + readonly firstChild: Node; + readonly lastChild: Node; + readonly localName: string; + readonly namespaceURI: string; + readonly nextSibling: Node; + readonly nodeName: string; + readonly nodeType: number; nodeValue: string; - ownerDocument: Document; - parentElement: HTMLElement; - parentNode: Node; - previousSibling: Node; + readonly ownerDocument: Document; + readonly parentElement: HTMLElement; + readonly parentNode: Node; + readonly previousSibling: Node; textContent: string; appendChild(newChild: Node): Node; cloneNode(deep?: boolean): Node; @@ -8743,47 +8743,47 @@ interface Node extends EventTarget { removeChild(oldChild: Node): Node; replaceChild(newChild: Node, oldChild: Node): Node; contains(node: Node): boolean; - ATTRIBUTE_NODE: number; - CDATA_SECTION_NODE: number; - COMMENT_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - DOCUMENT_NODE: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_POSITION_PRECEDING: number; - DOCUMENT_TYPE_NODE: number; - ELEMENT_NODE: number; - ENTITY_NODE: number; - ENTITY_REFERENCE_NODE: number; - NOTATION_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - TEXT_NODE: number; + readonly ATTRIBUTE_NODE: number; + readonly CDATA_SECTION_NODE: number; + readonly COMMENT_NODE: number; + readonly DOCUMENT_FRAGMENT_NODE: number; + readonly DOCUMENT_NODE: number; + readonly DOCUMENT_POSITION_CONTAINED_BY: number; + readonly DOCUMENT_POSITION_CONTAINS: number; + readonly DOCUMENT_POSITION_DISCONNECTED: number; + readonly DOCUMENT_POSITION_FOLLOWING: number; + readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + readonly DOCUMENT_POSITION_PRECEDING: number; + readonly DOCUMENT_TYPE_NODE: number; + readonly ELEMENT_NODE: number; + readonly ENTITY_NODE: number; + readonly ENTITY_REFERENCE_NODE: number; + readonly NOTATION_NODE: number; + readonly PROCESSING_INSTRUCTION_NODE: number; + readonly TEXT_NODE: number; } declare var Node: { prototype: Node; new(): Node; - ATTRIBUTE_NODE: number; - CDATA_SECTION_NODE: number; - COMMENT_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - DOCUMENT_NODE: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_POSITION_PRECEDING: number; - DOCUMENT_TYPE_NODE: number; - ELEMENT_NODE: number; - ENTITY_NODE: number; - ENTITY_REFERENCE_NODE: number; - NOTATION_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - TEXT_NODE: number; + readonly ATTRIBUTE_NODE: number; + readonly CDATA_SECTION_NODE: number; + readonly COMMENT_NODE: number; + readonly DOCUMENT_FRAGMENT_NODE: number; + readonly DOCUMENT_NODE: number; + readonly DOCUMENT_POSITION_CONTAINED_BY: number; + readonly DOCUMENT_POSITION_CONTAINS: number; + readonly DOCUMENT_POSITION_DISCONNECTED: number; + readonly DOCUMENT_POSITION_FOLLOWING: number; + readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + readonly DOCUMENT_POSITION_PRECEDING: number; + readonly DOCUMENT_TYPE_NODE: number; + readonly ELEMENT_NODE: number; + readonly ENTITY_NODE: number; + readonly ENTITY_REFERENCE_NODE: number; + readonly NOTATION_NODE: number; + readonly PROCESSING_INSTRUCTION_NODE: number; + readonly TEXT_NODE: number; } interface NodeFilter { @@ -8791,29 +8791,29 @@ interface NodeFilter { } declare var NodeFilter: { - FILTER_ACCEPT: number; - FILTER_REJECT: number; - FILTER_SKIP: number; - SHOW_ALL: number; - SHOW_ATTRIBUTE: number; - SHOW_CDATA_SECTION: number; - SHOW_COMMENT: number; - SHOW_DOCUMENT: number; - SHOW_DOCUMENT_FRAGMENT: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_ELEMENT: number; - SHOW_ENTITY: number; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_PROCESSING_INSTRUCTION: number; - SHOW_TEXT: number; + readonly FILTER_ACCEPT: number; + readonly FILTER_REJECT: number; + readonly FILTER_SKIP: number; + readonly SHOW_ALL: number; + readonly SHOW_ATTRIBUTE: number; + readonly SHOW_CDATA_SECTION: number; + readonly SHOW_COMMENT: number; + readonly SHOW_DOCUMENT: number; + readonly SHOW_DOCUMENT_FRAGMENT: number; + readonly SHOW_DOCUMENT_TYPE: number; + readonly SHOW_ELEMENT: number; + readonly SHOW_ENTITY: number; + readonly SHOW_ENTITY_REFERENCE: number; + readonly SHOW_NOTATION: number; + readonly SHOW_PROCESSING_INSTRUCTION: number; + readonly SHOW_TEXT: number; } interface NodeIterator { - expandEntityReferences: boolean; - filter: NodeFilter; - root: Node; - whatToShow: number; + readonly expandEntityReferences: boolean; + readonly filter: NodeFilter; + readonly root: Node; + readonly whatToShow: number; detach(): void; nextNode(): Node; previousNode(): Node; @@ -8825,7 +8825,7 @@ declare var NodeIterator: { } interface NodeList { - length: number; + readonly length: number; item(index: number): Node; [index: number]: Node; } @@ -8844,13 +8844,13 @@ declare var OES_element_index_uint: { } interface OES_standard_derivatives { - FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; + readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; } declare var OES_standard_derivatives: { prototype: OES_standard_derivatives; new(): OES_standard_derivatives; - FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; + readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; } interface OES_texture_float { @@ -8870,7 +8870,7 @@ declare var OES_texture_float_linear: { } interface OfflineAudioCompletionEvent extends Event { - renderedBuffer: AudioBuffer; + readonly renderedBuffer: AudioBuffer; } declare var OfflineAudioCompletionEvent: { @@ -8891,8 +8891,8 @@ declare var OfflineAudioContext: { } interface OscillatorNode extends AudioNode { - detune: AudioParam; - frequency: AudioParam; + readonly detune: AudioParam; + readonly frequency: AudioParam; onended: (ev: MediaStreamErrorEvent) => any; type: string; setPeriodicWave(periodicWave: PeriodicWave): void; @@ -8908,24 +8908,24 @@ declare var OscillatorNode: { } interface OverflowEvent extends UIEvent { - horizontalOverflow: boolean; - orient: number; - verticalOverflow: boolean; - BOTH: number; - HORIZONTAL: number; - VERTICAL: number; + readonly horizontalOverflow: boolean; + readonly orient: number; + readonly verticalOverflow: boolean; + readonly BOTH: number; + readonly HORIZONTAL: number; + readonly VERTICAL: number; } declare var OverflowEvent: { prototype: OverflowEvent; new(): OverflowEvent; - BOTH: number; - HORIZONTAL: number; - VERTICAL: number; + readonly BOTH: number; + readonly HORIZONTAL: number; + readonly VERTICAL: number; } interface PageTransitionEvent extends Event { - persisted: boolean; + readonly persisted: boolean; } declare var PageTransitionEvent: { @@ -8953,17 +8953,17 @@ declare var PannerNode: { } interface PerfWidgetExternal { - activeNetworkRequestCount: number; - averageFrameTime: number; - averagePaintTime: number; - extraInformationEnabled: boolean; - independentRenderingEnabled: boolean; - irDisablingContentString: string; - irStatusAvailable: boolean; - maxCpuSpeed: number; - paintRequestsPerSecond: number; - performanceCounter: number; - performanceCounterFrequency: number; + readonly activeNetworkRequestCount: number; + readonly averageFrameTime: number; + readonly averagePaintTime: number; + readonly extraInformationEnabled: boolean; + readonly independentRenderingEnabled: boolean; + readonly irDisablingContentString: string; + readonly irStatusAvailable: boolean; + readonly maxCpuSpeed: number; + readonly paintRequestsPerSecond: number; + readonly performanceCounter: number; + readonly performanceCounterFrequency: number; addEventListener(eventType: string, callback: Function): void; getMemoryUsage(): number; getProcessCpuUsage(): number; @@ -8982,8 +8982,8 @@ declare var PerfWidgetExternal: { } interface Performance { - navigation: PerformanceNavigation; - timing: PerformanceTiming; + readonly navigation: PerformanceNavigation; + readonly timing: PerformanceTiming; clearMarks(markName?: string): void; clearMeasures(measureName?: string): void; clearResourceTimings(): void; @@ -9005,10 +9005,10 @@ declare var Performance: { } interface PerformanceEntry { - duration: number; - entryType: string; - name: string; - startTime: number; + readonly duration: number; + readonly entryType: string; + readonly name: string; + readonly startTime: number; } declare var PerformanceEntry: { @@ -9033,47 +9033,47 @@ declare var PerformanceMeasure: { } interface PerformanceNavigation { - redirectCount: number; - type: number; + readonly redirectCount: number; + readonly type: number; toJSON(): any; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; - TYPE_RELOAD: number; - TYPE_RESERVED: number; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; } declare var PerformanceNavigation: { prototype: PerformanceNavigation; new(): PerformanceNavigation; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; - TYPE_RELOAD: number; - TYPE_RESERVED: number; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; } interface PerformanceNavigationTiming extends PerformanceEntry { - connectEnd: number; - connectStart: number; - domComplete: number; - domContentLoadedEventEnd: number; - domContentLoadedEventStart: number; - domInteractive: number; - domLoading: number; - domainLookupEnd: number; - domainLookupStart: number; - fetchStart: number; - loadEventEnd: number; - loadEventStart: number; - navigationStart: number; - redirectCount: number; - redirectEnd: number; - redirectStart: number; - requestStart: number; - responseEnd: number; - responseStart: number; - type: string; - unloadEventEnd: number; - unloadEventStart: number; + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly navigationStart: number; + readonly redirectCount: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly type: string; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; } declare var PerformanceNavigationTiming: { @@ -9082,17 +9082,17 @@ declare var PerformanceNavigationTiming: { } interface PerformanceResourceTiming extends PerformanceEntry { - connectEnd: number; - connectStart: number; - domainLookupEnd: number; - domainLookupStart: number; - fetchStart: number; - initiatorType: string; - redirectEnd: number; - redirectStart: number; - requestStart: number; - responseEnd: number; - responseStart: number; + readonly connectEnd: number; + readonly connectStart: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly initiatorType: string; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; } declare var PerformanceResourceTiming: { @@ -9101,27 +9101,27 @@ declare var PerformanceResourceTiming: { } interface PerformanceTiming { - connectEnd: number; - connectStart: number; - domComplete: number; - domContentLoadedEventEnd: number; - domContentLoadedEventStart: number; - domInteractive: number; - domLoading: number; - domainLookupEnd: number; - domainLookupStart: number; - fetchStart: number; - loadEventEnd: number; - loadEventStart: number; - msFirstPaint: number; - navigationStart: number; - redirectEnd: number; - redirectStart: number; - requestStart: number; - responseEnd: number; - responseStart: number; - unloadEventEnd: number; - unloadEventStart: number; + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly msFirstPaint: number; + readonly navigationStart: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; toJSON(): any; } @@ -9139,7 +9139,7 @@ declare var PeriodicWave: { } interface PermissionRequest extends DeferredPermissionRequest { - state: string; + readonly state: string; defer(): void; } @@ -9149,7 +9149,7 @@ declare var PermissionRequest: { } interface PermissionRequestedEvent extends Event { - permissionRequest: PermissionRequest; + readonly permissionRequest: PermissionRequest; } declare var PermissionRequestedEvent: { @@ -9158,11 +9158,11 @@ declare var PermissionRequestedEvent: { } interface Plugin { - description: string; - filename: string; - length: number; - name: string; - version: string; + readonly description: string; + readonly filename: string; + readonly length: number; + readonly name: string; + readonly version: string; item(index: number): MimeType; namedItem(type: string): MimeType; [index: number]: MimeType; @@ -9174,7 +9174,7 @@ declare var Plugin: { } interface PluginArray { - length: number; + readonly length: number; item(index: number): Plugin; namedItem(name: string): Plugin; refresh(reload?: boolean): void; @@ -9187,18 +9187,18 @@ declare var PluginArray: { } interface PointerEvent extends MouseEvent { - currentPoint: any; - height: number; - hwTimestamp: number; - intermediatePoints: any; - isPrimary: boolean; - pointerId: number; - pointerType: any; - pressure: number; - rotation: number; - tiltX: number; - tiltY: number; - width: number; + readonly currentPoint: any; + readonly height: number; + readonly hwTimestamp: number; + readonly intermediatePoints: any; + readonly isPrimary: boolean; + readonly pointerId: number; + readonly pointerType: any; + readonly pressure: number; + readonly rotation: number; + readonly tiltX: number; + readonly tiltY: number; + readonly width: number; getCurrentPoint(element: Element): void; getIntermediatePoints(element: Element): void; initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; @@ -9210,7 +9210,7 @@ declare var PointerEvent: { } interface PopStateEvent extends Event { - state: any; + readonly state: any; initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; } @@ -9220,8 +9220,8 @@ declare var PopStateEvent: { } interface Position { - coords: Coordinates; - timestamp: number; + readonly coords: Coordinates; + readonly timestamp: number; } declare var Position: { @@ -9230,24 +9230,24 @@ declare var Position: { } interface PositionError { - code: number; - message: string; + readonly code: number; + readonly message: string; toString(): string; - PERMISSION_DENIED: number; - POSITION_UNAVAILABLE: number; - TIMEOUT: number; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; } declare var PositionError: { prototype: PositionError; new(): PositionError; - PERMISSION_DENIED: number; - POSITION_UNAVAILABLE: number; - TIMEOUT: number; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; } interface ProcessingInstruction extends CharacterData { - target: string; + readonly target: string; } declare var ProcessingInstruction: { @@ -9256,9 +9256,9 @@ declare var ProcessingInstruction: { } interface ProgressEvent extends Event { - lengthComputable: boolean; - loaded: number; - total: number; + readonly lengthComputable: boolean; + readonly loaded: number; + readonly total: number; initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; } @@ -9268,7 +9268,7 @@ declare var ProgressEvent: { } interface RTCDTMFToneChangeEvent extends Event { - tone: string; + readonly tone: string; } declare var RTCDTMFToneChangeEvent: { @@ -9279,8 +9279,8 @@ declare var RTCDTMFToneChangeEvent: { interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: (ev: RTCDtlsTransportStateChangedEvent) => any; onerror: (ev: Event) => any; - state: string; - transport: RTCIceTransport; + readonly state: string; + readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; getRemoteCertificates(): ArrayBuffer[]; getRemoteParameters(): RTCDtlsParameters; @@ -9297,7 +9297,7 @@ declare var RTCDtlsTransport: { } interface RTCDtlsTransportStateChangedEvent extends Event { - state: string; + readonly state: string; } declare var RTCDtlsTransportStateChangedEvent: { @@ -9306,12 +9306,12 @@ declare var RTCDtlsTransportStateChangedEvent: { } interface RTCDtmfSender extends EventTarget { - canInsertDTMF: boolean; - duration: number; - interToneGap: number; + readonly canInsertDTMF: boolean; + readonly duration: number; + readonly interToneGap: number; ontonechange: (ev: RTCDTMFToneChangeEvent) => any; - sender: RTCRtpSender; - toneBuffer: string; + readonly sender: RTCRtpSender; + readonly toneBuffer: string; insertDTMF(tones: string, duration?: number, interToneGap?: number): void; addEventListener(type: "tonechange", listener: (ev: RTCDTMFToneChangeEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -9323,7 +9323,7 @@ declare var RTCDtmfSender: { } interface RTCIceCandidatePairChangedEvent extends Event { - pair: RTCIceCandidatePair; + readonly pair: RTCIceCandidatePair; } declare var RTCIceCandidatePairChangedEvent: { @@ -9332,7 +9332,7 @@ declare var RTCIceCandidatePairChangedEvent: { } interface RTCIceGatherer extends RTCStatsProvider { - component: string; + readonly component: string; onerror: (ev: Event) => any; onlocalcandidate: (ev: RTCIceGathererEvent) => any; createAssociatedGatherer(): RTCIceGatherer; @@ -9349,7 +9349,7 @@ declare var RTCIceGatherer: { } interface RTCIceGathererEvent extends Event { - candidate: RTCIceCandidate | RTCIceCandidateComplete; + readonly candidate: RTCIceCandidate | RTCIceCandidateComplete; } declare var RTCIceGathererEvent: { @@ -9358,12 +9358,12 @@ declare var RTCIceGathererEvent: { } interface RTCIceTransport extends RTCStatsProvider { - component: string; - iceGatherer: RTCIceGatherer; + readonly component: string; + readonly iceGatherer: RTCIceGatherer; oncandidatepairchange: (ev: RTCIceCandidatePairChangedEvent) => any; onicestatechange: (ev: RTCIceTransportStateChangedEvent) => any; - role: string; - state: string; + readonly role: string; + readonly state: string; addRemoteCandidate(remoteCandidate: RTCIceCandidate | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair; @@ -9383,7 +9383,7 @@ declare var RTCIceTransport: { } interface RTCIceTransportStateChangedEvent extends Event { - state: string; + readonly state: string; } declare var RTCIceTransportStateChangedEvent: { @@ -9393,9 +9393,9 @@ declare var RTCIceTransportStateChangedEvent: { interface RTCRtpReceiver extends RTCStatsProvider { onerror: (ev: Event) => any; - rtcpTransport: RTCDtlsTransport; - track: MediaStreamTrack; - transport: RTCDtlsTransport | RTCSrtpSdesTransport; + readonly rtcpTransport: RTCDtlsTransport; + readonly track: MediaStreamTrack; + readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; getContributingSources(): RTCRtpContributingSource[]; receive(parameters: RTCRtpParameters): void; requestSendCSRC(csrc: number): void; @@ -9414,9 +9414,9 @@ declare var RTCRtpReceiver: { interface RTCRtpSender extends RTCStatsProvider { onerror: (ev: Event) => any; onssrcconflict: (ev: RTCSsrcConflictEvent) => any; - rtcpTransport: RTCDtlsTransport; - track: MediaStreamTrack; - transport: RTCDtlsTransport | RTCSrtpSdesTransport; + readonly rtcpTransport: RTCDtlsTransport; + readonly track: MediaStreamTrack; + readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; send(parameters: RTCRtpParameters): void; setTrack(track: MediaStreamTrack): void; setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; @@ -9434,7 +9434,7 @@ declare var RTCRtpSender: { interface RTCSrtpSdesTransport extends EventTarget { onerror: (ev: Event) => any; - transport: RTCIceTransport; + readonly transport: RTCIceTransport; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9446,7 +9446,7 @@ declare var RTCSrtpSdesTransport: { } interface RTCSsrcConflictEvent extends Event { - ssrc: number; + readonly ssrc: number; } declare var RTCSsrcConflictEvent: { @@ -9465,12 +9465,12 @@ declare var RTCStatsProvider: { } interface Range { - collapsed: boolean; - commonAncestorContainer: Node; - endContainer: Node; - endOffset: number; - startContainer: Node; - startOffset: number; + readonly collapsed: boolean; + readonly commonAncestorContainer: Node; + readonly endContainer: Node; + readonly endOffset: number; + readonly startContainer: Node; + readonly startOffset: number; cloneContents(): DocumentFragment; cloneRange(): Range; collapse(toStart: boolean): void; @@ -9493,23 +9493,23 @@ interface Range { setStartBefore(refNode: Node): void; surroundContents(newParent: Node): void; toString(): string; - END_TO_END: number; - END_TO_START: number; - START_TO_END: number; - START_TO_START: number; + readonly END_TO_END: number; + readonly END_TO_START: number; + readonly START_TO_END: number; + readonly START_TO_START: number; } declare var Range: { prototype: Range; new(): Range; - END_TO_END: number; - END_TO_START: number; - START_TO_END: number; - START_TO_START: number; + readonly END_TO_END: number; + readonly END_TO_START: number; + readonly START_TO_END: number; + readonly START_TO_START: number; } interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { - target: SVGAnimatedString; + readonly target: SVGAnimatedString; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9519,32 +9519,32 @@ declare var SVGAElement: { } interface SVGAngle { - unitType: number; + readonly unitType: number; value: number; valueAsString: string; valueInSpecifiedUnits: number; convertToSpecifiedUnits(unitType: number): void; newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; + readonly SVG_ANGLETYPE_DEG: number; + readonly SVG_ANGLETYPE_GRAD: number; + readonly SVG_ANGLETYPE_RAD: number; + readonly SVG_ANGLETYPE_UNKNOWN: number; + readonly SVG_ANGLETYPE_UNSPECIFIED: number; } declare var SVGAngle: { prototype: SVGAngle; new(): SVGAngle; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; + readonly SVG_ANGLETYPE_DEG: number; + readonly SVG_ANGLETYPE_GRAD: number; + readonly SVG_ANGLETYPE_RAD: number; + readonly SVG_ANGLETYPE_UNKNOWN: number; + readonly SVG_ANGLETYPE_UNSPECIFIED: number; } interface SVGAnimatedAngle { - animVal: SVGAngle; - baseVal: SVGAngle; + readonly animVal: SVGAngle; + readonly baseVal: SVGAngle; } declare var SVGAnimatedAngle: { @@ -9553,7 +9553,7 @@ declare var SVGAnimatedAngle: { } interface SVGAnimatedBoolean { - animVal: boolean; + readonly animVal: boolean; baseVal: boolean; } @@ -9563,7 +9563,7 @@ declare var SVGAnimatedBoolean: { } interface SVGAnimatedEnumeration { - animVal: number; + readonly animVal: number; baseVal: number; } @@ -9573,7 +9573,7 @@ declare var SVGAnimatedEnumeration: { } interface SVGAnimatedInteger { - animVal: number; + readonly animVal: number; baseVal: number; } @@ -9583,8 +9583,8 @@ declare var SVGAnimatedInteger: { } interface SVGAnimatedLength { - animVal: SVGLength; - baseVal: SVGLength; + readonly animVal: SVGLength; + readonly baseVal: SVGLength; } declare var SVGAnimatedLength: { @@ -9593,8 +9593,8 @@ declare var SVGAnimatedLength: { } interface SVGAnimatedLengthList { - animVal: SVGLengthList; - baseVal: SVGLengthList; + readonly animVal: SVGLengthList; + readonly baseVal: SVGLengthList; } declare var SVGAnimatedLengthList: { @@ -9603,7 +9603,7 @@ declare var SVGAnimatedLengthList: { } interface SVGAnimatedNumber { - animVal: number; + readonly animVal: number; baseVal: number; } @@ -9613,8 +9613,8 @@ declare var SVGAnimatedNumber: { } interface SVGAnimatedNumberList { - animVal: SVGNumberList; - baseVal: SVGNumberList; + readonly animVal: SVGNumberList; + readonly baseVal: SVGNumberList; } declare var SVGAnimatedNumberList: { @@ -9623,8 +9623,8 @@ declare var SVGAnimatedNumberList: { } interface SVGAnimatedPreserveAspectRatio { - animVal: SVGPreserveAspectRatio; - baseVal: SVGPreserveAspectRatio; + readonly animVal: SVGPreserveAspectRatio; + readonly baseVal: SVGPreserveAspectRatio; } declare var SVGAnimatedPreserveAspectRatio: { @@ -9633,8 +9633,8 @@ declare var SVGAnimatedPreserveAspectRatio: { } interface SVGAnimatedRect { - animVal: SVGRect; - baseVal: SVGRect; + readonly animVal: SVGRect; + readonly baseVal: SVGRect; } declare var SVGAnimatedRect: { @@ -9643,7 +9643,7 @@ declare var SVGAnimatedRect: { } interface SVGAnimatedString { - animVal: string; + readonly animVal: string; baseVal: string; } @@ -9653,8 +9653,8 @@ declare var SVGAnimatedString: { } interface SVGAnimatedTransformList { - animVal: SVGTransformList; - baseVal: SVGTransformList; + readonly animVal: SVGTransformList; + readonly baseVal: SVGTransformList; } declare var SVGAnimatedTransformList: { @@ -9663,9 +9663,9 @@ declare var SVGAnimatedTransformList: { } interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - cx: SVGAnimatedLength; - cy: SVGAnimatedLength; - r: SVGAnimatedLength; + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly r: SVGAnimatedLength; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9675,7 +9675,7 @@ declare var SVGCircleElement: { } interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { - clipPathUnits: SVGAnimatedEnumeration; + readonly clipPathUnits: SVGAnimatedEnumeration; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9685,30 +9685,30 @@ declare var SVGClipPathElement: { } interface SVGComponentTransferFunctionElement extends SVGElement { - amplitude: SVGAnimatedNumber; - exponent: SVGAnimatedNumber; - intercept: SVGAnimatedNumber; - offset: SVGAnimatedNumber; - slope: SVGAnimatedNumber; - tableValues: SVGAnimatedNumberList; - type: SVGAnimatedEnumeration; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + readonly amplitude: SVGAnimatedNumber; + readonly exponent: SVGAnimatedNumber; + readonly intercept: SVGAnimatedNumber; + readonly offset: SVGAnimatedNumber; + readonly slope: SVGAnimatedNumber; + readonly tableValues: SVGAnimatedNumberList; + readonly type: SVGAnimatedEnumeration; + readonly SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; } declare var SVGComponentTransferFunctionElement: { prototype: SVGComponentTransferFunctionElement; new(): SVGComponentTransferFunctionElement; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; } interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { @@ -9740,8 +9740,8 @@ interface SVGElement extends Element { onmouseout: (ev: MouseEvent) => any; onmouseover: (ev: MouseEvent) => any; onmouseup: (ev: MouseEvent) => any; - ownerSVGElement: SVGSVGElement; - viewportElement: SVGElement; + readonly ownerSVGElement: SVGSVGElement; + readonly viewportElement: SVGElement; xmlbase: string; className: any; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -9799,14 +9799,14 @@ declare var SVGElement: { } interface SVGElementInstance extends EventTarget { - childNodes: SVGElementInstanceList; - correspondingElement: SVGElement; - correspondingUseElement: SVGUseElement; - firstChild: SVGElementInstance; - lastChild: SVGElementInstance; - nextSibling: SVGElementInstance; - parentNode: SVGElementInstance; - previousSibling: SVGElementInstance; + readonly childNodes: SVGElementInstanceList; + readonly correspondingElement: SVGElement; + readonly correspondingUseElement: SVGUseElement; + readonly firstChild: SVGElementInstance; + readonly lastChild: SVGElementInstance; + readonly nextSibling: SVGElementInstance; + readonly parentNode: SVGElementInstance; + readonly previousSibling: SVGElementInstance; } declare var SVGElementInstance: { @@ -9815,7 +9815,7 @@ declare var SVGElementInstance: { } interface SVGElementInstanceList { - length: number; + readonly length: number; item(index: number): SVGElementInstance; } @@ -9825,10 +9825,10 @@ declare var SVGElementInstanceList: { } interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - cx: SVGAnimatedLength; - cy: SVGAnimatedLength; - rx: SVGAnimatedLength; - ry: SVGAnimatedLength; + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly rx: SVGAnimatedLength; + readonly ry: SVGAnimatedLength; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9838,75 +9838,75 @@ declare var SVGEllipseElement: { } interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - in2: SVGAnimatedString; - mode: SVGAnimatedEnumeration; - SVG_FEBLEND_MODE_COLOR: number; - SVG_FEBLEND_MODE_COLOR_BURN: number; - SVG_FEBLEND_MODE_COLOR_DODGE: number; - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_DIFFERENCE: number; - SVG_FEBLEND_MODE_EXCLUSION: number; - SVG_FEBLEND_MODE_HARD_LIGHT: number; - SVG_FEBLEND_MODE_HUE: number; - SVG_FEBLEND_MODE_LIGHTEN: number; - SVG_FEBLEND_MODE_LUMINOSITY: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_OVERLAY: number; - SVG_FEBLEND_MODE_SATURATION: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_SOFT_LIGHT: number; - SVG_FEBLEND_MODE_UNKNOWN: number; + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly mode: SVGAnimatedEnumeration; + readonly SVG_FEBLEND_MODE_COLOR: number; + readonly SVG_FEBLEND_MODE_COLOR_BURN: number; + readonly SVG_FEBLEND_MODE_COLOR_DODGE: number; + readonly SVG_FEBLEND_MODE_DARKEN: number; + readonly SVG_FEBLEND_MODE_DIFFERENCE: number; + readonly SVG_FEBLEND_MODE_EXCLUSION: number; + readonly SVG_FEBLEND_MODE_HARD_LIGHT: number; + readonly SVG_FEBLEND_MODE_HUE: number; + readonly SVG_FEBLEND_MODE_LIGHTEN: number; + readonly SVG_FEBLEND_MODE_LUMINOSITY: number; + readonly SVG_FEBLEND_MODE_MULTIPLY: number; + readonly SVG_FEBLEND_MODE_NORMAL: number; + readonly SVG_FEBLEND_MODE_OVERLAY: number; + readonly SVG_FEBLEND_MODE_SATURATION: number; + readonly SVG_FEBLEND_MODE_SCREEN: number; + readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; + readonly SVG_FEBLEND_MODE_UNKNOWN: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEBlendElement: { prototype: SVGFEBlendElement; new(): SVGFEBlendElement; - SVG_FEBLEND_MODE_COLOR: number; - SVG_FEBLEND_MODE_COLOR_BURN: number; - SVG_FEBLEND_MODE_COLOR_DODGE: number; - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_DIFFERENCE: number; - SVG_FEBLEND_MODE_EXCLUSION: number; - SVG_FEBLEND_MODE_HARD_LIGHT: number; - SVG_FEBLEND_MODE_HUE: number; - SVG_FEBLEND_MODE_LIGHTEN: number; - SVG_FEBLEND_MODE_LUMINOSITY: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_OVERLAY: number; - SVG_FEBLEND_MODE_SATURATION: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_SOFT_LIGHT: number; - SVG_FEBLEND_MODE_UNKNOWN: number; + readonly SVG_FEBLEND_MODE_COLOR: number; + readonly SVG_FEBLEND_MODE_COLOR_BURN: number; + readonly SVG_FEBLEND_MODE_COLOR_DODGE: number; + readonly SVG_FEBLEND_MODE_DARKEN: number; + readonly SVG_FEBLEND_MODE_DIFFERENCE: number; + readonly SVG_FEBLEND_MODE_EXCLUSION: number; + readonly SVG_FEBLEND_MODE_HARD_LIGHT: number; + readonly SVG_FEBLEND_MODE_HUE: number; + readonly SVG_FEBLEND_MODE_LIGHTEN: number; + readonly SVG_FEBLEND_MODE_LUMINOSITY: number; + readonly SVG_FEBLEND_MODE_MULTIPLY: number; + readonly SVG_FEBLEND_MODE_NORMAL: number; + readonly SVG_FEBLEND_MODE_OVERLAY: number; + readonly SVG_FEBLEND_MODE_SATURATION: number; + readonly SVG_FEBLEND_MODE_SCREEN: number; + readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; + readonly SVG_FEBLEND_MODE_UNKNOWN: number; } interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - type: SVGAnimatedEnumeration; - values: SVGAnimatedNumberList; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + readonly in1: SVGAnimatedString; + readonly type: SVGAnimatedEnumeration; + readonly values: SVGAnimatedNumberList; + readonly SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + readonly SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; + readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; + readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEColorMatrixElement: { prototype: SVGFEColorMatrixElement; new(): SVGFEColorMatrixElement; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + readonly SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + readonly SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; + readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; + readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; } interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; + readonly in1: SVGAnimatedString; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9916,70 +9916,70 @@ declare var SVGFEComponentTransferElement: { } interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - in2: SVGAnimatedString; - k1: SVGAnimatedNumber; - k2: SVGAnimatedNumber; - k3: SVGAnimatedNumber; - k4: SVGAnimatedNumber; - operator: SVGAnimatedEnumeration; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly k1: SVGAnimatedNumber; + readonly k2: SVGAnimatedNumber; + readonly k3: SVGAnimatedNumber; + readonly k4: SVGAnimatedNumber; + readonly operator: SVGAnimatedEnumeration; + readonly SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + readonly SVG_FECOMPOSITE_OPERATOR_ATOP: number; + readonly SVG_FECOMPOSITE_OPERATOR_IN: number; + readonly SVG_FECOMPOSITE_OPERATOR_OUT: number; + readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; + readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFECompositeElement: { prototype: SVGFECompositeElement; new(): SVGFECompositeElement; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; + readonly SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + readonly SVG_FECOMPOSITE_OPERATOR_ATOP: number; + readonly SVG_FECOMPOSITE_OPERATOR_IN: number; + readonly SVG_FECOMPOSITE_OPERATOR_OUT: number; + readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; + readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; } interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - bias: SVGAnimatedNumber; - divisor: SVGAnimatedNumber; - edgeMode: SVGAnimatedEnumeration; - in1: SVGAnimatedString; - kernelMatrix: SVGAnimatedNumberList; - kernelUnitLengthX: SVGAnimatedNumber; - kernelUnitLengthY: SVGAnimatedNumber; - orderX: SVGAnimatedInteger; - orderY: SVGAnimatedInteger; - preserveAlpha: SVGAnimatedBoolean; - targetX: SVGAnimatedInteger; - targetY: SVGAnimatedInteger; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_NONE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_WRAP: number; + readonly bias: SVGAnimatedNumber; + readonly divisor: SVGAnimatedNumber; + readonly edgeMode: SVGAnimatedEnumeration; + readonly in1: SVGAnimatedString; + readonly kernelMatrix: SVGAnimatedNumberList; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly orderX: SVGAnimatedInteger; + readonly orderY: SVGAnimatedInteger; + readonly preserveAlpha: SVGAnimatedBoolean; + readonly targetX: SVGAnimatedInteger; + readonly targetY: SVGAnimatedInteger; + readonly SVG_EDGEMODE_DUPLICATE: number; + readonly SVG_EDGEMODE_NONE: number; + readonly SVG_EDGEMODE_UNKNOWN: number; + readonly SVG_EDGEMODE_WRAP: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEConvolveMatrixElement: { prototype: SVGFEConvolveMatrixElement; new(): SVGFEConvolveMatrixElement; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_NONE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_WRAP: number; + readonly SVG_EDGEMODE_DUPLICATE: number; + readonly SVG_EDGEMODE_NONE: number; + readonly SVG_EDGEMODE_UNKNOWN: number; + readonly SVG_EDGEMODE_WRAP: number; } interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - diffuseConstant: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; + readonly diffuseConstant: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly surfaceScale: SVGAnimatedNumber; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9989,32 +9989,32 @@ declare var SVGFEDiffuseLightingElement: { } interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - in2: SVGAnimatedString; - scale: SVGAnimatedNumber; - xChannelSelector: SVGAnimatedEnumeration; - yChannelSelector: SVGAnimatedEnumeration; - SVG_CHANNEL_A: number; - SVG_CHANNEL_B: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_UNKNOWN: number; + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly scale: SVGAnimatedNumber; + readonly xChannelSelector: SVGAnimatedEnumeration; + readonly yChannelSelector: SVGAnimatedEnumeration; + readonly SVG_CHANNEL_A: number; + readonly SVG_CHANNEL_B: number; + readonly SVG_CHANNEL_G: number; + readonly SVG_CHANNEL_R: number; + readonly SVG_CHANNEL_UNKNOWN: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEDisplacementMapElement: { prototype: SVGFEDisplacementMapElement; new(): SVGFEDisplacementMapElement; - SVG_CHANNEL_A: number; - SVG_CHANNEL_B: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_UNKNOWN: number; + readonly SVG_CHANNEL_A: number; + readonly SVG_CHANNEL_B: number; + readonly SVG_CHANNEL_G: number; + readonly SVG_CHANNEL_R: number; + readonly SVG_CHANNEL_UNKNOWN: number; } interface SVGFEDistantLightElement extends SVGElement { - azimuth: SVGAnimatedNumber; - elevation: SVGAnimatedNumber; + readonly azimuth: SVGAnimatedNumber; + readonly elevation: SVGAnimatedNumber; } declare var SVGFEDistantLightElement: { @@ -10064,9 +10064,9 @@ declare var SVGFEFuncRElement: { } interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - stdDeviationX: SVGAnimatedNumber; - stdDeviationY: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; + readonly stdDeviationX: SVGAnimatedNumber; + readonly stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10077,7 +10077,7 @@ declare var SVGFEGaussianBlurElement: { } interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10096,7 +10096,7 @@ declare var SVGFEMergeElement: { } interface SVGFEMergeNodeElement extends SVGElement { - in1: SVGAnimatedString; + readonly in1: SVGAnimatedString; } declare var SVGFEMergeNodeElement: { @@ -10105,28 +10105,28 @@ declare var SVGFEMergeNodeElement: { } interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - operator: SVGAnimatedEnumeration; - radiusX: SVGAnimatedNumber; - radiusY: SVGAnimatedNumber; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + readonly in1: SVGAnimatedString; + readonly operator: SVGAnimatedEnumeration; + readonly radiusX: SVGAnimatedNumber; + readonly radiusY: SVGAnimatedNumber; + readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; + readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; + readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFEMorphologyElement: { prototype: SVGFEMorphologyElement; new(): SVGFEMorphologyElement; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; + readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; + readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; } interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - dx: SVGAnimatedNumber; - dy: SVGAnimatedNumber; - in1: SVGAnimatedString; + readonly dx: SVGAnimatedNumber; + readonly dy: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10136,9 +10136,9 @@ declare var SVGFEOffsetElement: { } interface SVGFEPointLightElement extends SVGElement { - x: SVGAnimatedNumber; - y: SVGAnimatedNumber; - z: SVGAnimatedNumber; + readonly x: SVGAnimatedNumber; + readonly y: SVGAnimatedNumber; + readonly z: SVGAnimatedNumber; } declare var SVGFEPointLightElement: { @@ -10147,12 +10147,12 @@ declare var SVGFEPointLightElement: { } interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - kernelUnitLengthY: SVGAnimatedNumber; - specularConstant: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly specularConstant: SVGAnimatedNumber; + readonly specularExponent: SVGAnimatedNumber; + readonly surfaceScale: SVGAnimatedNumber; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10162,14 +10162,14 @@ declare var SVGFESpecularLightingElement: { } interface SVGFESpotLightElement extends SVGElement { - limitingConeAngle: SVGAnimatedNumber; - pointsAtX: SVGAnimatedNumber; - pointsAtY: SVGAnimatedNumber; - pointsAtZ: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - x: SVGAnimatedNumber; - y: SVGAnimatedNumber; - z: SVGAnimatedNumber; + readonly limitingConeAngle: SVGAnimatedNumber; + readonly pointsAtX: SVGAnimatedNumber; + readonly pointsAtY: SVGAnimatedNumber; + readonly pointsAtZ: SVGAnimatedNumber; + readonly specularExponent: SVGAnimatedNumber; + readonly x: SVGAnimatedNumber; + readonly y: SVGAnimatedNumber; + readonly z: SVGAnimatedNumber; } declare var SVGFESpotLightElement: { @@ -10178,7 +10178,7 @@ declare var SVGFESpotLightElement: { } interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; + readonly in1: SVGAnimatedString; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10188,41 +10188,41 @@ declare var SVGFETileElement: { } interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - baseFrequencyX: SVGAnimatedNumber; - baseFrequencyY: SVGAnimatedNumber; - numOctaves: SVGAnimatedInteger; - seed: SVGAnimatedNumber; - stitchTiles: SVGAnimatedEnumeration; - type: SVGAnimatedEnumeration; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_STITCHTYPE_STITCH: number; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; + readonly baseFrequencyX: SVGAnimatedNumber; + readonly baseFrequencyY: SVGAnimatedNumber; + readonly numOctaves: SVGAnimatedInteger; + readonly seed: SVGAnimatedNumber; + readonly stitchTiles: SVGAnimatedEnumeration; + readonly type: SVGAnimatedEnumeration; + readonly SVG_STITCHTYPE_NOSTITCH: number; + readonly SVG_STITCHTYPE_STITCH: number; + readonly SVG_STITCHTYPE_UNKNOWN: number; + readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; + readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGFETurbulenceElement: { prototype: SVGFETurbulenceElement; new(): SVGFETurbulenceElement; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_STITCHTYPE_STITCH: number; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; + readonly SVG_STITCHTYPE_NOSTITCH: number; + readonly SVG_STITCHTYPE_STITCH: number; + readonly SVG_STITCHTYPE_UNKNOWN: number; + readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; + readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; } interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { - filterResX: SVGAnimatedInteger; - filterResY: SVGAnimatedInteger; - filterUnits: SVGAnimatedEnumeration; - height: SVGAnimatedLength; - primitiveUnits: SVGAnimatedEnumeration; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - y: SVGAnimatedLength; + readonly filterResX: SVGAnimatedInteger; + readonly filterResY: SVGAnimatedInteger; + readonly filterUnits: SVGAnimatedEnumeration; + readonly height: SVGAnimatedLength; + readonly primitiveUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; setFilterRes(filterResX: number, filterResY: number): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10233,10 +10233,10 @@ declare var SVGFilterElement: { } interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - height: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - y: SVGAnimatedLength; + readonly height: SVGAnimatedLength; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10255,31 +10255,31 @@ declare var SVGGElement: { } interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { - gradientTransform: SVGAnimatedTransformList; - gradientUnits: SVGAnimatedEnumeration; - spreadMethod: SVGAnimatedEnumeration; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_REPEAT: number; - SVG_SPREADMETHOD_UNKNOWN: number; + readonly gradientTransform: SVGAnimatedTransformList; + readonly gradientUnits: SVGAnimatedEnumeration; + readonly spreadMethod: SVGAnimatedEnumeration; + readonly SVG_SPREADMETHOD_PAD: number; + readonly SVG_SPREADMETHOD_REFLECT: number; + readonly SVG_SPREADMETHOD_REPEAT: number; + readonly SVG_SPREADMETHOD_UNKNOWN: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGGradientElement: { prototype: SVGGradientElement; new(): SVGGradientElement; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_REPEAT: number; - SVG_SPREADMETHOD_UNKNOWN: number; + readonly SVG_SPREADMETHOD_PAD: number; + readonly SVG_SPREADMETHOD_REFLECT: number; + readonly SVG_SPREADMETHOD_REPEAT: number; + readonly SVG_SPREADMETHOD_UNKNOWN: number; } interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { - height: SVGAnimatedLength; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - y: SVGAnimatedLength; + readonly height: SVGAnimatedLength; + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10289,43 +10289,43 @@ declare var SVGImageElement: { } interface SVGLength { - unitType: number; + readonly unitType: number; value: number; valueAsString: string; valueInSpecifiedUnits: number; convertToSpecifiedUnits(unitType: number): void; newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_EXS: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; + readonly SVG_LENGTHTYPE_CM: number; + readonly SVG_LENGTHTYPE_EMS: number; + readonly SVG_LENGTHTYPE_EXS: number; + readonly SVG_LENGTHTYPE_IN: number; + readonly SVG_LENGTHTYPE_MM: number; + readonly SVG_LENGTHTYPE_NUMBER: number; + readonly SVG_LENGTHTYPE_PC: number; + readonly SVG_LENGTHTYPE_PERCENTAGE: number; + readonly SVG_LENGTHTYPE_PT: number; + readonly SVG_LENGTHTYPE_PX: number; + readonly SVG_LENGTHTYPE_UNKNOWN: number; } declare var SVGLength: { prototype: SVGLength; new(): SVGLength; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_EXS: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; + readonly SVG_LENGTHTYPE_CM: number; + readonly SVG_LENGTHTYPE_EMS: number; + readonly SVG_LENGTHTYPE_EXS: number; + readonly SVG_LENGTHTYPE_IN: number; + readonly SVG_LENGTHTYPE_MM: number; + readonly SVG_LENGTHTYPE_NUMBER: number; + readonly SVG_LENGTHTYPE_PC: number; + readonly SVG_LENGTHTYPE_PERCENTAGE: number; + readonly SVG_LENGTHTYPE_PT: number; + readonly SVG_LENGTHTYPE_PX: number; + readonly SVG_LENGTHTYPE_UNKNOWN: number; } interface SVGLengthList { - numberOfItems: number; + readonly numberOfItems: number; appendItem(newItem: SVGLength): SVGLength; clear(): void; getItem(index: number): SVGLength; @@ -10341,10 +10341,10 @@ declare var SVGLengthList: { } interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - x1: SVGAnimatedLength; - x2: SVGAnimatedLength; - y1: SVGAnimatedLength; - y2: SVGAnimatedLength; + readonly x1: SVGAnimatedLength; + readonly x2: SVGAnimatedLength; + readonly y1: SVGAnimatedLength; + readonly y2: SVGAnimatedLength; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10354,10 +10354,10 @@ declare var SVGLineElement: { } interface SVGLinearGradientElement extends SVGGradientElement { - x1: SVGAnimatedLength; - x2: SVGAnimatedLength; - y1: SVGAnimatedLength; - y2: SVGAnimatedLength; + readonly x1: SVGAnimatedLength; + readonly x2: SVGAnimatedLength; + readonly y1: SVGAnimatedLength; + readonly y2: SVGAnimatedLength; } declare var SVGLinearGradientElement: { @@ -10366,42 +10366,42 @@ declare var SVGLinearGradientElement: { } interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { - markerHeight: SVGAnimatedLength; - markerUnits: SVGAnimatedEnumeration; - markerWidth: SVGAnimatedLength; - orientAngle: SVGAnimatedAngle; - orientType: SVGAnimatedEnumeration; - refX: SVGAnimatedLength; - refY: SVGAnimatedLength; + readonly markerHeight: SVGAnimatedLength; + readonly markerUnits: SVGAnimatedEnumeration; + readonly markerWidth: SVGAnimatedLength; + readonly orientAngle: SVGAnimatedAngle; + readonly orientType: SVGAnimatedEnumeration; + readonly refX: SVGAnimatedLength; + readonly refY: SVGAnimatedLength; setOrientToAngle(angle: SVGAngle): void; setOrientToAuto(): void; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKER_ORIENT_UNKNOWN: number; + readonly SVG_MARKERUNITS_STROKEWIDTH: number; + readonly SVG_MARKERUNITS_UNKNOWN: number; + readonly SVG_MARKERUNITS_USERSPACEONUSE: number; + readonly SVG_MARKER_ORIENT_ANGLE: number; + readonly SVG_MARKER_ORIENT_AUTO: number; + readonly SVG_MARKER_ORIENT_UNKNOWN: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGMarkerElement: { prototype: SVGMarkerElement; new(): SVGMarkerElement; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKER_ORIENT_UNKNOWN: number; + readonly SVG_MARKERUNITS_STROKEWIDTH: number; + readonly SVG_MARKERUNITS_UNKNOWN: number; + readonly SVG_MARKERUNITS_USERSPACEONUSE: number; + readonly SVG_MARKER_ORIENT_ANGLE: number; + readonly SVG_MARKER_ORIENT_AUTO: number; + readonly SVG_MARKER_ORIENT_UNKNOWN: number; } interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { - height: SVGAnimatedLength; - maskContentUnits: SVGAnimatedEnumeration; - maskUnits: SVGAnimatedEnumeration; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - y: SVGAnimatedLength; + readonly height: SVGAnimatedLength; + readonly maskContentUnits: SVGAnimatedEnumeration; + readonly maskUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10453,7 +10453,7 @@ declare var SVGNumber: { } interface SVGNumberList { - numberOfItems: number; + readonly numberOfItems: number; appendItem(newItem: SVGNumber): SVGNumber; clear(): void; getItem(index: number): SVGNumber; @@ -10500,53 +10500,53 @@ declare var SVGPathElement: { } interface SVGPathSeg { - pathSegType: number; - pathSegTypeAsLetter: string; - PATHSEG_ARC_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_MOVETO_REL: number; - PATHSEG_UNKNOWN: number; + readonly pathSegType: number; + readonly pathSegTypeAsLetter: string; + readonly PATHSEG_ARC_ABS: number; + readonly PATHSEG_ARC_REL: number; + readonly PATHSEG_CLOSEPATH: number; + readonly PATHSEG_CURVETO_CUBIC_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_REL: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + readonly PATHSEG_LINETO_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_REL: number; + readonly PATHSEG_LINETO_REL: number; + readonly PATHSEG_LINETO_VERTICAL_ABS: number; + readonly PATHSEG_LINETO_VERTICAL_REL: number; + readonly PATHSEG_MOVETO_ABS: number; + readonly PATHSEG_MOVETO_REL: number; + readonly PATHSEG_UNKNOWN: number; } declare var SVGPathSeg: { prototype: SVGPathSeg; new(): SVGPathSeg; - PATHSEG_ARC_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_MOVETO_REL: number; - PATHSEG_UNKNOWN: number; + readonly PATHSEG_ARC_ABS: number; + readonly PATHSEG_ARC_REL: number; + readonly PATHSEG_CLOSEPATH: number; + readonly PATHSEG_CURVETO_CUBIC_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_REL: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + readonly PATHSEG_LINETO_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_REL: number; + readonly PATHSEG_LINETO_REL: number; + readonly PATHSEG_LINETO_VERTICAL_ABS: number; + readonly PATHSEG_LINETO_VERTICAL_REL: number; + readonly PATHSEG_MOVETO_ABS: number; + readonly PATHSEG_MOVETO_REL: number; + readonly PATHSEG_UNKNOWN: number; } interface SVGPathSegArcAbs extends SVGPathSeg { @@ -10740,7 +10740,7 @@ declare var SVGPathSegLinetoVerticalRel: { } interface SVGPathSegList { - numberOfItems: number; + readonly numberOfItems: number; appendItem(newItem: SVGPathSeg): SVGPathSeg; clear(): void; getItem(index: number): SVGPathSeg; @@ -10776,13 +10776,13 @@ declare var SVGPathSegMovetoRel: { } interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { - height: SVGAnimatedLength; - patternContentUnits: SVGAnimatedEnumeration; - patternTransform: SVGAnimatedTransformList; - patternUnits: SVGAnimatedEnumeration; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - y: SVGAnimatedLength; + readonly height: SVGAnimatedLength; + readonly patternContentUnits: SVGAnimatedEnumeration; + readonly patternTransform: SVGAnimatedTransformList; + readonly patternUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10803,7 +10803,7 @@ declare var SVGPoint: { } interface SVGPointList { - numberOfItems: number; + readonly numberOfItems: number; appendItem(newItem: SVGPoint): SVGPoint; clear(): void; getItem(index: number): SVGPoint; @@ -10839,47 +10839,47 @@ declare var SVGPolylineElement: { interface SVGPreserveAspectRatio { align: number; meetOrSlice: number; - SVG_MEETORSLICE_MEET: number; - SVG_MEETORSLICE_SLICE: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + readonly SVG_MEETORSLICE_MEET: number; + readonly SVG_MEETORSLICE_SLICE: number; + readonly SVG_MEETORSLICE_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_NONE: number; + readonly SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMIN: number; } declare var SVGPreserveAspectRatio: { prototype: SVGPreserveAspectRatio; new(): SVGPreserveAspectRatio; - SVG_MEETORSLICE_MEET: number; - SVG_MEETORSLICE_SLICE: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + readonly SVG_MEETORSLICE_MEET: number; + readonly SVG_MEETORSLICE_SLICE: number; + readonly SVG_MEETORSLICE_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_NONE: number; + readonly SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMIN: number; } interface SVGRadialGradientElement extends SVGGradientElement { - cx: SVGAnimatedLength; - cy: SVGAnimatedLength; - fx: SVGAnimatedLength; - fy: SVGAnimatedLength; - r: SVGAnimatedLength; + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly fx: SVGAnimatedLength; + readonly fy: SVGAnimatedLength; + readonly r: SVGAnimatedLength; } declare var SVGRadialGradientElement: { @@ -10900,12 +10900,12 @@ declare var SVGRect: { } interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - height: SVGAnimatedLength; - rx: SVGAnimatedLength; - ry: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - y: SVGAnimatedLength; + readonly height: SVGAnimatedLength; + readonly rx: SVGAnimatedLength; + readonly ry: SVGAnimatedLength; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10918,22 +10918,22 @@ interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTest contentScriptType: string; contentStyleType: string; currentScale: number; - currentTranslate: SVGPoint; - height: SVGAnimatedLength; + readonly currentTranslate: SVGPoint; + readonly height: SVGAnimatedLength; onabort: (ev: Event) => any; onerror: (ev: Event) => any; onresize: (ev: UIEvent) => any; onscroll: (ev: UIEvent) => any; onunload: (ev: Event) => any; onzoom: (ev: SVGZoomEvent) => any; - pixelUnitToMillimeterX: number; - pixelUnitToMillimeterY: number; - screenPixelToMillimeterX: number; - screenPixelToMillimeterY: number; - viewport: SVGRect; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - y: SVGAnimatedLength; + readonly pixelUnitToMillimeterX: number; + readonly pixelUnitToMillimeterY: number; + readonly screenPixelToMillimeterX: number; + readonly screenPixelToMillimeterY: number; + readonly viewport: SVGRect; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; checkEnclosure(element: SVGElement, rect: SVGRect): boolean; checkIntersection(element: SVGElement, rect: SVGRect): boolean; createSVGAngle(): SVGAngle; @@ -10949,8 +10949,8 @@ interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTest getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getCurrentTime(): number; getElementById(elementId: string): Element; - getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; - getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; + getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeListOf; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeListOf; pauseAnimations(): void; setCurrentTime(seconds: number): void; suspendRedraw(maxWaitMilliseconds: number): number; @@ -11028,7 +11028,7 @@ declare var SVGScriptElement: { } interface SVGStopElement extends SVGElement, SVGStylable { - offset: SVGAnimatedNumber; + readonly offset: SVGAnimatedNumber; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11038,7 +11038,7 @@ declare var SVGStopElement: { } interface SVGStringList { - numberOfItems: number; + readonly numberOfItems: number; appendItem(newItem: string): string; clear(): void; getItem(index: number): string; @@ -11093,8 +11093,8 @@ declare var SVGTSpanElement: { } interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { - lengthAdjust: SVGAnimatedEnumeration; - textLength: SVGAnimatedLength; + readonly lengthAdjust: SVGAnimatedEnumeration; + readonly textLength: SVGAnimatedLength; getCharNumAtPosition(point: SVGPoint): number; getComputedTextLength(): number; getEndPositionOfChar(charnum: number): SVGPoint; @@ -11104,18 +11104,18 @@ interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLa getStartPositionOfChar(charnum: number): SVGPoint; getSubStringLength(charnum: number, nchars: number): number; selectSubString(charnum: number, nchars: number): void; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; + readonly LENGTHADJUST_SPACING: number; + readonly LENGTHADJUST_SPACINGANDGLYPHS: number; + readonly LENGTHADJUST_UNKNOWN: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextContentElement: { prototype: SVGTextContentElement; new(): SVGTextContentElement; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; + readonly LENGTHADJUST_SPACING: number; + readonly LENGTHADJUST_SPACINGANDGLYPHS: number; + readonly LENGTHADJUST_UNKNOWN: number; } interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { @@ -11128,35 +11128,35 @@ declare var SVGTextElement: { } interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { - method: SVGAnimatedEnumeration; - spacing: SVGAnimatedEnumeration; - startOffset: SVGAnimatedLength; - TEXTPATH_METHODTYPE_ALIGN: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; + readonly method: SVGAnimatedEnumeration; + readonly spacing: SVGAnimatedEnumeration; + readonly startOffset: SVGAnimatedLength; + readonly TEXTPATH_METHODTYPE_ALIGN: number; + readonly TEXTPATH_METHODTYPE_STRETCH: number; + readonly TEXTPATH_METHODTYPE_UNKNOWN: number; + readonly TEXTPATH_SPACINGTYPE_AUTO: number; + readonly TEXTPATH_SPACINGTYPE_EXACT: number; + readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } declare var SVGTextPathElement: { prototype: SVGTextPathElement; new(): SVGTextPathElement; - TEXTPATH_METHODTYPE_ALIGN: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; + readonly TEXTPATH_METHODTYPE_ALIGN: number; + readonly TEXTPATH_METHODTYPE_STRETCH: number; + readonly TEXTPATH_METHODTYPE_UNKNOWN: number; + readonly TEXTPATH_SPACINGTYPE_AUTO: number; + readonly TEXTPATH_SPACINGTYPE_EXACT: number; + readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; } interface SVGTextPositioningElement extends SVGTextContentElement { - dx: SVGAnimatedLengthList; - dy: SVGAnimatedLengthList; - rotate: SVGAnimatedNumberList; - x: SVGAnimatedLengthList; - y: SVGAnimatedLengthList; + readonly dx: SVGAnimatedLengthList; + readonly dy: SVGAnimatedLengthList; + readonly rotate: SVGAnimatedNumberList; + readonly x: SVGAnimatedLengthList; + readonly y: SVGAnimatedLengthList; } declare var SVGTextPositioningElement: { @@ -11174,38 +11174,38 @@ declare var SVGTitleElement: { } interface SVGTransform { - angle: number; - matrix: SVGMatrix; - type: number; + readonly angle: number; + readonly matrix: SVGMatrix; + readonly type: number; setMatrix(matrix: SVGMatrix): void; setRotate(angle: number, cx: number, cy: number): void; setScale(sx: number, sy: number): void; setSkewX(angle: number): void; setSkewY(angle: number): void; setTranslate(tx: number, ty: number): void; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_SKEWY: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_UNKNOWN: number; + readonly SVG_TRANSFORM_MATRIX: number; + readonly SVG_TRANSFORM_ROTATE: number; + readonly SVG_TRANSFORM_SCALE: number; + readonly SVG_TRANSFORM_SKEWX: number; + readonly SVG_TRANSFORM_SKEWY: number; + readonly SVG_TRANSFORM_TRANSLATE: number; + readonly SVG_TRANSFORM_UNKNOWN: number; } declare var SVGTransform: { prototype: SVGTransform; new(): SVGTransform; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_SKEWY: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_UNKNOWN: number; + readonly SVG_TRANSFORM_MATRIX: number; + readonly SVG_TRANSFORM_ROTATE: number; + readonly SVG_TRANSFORM_SCALE: number; + readonly SVG_TRANSFORM_SKEWX: number; + readonly SVG_TRANSFORM_SKEWY: number; + readonly SVG_TRANSFORM_TRANSLATE: number; + readonly SVG_TRANSFORM_UNKNOWN: number; } interface SVGTransformList { - numberOfItems: number; + readonly numberOfItems: number; appendItem(newItem: SVGTransform): SVGTransform; clear(): void; consolidate(): SVGTransform; @@ -11223,19 +11223,19 @@ declare var SVGTransformList: { } interface SVGUnitTypes { - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; + readonly SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + readonly SVG_UNIT_TYPE_UNKNOWN: number; + readonly SVG_UNIT_TYPE_USERSPACEONUSE: number; } declare var SVGUnitTypes: SVGUnitTypes; interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { - animatedInstanceRoot: SVGElementInstance; - height: SVGAnimatedLength; - instanceRoot: SVGElementInstance; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - y: SVGAnimatedLength; + readonly animatedInstanceRoot: SVGElementInstance; + readonly height: SVGAnimatedLength; + readonly instanceRoot: SVGElementInstance; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11245,7 +11245,7 @@ declare var SVGUseElement: { } interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { - viewTarget: SVGStringList; + readonly viewTarget: SVGStringList; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11255,21 +11255,21 @@ declare var SVGViewElement: { } interface SVGZoomAndPan { - zoomAndPan: number; + readonly zoomAndPan: number; } declare var SVGZoomAndPan: { - SVG_ZOOMANDPAN_DISABLE: number; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; + readonly SVG_ZOOMANDPAN_DISABLE: number; + readonly SVG_ZOOMANDPAN_MAGNIFY: number; + readonly SVG_ZOOMANDPAN_UNKNOWN: number; } interface SVGZoomEvent extends UIEvent { - newScale: number; - newTranslate: SVGPoint; - previousScale: number; - previousTranslate: SVGPoint; - zoomRectScreen: SVGRect; + readonly newScale: number; + readonly newTranslate: SVGPoint; + readonly previousScale: number; + readonly previousTranslate: SVGPoint; + readonly zoomRectScreen: SVGRect; } declare var SVGZoomEvent: { @@ -11278,22 +11278,22 @@ declare var SVGZoomEvent: { } interface Screen extends EventTarget { - availHeight: number; - availWidth: number; + readonly availHeight: number; + readonly availWidth: number; bufferDepth: number; - colorDepth: number; - deviceXDPI: number; - deviceYDPI: number; - fontSmoothingEnabled: boolean; - height: number; - logicalXDPI: number; - logicalYDPI: number; - msOrientation: string; + readonly colorDepth: number; + readonly deviceXDPI: number; + readonly deviceYDPI: number; + readonly fontSmoothingEnabled: boolean; + readonly height: number; + readonly logicalXDPI: number; + readonly logicalYDPI: number; + readonly msOrientation: string; onmsorientationchange: (ev: Event) => any; - pixelDepth: number; - systemXDPI: number; - systemYDPI: number; - width: number; + readonly pixelDepth: number; + readonly systemXDPI: number; + readonly systemYDPI: number; + readonly width: number; msLockOrientation(orientations: string | string[]): boolean; msUnlockOrientation(): void; addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -11306,8 +11306,8 @@ declare var Screen: { } interface ScriptNotifyEvent extends Event { - callingUri: string; - value: string; + readonly callingUri: string; + readonly value: string; } declare var ScriptNotifyEvent: { @@ -11316,7 +11316,7 @@ declare var ScriptNotifyEvent: { } interface ScriptProcessorNode extends AudioNode { - bufferSize: number; + readonly bufferSize: number; onaudioprocess: (ev: AudioProcessingEvent) => any; addEventListener(type: "audioprocess", listener: (ev: AudioProcessingEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -11328,13 +11328,13 @@ declare var ScriptProcessorNode: { } interface Selection { - anchorNode: Node; - anchorOffset: number; - focusNode: Node; - focusOffset: number; - isCollapsed: boolean; - rangeCount: number; - type: string; + readonly anchorNode: Node; + readonly anchorOffset: number; + readonly focusNode: Node; + readonly focusOffset: number; + readonly isCollapsed: boolean; + readonly rangeCount: number; + readonly type: string; addRange(range: Range): void; collapse(parentNode: Node, offset: number): void; collapseToEnd(): void; @@ -11359,12 +11359,12 @@ declare var Selection: { interface SourceBuffer extends EventTarget { appendWindowEnd: number; appendWindowStart: number; - audioTracks: AudioTrackList; - buffered: TimeRanges; + readonly audioTracks: AudioTrackList; + readonly buffered: TimeRanges; mode: string; timestampOffset: number; - updating: boolean; - videoTracks: VideoTrackList; + readonly updating: boolean; + readonly videoTracks: VideoTrackList; abort(): void; appendBuffer(data: ArrayBuffer | ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; @@ -11377,7 +11377,7 @@ declare var SourceBuffer: { } interface SourceBufferList extends EventTarget { - length: number; + readonly length: number; item(index: number): SourceBuffer; [index: number]: SourceBuffer; } @@ -11388,7 +11388,7 @@ declare var SourceBufferList: { } interface StereoPannerNode extends AudioNode { - pan: AudioParam; + readonly pan: AudioParam; } declare var StereoPannerNode: { @@ -11397,7 +11397,7 @@ declare var StereoPannerNode: { } interface Storage { - length: number; + readonly length: number; clear(): void; getItem(key: string): string; key(index: number): string; @@ -11413,7 +11413,7 @@ declare var Storage: { } interface StorageEvent extends Event { - url: string; + readonly url: string; key?: string; oldValue?: string; newValue?: string; @@ -11426,7 +11426,7 @@ declare var StorageEvent: { } interface StyleMedia { - type: string; + readonly type: string; matchMedium(mediaquery: string): boolean; } @@ -11437,12 +11437,12 @@ declare var StyleMedia: { interface StyleSheet { disabled: boolean; - href: string; - media: MediaList; - ownerNode: Node; - parentStyleSheet: StyleSheet; - title: string; - type: string; + readonly href: string; + readonly media: MediaList; + readonly ownerNode: Node; + readonly parentStyleSheet: StyleSheet; + readonly title: string; + readonly type: string; } declare var StyleSheet: { @@ -11451,7 +11451,7 @@ declare var StyleSheet: { } interface StyleSheetList { - length: number; + readonly length: number; item(index?: number): StyleSheet; [index: number]: StyleSheet; } @@ -11462,7 +11462,7 @@ declare var StyleSheetList: { } interface StyleSheetPageList { - length: number; + readonly length: number; item(index: number): CSSPageRule; [index: number]: CSSPageRule; } @@ -11493,7 +11493,7 @@ declare var SubtleCrypto: { } interface Text extends CharacterData { - wholeText: string; + readonly wholeText: string; splitText(offset: number): Text; } @@ -11503,39 +11503,39 @@ declare var Text: { } interface TextEvent extends UIEvent { - data: string; - inputMethod: number; - locale: string; + readonly data: string; + readonly inputMethod: number; + readonly locale: string; initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_MULTIMODAL: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_VOICE: number; + readonly DOM_INPUT_METHOD_DROP: number; + readonly DOM_INPUT_METHOD_HANDWRITING: number; + readonly DOM_INPUT_METHOD_IME: number; + readonly DOM_INPUT_METHOD_KEYBOARD: number; + readonly DOM_INPUT_METHOD_MULTIMODAL: number; + readonly DOM_INPUT_METHOD_OPTION: number; + readonly DOM_INPUT_METHOD_PASTE: number; + readonly DOM_INPUT_METHOD_SCRIPT: number; + readonly DOM_INPUT_METHOD_UNKNOWN: number; + readonly DOM_INPUT_METHOD_VOICE: number; } declare var TextEvent: { prototype: TextEvent; new(): TextEvent; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_MULTIMODAL: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_VOICE: number; + readonly DOM_INPUT_METHOD_DROP: number; + readonly DOM_INPUT_METHOD_HANDWRITING: number; + readonly DOM_INPUT_METHOD_IME: number; + readonly DOM_INPUT_METHOD_KEYBOARD: number; + readonly DOM_INPUT_METHOD_MULTIMODAL: number; + readonly DOM_INPUT_METHOD_OPTION: number; + readonly DOM_INPUT_METHOD_PASTE: number; + readonly DOM_INPUT_METHOD_SCRIPT: number; + readonly DOM_INPUT_METHOD_UNKNOWN: number; + readonly DOM_INPUT_METHOD_VOICE: number; } interface TextMetrics { - width: number; + readonly width: number; } declare var TextMetrics: { @@ -11544,26 +11544,26 @@ declare var TextMetrics: { } interface TextTrack extends EventTarget { - activeCues: TextTrackCueList; - cues: TextTrackCueList; - inBandMetadataTrackDispatchType: string; - kind: string; - label: string; - language: string; + readonly activeCues: TextTrackCueList; + readonly cues: TextTrackCueList; + readonly inBandMetadataTrackDispatchType: string; + readonly kind: string; + readonly label: string; + readonly language: string; mode: any; oncuechange: (ev: Event) => any; onerror: (ev: Event) => any; onload: (ev: Event) => any; - readyState: number; + readonly readyState: number; addCue(cue: TextTrackCue): void; removeCue(cue: TextTrackCue): void; - DISABLED: number; - ERROR: number; - HIDDEN: number; - LOADED: number; - LOADING: number; - NONE: number; - SHOWING: number; + readonly DISABLED: number; + readonly ERROR: number; + readonly HIDDEN: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + readonly SHOWING: number; addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -11573,13 +11573,13 @@ interface TextTrack extends EventTarget { declare var TextTrack: { prototype: TextTrack; new(): TextTrack; - DISABLED: number; - ERROR: number; - HIDDEN: number; - LOADED: number; - LOADING: number; - NONE: number; - SHOWING: number; + readonly DISABLED: number; + readonly ERROR: number; + readonly HIDDEN: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + readonly SHOWING: number; } interface TextTrackCue extends EventTarget { @@ -11590,7 +11590,7 @@ interface TextTrackCue extends EventTarget { pauseOnExit: boolean; startTime: number; text: string; - track: TextTrack; + readonly track: TextTrack; getCueAsHTML(): DocumentFragment; addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -11603,7 +11603,7 @@ declare var TextTrackCue: { } interface TextTrackCueList { - length: number; + readonly length: number; getCueById(id: string): TextTrackCue; item(index: number): TextTrackCue; [index: number]: TextTrackCue; @@ -11615,7 +11615,7 @@ declare var TextTrackCueList: { } interface TextTrackList extends EventTarget { - length: number; + readonly length: number; onaddtrack: (ev: TrackEvent) => any; item(index: number): TextTrack; addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; @@ -11629,7 +11629,7 @@ declare var TextTrackList: { } interface TimeRanges { - length: number; + readonly length: number; end(index: number): number; start(index: number): number; } @@ -11640,14 +11640,14 @@ declare var TimeRanges: { } interface Touch { - clientX: number; - clientY: number; - identifier: number; - pageX: number; - pageY: number; - screenX: number; - screenY: number; - target: EventTarget; + readonly clientX: number; + readonly clientY: number; + readonly identifier: number; + readonly pageX: number; + readonly pageY: number; + readonly screenX: number; + readonly screenY: number; + readonly target: EventTarget; } declare var Touch: { @@ -11656,13 +11656,13 @@ declare var Touch: { } interface TouchEvent extends UIEvent { - altKey: boolean; - changedTouches: TouchList; - ctrlKey: boolean; - metaKey: boolean; - shiftKey: boolean; - targetTouches: TouchList; - touches: TouchList; + readonly altKey: boolean; + readonly changedTouches: TouchList; + readonly ctrlKey: boolean; + readonly metaKey: boolean; + readonly shiftKey: boolean; + readonly targetTouches: TouchList; + readonly touches: TouchList; } declare var TouchEvent: { @@ -11671,7 +11671,7 @@ declare var TouchEvent: { } interface TouchList { - length: number; + readonly length: number; item(index: number): Touch; [index: number]: Touch; } @@ -11682,7 +11682,7 @@ declare var TouchList: { } interface TrackEvent extends Event { - track: any; + readonly track: any; } declare var TrackEvent: { @@ -11691,8 +11691,8 @@ declare var TrackEvent: { } interface TransitionEvent extends Event { - elapsedTime: number; - propertyName: string; + readonly elapsedTime: number; + readonly propertyName: string; initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; } @@ -11703,10 +11703,10 @@ declare var TransitionEvent: { interface TreeWalker { currentNode: Node; - expandEntityReferences: boolean; - filter: NodeFilter; - root: Node; - whatToShow: number; + readonly expandEntityReferences: boolean; + readonly filter: NodeFilter; + readonly root: Node; + readonly whatToShow: number; firstChild(): Node; lastChild(): Node; nextNode(): Node; @@ -11722,8 +11722,8 @@ declare var TreeWalker: { } interface UIEvent extends Event { - detail: number; - view: Window; + readonly detail: number; + readonly view: Window; initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; } @@ -11737,7 +11737,7 @@ interface URL { host: string; hostname: string; href: string; - origin: string; + readonly origin: string; password: string; pathname: string; port: string; @@ -11755,7 +11755,7 @@ declare var URL: { } interface UnviewableContentIdentifiedEvent extends NavigationEventWithReferrer { - mediaType: string; + readonly mediaType: string; } declare var UnviewableContentIdentifiedEvent: { @@ -11764,16 +11764,16 @@ declare var UnviewableContentIdentifiedEvent: { } interface ValidityState { - badInput: boolean; - customError: boolean; - patternMismatch: boolean; - rangeOverflow: boolean; - rangeUnderflow: boolean; - stepMismatch: boolean; - tooLong: boolean; - typeMismatch: boolean; - valid: boolean; - valueMissing: boolean; + readonly badInput: boolean; + readonly customError: boolean; + readonly patternMismatch: boolean; + readonly rangeOverflow: boolean; + readonly rangeUnderflow: boolean; + readonly stepMismatch: boolean; + readonly tooLong: boolean; + readonly typeMismatch: boolean; + readonly valid: boolean; + readonly valueMissing: boolean; } declare var ValidityState: { @@ -11782,11 +11782,11 @@ declare var ValidityState: { } interface VideoPlaybackQuality { - corruptedVideoFrames: number; - creationTime: number; - droppedVideoFrames: number; - totalFrameDelay: number; - totalVideoFrames: number; + readonly corruptedVideoFrames: number; + readonly creationTime: number; + readonly droppedVideoFrames: number; + readonly totalFrameDelay: number; + readonly totalVideoFrames: number; } declare var VideoPlaybackQuality: { @@ -11795,12 +11795,12 @@ declare var VideoPlaybackQuality: { } interface VideoTrack { - id: string; + readonly id: string; kind: string; - label: string; + readonly label: string; language: string; selected: boolean; - sourceBuffer: SourceBuffer; + readonly sourceBuffer: SourceBuffer; } declare var VideoTrack: { @@ -11809,11 +11809,11 @@ declare var VideoTrack: { } interface VideoTrackList extends EventTarget { - length: number; + readonly length: number; onaddtrack: (ev: TrackEvent) => any; onchange: (ev: Event) => any; onremovetrack: (ev: TrackEvent) => any; - selectedIndex: number; + readonly selectedIndex: number; getTrackById(id: string): VideoTrack; item(index: number): VideoTrack; addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; @@ -11829,41 +11829,41 @@ declare var VideoTrackList: { } interface WEBGL_compressed_texture_s3tc { - COMPRESSED_RGBA_S3TC_DXT1_EXT: number; - COMPRESSED_RGBA_S3TC_DXT3_EXT: number; - COMPRESSED_RGBA_S3TC_DXT5_EXT: number; - COMPRESSED_RGB_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; } declare var WEBGL_compressed_texture_s3tc: { prototype: WEBGL_compressed_texture_s3tc; new(): WEBGL_compressed_texture_s3tc; - COMPRESSED_RGBA_S3TC_DXT1_EXT: number; - COMPRESSED_RGBA_S3TC_DXT3_EXT: number; - COMPRESSED_RGBA_S3TC_DXT5_EXT: number; - COMPRESSED_RGB_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; } interface WEBGL_debug_renderer_info { - UNMASKED_RENDERER_WEBGL: number; - UNMASKED_VENDOR_WEBGL: number; + readonly UNMASKED_RENDERER_WEBGL: number; + readonly UNMASKED_VENDOR_WEBGL: number; } declare var WEBGL_debug_renderer_info: { prototype: WEBGL_debug_renderer_info; new(): WEBGL_debug_renderer_info; - UNMASKED_RENDERER_WEBGL: number; - UNMASKED_VENDOR_WEBGL: number; + readonly UNMASKED_RENDERER_WEBGL: number; + readonly UNMASKED_VENDOR_WEBGL: number; } interface WEBGL_depth_texture { - UNSIGNED_INT_24_8_WEBGL: number; + readonly UNSIGNED_INT_24_8_WEBGL: number; } declare var WEBGL_depth_texture: { prototype: WEBGL_depth_texture; new(): WEBGL_depth_texture; - UNSIGNED_INT_24_8_WEBGL: number; + readonly UNSIGNED_INT_24_8_WEBGL: number; } interface WaveShaperNode extends AudioNode { @@ -11877,9 +11877,9 @@ declare var WaveShaperNode: { } interface WebGLActiveInfo { - name: string; - size: number; - type: number; + readonly name: string; + readonly size: number; + readonly type: number; } declare var WebGLActiveInfo: { @@ -11896,7 +11896,7 @@ declare var WebGLBuffer: { } interface WebGLContextEvent extends Event { - statusMessage: string; + readonly statusMessage: string; } declare var WebGLContextEvent: { @@ -11937,9 +11937,9 @@ declare var WebGLRenderbuffer: { } interface WebGLRenderingContext { - canvas: HTMLCanvasElement; - drawingBufferHeight: number; - drawingBufferWidth: number; + readonly canvas: HTMLCanvasElement; + readonly drawingBufferHeight: number; + readonly drawingBufferWidth: number; activeTexture(texture: number): void; attachShader(program: WebGLProgram, shader: WebGLShader): void; bindAttribLocation(program: WebGLProgram, index: number, name: string): void; @@ -12054,635 +12054,635 @@ interface WebGLRenderingContext { 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; - uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; uniform1i(location: WebGLUniformLocation, x: number): void; - uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; - uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): 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; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: Float32Array): void; + vertexAttrib1fv(indx: number, values: Float32Array | number[]): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: Float32Array): void; + vertexAttrib2fv(indx: number, values: Float32Array | number[]): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: Float32Array): void; + vertexAttrib3fv(indx: number, values: Float32Array | number[]): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: Float32Array): void; + vertexAttrib4fv(indx: number, values: Float32Array | number[]): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; - ACTIVE_ATTRIBUTES: number; - ACTIVE_TEXTURE: number; - ACTIVE_UNIFORMS: number; - ALIASED_LINE_WIDTH_RANGE: number; - ALIASED_POINT_SIZE_RANGE: number; - ALPHA: number; - ALPHA_BITS: number; - ALWAYS: number; - ARRAY_BUFFER: number; - ARRAY_BUFFER_BINDING: number; - ATTACHED_SHADERS: number; - BACK: number; - BLEND: number; - BLEND_COLOR: number; - BLEND_DST_ALPHA: number; - BLEND_DST_RGB: number; - BLEND_EQUATION: number; - BLEND_EQUATION_ALPHA: number; - BLEND_EQUATION_RGB: number; - BLEND_SRC_ALPHA: number; - BLEND_SRC_RGB: number; - BLUE_BITS: number; - BOOL: number; - BOOL_VEC2: number; - BOOL_VEC3: number; - BOOL_VEC4: number; - BROWSER_DEFAULT_WEBGL: number; - BUFFER_SIZE: number; - BUFFER_USAGE: number; - BYTE: number; - CCW: number; - CLAMP_TO_EDGE: number; - COLOR_ATTACHMENT0: number; - COLOR_BUFFER_BIT: number; - COLOR_CLEAR_VALUE: number; - COLOR_WRITEMASK: number; - COMPILE_STATUS: number; - COMPRESSED_TEXTURE_FORMATS: number; - CONSTANT_ALPHA: number; - CONSTANT_COLOR: number; - CONTEXT_LOST_WEBGL: number; - CULL_FACE: number; - CULL_FACE_MODE: number; - CURRENT_PROGRAM: number; - CURRENT_VERTEX_ATTRIB: number; - CW: number; - DECR: number; - DECR_WRAP: number; - DELETE_STATUS: number; - DEPTH_ATTACHMENT: number; - DEPTH_BITS: number; - DEPTH_BUFFER_BIT: number; - DEPTH_CLEAR_VALUE: number; - DEPTH_COMPONENT: number; - DEPTH_COMPONENT16: number; - DEPTH_FUNC: number; - DEPTH_RANGE: number; - DEPTH_STENCIL: number; - DEPTH_STENCIL_ATTACHMENT: number; - DEPTH_TEST: number; - DEPTH_WRITEMASK: number; - DITHER: number; - DONT_CARE: number; - DST_ALPHA: number; - DST_COLOR: number; - DYNAMIC_DRAW: number; - ELEMENT_ARRAY_BUFFER: number; - ELEMENT_ARRAY_BUFFER_BINDING: number; - EQUAL: number; - FASTEST: number; - FLOAT: number; - FLOAT_MAT2: number; - FLOAT_MAT3: number; - FLOAT_MAT4: number; - FLOAT_VEC2: number; - FLOAT_VEC3: number; - FLOAT_VEC4: number; - FRAGMENT_SHADER: number; - FRAMEBUFFER: number; - FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; - FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; - FRAMEBUFFER_BINDING: number; - FRAMEBUFFER_COMPLETE: number; - FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; - FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; - FRAMEBUFFER_UNSUPPORTED: number; - FRONT: number; - FRONT_AND_BACK: number; - FRONT_FACE: number; - FUNC_ADD: number; - FUNC_REVERSE_SUBTRACT: number; - FUNC_SUBTRACT: number; - GENERATE_MIPMAP_HINT: number; - GEQUAL: number; - GREATER: number; - GREEN_BITS: number; - HIGH_FLOAT: number; - HIGH_INT: number; - IMPLEMENTATION_COLOR_READ_FORMAT: number; - IMPLEMENTATION_COLOR_READ_TYPE: number; - INCR: number; - INCR_WRAP: number; - INT: number; - INT_VEC2: number; - INT_VEC3: number; - INT_VEC4: number; - INVALID_ENUM: number; - INVALID_FRAMEBUFFER_OPERATION: number; - INVALID_OPERATION: number; - INVALID_VALUE: number; - INVERT: number; - KEEP: number; - LEQUAL: number; - LESS: number; - LINEAR: number; - LINEAR_MIPMAP_LINEAR: number; - LINEAR_MIPMAP_NEAREST: number; - LINES: number; - LINE_LOOP: number; - LINE_STRIP: number; - LINE_WIDTH: number; - LINK_STATUS: number; - LOW_FLOAT: number; - LOW_INT: number; - LUMINANCE: number; - LUMINANCE_ALPHA: number; - MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; - MAX_CUBE_MAP_TEXTURE_SIZE: number; - MAX_FRAGMENT_UNIFORM_VECTORS: number; - MAX_RENDERBUFFER_SIZE: number; - MAX_TEXTURE_IMAGE_UNITS: number; - MAX_TEXTURE_SIZE: number; - MAX_VARYING_VECTORS: number; - MAX_VERTEX_ATTRIBS: number; - MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; - MAX_VERTEX_UNIFORM_VECTORS: number; - MAX_VIEWPORT_DIMS: number; - MEDIUM_FLOAT: number; - MEDIUM_INT: number; - MIRRORED_REPEAT: number; - NEAREST: number; - NEAREST_MIPMAP_LINEAR: number; - NEAREST_MIPMAP_NEAREST: number; - NEVER: number; - NICEST: number; - NONE: number; - NOTEQUAL: number; - NO_ERROR: number; - ONE: number; - ONE_MINUS_CONSTANT_ALPHA: number; - ONE_MINUS_CONSTANT_COLOR: number; - ONE_MINUS_DST_ALPHA: number; - ONE_MINUS_DST_COLOR: number; - ONE_MINUS_SRC_ALPHA: number; - ONE_MINUS_SRC_COLOR: number; - OUT_OF_MEMORY: number; - PACK_ALIGNMENT: number; - POINTS: number; - POLYGON_OFFSET_FACTOR: number; - POLYGON_OFFSET_FILL: number; - POLYGON_OFFSET_UNITS: number; - RED_BITS: number; - RENDERBUFFER: number; - RENDERBUFFER_ALPHA_SIZE: number; - RENDERBUFFER_BINDING: number; - RENDERBUFFER_BLUE_SIZE: number; - RENDERBUFFER_DEPTH_SIZE: number; - RENDERBUFFER_GREEN_SIZE: number; - RENDERBUFFER_HEIGHT: number; - RENDERBUFFER_INTERNAL_FORMAT: number; - RENDERBUFFER_RED_SIZE: number; - RENDERBUFFER_STENCIL_SIZE: number; - RENDERBUFFER_WIDTH: number; - RENDERER: number; - REPEAT: number; - REPLACE: number; - RGB: number; - RGB565: number; - RGB5_A1: number; - RGBA: number; - RGBA4: number; - SAMPLER_2D: number; - SAMPLER_CUBE: number; - SAMPLES: number; - SAMPLE_ALPHA_TO_COVERAGE: number; - SAMPLE_BUFFERS: number; - SAMPLE_COVERAGE: number; - SAMPLE_COVERAGE_INVERT: number; - SAMPLE_COVERAGE_VALUE: number; - SCISSOR_BOX: number; - SCISSOR_TEST: number; - SHADER_TYPE: number; - SHADING_LANGUAGE_VERSION: number; - SHORT: number; - SRC_ALPHA: number; - SRC_ALPHA_SATURATE: number; - SRC_COLOR: number; - STATIC_DRAW: number; - STENCIL_ATTACHMENT: number; - STENCIL_BACK_FAIL: number; - STENCIL_BACK_FUNC: number; - STENCIL_BACK_PASS_DEPTH_FAIL: number; - STENCIL_BACK_PASS_DEPTH_PASS: number; - STENCIL_BACK_REF: number; - STENCIL_BACK_VALUE_MASK: number; - STENCIL_BACK_WRITEMASK: number; - STENCIL_BITS: number; - STENCIL_BUFFER_BIT: number; - STENCIL_CLEAR_VALUE: number; - STENCIL_FAIL: number; - STENCIL_FUNC: number; - STENCIL_INDEX: number; - STENCIL_INDEX8: number; - STENCIL_PASS_DEPTH_FAIL: number; - STENCIL_PASS_DEPTH_PASS: number; - STENCIL_REF: number; - STENCIL_TEST: number; - STENCIL_VALUE_MASK: number; - STENCIL_WRITEMASK: number; - STREAM_DRAW: number; - SUBPIXEL_BITS: number; - TEXTURE: number; - TEXTURE0: number; - TEXTURE1: number; - TEXTURE10: number; - TEXTURE11: number; - TEXTURE12: number; - TEXTURE13: number; - TEXTURE14: number; - TEXTURE15: number; - TEXTURE16: number; - TEXTURE17: number; - TEXTURE18: number; - TEXTURE19: number; - TEXTURE2: number; - TEXTURE20: number; - TEXTURE21: number; - TEXTURE22: number; - TEXTURE23: number; - TEXTURE24: number; - TEXTURE25: number; - TEXTURE26: number; - TEXTURE27: number; - TEXTURE28: number; - TEXTURE29: number; - TEXTURE3: number; - TEXTURE30: number; - TEXTURE31: number; - TEXTURE4: number; - TEXTURE5: number; - TEXTURE6: number; - TEXTURE7: number; - TEXTURE8: number; - TEXTURE9: number; - TEXTURE_2D: number; - TEXTURE_BINDING_2D: number; - TEXTURE_BINDING_CUBE_MAP: number; - TEXTURE_CUBE_MAP: number; - TEXTURE_CUBE_MAP_NEGATIVE_X: number; - TEXTURE_CUBE_MAP_NEGATIVE_Y: number; - TEXTURE_CUBE_MAP_NEGATIVE_Z: number; - TEXTURE_CUBE_MAP_POSITIVE_X: number; - TEXTURE_CUBE_MAP_POSITIVE_Y: number; - TEXTURE_CUBE_MAP_POSITIVE_Z: number; - TEXTURE_MAG_FILTER: number; - TEXTURE_MIN_FILTER: number; - TEXTURE_WRAP_S: number; - TEXTURE_WRAP_T: number; - TRIANGLES: number; - TRIANGLE_FAN: number; - TRIANGLE_STRIP: number; - UNPACK_ALIGNMENT: number; - UNPACK_COLORSPACE_CONVERSION_WEBGL: number; - UNPACK_FLIP_Y_WEBGL: number; - UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; - UNSIGNED_BYTE: number; - UNSIGNED_INT: number; - UNSIGNED_SHORT: number; - UNSIGNED_SHORT_4_4_4_4: number; - UNSIGNED_SHORT_5_5_5_1: number; - UNSIGNED_SHORT_5_6_5: number; - VALIDATE_STATUS: number; - VENDOR: number; - VERSION: number; - VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; - VERTEX_ATTRIB_ARRAY_ENABLED: number; - VERTEX_ATTRIB_ARRAY_NORMALIZED: number; - VERTEX_ATTRIB_ARRAY_POINTER: number; - VERTEX_ATTRIB_ARRAY_SIZE: number; - VERTEX_ATTRIB_ARRAY_STRIDE: number; - VERTEX_ATTRIB_ARRAY_TYPE: number; - VERTEX_SHADER: number; - VIEWPORT: number; - ZERO: number; + readonly ACTIVE_ATTRIBUTES: number; + readonly ACTIVE_TEXTURE: number; + readonly ACTIVE_UNIFORMS: number; + readonly ALIASED_LINE_WIDTH_RANGE: number; + readonly ALIASED_POINT_SIZE_RANGE: number; + readonly ALPHA: number; + readonly ALPHA_BITS: number; + readonly ALWAYS: number; + readonly ARRAY_BUFFER: number; + readonly ARRAY_BUFFER_BINDING: number; + readonly ATTACHED_SHADERS: number; + readonly BACK: number; + readonly BLEND: number; + readonly BLEND_COLOR: number; + readonly BLEND_DST_ALPHA: number; + readonly BLEND_DST_RGB: number; + readonly BLEND_EQUATION: number; + readonly BLEND_EQUATION_ALPHA: number; + readonly BLEND_EQUATION_RGB: number; + readonly BLEND_SRC_ALPHA: number; + readonly BLEND_SRC_RGB: number; + readonly BLUE_BITS: number; + readonly BOOL: number; + readonly BOOL_VEC2: number; + readonly BOOL_VEC3: number; + readonly BOOL_VEC4: number; + readonly BROWSER_DEFAULT_WEBGL: number; + readonly BUFFER_SIZE: number; + readonly BUFFER_USAGE: number; + readonly BYTE: number; + readonly CCW: number; + readonly CLAMP_TO_EDGE: number; + readonly COLOR_ATTACHMENT0: number; + readonly COLOR_BUFFER_BIT: number; + readonly COLOR_CLEAR_VALUE: number; + readonly COLOR_WRITEMASK: number; + readonly COMPILE_STATUS: number; + readonly COMPRESSED_TEXTURE_FORMATS: number; + readonly CONSTANT_ALPHA: number; + readonly CONSTANT_COLOR: number; + readonly CONTEXT_LOST_WEBGL: number; + readonly CULL_FACE: number; + readonly CULL_FACE_MODE: number; + readonly CURRENT_PROGRAM: number; + readonly CURRENT_VERTEX_ATTRIB: number; + readonly CW: number; + readonly DECR: number; + readonly DECR_WRAP: number; + readonly DELETE_STATUS: number; + readonly DEPTH_ATTACHMENT: number; + readonly DEPTH_BITS: number; + readonly DEPTH_BUFFER_BIT: number; + readonly DEPTH_CLEAR_VALUE: number; + readonly DEPTH_COMPONENT: number; + readonly DEPTH_COMPONENT16: number; + readonly DEPTH_FUNC: number; + readonly DEPTH_RANGE: number; + readonly DEPTH_STENCIL: number; + readonly DEPTH_STENCIL_ATTACHMENT: number; + readonly DEPTH_TEST: number; + readonly DEPTH_WRITEMASK: number; + readonly DITHER: number; + readonly DONT_CARE: number; + readonly DST_ALPHA: number; + readonly DST_COLOR: number; + readonly DYNAMIC_DRAW: number; + readonly ELEMENT_ARRAY_BUFFER: number; + readonly ELEMENT_ARRAY_BUFFER_BINDING: number; + readonly EQUAL: number; + readonly FASTEST: number; + readonly FLOAT: number; + readonly FLOAT_MAT2: number; + readonly FLOAT_MAT3: number; + readonly FLOAT_MAT4: number; + readonly FLOAT_VEC2: number; + readonly FLOAT_VEC3: number; + readonly FLOAT_VEC4: number; + readonly FRAGMENT_SHADER: number; + readonly FRAMEBUFFER: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + readonly FRAMEBUFFER_BINDING: number; + readonly FRAMEBUFFER_COMPLETE: number; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + readonly FRAMEBUFFER_UNSUPPORTED: number; + readonly FRONT: number; + readonly FRONT_AND_BACK: number; + readonly FRONT_FACE: number; + readonly FUNC_ADD: number; + readonly FUNC_REVERSE_SUBTRACT: number; + readonly FUNC_SUBTRACT: number; + readonly GENERATE_MIPMAP_HINT: number; + readonly GEQUAL: number; + readonly GREATER: number; + readonly GREEN_BITS: number; + readonly HIGH_FLOAT: number; + readonly HIGH_INT: number; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: number; + readonly IMPLEMENTATION_COLOR_READ_TYPE: number; + readonly INCR: number; + readonly INCR_WRAP: number; + readonly INT: number; + readonly INT_VEC2: number; + readonly INT_VEC3: number; + readonly INT_VEC4: number; + readonly INVALID_ENUM: number; + readonly INVALID_FRAMEBUFFER_OPERATION: number; + readonly INVALID_OPERATION: number; + readonly INVALID_VALUE: number; + readonly INVERT: number; + readonly KEEP: number; + readonly LEQUAL: number; + readonly LESS: number; + readonly LINEAR: number; + readonly LINEAR_MIPMAP_LINEAR: number; + readonly LINEAR_MIPMAP_NEAREST: number; + readonly LINES: number; + readonly LINE_LOOP: number; + readonly LINE_STRIP: number; + readonly LINE_WIDTH: number; + readonly LINK_STATUS: number; + readonly LOW_FLOAT: number; + readonly LOW_INT: number; + readonly LUMINANCE: number; + readonly LUMINANCE_ALPHA: number; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: number; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: number; + readonly MAX_RENDERBUFFER_SIZE: number; + readonly MAX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_TEXTURE_SIZE: number; + readonly MAX_VARYING_VECTORS: number; + readonly MAX_VERTEX_ATTRIBS: number; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_VERTEX_UNIFORM_VECTORS: number; + readonly MAX_VIEWPORT_DIMS: number; + readonly MEDIUM_FLOAT: number; + readonly MEDIUM_INT: number; + readonly MIRRORED_REPEAT: number; + readonly NEAREST: number; + readonly NEAREST_MIPMAP_LINEAR: number; + readonly NEAREST_MIPMAP_NEAREST: number; + readonly NEVER: number; + readonly NICEST: number; + readonly NONE: number; + readonly NOTEQUAL: number; + readonly NO_ERROR: number; + readonly ONE: number; + readonly ONE_MINUS_CONSTANT_ALPHA: number; + readonly ONE_MINUS_CONSTANT_COLOR: number; + readonly ONE_MINUS_DST_ALPHA: number; + readonly ONE_MINUS_DST_COLOR: number; + readonly ONE_MINUS_SRC_ALPHA: number; + readonly ONE_MINUS_SRC_COLOR: number; + readonly OUT_OF_MEMORY: number; + readonly PACK_ALIGNMENT: number; + readonly POINTS: number; + readonly POLYGON_OFFSET_FACTOR: number; + readonly POLYGON_OFFSET_FILL: number; + readonly POLYGON_OFFSET_UNITS: number; + readonly RED_BITS: number; + readonly RENDERBUFFER: number; + readonly RENDERBUFFER_ALPHA_SIZE: number; + readonly RENDERBUFFER_BINDING: number; + readonly RENDERBUFFER_BLUE_SIZE: number; + readonly RENDERBUFFER_DEPTH_SIZE: number; + readonly RENDERBUFFER_GREEN_SIZE: number; + readonly RENDERBUFFER_HEIGHT: number; + readonly RENDERBUFFER_INTERNAL_FORMAT: number; + readonly RENDERBUFFER_RED_SIZE: number; + readonly RENDERBUFFER_STENCIL_SIZE: number; + readonly RENDERBUFFER_WIDTH: number; + readonly RENDERER: number; + readonly REPEAT: number; + readonly REPLACE: number; + readonly RGB: number; + readonly RGB565: number; + readonly RGB5_A1: number; + readonly RGBA: number; + readonly RGBA4: number; + readonly SAMPLER_2D: number; + readonly SAMPLER_CUBE: number; + readonly SAMPLES: number; + readonly SAMPLE_ALPHA_TO_COVERAGE: number; + readonly SAMPLE_BUFFERS: number; + readonly SAMPLE_COVERAGE: number; + readonly SAMPLE_COVERAGE_INVERT: number; + readonly SAMPLE_COVERAGE_VALUE: number; + readonly SCISSOR_BOX: number; + readonly SCISSOR_TEST: number; + readonly SHADER_TYPE: number; + readonly SHADING_LANGUAGE_VERSION: number; + readonly SHORT: number; + readonly SRC_ALPHA: number; + readonly SRC_ALPHA_SATURATE: number; + readonly SRC_COLOR: number; + readonly STATIC_DRAW: number; + readonly STENCIL_ATTACHMENT: number; + readonly STENCIL_BACK_FAIL: number; + readonly STENCIL_BACK_FUNC: number; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: number; + readonly STENCIL_BACK_PASS_DEPTH_PASS: number; + readonly STENCIL_BACK_REF: number; + readonly STENCIL_BACK_VALUE_MASK: number; + readonly STENCIL_BACK_WRITEMASK: number; + readonly STENCIL_BITS: number; + readonly STENCIL_BUFFER_BIT: number; + readonly STENCIL_CLEAR_VALUE: number; + readonly STENCIL_FAIL: number; + readonly STENCIL_FUNC: number; + readonly STENCIL_INDEX: number; + readonly STENCIL_INDEX8: number; + readonly STENCIL_PASS_DEPTH_FAIL: number; + readonly STENCIL_PASS_DEPTH_PASS: number; + readonly STENCIL_REF: number; + readonly STENCIL_TEST: number; + readonly STENCIL_VALUE_MASK: number; + readonly STENCIL_WRITEMASK: number; + readonly STREAM_DRAW: number; + readonly SUBPIXEL_BITS: number; + readonly TEXTURE: number; + readonly TEXTURE0: number; + readonly TEXTURE1: number; + readonly TEXTURE10: number; + readonly TEXTURE11: number; + readonly TEXTURE12: number; + readonly TEXTURE13: number; + readonly TEXTURE14: number; + readonly TEXTURE15: number; + readonly TEXTURE16: number; + readonly TEXTURE17: number; + readonly TEXTURE18: number; + readonly TEXTURE19: number; + readonly TEXTURE2: number; + readonly TEXTURE20: number; + readonly TEXTURE21: number; + readonly TEXTURE22: number; + readonly TEXTURE23: number; + readonly TEXTURE24: number; + readonly TEXTURE25: number; + readonly TEXTURE26: number; + readonly TEXTURE27: number; + readonly TEXTURE28: number; + readonly TEXTURE29: number; + readonly TEXTURE3: number; + readonly TEXTURE30: number; + readonly TEXTURE31: number; + readonly TEXTURE4: number; + readonly TEXTURE5: number; + readonly TEXTURE6: number; + readonly TEXTURE7: number; + readonly TEXTURE8: number; + readonly TEXTURE9: number; + readonly TEXTURE_2D: number; + readonly TEXTURE_BINDING_2D: number; + readonly TEXTURE_BINDING_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: number; + readonly TEXTURE_MAG_FILTER: number; + readonly TEXTURE_MIN_FILTER: number; + readonly TEXTURE_WRAP_S: number; + readonly TEXTURE_WRAP_T: number; + readonly TRIANGLES: number; + readonly TRIANGLE_FAN: number; + readonly TRIANGLE_STRIP: number; + readonly UNPACK_ALIGNMENT: number; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + readonly UNPACK_FLIP_Y_WEBGL: number; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + readonly UNSIGNED_BYTE: number; + readonly UNSIGNED_INT: number; + readonly UNSIGNED_SHORT: number; + readonly UNSIGNED_SHORT_4_4_4_4: number; + readonly UNSIGNED_SHORT_5_5_5_1: number; + readonly UNSIGNED_SHORT_5_6_5: number; + readonly VALIDATE_STATUS: number; + readonly VENDOR: number; + readonly VERSION: number; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: number; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + readonly VERTEX_ATTRIB_ARRAY_POINTER: number; + readonly VERTEX_ATTRIB_ARRAY_SIZE: number; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: number; + readonly VERTEX_ATTRIB_ARRAY_TYPE: number; + readonly VERTEX_SHADER: number; + readonly VIEWPORT: number; + readonly ZERO: number; } declare var WebGLRenderingContext: { prototype: WebGLRenderingContext; new(): WebGLRenderingContext; - ACTIVE_ATTRIBUTES: number; - ACTIVE_TEXTURE: number; - ACTIVE_UNIFORMS: number; - ALIASED_LINE_WIDTH_RANGE: number; - ALIASED_POINT_SIZE_RANGE: number; - ALPHA: number; - ALPHA_BITS: number; - ALWAYS: number; - ARRAY_BUFFER: number; - ARRAY_BUFFER_BINDING: number; - ATTACHED_SHADERS: number; - BACK: number; - BLEND: number; - BLEND_COLOR: number; - BLEND_DST_ALPHA: number; - BLEND_DST_RGB: number; - BLEND_EQUATION: number; - BLEND_EQUATION_ALPHA: number; - BLEND_EQUATION_RGB: number; - BLEND_SRC_ALPHA: number; - BLEND_SRC_RGB: number; - BLUE_BITS: number; - BOOL: number; - BOOL_VEC2: number; - BOOL_VEC3: number; - BOOL_VEC4: number; - BROWSER_DEFAULT_WEBGL: number; - BUFFER_SIZE: number; - BUFFER_USAGE: number; - BYTE: number; - CCW: number; - CLAMP_TO_EDGE: number; - COLOR_ATTACHMENT0: number; - COLOR_BUFFER_BIT: number; - COLOR_CLEAR_VALUE: number; - COLOR_WRITEMASK: number; - COMPILE_STATUS: number; - COMPRESSED_TEXTURE_FORMATS: number; - CONSTANT_ALPHA: number; - CONSTANT_COLOR: number; - CONTEXT_LOST_WEBGL: number; - CULL_FACE: number; - CULL_FACE_MODE: number; - CURRENT_PROGRAM: number; - CURRENT_VERTEX_ATTRIB: number; - CW: number; - DECR: number; - DECR_WRAP: number; - DELETE_STATUS: number; - DEPTH_ATTACHMENT: number; - DEPTH_BITS: number; - DEPTH_BUFFER_BIT: number; - DEPTH_CLEAR_VALUE: number; - DEPTH_COMPONENT: number; - DEPTH_COMPONENT16: number; - DEPTH_FUNC: number; - DEPTH_RANGE: number; - DEPTH_STENCIL: number; - DEPTH_STENCIL_ATTACHMENT: number; - DEPTH_TEST: number; - DEPTH_WRITEMASK: number; - DITHER: number; - DONT_CARE: number; - DST_ALPHA: number; - DST_COLOR: number; - DYNAMIC_DRAW: number; - ELEMENT_ARRAY_BUFFER: number; - ELEMENT_ARRAY_BUFFER_BINDING: number; - EQUAL: number; - FASTEST: number; - FLOAT: number; - FLOAT_MAT2: number; - FLOAT_MAT3: number; - FLOAT_MAT4: number; - FLOAT_VEC2: number; - FLOAT_VEC3: number; - FLOAT_VEC4: number; - FRAGMENT_SHADER: number; - FRAMEBUFFER: number; - FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; - FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; - FRAMEBUFFER_BINDING: number; - FRAMEBUFFER_COMPLETE: number; - FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; - FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; - FRAMEBUFFER_UNSUPPORTED: number; - FRONT: number; - FRONT_AND_BACK: number; - FRONT_FACE: number; - FUNC_ADD: number; - FUNC_REVERSE_SUBTRACT: number; - FUNC_SUBTRACT: number; - GENERATE_MIPMAP_HINT: number; - GEQUAL: number; - GREATER: number; - GREEN_BITS: number; - HIGH_FLOAT: number; - HIGH_INT: number; - IMPLEMENTATION_COLOR_READ_FORMAT: number; - IMPLEMENTATION_COLOR_READ_TYPE: number; - INCR: number; - INCR_WRAP: number; - INT: number; - INT_VEC2: number; - INT_VEC3: number; - INT_VEC4: number; - INVALID_ENUM: number; - INVALID_FRAMEBUFFER_OPERATION: number; - INVALID_OPERATION: number; - INVALID_VALUE: number; - INVERT: number; - KEEP: number; - LEQUAL: number; - LESS: number; - LINEAR: number; - LINEAR_MIPMAP_LINEAR: number; - LINEAR_MIPMAP_NEAREST: number; - LINES: number; - LINE_LOOP: number; - LINE_STRIP: number; - LINE_WIDTH: number; - LINK_STATUS: number; - LOW_FLOAT: number; - LOW_INT: number; - LUMINANCE: number; - LUMINANCE_ALPHA: number; - MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; - MAX_CUBE_MAP_TEXTURE_SIZE: number; - MAX_FRAGMENT_UNIFORM_VECTORS: number; - MAX_RENDERBUFFER_SIZE: number; - MAX_TEXTURE_IMAGE_UNITS: number; - MAX_TEXTURE_SIZE: number; - MAX_VARYING_VECTORS: number; - MAX_VERTEX_ATTRIBS: number; - MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; - MAX_VERTEX_UNIFORM_VECTORS: number; - MAX_VIEWPORT_DIMS: number; - MEDIUM_FLOAT: number; - MEDIUM_INT: number; - MIRRORED_REPEAT: number; - NEAREST: number; - NEAREST_MIPMAP_LINEAR: number; - NEAREST_MIPMAP_NEAREST: number; - NEVER: number; - NICEST: number; - NONE: number; - NOTEQUAL: number; - NO_ERROR: number; - ONE: number; - ONE_MINUS_CONSTANT_ALPHA: number; - ONE_MINUS_CONSTANT_COLOR: number; - ONE_MINUS_DST_ALPHA: number; - ONE_MINUS_DST_COLOR: number; - ONE_MINUS_SRC_ALPHA: number; - ONE_MINUS_SRC_COLOR: number; - OUT_OF_MEMORY: number; - PACK_ALIGNMENT: number; - POINTS: number; - POLYGON_OFFSET_FACTOR: number; - POLYGON_OFFSET_FILL: number; - POLYGON_OFFSET_UNITS: number; - RED_BITS: number; - RENDERBUFFER: number; - RENDERBUFFER_ALPHA_SIZE: number; - RENDERBUFFER_BINDING: number; - RENDERBUFFER_BLUE_SIZE: number; - RENDERBUFFER_DEPTH_SIZE: number; - RENDERBUFFER_GREEN_SIZE: number; - RENDERBUFFER_HEIGHT: number; - RENDERBUFFER_INTERNAL_FORMAT: number; - RENDERBUFFER_RED_SIZE: number; - RENDERBUFFER_STENCIL_SIZE: number; - RENDERBUFFER_WIDTH: number; - RENDERER: number; - REPEAT: number; - REPLACE: number; - RGB: number; - RGB565: number; - RGB5_A1: number; - RGBA: number; - RGBA4: number; - SAMPLER_2D: number; - SAMPLER_CUBE: number; - SAMPLES: number; - SAMPLE_ALPHA_TO_COVERAGE: number; - SAMPLE_BUFFERS: number; - SAMPLE_COVERAGE: number; - SAMPLE_COVERAGE_INVERT: number; - SAMPLE_COVERAGE_VALUE: number; - SCISSOR_BOX: number; - SCISSOR_TEST: number; - SHADER_TYPE: number; - SHADING_LANGUAGE_VERSION: number; - SHORT: number; - SRC_ALPHA: number; - SRC_ALPHA_SATURATE: number; - SRC_COLOR: number; - STATIC_DRAW: number; - STENCIL_ATTACHMENT: number; - STENCIL_BACK_FAIL: number; - STENCIL_BACK_FUNC: number; - STENCIL_BACK_PASS_DEPTH_FAIL: number; - STENCIL_BACK_PASS_DEPTH_PASS: number; - STENCIL_BACK_REF: number; - STENCIL_BACK_VALUE_MASK: number; - STENCIL_BACK_WRITEMASK: number; - STENCIL_BITS: number; - STENCIL_BUFFER_BIT: number; - STENCIL_CLEAR_VALUE: number; - STENCIL_FAIL: number; - STENCIL_FUNC: number; - STENCIL_INDEX: number; - STENCIL_INDEX8: number; - STENCIL_PASS_DEPTH_FAIL: number; - STENCIL_PASS_DEPTH_PASS: number; - STENCIL_REF: number; - STENCIL_TEST: number; - STENCIL_VALUE_MASK: number; - STENCIL_WRITEMASK: number; - STREAM_DRAW: number; - SUBPIXEL_BITS: number; - TEXTURE: number; - TEXTURE0: number; - TEXTURE1: number; - TEXTURE10: number; - TEXTURE11: number; - TEXTURE12: number; - TEXTURE13: number; - TEXTURE14: number; - TEXTURE15: number; - TEXTURE16: number; - TEXTURE17: number; - TEXTURE18: number; - TEXTURE19: number; - TEXTURE2: number; - TEXTURE20: number; - TEXTURE21: number; - TEXTURE22: number; - TEXTURE23: number; - TEXTURE24: number; - TEXTURE25: number; - TEXTURE26: number; - TEXTURE27: number; - TEXTURE28: number; - TEXTURE29: number; - TEXTURE3: number; - TEXTURE30: number; - TEXTURE31: number; - TEXTURE4: number; - TEXTURE5: number; - TEXTURE6: number; - TEXTURE7: number; - TEXTURE8: number; - TEXTURE9: number; - TEXTURE_2D: number; - TEXTURE_BINDING_2D: number; - TEXTURE_BINDING_CUBE_MAP: number; - TEXTURE_CUBE_MAP: number; - TEXTURE_CUBE_MAP_NEGATIVE_X: number; - TEXTURE_CUBE_MAP_NEGATIVE_Y: number; - TEXTURE_CUBE_MAP_NEGATIVE_Z: number; - TEXTURE_CUBE_MAP_POSITIVE_X: number; - TEXTURE_CUBE_MAP_POSITIVE_Y: number; - TEXTURE_CUBE_MAP_POSITIVE_Z: number; - TEXTURE_MAG_FILTER: number; - TEXTURE_MIN_FILTER: number; - TEXTURE_WRAP_S: number; - TEXTURE_WRAP_T: number; - TRIANGLES: number; - TRIANGLE_FAN: number; - TRIANGLE_STRIP: number; - UNPACK_ALIGNMENT: number; - UNPACK_COLORSPACE_CONVERSION_WEBGL: number; - UNPACK_FLIP_Y_WEBGL: number; - UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; - UNSIGNED_BYTE: number; - UNSIGNED_INT: number; - UNSIGNED_SHORT: number; - UNSIGNED_SHORT_4_4_4_4: number; - UNSIGNED_SHORT_5_5_5_1: number; - UNSIGNED_SHORT_5_6_5: number; - VALIDATE_STATUS: number; - VENDOR: number; - VERSION: number; - VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; - VERTEX_ATTRIB_ARRAY_ENABLED: number; - VERTEX_ATTRIB_ARRAY_NORMALIZED: number; - VERTEX_ATTRIB_ARRAY_POINTER: number; - VERTEX_ATTRIB_ARRAY_SIZE: number; - VERTEX_ATTRIB_ARRAY_STRIDE: number; - VERTEX_ATTRIB_ARRAY_TYPE: number; - VERTEX_SHADER: number; - VIEWPORT: number; - ZERO: number; + readonly ACTIVE_ATTRIBUTES: number; + readonly ACTIVE_TEXTURE: number; + readonly ACTIVE_UNIFORMS: number; + readonly ALIASED_LINE_WIDTH_RANGE: number; + readonly ALIASED_POINT_SIZE_RANGE: number; + readonly ALPHA: number; + readonly ALPHA_BITS: number; + readonly ALWAYS: number; + readonly ARRAY_BUFFER: number; + readonly ARRAY_BUFFER_BINDING: number; + readonly ATTACHED_SHADERS: number; + readonly BACK: number; + readonly BLEND: number; + readonly BLEND_COLOR: number; + readonly BLEND_DST_ALPHA: number; + readonly BLEND_DST_RGB: number; + readonly BLEND_EQUATION: number; + readonly BLEND_EQUATION_ALPHA: number; + readonly BLEND_EQUATION_RGB: number; + readonly BLEND_SRC_ALPHA: number; + readonly BLEND_SRC_RGB: number; + readonly BLUE_BITS: number; + readonly BOOL: number; + readonly BOOL_VEC2: number; + readonly BOOL_VEC3: number; + readonly BOOL_VEC4: number; + readonly BROWSER_DEFAULT_WEBGL: number; + readonly BUFFER_SIZE: number; + readonly BUFFER_USAGE: number; + readonly BYTE: number; + readonly CCW: number; + readonly CLAMP_TO_EDGE: number; + readonly COLOR_ATTACHMENT0: number; + readonly COLOR_BUFFER_BIT: number; + readonly COLOR_CLEAR_VALUE: number; + readonly COLOR_WRITEMASK: number; + readonly COMPILE_STATUS: number; + readonly COMPRESSED_TEXTURE_FORMATS: number; + readonly CONSTANT_ALPHA: number; + readonly CONSTANT_COLOR: number; + readonly CONTEXT_LOST_WEBGL: number; + readonly CULL_FACE: number; + readonly CULL_FACE_MODE: number; + readonly CURRENT_PROGRAM: number; + readonly CURRENT_VERTEX_ATTRIB: number; + readonly CW: number; + readonly DECR: number; + readonly DECR_WRAP: number; + readonly DELETE_STATUS: number; + readonly DEPTH_ATTACHMENT: number; + readonly DEPTH_BITS: number; + readonly DEPTH_BUFFER_BIT: number; + readonly DEPTH_CLEAR_VALUE: number; + readonly DEPTH_COMPONENT: number; + readonly DEPTH_COMPONENT16: number; + readonly DEPTH_FUNC: number; + readonly DEPTH_RANGE: number; + readonly DEPTH_STENCIL: number; + readonly DEPTH_STENCIL_ATTACHMENT: number; + readonly DEPTH_TEST: number; + readonly DEPTH_WRITEMASK: number; + readonly DITHER: number; + readonly DONT_CARE: number; + readonly DST_ALPHA: number; + readonly DST_COLOR: number; + readonly DYNAMIC_DRAW: number; + readonly ELEMENT_ARRAY_BUFFER: number; + readonly ELEMENT_ARRAY_BUFFER_BINDING: number; + readonly EQUAL: number; + readonly FASTEST: number; + readonly FLOAT: number; + readonly FLOAT_MAT2: number; + readonly FLOAT_MAT3: number; + readonly FLOAT_MAT4: number; + readonly FLOAT_VEC2: number; + readonly FLOAT_VEC3: number; + readonly FLOAT_VEC4: number; + readonly FRAGMENT_SHADER: number; + readonly FRAMEBUFFER: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + readonly FRAMEBUFFER_BINDING: number; + readonly FRAMEBUFFER_COMPLETE: number; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + readonly FRAMEBUFFER_UNSUPPORTED: number; + readonly FRONT: number; + readonly FRONT_AND_BACK: number; + readonly FRONT_FACE: number; + readonly FUNC_ADD: number; + readonly FUNC_REVERSE_SUBTRACT: number; + readonly FUNC_SUBTRACT: number; + readonly GENERATE_MIPMAP_HINT: number; + readonly GEQUAL: number; + readonly GREATER: number; + readonly GREEN_BITS: number; + readonly HIGH_FLOAT: number; + readonly HIGH_INT: number; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: number; + readonly IMPLEMENTATION_COLOR_READ_TYPE: number; + readonly INCR: number; + readonly INCR_WRAP: number; + readonly INT: number; + readonly INT_VEC2: number; + readonly INT_VEC3: number; + readonly INT_VEC4: number; + readonly INVALID_ENUM: number; + readonly INVALID_FRAMEBUFFER_OPERATION: number; + readonly INVALID_OPERATION: number; + readonly INVALID_VALUE: number; + readonly INVERT: number; + readonly KEEP: number; + readonly LEQUAL: number; + readonly LESS: number; + readonly LINEAR: number; + readonly LINEAR_MIPMAP_LINEAR: number; + readonly LINEAR_MIPMAP_NEAREST: number; + readonly LINES: number; + readonly LINE_LOOP: number; + readonly LINE_STRIP: number; + readonly LINE_WIDTH: number; + readonly LINK_STATUS: number; + readonly LOW_FLOAT: number; + readonly LOW_INT: number; + readonly LUMINANCE: number; + readonly LUMINANCE_ALPHA: number; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: number; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: number; + readonly MAX_RENDERBUFFER_SIZE: number; + readonly MAX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_TEXTURE_SIZE: number; + readonly MAX_VARYING_VECTORS: number; + readonly MAX_VERTEX_ATTRIBS: number; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_VERTEX_UNIFORM_VECTORS: number; + readonly MAX_VIEWPORT_DIMS: number; + readonly MEDIUM_FLOAT: number; + readonly MEDIUM_INT: number; + readonly MIRRORED_REPEAT: number; + readonly NEAREST: number; + readonly NEAREST_MIPMAP_LINEAR: number; + readonly NEAREST_MIPMAP_NEAREST: number; + readonly NEVER: number; + readonly NICEST: number; + readonly NONE: number; + readonly NOTEQUAL: number; + readonly NO_ERROR: number; + readonly ONE: number; + readonly ONE_MINUS_CONSTANT_ALPHA: number; + readonly ONE_MINUS_CONSTANT_COLOR: number; + readonly ONE_MINUS_DST_ALPHA: number; + readonly ONE_MINUS_DST_COLOR: number; + readonly ONE_MINUS_SRC_ALPHA: number; + readonly ONE_MINUS_SRC_COLOR: number; + readonly OUT_OF_MEMORY: number; + readonly PACK_ALIGNMENT: number; + readonly POINTS: number; + readonly POLYGON_OFFSET_FACTOR: number; + readonly POLYGON_OFFSET_FILL: number; + readonly POLYGON_OFFSET_UNITS: number; + readonly RED_BITS: number; + readonly RENDERBUFFER: number; + readonly RENDERBUFFER_ALPHA_SIZE: number; + readonly RENDERBUFFER_BINDING: number; + readonly RENDERBUFFER_BLUE_SIZE: number; + readonly RENDERBUFFER_DEPTH_SIZE: number; + readonly RENDERBUFFER_GREEN_SIZE: number; + readonly RENDERBUFFER_HEIGHT: number; + readonly RENDERBUFFER_INTERNAL_FORMAT: number; + readonly RENDERBUFFER_RED_SIZE: number; + readonly RENDERBUFFER_STENCIL_SIZE: number; + readonly RENDERBUFFER_WIDTH: number; + readonly RENDERER: number; + readonly REPEAT: number; + readonly REPLACE: number; + readonly RGB: number; + readonly RGB565: number; + readonly RGB5_A1: number; + readonly RGBA: number; + readonly RGBA4: number; + readonly SAMPLER_2D: number; + readonly SAMPLER_CUBE: number; + readonly SAMPLES: number; + readonly SAMPLE_ALPHA_TO_COVERAGE: number; + readonly SAMPLE_BUFFERS: number; + readonly SAMPLE_COVERAGE: number; + readonly SAMPLE_COVERAGE_INVERT: number; + readonly SAMPLE_COVERAGE_VALUE: number; + readonly SCISSOR_BOX: number; + readonly SCISSOR_TEST: number; + readonly SHADER_TYPE: number; + readonly SHADING_LANGUAGE_VERSION: number; + readonly SHORT: number; + readonly SRC_ALPHA: number; + readonly SRC_ALPHA_SATURATE: number; + readonly SRC_COLOR: number; + readonly STATIC_DRAW: number; + readonly STENCIL_ATTACHMENT: number; + readonly STENCIL_BACK_FAIL: number; + readonly STENCIL_BACK_FUNC: number; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: number; + readonly STENCIL_BACK_PASS_DEPTH_PASS: number; + readonly STENCIL_BACK_REF: number; + readonly STENCIL_BACK_VALUE_MASK: number; + readonly STENCIL_BACK_WRITEMASK: number; + readonly STENCIL_BITS: number; + readonly STENCIL_BUFFER_BIT: number; + readonly STENCIL_CLEAR_VALUE: number; + readonly STENCIL_FAIL: number; + readonly STENCIL_FUNC: number; + readonly STENCIL_INDEX: number; + readonly STENCIL_INDEX8: number; + readonly STENCIL_PASS_DEPTH_FAIL: number; + readonly STENCIL_PASS_DEPTH_PASS: number; + readonly STENCIL_REF: number; + readonly STENCIL_TEST: number; + readonly STENCIL_VALUE_MASK: number; + readonly STENCIL_WRITEMASK: number; + readonly STREAM_DRAW: number; + readonly SUBPIXEL_BITS: number; + readonly TEXTURE: number; + readonly TEXTURE0: number; + readonly TEXTURE1: number; + readonly TEXTURE10: number; + readonly TEXTURE11: number; + readonly TEXTURE12: number; + readonly TEXTURE13: number; + readonly TEXTURE14: number; + readonly TEXTURE15: number; + readonly TEXTURE16: number; + readonly TEXTURE17: number; + readonly TEXTURE18: number; + readonly TEXTURE19: number; + readonly TEXTURE2: number; + readonly TEXTURE20: number; + readonly TEXTURE21: number; + readonly TEXTURE22: number; + readonly TEXTURE23: number; + readonly TEXTURE24: number; + readonly TEXTURE25: number; + readonly TEXTURE26: number; + readonly TEXTURE27: number; + readonly TEXTURE28: number; + readonly TEXTURE29: number; + readonly TEXTURE3: number; + readonly TEXTURE30: number; + readonly TEXTURE31: number; + readonly TEXTURE4: number; + readonly TEXTURE5: number; + readonly TEXTURE6: number; + readonly TEXTURE7: number; + readonly TEXTURE8: number; + readonly TEXTURE9: number; + readonly TEXTURE_2D: number; + readonly TEXTURE_BINDING_2D: number; + readonly TEXTURE_BINDING_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: number; + readonly TEXTURE_MAG_FILTER: number; + readonly TEXTURE_MIN_FILTER: number; + readonly TEXTURE_WRAP_S: number; + readonly TEXTURE_WRAP_T: number; + readonly TRIANGLES: number; + readonly TRIANGLE_FAN: number; + readonly TRIANGLE_STRIP: number; + readonly UNPACK_ALIGNMENT: number; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + readonly UNPACK_FLIP_Y_WEBGL: number; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + readonly UNSIGNED_BYTE: number; + readonly UNSIGNED_INT: number; + readonly UNSIGNED_SHORT: number; + readonly UNSIGNED_SHORT_4_4_4_4: number; + readonly UNSIGNED_SHORT_5_5_5_1: number; + readonly UNSIGNED_SHORT_5_6_5: number; + readonly VALIDATE_STATUS: number; + readonly VENDOR: number; + readonly VERSION: number; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: number; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + readonly VERTEX_ATTRIB_ARRAY_POINTER: number; + readonly VERTEX_ATTRIB_ARRAY_SIZE: number; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: number; + readonly VERTEX_ATTRIB_ARRAY_TYPE: number; + readonly VERTEX_SHADER: number; + readonly VIEWPORT: number; + readonly ZERO: number; } interface WebGLShader extends WebGLObject { @@ -12694,9 +12694,9 @@ declare var WebGLShader: { } interface WebGLShaderPrecisionFormat { - precision: number; - rangeMax: number; - rangeMin: number; + readonly precision: number; + readonly rangeMax: number; + readonly rangeMin: number; } declare var WebGLShaderPrecisionFormat: { @@ -12772,21 +12772,21 @@ declare var WebKitPoint: { interface WebSocket extends EventTarget { binaryType: string; - bufferedAmount: number; - extensions: string; + readonly bufferedAmount: number; + readonly extensions: string; onclose: (ev: CloseEvent) => any; onerror: (ev: Event) => any; onmessage: (ev: MessageEvent) => any; onopen: (ev: Event) => any; - protocol: string; - readyState: number; - url: string; + readonly protocol: string; + readonly readyState: number; + readonly url: string; close(code?: number, reason?: string): void; send(data: any): void; - CLOSED: number; - CLOSING: number; - CONNECTING: number; - OPEN: number; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; @@ -12797,58 +12797,58 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; new(url: string, protocols?: string | string[]): WebSocket; - CLOSED: number; - CLOSING: number; - CONNECTING: number; - OPEN: number; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; } interface WheelEvent extends MouseEvent { - deltaMode: number; - deltaX: number; - deltaY: number; - deltaZ: number; - wheelDelta: number; - wheelDeltaX: number; - wheelDeltaY: number; + readonly deltaMode: number; + readonly deltaX: number; + readonly deltaY: number; + readonly deltaZ: number; + readonly wheelDelta: number; + readonly wheelDeltaX: number; + readonly wheelDeltaY: number; getCurrentPoint(element: Element): void; initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; - DOM_DELTA_PIXEL: number; + readonly DOM_DELTA_LINE: number; + readonly DOM_DELTA_PAGE: number; + readonly DOM_DELTA_PIXEL: number; } declare var WheelEvent: { prototype: WheelEvent; new(typeArg: string, eventInitDict?: WheelEventInit): WheelEvent; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; - DOM_DELTA_PIXEL: number; + readonly DOM_DELTA_LINE: number; + readonly DOM_DELTA_PAGE: number; + readonly DOM_DELTA_PIXEL: number; } interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { - applicationCache: ApplicationCache; - clientInformation: Navigator; - closed: boolean; - crypto: Crypto; + readonly applicationCache: ApplicationCache; + readonly clientInformation: Navigator; + readonly closed: boolean; + readonly crypto: Crypto; defaultStatus: string; - devicePixelRatio: number; - doNotTrack: string; - document: Document; + readonly devicePixelRatio: number; + readonly doNotTrack: string; + readonly document: Document; event: Event; - external: External; - frameElement: Element; - frames: Window; - history: History; - innerHeight: number; - innerWidth: number; - length: number; - location: Location; - locationbar: BarProp; - menubar: BarProp; - msCredentials: MSCredentials; + readonly external: External; + readonly frameElement: Element; + readonly frames: Window; + readonly history: History; + readonly innerHeight: number; + readonly innerWidth: number; + readonly length: number; + readonly location: Location; + readonly locationbar: BarProp; + readonly menubar: BarProp; + readonly msCredentials: MSCredentials; name: string; - navigator: Navigator; + readonly navigator: Navigator; offscreenBuffering: string | boolean; onabort: (ev: Event) => any; onafterprint: (ev: Event) => any; @@ -12941,30 +12941,30 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onunload: (ev: Event) => any; onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; - opener: Window; + readonly opener: Window; orientation: string | number; - outerHeight: number; - outerWidth: number; - pageXOffset: number; - pageYOffset: number; - parent: Window; - performance: Performance; - personalbar: BarProp; - screen: Screen; - screenLeft: number; - screenTop: number; - screenX: number; - screenY: number; - scrollX: number; - scrollY: number; - scrollbars: BarProp; - self: Window; + readonly outerHeight: number; + readonly outerWidth: number; + readonly pageXOffset: number; + readonly pageYOffset: number; + readonly parent: Window; + readonly performance: Performance; + readonly personalbar: BarProp; + readonly screen: Screen; + readonly screenLeft: number; + readonly screenTop: number; + readonly screenX: number; + readonly screenY: number; + readonly scrollX: number; + readonly scrollY: number; + readonly scrollbars: BarProp; + readonly self: Window; status: string; - statusbar: BarProp; - styleMedia: StyleMedia; - toolbar: BarProp; - top: Window; - window: Window; + readonly statusbar: BarProp; + readonly styleMedia: StyleMedia; + readonly toolbar: BarProp; + readonly top: Window; + readonly window: Window; URL: typeof URL; alert(message?: any): void; blur(): void; @@ -13124,15 +13124,15 @@ declare var XMLDocument: { interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { msCaching: string; onreadystatechange: (ev: ProgressEvent) => any; - readyState: number; - response: any; - responseText: string; + readonly readyState: number; + readonly response: any; + readonly responseText: string; responseType: string; - responseXML: any; - status: number; - statusText: string; + readonly responseXML: any; + readonly status: number; + readonly statusText: string; timeout: number; - upload: XMLHttpRequestUpload; + readonly upload: XMLHttpRequestUpload; withCredentials: boolean; abort(): void; getAllResponseHeaders(): string; @@ -13144,11 +13144,11 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { send(data?: string): void; send(data?: any): void; setRequestHeader(header: string, value: string): void; - DONE: number; - HEADERS_RECEIVED: number; - LOADING: number; - OPENED: number; - UNSENT: number; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -13163,11 +13163,11 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { declare var XMLHttpRequest: { prototype: XMLHttpRequest; new(): XMLHttpRequest; - DONE: number; - HEADERS_RECEIVED: number; - LOADING: number; - OPENED: number; - UNSENT: number; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; create(): XMLHttpRequest; } @@ -13219,40 +13219,40 @@ declare var XPathNSResolver: { } interface XPathResult { - booleanValue: boolean; - invalidIteratorState: boolean; - numberValue: number; - resultType: number; - singleNodeValue: Node; - snapshotLength: number; - stringValue: string; + readonly booleanValue: boolean; + readonly invalidIteratorState: boolean; + readonly numberValue: number; + readonly resultType: number; + readonly singleNodeValue: Node; + readonly snapshotLength: number; + readonly stringValue: string; iterateNext(): Node; snapshotItem(index: number): Node; - ANY_TYPE: number; - ANY_UNORDERED_NODE_TYPE: number; - BOOLEAN_TYPE: number; - FIRST_ORDERED_NODE_TYPE: number; - NUMBER_TYPE: number; - ORDERED_NODE_ITERATOR_TYPE: number; - ORDERED_NODE_SNAPSHOT_TYPE: number; - STRING_TYPE: number; - UNORDERED_NODE_ITERATOR_TYPE: number; - UNORDERED_NODE_SNAPSHOT_TYPE: number; + readonly ANY_TYPE: number; + readonly ANY_UNORDERED_NODE_TYPE: number; + readonly BOOLEAN_TYPE: number; + readonly FIRST_ORDERED_NODE_TYPE: number; + readonly NUMBER_TYPE: number; + readonly ORDERED_NODE_ITERATOR_TYPE: number; + readonly ORDERED_NODE_SNAPSHOT_TYPE: number; + readonly STRING_TYPE: number; + readonly UNORDERED_NODE_ITERATOR_TYPE: number; + readonly UNORDERED_NODE_SNAPSHOT_TYPE: number; } declare var XPathResult: { prototype: XPathResult; new(): XPathResult; - ANY_TYPE: number; - ANY_UNORDERED_NODE_TYPE: number; - BOOLEAN_TYPE: number; - FIRST_ORDERED_NODE_TYPE: number; - NUMBER_TYPE: number; - ORDERED_NODE_ITERATOR_TYPE: number; - ORDERED_NODE_SNAPSHOT_TYPE: number; - STRING_TYPE: number; - UNORDERED_NODE_ITERATOR_TYPE: number; - UNORDERED_NODE_SNAPSHOT_TYPE: number; + readonly ANY_TYPE: number; + readonly ANY_UNORDERED_NODE_TYPE: number; + readonly BOOLEAN_TYPE: number; + readonly FIRST_ORDERED_NODE_TYPE: number; + readonly NUMBER_TYPE: number; + readonly ORDERED_NODE_ITERATOR_TYPE: number; + readonly ORDERED_NODE_SNAPSHOT_TYPE: number; + readonly STRING_TYPE: number; + readonly UNORDERED_NODE_ITERATOR_TYPE: number; + readonly UNORDERED_NODE_SNAPSHOT_TYPE: number; } interface XSLTProcessor { @@ -13373,11 +13373,11 @@ interface DocumentEvent { } interface ElementTraversal { - childElementCount: number; - firstElementChild: Element; - lastElementChild: Element; - nextElementSibling: Element; - previousElementSibling: Element; + readonly childElementCount: number; + readonly firstElementChild: Element; + readonly lastElementChild: Element; + readonly nextElementSibling: Element; + readonly previousElementSibling: Element; } interface GetSVGDocument { @@ -13422,11 +13422,11 @@ interface HTMLTableAlignment { } interface IDBEnvironment { - indexedDB: IDBFactory; + readonly indexedDB: IDBFactory; } interface LinkStyle { - sheet: StyleSheet; + readonly sheet: StyleSheet; } interface MSBaseReader { @@ -13436,12 +13436,12 @@ interface MSBaseReader { onloadend: (ev: ProgressEvent) => any; onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; - readyState: number; - result: any; + readonly readyState: number; + readonly result: any; abort(): void; - DONE: number; - EMPTY: number; - LOADING: number; + readonly DONE: number; + readonly EMPTY: number; + readonly LOADING: number; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -13469,29 +13469,29 @@ interface NavigatorContentUtils { } interface NavigatorGeolocation { - geolocation: Geolocation; + readonly geolocation: Geolocation; } interface NavigatorID { - appName: string; - appVersion: string; - platform: string; - product: string; - productSub: string; - userAgent: string; - vendor: string; - vendorSub: string; + readonly appName: string; + readonly appVersion: string; + readonly platform: string; + readonly product: string; + readonly productSub: string; + readonly userAgent: string; + readonly vendor: string; + readonly vendorSub: string; } interface NavigatorOnLine { - onLine: boolean; + readonly onLine: boolean; } interface NavigatorStorageUtils { } interface NavigatorUserMedia { - mediaDevices: MediaDevices; + readonly mediaDevices: MediaDevices; getUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; } @@ -13505,29 +13505,29 @@ interface RandomSource { } interface SVGAnimatedPathData { - pathSegList: SVGPathSegList; + readonly pathSegList: SVGPathSegList; } interface SVGAnimatedPoints { - animatedPoints: SVGPointList; - points: SVGPointList; + readonly animatedPoints: SVGPointList; + readonly points: SVGPointList; } interface SVGExternalResourcesRequired { - externalResourcesRequired: SVGAnimatedBoolean; + readonly externalResourcesRequired: SVGAnimatedBoolean; } interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { - height: SVGAnimatedLength; - result: SVGAnimatedString; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - y: SVGAnimatedLength; + readonly height: SVGAnimatedLength; + readonly result: SVGAnimatedString; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; } interface SVGFitToViewBox { - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - viewBox: SVGAnimatedRect; + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + readonly viewBox: SVGAnimatedRect; } interface SVGLangSpace { @@ -13536,8 +13536,8 @@ interface SVGLangSpace { } interface SVGLocatable { - farthestViewportElement: SVGElement; - nearestViewportElement: SVGElement; + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; getBBox(): SVGRect; getCTM(): SVGMatrix; getScreenCTM(): SVGMatrix; @@ -13546,22 +13546,22 @@ interface SVGLocatable { interface SVGStylable { className: any; - style: CSSStyleDeclaration; + readonly style: CSSStyleDeclaration; } interface SVGTests { - requiredExtensions: SVGStringList; - requiredFeatures: SVGStringList; - systemLanguage: SVGStringList; + readonly requiredExtensions: SVGStringList; + readonly requiredFeatures: SVGStringList; + readonly systemLanguage: SVGStringList; hasExtension(extension: string): boolean; } interface SVGTransformable extends SVGLocatable { - transform: SVGAnimatedTransformList; + readonly transform: SVGAnimatedTransformList; } interface SVGURIReference { - href: SVGAnimatedString; + readonly href: SVGAnimatedString; } interface WindowBase64 { @@ -13570,15 +13570,15 @@ interface WindowBase64 { } interface WindowConsole { - console: Console; + readonly console: Console; } interface WindowLocalStorage { - localStorage: Storage; + readonly localStorage: Storage; } interface WindowSessionStorage { - sessionStorage: Storage; + readonly sessionStorage: Storage; } interface WindowTimers extends Object, WindowTimersExtension { @@ -13625,6 +13625,12 @@ interface NodeListOf extends NodeList { [index: number]: TNode; } +interface HTMLCollectionOf extends HTMLCollection { + item(index: number): T; + namedItem(name: string): T; + [index: number]: T; +} + interface BlobPropertyBag { type?: string; endings?: string; diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index b342c88a9fd..2b302dea6a2 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -13,10 +13,10 @@ interface EventListener { } interface AudioBuffer { - duration: number; - length: number; - numberOfChannels: number; - sampleRate: number; + readonly duration: number; + readonly length: number; + readonly numberOfChannels: number; + readonly sampleRate: number; copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void; copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void; getChannelData(channel: number): Float32Array; @@ -28,8 +28,8 @@ declare var AudioBuffer: { } interface Blob { - size: number; - type: string; + readonly size: number; + readonly type: string; msClose(): void; msDetachStream(): any; slice(start?: number, end?: number, contentType?: string): Blob; @@ -41,9 +41,9 @@ declare var Blob: { } interface CloseEvent extends Event { - code: number; - reason: string; - wasClean: boolean; + readonly code: number; + readonly reason: string; + readonly wasClean: boolean; initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; } @@ -83,13 +83,13 @@ declare var Console: { } interface Coordinates { - accuracy: number; - altitude: number; - altitudeAccuracy: number; - heading: number; - latitude: number; - longitude: number; - speed: number; + readonly accuracy: number; + readonly altitude: number; + readonly altitudeAccuracy: number; + readonly heading: number; + readonly latitude: number; + readonly longitude: number; + readonly speed: number; } declare var Coordinates: { @@ -98,7 +98,7 @@ declare var Coordinates: { } interface DOMError { - name: string; + readonly name: string; toString(): string; } @@ -108,73 +108,73 @@ declare var DOMError: { } interface DOMException { - code: number; - message: string; - name: string; + readonly code: number; + readonly message: string; + readonly name: string; toString(): string; - ABORT_ERR: number; - DATA_CLONE_ERR: number; - DOMSTRING_SIZE_ERR: number; - HIERARCHY_REQUEST_ERR: number; - INDEX_SIZE_ERR: number; - INUSE_ATTRIBUTE_ERR: number; - INVALID_ACCESS_ERR: number; - INVALID_CHARACTER_ERR: number; - INVALID_MODIFICATION_ERR: number; - INVALID_NODE_TYPE_ERR: number; - INVALID_STATE_ERR: number; - NAMESPACE_ERR: number; - NETWORK_ERR: number; - NOT_FOUND_ERR: number; - NOT_SUPPORTED_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - PARSE_ERR: number; - QUOTA_EXCEEDED_ERR: number; - SECURITY_ERR: number; - SERIALIZE_ERR: number; - SYNTAX_ERR: number; - TIMEOUT_ERR: number; - TYPE_MISMATCH_ERR: number; - URL_MISMATCH_ERR: number; - VALIDATION_ERR: number; - WRONG_DOCUMENT_ERR: number; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; } declare var DOMException: { prototype: DOMException; new(): DOMException; - ABORT_ERR: number; - DATA_CLONE_ERR: number; - DOMSTRING_SIZE_ERR: number; - HIERARCHY_REQUEST_ERR: number; - INDEX_SIZE_ERR: number; - INUSE_ATTRIBUTE_ERR: number; - INVALID_ACCESS_ERR: number; - INVALID_CHARACTER_ERR: number; - INVALID_MODIFICATION_ERR: number; - INVALID_NODE_TYPE_ERR: number; - INVALID_STATE_ERR: number; - NAMESPACE_ERR: number; - NETWORK_ERR: number; - NOT_FOUND_ERR: number; - NOT_SUPPORTED_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - PARSE_ERR: number; - QUOTA_EXCEEDED_ERR: number; - SECURITY_ERR: number; - SERIALIZE_ERR: number; - SYNTAX_ERR: number; - TIMEOUT_ERR: number; - TYPE_MISMATCH_ERR: number; - URL_MISMATCH_ERR: number; - VALIDATION_ERR: number; - WRONG_DOCUMENT_ERR: number; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; } interface DOMStringList { - length: number; + readonly length: number; contains(str: string): boolean; item(index: number): string; [index: number]: string; @@ -186,11 +186,11 @@ declare var DOMStringList: { } interface ErrorEvent extends Event { - colno: number; - error: any; - filename: string; - lineno: number; - message: string; + readonly colno: number; + readonly error: any; + readonly filename: string; + readonly lineno: number; + readonly message: string; initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; } @@ -200,33 +200,33 @@ declare var ErrorEvent: { } interface Event { - bubbles: boolean; + readonly bubbles: boolean; cancelBubble: boolean; - cancelable: boolean; - currentTarget: EventTarget; - defaultPrevented: boolean; - eventPhase: number; - isTrusted: boolean; + readonly cancelable: boolean; + readonly currentTarget: EventTarget; + readonly defaultPrevented: boolean; + readonly eventPhase: number; + readonly isTrusted: boolean; returnValue: boolean; - srcElement: any; - target: EventTarget; - timeStamp: number; - type: string; + readonly srcElement: any; + readonly target: EventTarget; + readonly timeStamp: number; + readonly type: string; initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; preventDefault(): void; stopImmediatePropagation(): void; stopPropagation(): void; - AT_TARGET: number; - BUBBLING_PHASE: number; - CAPTURING_PHASE: number; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; } declare var Event: { prototype: Event; new(type: string, eventInitDict?: EventInit): Event; - AT_TARGET: number; - BUBBLING_PHASE: number; - CAPTURING_PHASE: number; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; } interface EventTarget { @@ -241,9 +241,9 @@ declare var EventTarget: { } interface File extends Blob { - lastModifiedDate: any; - name: string; - webkitRelativePath: string; + readonly lastModifiedDate: any; + readonly name: string; + readonly webkitRelativePath: string; } declare var File: { @@ -252,7 +252,7 @@ declare var File: { } interface FileList { - length: number; + readonly length: number; item(index: number): File; [index: number]: File; } @@ -263,7 +263,7 @@ declare var FileList: { } interface FileReader extends EventTarget, MSBaseReader { - error: DOMError; + readonly error: DOMError; readAsArrayBuffer(blob: Blob): void; readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; @@ -277,31 +277,31 @@ declare var FileReader: { } interface IDBCursor { - direction: string; + readonly direction: string; key: IDBKeyRange | IDBValidKey; - primaryKey: any; + readonly primaryKey: any; source: IDBObjectStore | IDBIndex; advance(count: number): void; continue(key?: IDBKeyRange | IDBValidKey): void; delete(): IDBRequest; update(value: any): IDBRequest; - NEXT: string; - NEXT_NO_DUPLICATE: string; - PREV: string; - PREV_NO_DUPLICATE: string; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; } declare var IDBCursor: { prototype: IDBCursor; new(): IDBCursor; - NEXT: string; - NEXT_NO_DUPLICATE: string; - PREV: string; - PREV_NO_DUPLICATE: string; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; } interface IDBCursorWithValue extends IDBCursor { - value: any; + readonly value: any; } declare var IDBCursorWithValue: { @@ -310,8 +310,8 @@ declare var IDBCursorWithValue: { } interface IDBDatabase extends EventTarget { - name: string; - objectStoreNames: DOMStringList; + readonly name: string; + readonly objectStoreNames: DOMStringList; onabort: (ev: Event) => any; onerror: (ev: Event) => any; version: number; @@ -344,9 +344,9 @@ declare var IDBFactory: { interface IDBIndex { keyPath: string | string[]; - name: string; - objectStore: IDBObjectStore; - unique: boolean; + readonly name: string; + readonly objectStore: IDBObjectStore; + readonly unique: boolean; multiEntry: boolean; count(key?: IDBKeyRange | IDBValidKey): IDBRequest; get(key: IDBKeyRange | IDBValidKey): IDBRequest; @@ -361,10 +361,10 @@ declare var IDBIndex: { } interface IDBKeyRange { - lower: any; - lowerOpen: boolean; - upper: any; - upperOpen: boolean; + readonly lower: any; + readonly lowerOpen: boolean; + readonly upper: any; + readonly upperOpen: boolean; } declare var IDBKeyRange: { @@ -377,10 +377,10 @@ declare var IDBKeyRange: { } interface IDBObjectStore { - indexNames: DOMStringList; + readonly indexNames: DOMStringList; keyPath: string | string[]; - name: string; - transaction: IDBTransaction; + readonly name: string; + readonly transaction: IDBTransaction; autoIncrement: boolean; add(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; clear(): IDBRequest; @@ -415,13 +415,13 @@ declare var IDBOpenDBRequest: { } interface IDBRequest extends EventTarget { - error: DOMError; + readonly error: DOMError; onerror: (ev: Event) => any; onsuccess: (ev: Event) => any; - readyState: string; - result: any; + readonly readyState: string; + readonly result: any; source: IDBObjectStore | IDBIndex | IDBCursor; - transaction: IDBTransaction; + readonly transaction: IDBTransaction; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -433,17 +433,17 @@ declare var IDBRequest: { } interface IDBTransaction extends EventTarget { - db: IDBDatabase; - error: DOMError; - mode: string; + readonly db: IDBDatabase; + readonly error: DOMError; + readonly mode: string; onabort: (ev: Event) => any; oncomplete: (ev: Event) => any; onerror: (ev: Event) => any; abort(): void; objectStore(name: string): IDBObjectStore; - READ_ONLY: string; - READ_WRITE: string; - VERSION_CHANGE: string; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; @@ -453,14 +453,14 @@ interface IDBTransaction extends EventTarget { declare var IDBTransaction: { prototype: IDBTransaction; new(): IDBTransaction; - READ_ONLY: string; - READ_WRITE: string; - VERSION_CHANGE: string; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; } interface IDBVersionChangeEvent extends Event { - newVersion: number; - oldVersion: number; + readonly newVersion: number; + readonly oldVersion: number; } declare var IDBVersionChangeEvent: { @@ -470,8 +470,8 @@ declare var IDBVersionChangeEvent: { interface ImageData { data: Uint8ClampedArray; - height: number; - width: number; + readonly height: number; + readonly width: number; } declare var ImageData: { @@ -496,23 +496,23 @@ interface MSApp { pageHandlesAllApplicationActivations(enabled: boolean): void; suppressSubdownloadCredentialPrompts(suppress: boolean): void; terminateApp(exceptionObject: any): void; - CURRENT: string; - HIGH: string; - IDLE: string; - NORMAL: string; + readonly CURRENT: string; + readonly HIGH: string; + readonly IDLE: string; + readonly NORMAL: string; } declare var MSApp: MSApp; interface MSAppAsyncOperation extends EventTarget { - error: DOMError; + readonly error: DOMError; oncomplete: (ev: Event) => any; onerror: (ev: Event) => any; - readyState: number; - result: any; + readonly readyState: number; + readonly result: any; start(): void; - COMPLETED: number; - ERROR: number; - STARTED: number; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -521,9 +521,9 @@ interface MSAppAsyncOperation extends EventTarget { declare var MSAppAsyncOperation: { prototype: MSAppAsyncOperation; new(): MSAppAsyncOperation; - COMPLETED: number; - ERROR: number; - STARTED: number; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; } interface MSBlobBuilder { @@ -537,7 +537,7 @@ declare var MSBlobBuilder: { } interface MSStream { - type: string; + readonly type: string; msClose(): void; msDetachStream(): any; } @@ -548,7 +548,7 @@ declare var MSStream: { } interface MSStreamReader extends EventTarget, MSBaseReader { - error: DOMError; + readonly error: DOMError; readAsArrayBuffer(stream: MSStream, size?: number): void; readAsBinaryString(stream: MSStream, size?: number): void; readAsBlob(stream: MSStream, size?: number): void; @@ -563,8 +563,8 @@ declare var MSStreamReader: { } interface MediaQueryList { - matches: boolean; - media: string; + readonly matches: boolean; + readonly media: string; addListener(listener: MediaQueryListListener): void; removeListener(listener: MediaQueryListListener): void; } @@ -575,8 +575,8 @@ declare var MediaQueryList: { } interface MessageChannel { - port1: MessagePort; - port2: MessagePort; + readonly port1: MessagePort; + readonly port2: MessagePort; } declare var MessageChannel: { @@ -585,10 +585,10 @@ declare var MessageChannel: { } interface MessageEvent extends Event { - data: any; - origin: string; - ports: any; - source: any; + readonly data: any; + readonly origin: string; + readonly ports: any; + readonly source: any; initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: any): void; } @@ -612,8 +612,8 @@ declare var MessagePort: { } interface Position { - coords: Coordinates; - timestamp: number; + readonly coords: Coordinates; + readonly timestamp: number; } declare var Position: { @@ -622,26 +622,26 @@ declare var Position: { } interface PositionError { - code: number; - message: string; + readonly code: number; + readonly message: string; toString(): string; - PERMISSION_DENIED: number; - POSITION_UNAVAILABLE: number; - TIMEOUT: number; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; } declare var PositionError: { prototype: PositionError; new(): PositionError; - PERMISSION_DENIED: number; - POSITION_UNAVAILABLE: number; - TIMEOUT: number; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; } interface ProgressEvent extends Event { - lengthComputable: boolean; - loaded: number; - total: number; + readonly lengthComputable: boolean; + readonly loaded: number; + readonly total: number; initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; } @@ -652,21 +652,21 @@ declare var ProgressEvent: { interface WebSocket extends EventTarget { binaryType: string; - bufferedAmount: number; - extensions: string; + readonly bufferedAmount: number; + readonly extensions: string; onclose: (ev: CloseEvent) => any; onerror: (ev: Event) => any; onmessage: (ev: MessageEvent) => any; onopen: (ev: Event) => any; - protocol: string; - readyState: number; - url: string; + readonly protocol: string; + readonly readyState: number; + readonly url: string; close(code?: number, reason?: string): void; send(data: any): void; - CLOSED: number; - CLOSING: number; - CONNECTING: number; - OPEN: number; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; @@ -677,10 +677,10 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; new(url: string, protocols?: string | string[]): WebSocket; - CLOSED: number; - CLOSING: number; - CONNECTING: number; - OPEN: number; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; } interface Worker extends EventTarget, AbstractWorker { @@ -700,15 +700,15 @@ declare var Worker: { interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { msCaching: string; onreadystatechange: (ev: ProgressEvent) => any; - readyState: number; - response: any; - responseText: string; + readonly readyState: number; + readonly response: any; + readonly responseText: string; responseType: string; - responseXML: any; - status: number; - statusText: string; + readonly responseXML: any; + readonly status: number; + readonly statusText: string; timeout: number; - upload: XMLHttpRequestUpload; + readonly upload: XMLHttpRequestUpload; withCredentials: boolean; abort(): void; getAllResponseHeaders(): string; @@ -719,11 +719,11 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { send(data?: string): void; send(data?: any): void; setRequestHeader(header: string, value: string): void; - DONE: number; - HEADERS_RECEIVED: number; - LOADING: number; - OPENED: number; - UNSENT: number; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -738,11 +738,11 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { declare var XMLHttpRequest: { prototype: XMLHttpRequest; new(): XMLHttpRequest; - DONE: number; - HEADERS_RECEIVED: number; - LOADING: number; - OPENED: number; - UNSENT: number; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; create(): XMLHttpRequest; } @@ -768,12 +768,12 @@ interface MSBaseReader { onloadend: (ev: ProgressEvent) => any; onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; - readyState: number; - result: any; + readonly readyState: number; + readonly result: any; abort(): void; - DONE: number; - EMPTY: number; - LOADING: number; + readonly DONE: number; + readonly EMPTY: number; + readonly LOADING: number; addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -784,18 +784,18 @@ interface MSBaseReader { } interface NavigatorID { - appName: string; - appVersion: string; - platform: string; - product: string; - productSub: string; - userAgent: string; - vendor: string; - vendorSub: string; + readonly appName: string; + readonly appVersion: string; + readonly platform: string; + readonly product: string; + readonly productSub: string; + readonly userAgent: string; + readonly vendor: string; + readonly vendorSub: string; } interface NavigatorOnLine { - onLine: boolean; + readonly onLine: boolean; } interface WindowBase64 { @@ -804,7 +804,7 @@ interface WindowBase64 { } interface WindowConsole { - console: Console; + readonly console: Console; } interface XMLHttpRequestEventTarget { @@ -838,9 +838,9 @@ declare var FileReaderSync: { } interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole { - location: WorkerLocation; + readonly location: WorkerLocation; onerror: (ev: Event) => any; - self: WorkerGlobalScope; + readonly self: WorkerGlobalScope; close(): void; msWriteProfilerMark(profilerMarkName: string): void; toString(): string; @@ -855,14 +855,14 @@ declare var WorkerGlobalScope: { } interface WorkerLocation { - hash: string; - host: string; - hostname: string; - href: string; - pathname: string; - port: string; - protocol: string; - search: string; + readonly hash: string; + readonly host: string; + readonly hostname: string; + readonly href: string; + readonly pathname: string; + readonly port: string; + readonly protocol: string; + readonly search: string; toString(): string; } @@ -888,9 +888,9 @@ interface DedicatedWorkerGlobalScope { } interface WorkerUtils extends Object, WindowBase64 { - indexedDB: IDBFactory; - msIndexedDB: IDBFactory; - navigator: WorkerNavigator; + readonly indexedDB: IDBFactory; + readonly msIndexedDB: IDBFactory; + readonly navigator: WorkerNavigator; clearImmediate(handle: number): void; clearInterval(handle: number): void; clearTimeout(handle: number): void; From 26e1d8dee05f1fc3469cace41a35f93e479306bd Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 7 Apr 2016 00:41:40 -0700 Subject: [PATCH 43/48] Added test. --- tests/cases/compiler/useStrictLikePrologueString01.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/cases/compiler/useStrictLikePrologueString01.ts diff --git a/tests/cases/compiler/useStrictLikePrologueString01.ts b/tests/cases/compiler/useStrictLikePrologueString01.ts new file mode 100644 index 00000000000..b76e38ebb06 --- /dev/null +++ b/tests/cases/compiler/useStrictLikePrologueString01.ts @@ -0,0 +1,7 @@ +//@target: commonjs +//@target: es5 + +"hey!" +" use strict " +export function f() { +} \ No newline at end of file From dbaa6e163c5c4576f1c02a344456215c53dea1a7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 7 Apr 2016 00:42:04 -0700 Subject: [PATCH 44/48] Accepted baselines. --- .../reference/useStrictLikePrologueString01.js | 13 +++++++++++++ .../reference/useStrictLikePrologueString01.symbols | 7 +++++++ .../reference/useStrictLikePrologueString01.types | 11 +++++++++++ 3 files changed, 31 insertions(+) create mode 100644 tests/baselines/reference/useStrictLikePrologueString01.js create mode 100644 tests/baselines/reference/useStrictLikePrologueString01.symbols create mode 100644 tests/baselines/reference/useStrictLikePrologueString01.types diff --git a/tests/baselines/reference/useStrictLikePrologueString01.js b/tests/baselines/reference/useStrictLikePrologueString01.js new file mode 100644 index 00000000000..12cec220725 --- /dev/null +++ b/tests/baselines/reference/useStrictLikePrologueString01.js @@ -0,0 +1,13 @@ +//// [useStrictLikePrologueString01.ts] + +"hey!" +" use strict " +export function f() { +} + +//// [useStrictLikePrologueString01.js] +"hey!"; +" use strict "; +function f() { +} +exports.f = f; diff --git a/tests/baselines/reference/useStrictLikePrologueString01.symbols b/tests/baselines/reference/useStrictLikePrologueString01.symbols new file mode 100644 index 00000000000..e96d48d9933 --- /dev/null +++ b/tests/baselines/reference/useStrictLikePrologueString01.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/useStrictLikePrologueString01.ts === + +"hey!" +" use strict " +export function f() { +>f : Symbol(f, Decl(useStrictLikePrologueString01.ts, 2, 14)) +} diff --git a/tests/baselines/reference/useStrictLikePrologueString01.types b/tests/baselines/reference/useStrictLikePrologueString01.types new file mode 100644 index 00000000000..a12dfe3abd3 --- /dev/null +++ b/tests/baselines/reference/useStrictLikePrologueString01.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/useStrictLikePrologueString01.ts === + +"hey!" +>"hey!" : string + +" use strict " +>" use strict " : string + +export function f() { +>f : () => void +} From e9e8837474c3881d93ebe69613b69c5c117888ba Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 7 Apr 2016 00:47:29 -0700 Subject: [PATCH 45/48] Ensure that the entire contents are simply 'use strict'. --- src/compiler/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 469530bb6be..19c32acd5ae 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7651,7 +7651,7 @@ const _super = (function (geti, seti) { } function isUseStrictPrologue(node: ExpressionStatement): boolean { - return !!(node.expression as StringLiteral).text.match(/use strict/); + return (node.expression as StringLiteral).text === "use strict"; } function ensureUseStrictPrologue(startWithNewLine: boolean, writeUseStrict: boolean) { From 1d16356cc603ddcc6f0928fb781dc2bfda69563b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 7 Apr 2016 00:48:11 -0700 Subject: [PATCH 46/48] Accepted baselines. --- tests/baselines/reference/useStrictLikePrologueString01.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/baselines/reference/useStrictLikePrologueString01.js b/tests/baselines/reference/useStrictLikePrologueString01.js index 12cec220725..56df03abfe5 100644 --- a/tests/baselines/reference/useStrictLikePrologueString01.js +++ b/tests/baselines/reference/useStrictLikePrologueString01.js @@ -8,6 +8,7 @@ export function f() { //// [useStrictLikePrologueString01.js] "hey!"; " use strict "; +"use strict"; function f() { } exports.f = f; From 6c735b5cbf889cc703ed6d415d0af972439ddbbf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Apr 2016 07:59:46 -0700 Subject: [PATCH 47/48] Add contextual typing test with `this` specified --- .../reference/thisTypeInFunctions.js | 7 + .../reference/thisTypeInFunctions.symbols | 257 +++++++++--------- .../reference/thisTypeInFunctions.types | 16 ++ .../types/thisType/thisTypeInFunctions.ts | 4 + 4 files changed, 162 insertions(+), 122 deletions(-) diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index 74eba32082b..cfe1706ae99 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -129,6 +129,10 @@ c.explicitC = function(m) { return this.n + m }; c.explicitProperty = function(m) { return this.n + m }; c.explicitThis = function(m) { return this.n + m }; +// this: contextual typing +c.explicitThis = function(this, m) { return this.n + m }; + +// this: superclass compatibility c.explicitC = function(this: B, m: number) { return this.n + m }; // this:void compatibility @@ -314,6 +318,9 @@ c.explicitThis = function (m) { return this.n + m; }; c.explicitC = function (m) { return this.n + m; }; c.explicitProperty = function (m) { return this.n + m; }; c.explicitThis = function (m) { return this.n + m; }; +// this: contextual typing +c.explicitThis = function (m) { return this.n + m; }; +// this: superclass compatibility c.explicitC = function (m) { return this.n + m; }; // this:void compatibility c.explicitVoid = function (n) { return n; }; diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 0d7c8263206..3d4c3f6ecc7 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -560,163 +560,176 @@ c.explicitThis = function(m) { return this.n + m }; >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 26)) +// this: contextual typing +c.explicitThis = function(this, m) { return this.n + m }; +>c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 131, 26)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 131, 31)) +>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) +>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 131, 31)) + +// this: superclass compatibility c.explicitC = function(this: B, m: number) { return this.n + m }; >c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 130, 23)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 134, 23)) >B : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 130, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 31)) >this.n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9)) >this : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) >n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 130, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 31)) // this:void compatibility c.explicitVoid = n => n; >c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) >c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 133, 16)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 133, 16)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 137, 16)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 137, 16)) // class-based assignability class Base1 { ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) x: number; ->x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13)) public polymorphic(this: this): number { return this.x; } ->polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 138, 23)) ->this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 142, 23)) +>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13)) explicit(this: Base1): number { return this.x; } ->explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 139, 13)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 142, 61)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 143, 13)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) +>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13)) static explicitStatic(this: typeof Base1): number { return this.y; } ->explicitStatic : Symbol(Base1.explicitStatic, Decl(thisTypeInFunctions.ts, 139, 52)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 140, 26)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 140, 72)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 140, 72)) +>explicitStatic : Symbol(Base1.explicitStatic, Decl(thisTypeInFunctions.ts, 143, 52)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 144, 26)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) +>this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 144, 72)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) +>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 144, 72)) static y: number; ->y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 140, 72)) +>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 144, 72)) } class Derived1 extends Base1 { ->Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 142, 1)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 146, 1)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) y: number ->y : Symbol(Derived1.y, Decl(thisTypeInFunctions.ts, 143, 30)) +>y : Symbol(Derived1.y, Decl(thisTypeInFunctions.ts, 147, 30)) } class Base2 { ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 149, 1)) y: number ->y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 146, 13)) +>y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 150, 13)) polymorphic(this: this): number { return this.y; } ->polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 148, 16)) ->this.y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 146, 13)) ->this : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) ->y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 146, 13)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 152, 16)) +>this.y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 150, 13)) +>this : Symbol(Base2, Decl(thisTypeInFunctions.ts, 149, 1)) +>y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 150, 13)) explicit(this: Base1): number { return this.x; } ->explicit : Symbol(Base2.explicit, Decl(thisTypeInFunctions.ts, 148, 54)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 149, 13)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) ->x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) +>explicit : Symbol(Base2.explicit, Decl(thisTypeInFunctions.ts, 152, 54)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 153, 13)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) +>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13)) } class Derived2 extends Base2 { ->Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 150, 1)) ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) +>Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 154, 1)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 149, 1)) x: number ->x : Symbol(Derived2.x, Decl(thisTypeInFunctions.ts, 151, 30)) +>x : Symbol(Derived2.x, Decl(thisTypeInFunctions.ts, 155, 30)) } let b1 = new Base1(); ->b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 158, 3)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24)) let b2 = new Base2(); ->b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 155, 3)) ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) +>b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 159, 3)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 149, 1)) let d1 = new Derived1(); ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) ->Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 142, 1)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 160, 3)) +>Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 146, 1)) let d2 = new Derived2(); ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) ->Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 150, 1)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 161, 3)) +>Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 154, 1)) d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } ->d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) ->polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ->d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) ->polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 161, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) +>d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 160, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14)) d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } ->d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) ->polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) ->d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) ->polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 160, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 161, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) // bivariance-allowed cases d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } ->d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) ->polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) ->b2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ->b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 155, 3)) ->polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 160, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14)) +>b2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) +>b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 159, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) d2.polymorphic = d1.explicit // ok, 'y' in { x, y } ->d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) ->polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ->d1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) ->explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 161, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) +>d1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 142, 61)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 160, 3)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 142, 61)) b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } ->b1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) ->b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) ->polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) ->d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) ->polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>b1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 158, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 161, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } ->b1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) ->b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) ->explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) ->d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) ->polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>b1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 142, 61)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 158, 3)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 142, 61)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 161, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13)) ////// use this-type for construction with new //// function InterfaceThis(this: I) { ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 165, 28)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 168, 23)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 169, 28)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 172, 23)) >I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) this.a = 12; @@ -725,60 +738,60 @@ function InterfaceThis(this: I) { >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) } function LiteralTypeThis(this: {x: string}) { ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 170, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 171, 25)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 171, 32)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 174, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 175, 25)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 175, 32)) this.x = "ok"; ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 171, 32)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 171, 30)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 171, 32)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 175, 32)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 175, 30)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 175, 32)) } function AnyThis(this: any) { ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 173, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 174, 17)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 177, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 178, 17)) this.x = "ok"; } let interfaceThis = new InterfaceThis(); ->interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 177, 3)) ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 165, 28)) +>interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 181, 3)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 169, 28)) let literalTypeThis = new LiteralTypeThis(); ->literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 178, 3)) ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 170, 1)) +>literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 182, 3)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 174, 1)) let anyThis = new AnyThis(); ->anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 179, 3)) ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 173, 1)) +>anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 183, 3)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 177, 1)) //// type parameter inference //// declare var f: { ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 182, 11)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 186, 11)) (this: void, x: number): number, ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 183, 5)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 183, 16)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 187, 5)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 187, 16)) call(this: (...argArray: any[]) => U, ...argArray: any[]): U; ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 183, 36)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 184, 9)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 184, 12)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 184, 19)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 184, 9)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 184, 44)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 184, 9)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 187, 36)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 188, 9)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 188, 12)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 188, 19)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 188, 9)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 188, 44)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 188, 9)) }; let n: number = f.call(12); ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 186, 3)) ->f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 183, 36)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 182, 11)) ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 183, 36)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) +>f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 187, 36)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 186, 11)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 187, 36)) function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } ->missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 186, 27)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 188, 34)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 188, 39)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 188, 39)) +>missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 190, 27)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 192, 34)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 192, 39)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 192, 39)) diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 24d3bf9f178..ddef8544a54 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -690,6 +690,22 @@ c.explicitThis = function(m) { return this.n + m }; >n : number >m : number +// this: contextual typing +c.explicitThis = function(this, m) { return this.n + m }; +>c.explicitThis = function(this, m) { return this.n + m } : (this: any, m: number) => number +>c.explicitThis : (this: C, m: number) => number +>c : C +>explicitThis : (this: C, m: number) => number +>function(this, m) { return this.n + m } : (this: any, m: number) => number +>this : C +>m : number +>this.n + m : number +>this.n : number +>this : C +>n : number +>m : number + +// this: superclass compatibility c.explicitC = function(this: B, m: number) { return this.n + m }; >c.explicitC = function(this: B, m: number) { return this.n + m } : (this: B, m: number) => number >c.explicitC : (this: C, m: number) => number diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts index 80f5fce9a97..481e1630092 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts @@ -128,6 +128,10 @@ c.explicitC = function(m) { return this.n + m }; c.explicitProperty = function(m) { return this.n + m }; c.explicitThis = function(m) { return this.n + m }; +// this: contextual typing +c.explicitThis = function(this, m) { return this.n + m }; + +// this: superclass compatibility c.explicitC = function(this: B, m: number) { return this.n + m }; // this:void compatibility From f0a996e6fb9747a97ba1cbafb08e9fd101b28f92 Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 7 Apr 2016 11:17:43 -0700 Subject: [PATCH 48/48] Fix rwc (#7895) * Fix RWC * Fix RWC * Addres PR --- src/compiler/program.ts | 9 --------- src/compiler/utilities.ts | 9 +++++++++ src/harness/fourslash.ts | 4 ++-- src/harness/harness.ts | 15 +++++++-------- src/harness/projectsRunner.ts | 2 +- src/harness/rwcRunner.ts | 4 ++-- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 70c421f9d2b..bbe5505b0a0 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -44,15 +44,6 @@ namespace ts { return compilerOptions.traceModuleResolution && host.trace !== undefined; } - function startsWith(str: string, prefix: string): boolean { - return str.lastIndexOf(prefix, 0) === 0; - } - - function endsWith(str: string, suffix: string): boolean { - const expectedPos = str.length - suffix.length; - return str.indexOf(suffix, expectedPos) === expectedPos; - } - function hasZeroOrOneAsteriskCharacter(str: string): boolean { let seenAsterisk = false; for (let i = 0; i < str.length; i++) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 8f15891fcf7..780a6d615ef 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2927,4 +2927,13 @@ namespace ts { export function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean { return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent); } + + export function startsWith(str: string, prefix: string): boolean { + return str.lastIndexOf(prefix, 0) === 0; + } + + export function endsWith(str: string, suffix: string): boolean { + const expectedPos = str.length - suffix.length; + return str.indexOf(suffix, expectedPos) === expectedPos; + } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2abcee8c6d5..44057cad327 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -221,7 +221,7 @@ namespace FourSlash { function tryAdd(path: string) { const inputFile = inputFiles[path]; - if (inputFile && !Harness.isLibraryFile(path)) { + if (inputFile && !Harness.isDefaultLibraryFile(path)) { languageServiceAdapterHost.addScript(path, inputFile); return true; } @@ -298,7 +298,7 @@ namespace FourSlash { else { // resolveReference file-option is not specified then do not resolve any files and include all inputFiles ts.forEachKey(this.inputFiles, fileName => { - if (!Harness.isLibraryFile(fileName)) { + if (!Harness.isDefaultLibraryFile(fileName)) { this.languageServiceAdapterHost.addScript(fileName, this.inputFiles[fileName]); } }); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index f21167eeeba..d5191566413 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -816,8 +816,7 @@ namespace Harness { }; export function getDefaultLibrarySourceFile(fileName = defaultLibFileName): ts.SourceFile { - if (!isLibraryFile(fileName)) { - assert(!isLibraryFile(fileName), "Expected library fileName"); + if (!isDefaultLibraryFile(fileName)) { return undefined; } @@ -1157,7 +1156,7 @@ namespace Harness { // then they will be added twice thus triggering 'total errors' assertion with condition // 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length - if (!error.file || !isLibraryFile(error.file.fileName)) { + if (!error.file || !isDefaultLibraryFile(error.file.fileName)) { totalErrorsReportedInNonLibraryFiles++; } } @@ -1236,7 +1235,7 @@ namespace Harness { }); const numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => { - return diagnostic.file && (isLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName)); + return diagnostic.file && (isDefaultLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName)); }); const numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => { @@ -1623,10 +1622,10 @@ namespace Harness { } } - // Regex for check if the give filePath is a library file - const libRegex = /lib(\.\S+)*\.d\.ts/; - export function isLibraryFile(filePath: string): boolean { - return !!libRegex.exec(Path.getFileName(filePath)); + export function isDefaultLibraryFile(filePath: string): boolean { + // We need to make sure that the filePath is prefixed with "lib." not just containing "lib." and end with ".d.ts" + const fileName = Path.getFileName(filePath); + return ts.startsWith(fileName, "lib.") && ts.endsWith(fileName, ".d.ts"); } export function isBuiltFile(filePath: string): boolean { diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 6db745bd7a0..3385d0218c3 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -412,7 +412,7 @@ class ProjectRunner extends RunnerBase { function getErrorsBaseline(compilerResult: CompileProjectFilesResult) { const inputFiles = compilerResult.program ? ts.map(ts.filter(compilerResult.program.getSourceFiles(), - sourceFile => !Harness.isLibraryFile(sourceFile.fileName)), + sourceFile => !Harness.isDefaultLibraryFile(sourceFile.fileName)), sourceFile => { return { unitName: ts.isRootedDiskPath(sourceFile.fileName) ? diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 11ed5e7a680..c7127e52834 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -95,13 +95,13 @@ namespace RWC { continue; } - if (!Harness.isLibraryFile(fileRead.path)) { + if (!Harness.isDefaultLibraryFile(fileRead.path)) { if (inInputList) { continue; } otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } - else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)) { + else if (!opts.options.noLib && Harness.isDefaultLibraryFile(fileRead.path)) { if (!inInputList) { // If useCustomLibraryFile is true, we will use lib.d.ts from json object // otherwise use the lib.d.ts from built/local