merge with origin/master

This commit is contained in:
Vladimir Matveev
2016-04-08 14:38:47 -07:00
158 changed files with 10252 additions and 6334 deletions
+2 -8
View File
@@ -166,19 +166,13 @@ var harnessSources = harnessCoreSources.concat([
}));
var es2015LibrarySources = [
"es2015.array.d.ts",
"es2015.core.d.ts",
"es2015.collection.d.ts",
"es2015.function.d.ts",
"es2015.generator.d.ts",
"es2015.iterable.d.ts",
"es2015.math.d.ts",
"es2015.number.d.ts",
"es2015.object.d.ts",
"es2015.promise.d.ts",
"es2015.proxy.d.ts",
"es2015.reflect.d.ts",
"es2015.regexp.d.ts",
"es2015.string.d.ts",
"es2015.symbol.d.ts",
"es2015.symbol.wellknown.d.ts",
];
@@ -209,7 +203,7 @@ var librarySourceMap = [
// JavaScript + all host library
{ target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources), },
{ target: "lib.full.es2015.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources), },
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources), },
].concat(es2015LibrarySourceMap, es2016LibrarySourceMap);
var libraryTargets = librarySourceMap.map(function (f) {
+9
View File
@@ -122,6 +122,7 @@ namespace ts {
let hasAsyncFunctions: boolean;
let hasDecorators: boolean;
let hasParameterDecorators: boolean;
let hasJsxSpreadAttribute: boolean;
// If this file is an external module, then it is automatically in strict-mode according to
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
@@ -161,6 +162,7 @@ namespace ts {
hasAsyncFunctions = false;
hasDecorators = false;
hasParameterDecorators = false;
hasJsxSpreadAttribute = false;
}
return bindSourceFile;
@@ -498,6 +500,9 @@ namespace ts {
if (hasAsyncFunctions) {
flags |= NodeFlags.HasAsyncFunctions;
}
if (hasJsxSpreadAttribute) {
flags |= NodeFlags.HasJsxSpreadAttribute;
}
}
node.flags = flags;
@@ -1298,6 +1303,10 @@ namespace ts {
case SyntaxKind.EnumMember:
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes);
case SyntaxKind.JsxSpreadAttribute:
hasJsxSpreadAttribute = true;
return;
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
+164 -38
View File
@@ -131,8 +131,8 @@ namespace ts {
const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
const anySignature = createSignature(undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
const unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true);
@@ -2299,10 +2299,16 @@ 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);
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) {
if (i > 0 || thisType) {
writePunctuation(writer, SyntaxKind.CommaToken);
writeSpace(writer);
}
@@ -2358,7 +2364,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);
}
@@ -2798,7 +2804,9 @@ namespace ts {
}
}
// Use contextual parameter type if one is available
const type = getContextuallyTypedParameterType(<ParameterDeclaration>declaration);
const type = declaration.symbol.name === "this"
? getContextuallyTypedThisType(func)
: getContextuallyTypedParameterType(<ParameterDeclaration>declaration);
if (type) {
return strictNullChecks && declaration.questionToken ? addNullableKind(type, TypeFlags.Undefined) : type;
}
@@ -2828,11 +2836,16 @@ namespace ts {
// pattern. Otherwise, it is the type any.
function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean): Type {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
const type = checkExpressionCached(element.initializer);
reportErrorsFromWidening(element, type);
return getWidenedType(type);
}
if (isBindingPattern(element.name)) {
return getTypeFromBindingPattern(<BindingPattern>element.name, includePatternInType);
}
if (compilerOptions.noImplicitAny) {
reportImplicitAnyError(element, anyType);
}
return anyType;
}
@@ -3656,12 +3669,13 @@ namespace ts {
resolveObjectTypeMembers(type, source, typeParameters, typeArguments);
}
function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], parameters: Symbol[],
function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], thisType: Type, parameters: Symbol[],
resolvedReturnType: Type, typePredicate: TypePredicate, 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.typePredicate = typePredicate;
sig.minArgumentCount = minArgumentCount;
@@ -3671,7 +3685,7 @@ namespace ts {
}
function cloneSignature(sig: Signature): Signature {
return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType,
return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType,
sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
}
@@ -3679,7 +3693,7 @@ namespace ts {
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct);
if (baseSignatures.length === 0) {
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)];
return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)];
}
const baseTypeNode = getBaseTypeNodeOfClass(classType);
const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode);
@@ -3716,9 +3730,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;
}
}
@@ -3732,7 +3746,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;
}
}
@@ -3741,7 +3755,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;
}
@@ -3762,13 +3776,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;
@@ -4222,6 +4239,8 @@ namespace ts {
const parameters: Symbol[] = [];
let hasStringLiterals = false;
let minArgumentCount = -1;
let thisType: Type = undefined;
let hasThisParameter: boolean;
const isJSConstructSignature = isJSDocConstructSignature(declaration);
let returnType: Type = undefined;
let typePredicate: TypePredicate = undefined;
@@ -4238,7 +4257,13 @@ namespace ts {
const resolvedSymbol = resolveName(param, paramSymbol.name, SymbolFlags.Value, undefined, undefined);
paramSymbol = resolvedSymbol;
}
parameters.push(paramSymbol);
if (i === 0 && paramSymbol.name === "this") {
hasThisParameter = true;
thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType;
}
else {
parameters.push(paramSymbol);
}
if (param.type && param.type.kind === SyntaxKind.StringLiteralType) {
hasStringLiterals = true;
@@ -4246,7 +4271,7 @@ namespace ts {
if (param.initializer || param.questionToken || param.dotDotDotToken) {
if (minArgumentCount < 0) {
minArgumentCount = i;
minArgumentCount = i - (hasThisParameter ? 1 : 0);
}
}
else {
@@ -4256,7 +4281,7 @@ namespace ts {
}
if (minArgumentCount < 0) {
minArgumentCount = declaration.parameters.length;
minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0);
}
if (isJSConstructSignature) {
@@ -4292,7 +4317,7 @@ namespace ts {
}
}
links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, hasRestParameter(declaration), hasStringLiterals);
links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, typePredicate, minArgumentCount, hasRestParameter(declaration), hasStringLiterals);
}
return links.resolvedSignature;
}
@@ -4984,7 +5009,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)) {
@@ -5190,6 +5215,7 @@ namespace ts {
freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper);
}
const result = createSignature(signature.declaration, freshTypeParameters,
signature.thisType && instantiateType(signature.thisType, mapper),
instantiateList(signature.parameters, mapper, instantiateSymbol),
instantiateType(signature.resolvedReturnType, mapper),
freshTypePredicate,
@@ -5358,7 +5384,9 @@ namespace ts {
}
function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration) {
return !node.typeParameters && node.parameters.length && !forEach(node.parameters, p => p.type);
const areAllParametersUntyped = !forEach(node.parameters, p => p.type);
const isNullaryArrow = node.kind === SyntaxKind.ArrowFunction && !node.parameters.length;
return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow;
}
function getTypeWithoutSignatures(type: Type): Type {
@@ -5451,6 +5479,18 @@ namespace ts {
target = getErasedSignature(target);
let result = Ternary.True;
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.The_this_types_of_each_signature_are_incompatible);
}
return Ternary.False;
}
result &= related;
}
const sourceMax = getNumNonRestParameters(source);
const targetMax = getNumNonRestParameters(target);
@@ -6207,7 +6247,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;
}
@@ -6429,7 +6469,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;
@@ -6450,6 +6490,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) : getTypeOfParameter(source.parameters[i]);
@@ -6757,6 +6804,9 @@ namespace ts {
Diagnostics.Rest_parameter_0_implicitly_has_an_any_type :
Diagnostics.Parameter_0_implicitly_has_an_1_type;
break;
case SyntaxKind.BindingElement:
diagnostic = Diagnostics.Binding_element_0_implicitly_has_an_1_type;
break;
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
@@ -6786,29 +6836,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++) {
const s = i < sourceMax ? getTypeOfParameter(source.parameters[i]) : getRestTypeOfSignature(source);
const t = i < targetMax ? getTypeOfParameter(target.parameters[i]) : getRestTypeOfSignature(target);
callback(s, t);
callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
}
}
@@ -8040,7 +8084,24 @@ namespace ts {
if (needToCaptureLexicalThis) {
captureLexicalThis(node, container);
}
if (isFunctionLike(container)) {
const type = getContextuallyTypedThisType(container);
if (type) {
return type;
}
const signature = getSignatureFromDeclaration(container);
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(<ObjectLiteralExpression>container.parent);
if (type) {
return type;
}
}
}
if (isClassLike(container.parent)) {
const symbol = getSymbolOfNode(container.parent);
const type = container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (<InterfaceType>getDeclaredTypeOfSymbol(symbol)).thisType;
@@ -8070,6 +8131,10 @@ namespace ts {
}
}
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);
}
return anyType;
}
@@ -8287,6 +8352,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;
@@ -8696,7 +8774,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;
}
@@ -10066,6 +10144,12 @@ namespace ts {
context.failedTypeParameterIndex = undefined;
}
if (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
// wildcards for all context sensitive function expressions.
const argCount = getEffectiveArgumentCount(node, args, signature);
@@ -10139,6 +10223,20 @@ namespace ts {
}
function checkApplicableSignature(node: CallLikeExpression, args: Expression[], signature: Signature, relation: Map<RelationComparisonResult>, excludeArgument: boolean[], reportErrors: boolean) {
if (signature.thisType && signature.thisType !== voidType && node.kind !== SyntaxKind.NewExpression) {
// 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.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;
}
}
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);
@@ -10158,7 +10256,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;
}
@@ -10168,6 +10265,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 = (<CallExpression>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.
*
@@ -10825,13 +10937,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 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);
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;
}
@@ -12305,6 +12420,17 @@ 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 ((<Identifier>node.name).text === "this") {
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 || func.kind === SyntaxKind.ConstructorType) {
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
// not allowed in a rest parameter, we already have an error from checkGrammarParameterList.
+10 -7
View File
@@ -122,6 +122,11 @@ namespace ts {
type: "boolean",
description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type,
},
{
name: "noImplicitThis",
type: "boolean",
description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
},
{
name: "noLib",
type: "boolean",
@@ -354,6 +359,10 @@ namespace ts {
type: "boolean",
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
},
{
name: "listEmittedFiles",
type: "boolean"
},
{
name: "lib",
type: "list",
@@ -371,19 +380,13 @@ namespace ts {
"webworker": "lib.webworker.d.ts",
"scripthost": "lib.scripthost.d.ts",
// ES2015 Or ESNext By-feature options
"es2015.array": "lib.es2015.array.d.ts",
"es2015.core": "lib.es2015.core.d.ts",
"es2015.collection": "lib.es2015.collection.d.ts",
"es2015.generator": "lib.es2015.generator.d.ts",
"es2015.function": "lib.es2015.function.d.ts",
"es2015.iterable": "lib.es2015.iterable.d.ts",
"es2015.math": "lib.es2015.math.d.ts",
"es2015.number": "lib.es2015.number.d.ts",
"es2015.object": "lib.es2015.object.d.ts",
"es2015.promise": "lib.es2015.promise.d.ts",
"es2015.proxy": "lib.es2015.proxy.d.ts",
"es2015.reflect": "lib.es2015.reflect.d.ts",
"es2015.regexp": "lib.es2015.regexp.d.ts",
"es2015.string": "lib.es2015.string.d.ts",
"es2015.symbol": "lib.es2015.symbol.d.ts",
"es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts",
"es2016.array.include": "lib.es2016.array.include.d.ts"
+5 -2
View File
@@ -35,7 +35,7 @@ namespace ts {
forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile);
return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined);
function getDeclarationDiagnosticsFromFile({ declarationFilePath }, sources: SourceFile[], isBundledEmit: boolean) {
function getDeclarationDiagnosticsFromFile({ declarationFilePath }: EmitFileNames, sources: SourceFile[], isBundledEmit: boolean) {
emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit);
}
}
@@ -530,7 +530,10 @@ namespace ts {
else {
// Expression
const tempVarName = getExportDefaultTempVariableName();
write("declare var ");
if (!noDeclare) {
write("declare ");
}
write("var ");
write(tempVarName);
write(": ");
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
+49 -13
View File
@@ -1879,6 +1879,34 @@
"category": "Error",
"code": 2678
},
"A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'.": {
"category": "Error",
"code": 2679
},
"A 'this' parameter must be the first parameter.": {
"category": "Error",
"code": 2680
},
"A constructor cannot have a 'this' parameter.": {
"category": "Error",
"code": 2681
},
"A setter cannot have a 'this' parameter.": {
"category": "Error",
"code": 2682
},
"'this' implicitly has type 'any' because it does not have a type annotation.": {
"category": "Error",
"code": 2683
},
"The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'.": {
"category": "Error",
"code": 2684
},
"The 'this' types of each signature are incompatible.": {
"category": "Error",
"code": 2685
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
@@ -2637,58 +2665,62 @@
"category": "Error",
"code": 6114
},
"======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========": {
"Raise error on 'this' expressions with an implied 'any' type.": {
"category": "Message",
"code": 6115
},
"Resolving using primary search paths...": {
"======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========": {
"category": "Message",
"code": 6116
},
"Resolving from node_modules folder...": {
"Resolving using primary search paths...": {
"category": "Message",
"code": 6117
},
"======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========": {
"Resolving from node_modules folder...": {
"category": "Message",
"code": 6118
},
"======== Type reference directive '{0}' was not resolved. ========": {
"======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========": {
"category": "Message",
"code": 6119
},
"Resolving with primary search path '{0}'": {
"======== Type reference directive '{0}' was not resolved. ========": {
"category": "Message",
"code": 6120
},
"Root directory cannot be determined, skipping primary search paths.": {
"Resolving with primary search path '{0}'": {
"category": "Message",
"code": 6121
},
"======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========": {
"Root directory cannot be determined, skipping primary search paths.": {
"category": "Message",
"code": 6122
},
"Type declaration files to be included in compilation.": {
"======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========": {
"category": "Message",
"code": 6123
},
"Looking up in 'node_modules' folder, initial location '{0}'": {
"Type declaration files to be included in compilation.": {
"category": "Message",
"code": 6124
},
"Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder.": {
"Looking up in 'node_modules' folder, initial location '{0}'": {
"category": "Message",
"code": 6125
},
"======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========": {
"Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder.": {
"category": "Message",
"code": 6126
},
"======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========": {
"======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========": {
"category": "Message",
"code": 6127
},
"======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========": {
"category": "Message",
"code": 6128
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
"code": 7005
@@ -2777,6 +2809,10 @@
"category": "Error",
"code": 7030
},
"Binding element '{0}' implicitly has an '{1}' type.": {
"category": "Error",
"code": 7031
},
"You cannot rename this element.": {
"category": "Error",
"code": 8000
+35 -6
View File
@@ -345,6 +345,16 @@ var __extends = (this && this.__extends) || function (d, b) {
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};`;
const assignHelper = `
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};`;
// emit output for the __decorate helper function
const decorateHelper = `
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -380,6 +390,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
const languageVersion = getEmitScriptTarget(compilerOptions);
const modulekind = getEmitModuleKind(compilerOptions);
const sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined;
const emittedFilesList: string[] = compilerOptions.listEmittedFiles ? [] : undefined;
const emitterDiagnostics = createDiagnosticCollection();
let emitSkipped = false;
const newLine = host.getNewLine();
@@ -390,6 +401,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
return {
emitSkipped,
diagnostics: emitterDiagnostics.getDiagnostics(),
emittedFiles: emittedFilesList,
sourceMaps: sourceMapDataList
};
@@ -540,6 +552,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
let convertedLoopState: ConvertedLoopState;
let extendsEmitted: boolean;
let assignEmitted: boolean;
let decorateEmitted: boolean;
let paramEmitted: boolean;
let awaiterEmitted: boolean;
@@ -623,6 +636,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
decorateEmitted = false;
paramEmitted = false;
awaiterEmitted = false;
assignEmitted = false;
tempFlags = 0;
tempVariables = undefined;
tempParameters = undefined;
@@ -1259,11 +1273,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
else {
// Either emit one big object literal (no spread attribs), or
// a call to React.__spread
// a call to the __assign helper
const attrs = openingNode.attributes;
if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) {
emitExpressionIdentifier(syntheticReactRef);
write(".__spread(");
write("__assign(");
let haveOpenedObjectLiteral = false;
for (let i = 0; i < attrs.length; i++) {
@@ -4630,8 +4643,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
write("(");
if (node) {
const parameters = node.parameters;
const skipCount = node.parameters.length && (<Identifier>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();
@@ -7651,7 +7665,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) {
@@ -7701,11 +7715,16 @@ const _super = (function (geti, seti) {
if (!compilerOptions.noEmitHelpers) {
// Only Emit __extends function when target ES5.
// For target ES6 and above, we can emit classDeclaration as is.
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) {
if (languageVersion < ScriptTarget.ES6 && !extendsEmitted && node.flags & NodeFlags.HasClassExtends) {
writeLines(extendsHelper);
extendsEmitted = true;
}
if (compilerOptions.jsx !== JsxEmit.Preserve && !assignEmitted && (node.flags & NodeFlags.HasJsxSpreadAttribute)) {
writeLines(assignHelper);
assignEmitted = true;
}
if (!decorateEmitted && node.flags & NodeFlags.HasDecorators) {
writeLines(decorateHelper);
if (compilerOptions.emitDecoratorMetadata) {
@@ -8232,6 +8251,16 @@ const _super = (function (geti, seti) {
if (declarationFilePath) {
emitSkipped = writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped;
}
if (!emitSkipped && emittedFilesList) {
emittedFilesList.push(jsFilePath);
if (sourceMapFilePath) {
emittedFilesList.push(sourceMapFilePath);
}
if (declarationFilePath) {
emittedFilesList.push(declarationFilePath);
}
}
}
}
}
+13 -9
View File
@@ -2010,7 +2010,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) {
@@ -2022,15 +2022,19 @@ namespace ts {
function parseParameter(): ParameterDeclaration {
const node = <ParameterDeclaration>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'
@@ -2068,11 +2072,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();
@@ -2473,7 +2477,7 @@ namespace ts {
// Skip modifiers
parseModifiers();
}
if (isIdentifier()) {
if (isIdentifier() || token === SyntaxKind.ThisKeyword) {
nextToken();
return true;
}
+48 -11
View File
@@ -95,15 +95,6 @@ namespace ts {
return compilerOptions.traceResolution && 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++) {
@@ -768,6 +759,12 @@ namespace ts {
sourceMap: false,
};
interface OutputFingerprint {
hash: string;
byteOrderMark: boolean;
mtime: Date;
}
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
const existingDirectories: Map<boolean> = {};
@@ -818,11 +815,50 @@ namespace ts {
}
}
let outputFingerprints: Map<OutputFingerprint>;
function writeFileIfUpdated(fileName: string, data: string, writeByteOrderMark: boolean): void {
if (!outputFingerprints) {
outputFingerprints = {};
}
const hash = sys.createHash(data);
const mtimeBefore = sys.getModifiedTime(fileName);
if (mtimeBefore && hasProperty(outputFingerprints, fileName)) {
const fingerprint = outputFingerprints[fileName];
// If output has not been changed, and the file has no external modification
if (fingerprint.byteOrderMark === writeByteOrderMark &&
fingerprint.hash === hash &&
fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
return;
}
}
sys.writeFile(fileName, data, writeByteOrderMark);
const mtimeAfter = sys.getModifiedTime(fileName);
outputFingerprints[fileName] = {
hash,
byteOrderMark: writeByteOrderMark,
mtime: mtimeAfter
};
}
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
try {
const start = new Date().getTime();
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
sys.writeFile(fileName, data, writeByteOrderMark);
if (isWatchSet(options) && sys.createHash && sys.getModifiedTime) {
writeFileIfUpdated(fileName, data, writeByteOrderMark);
}
else {
sys.writeFile(fileName, data, writeByteOrderMark);
}
ioWriteTime += new Date().getTime() - start;
}
catch (e) {
@@ -1213,7 +1249,7 @@ namespace ts {
let declarationDiagnostics: Diagnostic[] = [];
if (options.noEmit) {
return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true };
return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };
}
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
@@ -1233,6 +1269,7 @@ namespace ts {
return {
diagnostics: concatenate(diagnostics, declarationDiagnostics),
sourceMaps: undefined,
emittedFiles: undefined,
emitSkipped: true
};
}
+16
View File
@@ -20,6 +20,8 @@ namespace ts {
getExecutingFilePath(): string;
getCurrentDirectory(): string;
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
getModifiedTime?(path: string): Date;
createHash?(data: string): string;
getMemoryUsage?(): number;
exit(exitCode?: number): void;
}
@@ -226,6 +228,7 @@ namespace ts {
const _fs = require("fs");
const _path = require("path");
const _os = require("os");
const _crypto = require("crypto");
// average async stat takes about 30 microseconds
// set chunk size to do 30 files in < 1 millisecond
@@ -584,6 +587,19 @@ namespace ts {
return process.cwd();
},
readDirectory,
getModifiedTime(path) {
try {
return _fs.statSync(path).mtime;
}
catch (e) {
return undefined;
}
},
createHash(data) {
const hash = _crypto.createHash("md5");
hash.update(data);
return hash.digest("hex");
},
getMemoryUsage() {
if (global.gc) {
global.gc();
+18 -10
View File
@@ -14,6 +14,20 @@ namespace ts {
}
}
function reportEmittedFiles(files: string[], host: CompilerHost): void {
if (!files || files.length == 0) {
return;
}
const currentDir = sys.getCurrentDirectory();
for (const file of files) {
const filepath = getNormalizedAbsolutePath(file, currentDir);
sys.write(`TSFILE: ${filepath}${sys.newLine}`);
}
}
/**
* Checks to see if the locale is in the appropriate format,
* and if it is, attempts to set the appropriate language.
@@ -108,7 +122,6 @@ namespace ts {
sys.write(output);
}
const redForegroundEscapeSequence = "\u001b[91m";
const yellowForegroundEscapeSequence = "\u001b[93m";
const blueForegroundEscapeSequence = "\u001b[93m";
@@ -240,11 +253,6 @@ namespace ts {
return typeof JSON === "object" && typeof JSON.parse === "function";
}
function isWatchSet(options: CompilerOptions) {
// Firefox has Object.prototype.watch
return options.watch && options.hasOwnProperty("watch");
}
export function executeCommandLine(args: string[]): void {
const commandLine = parseCommandLine(args);
let configFileName: string; // Configuration file name (if any)
@@ -338,8 +346,7 @@ namespace ts {
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (configFileName) {
const configFilePath = toPath(configFileName, sys.getCurrentDirectory(), createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
configFileWatcher = sys.watchFile(configFilePath, configFileChanged);
configFileWatcher = sys.watchFile(configFileName, configFileChanged);
}
if (sys.watchDirectory && configFileName) {
const directory = ts.getDirectoryPath(configFileName);
@@ -451,8 +458,7 @@ namespace ts {
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
if (sourceFile && isWatchSet(compilerOptions) && sys.watchFile) {
// Attach a file watcher
const filePath = toPath(sourceFile.fileName, sys.getCurrentDirectory(), createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
sourceFile.fileWatcher = sys.watchFile(filePath, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
}
return sourceFile;
}
@@ -604,6 +610,8 @@ namespace ts {
reportDiagnostics(sortAndDeduplicateDiagnostics(diagnostics), compilerHost);
reportEmittedFiles(emitOutput.emittedFiles, compilerHost);
if (emitOutput.emitSkipped && diagnostics.length > 0) {
// If the emitter didn't emit anything, then pass that value along.
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
+6 -1
View File
@@ -405,6 +405,7 @@ namespace ts {
JavaScriptFile = 1 << 27, // If node was parsed in a JavaScript
ThisNodeOrAnySubNodesHasError = 1 << 28, // If this node or any of its children had an error
HasAggregatedChildData = 1 << 29, // If we've computed data from children and cached it in this node
HasJsxSpreadAttribute = 1 << 30,
Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async,
AccessibilityModifier = Public | Private | Protected,
@@ -1712,6 +1713,7 @@ namespace ts {
emitSkipped: boolean;
/** Contains declaration emit diagnostics */
diagnostics: Diagnostic[];
emittedFiles: string[]; // Array of files the compiler wrote to disk
/* @internal */ sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
}
@@ -1781,7 +1783,7 @@ namespace ts {
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: 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;
}
@@ -2283,6 +2285,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 */
@@ -2428,6 +2431,7 @@ namespace ts {
noEmitOnError?: boolean;
noErrorTruncation?: boolean;
noImplicitAny?: boolean;
noImplicitThis?: boolean;
noLib?: boolean;
noResolve?: boolean;
out?: string;
@@ -2462,6 +2466,7 @@ namespace ts {
allowJs?: boolean;
noImplicitUseStrict?: boolean;
strictNullChecks?: boolean;
listEmittedFiles?: boolean;
lib?: string[];
/* @internal */ stripInternal?: boolean;
+58 -1
View File
@@ -217,6 +217,33 @@ namespace ts {
return node.pos;
}
export function getEndLinePosition(line: number, sourceFile: SourceFile): number {
Debug.assert(line >= 0);
const lineStarts = getLineStarts(sourceFile);
const lineIndex = line;
const sourceText = sourceFile.text;
if (lineIndex + 1 === lineStarts.length) {
// last line - return EOF
return sourceText.length - 1;
}
else {
// current line start
const start = lineStarts[lineIndex];
// take the start position of the next line - 1 = it should be some line break
let pos = lineStarts[lineIndex + 1] - 1;
Debug.assert(isLineBreak(sourceText.charCodeAt(pos)));
// walk backwards skipping line breaks, stop the the beginning of current line.
// i.e:
// <some text>
// $ <- end of line for this position should match the start position
while (start <= pos && isLineBreak(sourceText.charCodeAt(pos))) {
pos--;
}
return pos;
}
}
// Returns true if this node is missing from the actual source code. A 'missing' node is different
// from 'undefined/defined'. When a node is undefined (which can happen for optional nodes
// in the tree), it is definitely missing. However, a node may be defined, but still be
@@ -402,6 +429,20 @@ namespace ts {
return createTextSpanFromBounds(start, scanner.getTextPos());
}
function getErrorSpanForArrowFunction(sourceFile: SourceFile, node: ArrowFunction): TextSpan {
const pos = skipTrivia(sourceFile.text, node.pos);
if (node.body && node.body.kind === SyntaxKind.Block) {
const { line: startLine } = getLineAndCharacterOfPosition(sourceFile, node.body.pos);
const { line: endLine } = getLineAndCharacterOfPosition(sourceFile, node.body.end);
if (startLine < endLine) {
// The arrow function spans multiple lines,
// make the error span be the first line, inclusive.
return createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
}
}
return createTextSpanFromBounds(pos, node.end);
}
export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan {
let errorNode = node;
switch (node.kind) {
@@ -430,6 +471,8 @@ namespace ts {
case SyntaxKind.TypeAliasDeclaration:
errorNode = (<Declaration>node).name;
break;
case SyntaxKind.ArrowFunction:
return getErrorSpanForArrowFunction(sourceFile, <ArrowFunction>node);
}
if (errorNode === undefined) {
@@ -2682,11 +2725,16 @@ namespace ts {
}
return carriageReturnLineFeed;
}
export function isWatchSet(options: CompilerOptions) {
// Firefox has Object.prototype.watch
return options.watch && options.hasOwnProperty("watch");
}
}
namespace ts {
export function getDefaultLibFileName(options: CompilerOptions): string {
return options.target === ScriptTarget.ES6 ? "lib.full.es2015.d.ts" : "lib.d.ts";
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
}
export function textSpanEnd(span: TextSpan) {
@@ -2919,4 +2967,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;
}
}
+2 -2
View File
@@ -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, /*isRootFile*/ true);
return true;
}
@@ -302,7 +302,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], /*isRootFile*/ true);
}
});
+7 -8
View File
@@ -821,8 +821,7 @@ namespace Harness {
};
export function getDefaultLibrarySourceFile(fileName = defaultLibFileName): ts.SourceFile {
if (!isLibraryFile(fileName)) {
assert(!isLibraryFile(fileName), "Expected library fileName");
if (!isDefaultLibraryFile(fileName)) {
return undefined;
}
@@ -1167,7 +1166,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++;
}
}
@@ -1246,7 +1245,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 => {
@@ -1634,10 +1633,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 {
+2 -2
View File
@@ -237,8 +237,8 @@ namespace Playback {
), 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(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),
(path: string, contents: string) => noOpReplay("writeFile"));
wrapper.exit = (exitCode) => {
if (recordLog !== undefined) {
+1 -1
View File
@@ -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) ?
+2 -2
View File
@@ -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
+3998 -2941
View File
File diff suppressed because it is too large Load Diff
-67
View File
@@ -1,67 +0,0 @@
interface Array<T> {
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
/**
* Returns the this object after filling the section identified by start and end with value
* @param value value to fill array section with
* @param start index to start filling the array at. If start is negative, it is treated as
* length+start where length is the length of the array.
* @param end index to stop filling the array at. If end is negative, it is treated as
* length+end.
*/
fill(value: T, start?: number, end?: number): T[];
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): T[];
}
interface ArrayConstructor {
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
*/
from<T>(arrayLike: ArrayLike<T>): Array<T>;
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of<T>(...items: T[]): Array<T>;
}
+2 -2
View File
@@ -2,7 +2,7 @@ interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
get(key: K): V | undefined;
has(key: K): boolean;
set(key: K, value?: V): Map<K, V>;
readonly size: number;
@@ -18,7 +18,7 @@ declare var Map: MapConstructor;
interface WeakMap<K, V> {
clear(): void;
delete(key: K): boolean;
get(key: K): V;
get(key: K): V | undefined;
has(key: K): boolean;
set(key: K, value?: V): WeakMap<K, V>;
+483
View File
@@ -0,0 +1,483 @@
declare type PropertyKey = string | number | symbol;
interface Array<T> {
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: T) => boolean, thisArg?: any): number | undefined;
/**
* Returns the this object after filling the section identified by start and end with value
* @param value value to fill array section with
* @param start index to start filling the array at. If start is negative, it is treated as
* length+start where length is the length of the array.
* @param end index to stop filling the array at. If end is negative, it is treated as
* length+end.
*/
fill(value: T, start?: number, end?: number): T[];
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): T[];
}
interface ArrayConstructor {
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
*/
from<T>(arrayLike: ArrayLike<T>): Array<T>;
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of<T>(...items: T[]): Array<T>;
}
interface Function {
/**
* Returns the name of the function. Function names are read-only and can not be changed.
*/
readonly name: string;
}
interface Math {
/**
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
* @param x A numeric expression.
*/
clz32(x: number): number;
/**
* Returns the result of 32-bit multiplication of two numbers.
* @param x First number
* @param y Second number
*/
imul(x: number, y: number): number;
/**
* Returns the sign of the x, indicating whether x is positive, negative or zero.
* @param x The numeric expression to test
*/
sign(x: number): number;
/**
* Returns the base 10 logarithm of a number.
* @param x A numeric expression.
*/
log10(x: number): number;
/**
* Returns the base 2 logarithm of a number.
* @param x A numeric expression.
*/
log2(x: number): number;
/**
* Returns the natural logarithm of 1 + x.
* @param x A numeric expression.
*/
log1p(x: number): number;
/**
* Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
* the natural logarithms).
* @param x A numeric expression.
*/
expm1(x: number): number;
/**
* Returns the hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
cosh(x: number): number;
/**
* Returns the hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
sinh(x: number): number;
/**
* Returns the hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
tanh(x: number): number;
/**
* Returns the inverse hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
acosh(x: number): number;
/**
* Returns the inverse hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
asinh(x: number): number;
/**
* Returns the inverse hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
atanh(x: number): number;
/**
* Returns the square root of the sum of squares of its arguments.
* @param values Values to compute the square root for.
* If no arguments are passed, the result is +0.
* If there is only one argument, the result is the absolute value.
* If any argument is +Infinity or -Infinity, the result is +Infinity.
* If any argument is NaN, the result is NaN.
* If all arguments are either +0 or −0, the result is +0.
*/
hypot(...values: number[] ): number;
/**
* Returns the integral part of the a numeric expression, x, removing any fractional digits.
* If x is already an integer, the result is x.
* @param x A numeric expression.
*/
trunc(x: number): number;
/**
* Returns the nearest single precision float representation of a number.
* @param x A numeric expression.
*/
fround(x: number): number;
/**
* Returns an implementation-dependent approximation to the cube root of number.
* @param x A numeric expression.
*/
cbrt(x: number): number;
}
interface NumberConstructor {
/**
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
* that is representable as a Number value, which is approximately:
* 2.2204460492503130808472633361816 x 10‍−‍16.
*/
readonly EPSILON: number;
/**
* Returns true if passed value is finite.
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
* number. Only finite values of the type number, result in true.
* @param number A numeric value.
*/
isFinite(number: number): boolean;
/**
* Returns true if the value passed is an integer, false otherwise.
* @param number A numeric value.
*/
isInteger(number: number): boolean;
/**
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
* to a number. Only values of the type number, that are also NaN, result in true.
* @param number A numeric value.
*/
isNaN(number: number): boolean;
/**
* Returns true if the value passed is a safe integer.
* @param number A numeric value.
*/
isSafeInteger(number: number): boolean;
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1.
*/
readonly MAX_SAFE_INTEGER: number;
/**
* The value of the smallest integer n such that n and n − 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
*/
readonly MIN_SAFE_INTEGER: number;
/**
* Converts a string to a floating-point number.
* @param string A string that contains a floating-point number.
*/
parseFloat(string: string): number;
/**
* Converts A string to an integer.
* @param s A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
parseInt(string: string, radix?: number): number;
}
interface Object {
/**
* Determines whether an object has a property with the specified name.
* @param v A property name.
*/
hasOwnProperty(v: PropertyKey): boolean
/**
* Determines whether a specified property is enumerable.
* @param v A property name.
*/
propertyIsEnumerable(v: PropertyKey): boolean;
}
interface ObjectConstructor {
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source The source object from which to copy properties.
*/
assign<T, U>(target: T, source: U): T & U;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source1 The first source object from which to copy properties.
* @param source2 The second source object from which to copy properties.
*/
assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source1 The first source object from which to copy properties.
* @param source2 The second source object from which to copy properties.
* @param source3 The third source object from which to copy properties.
*/
assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param sources One or more source objects from which to copy properties
*/
assign(target: any, ...sources: any[]): any;
/**
* Returns an array of all symbol properties found directly on object o.
* @param o Object to retrieve the symbols from.
*/
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
is(value1: any, value2: any): boolean;
/**
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
* @param o The object to change its prototype.
* @param proto The value of the new prototype or null.
*/
setPrototypeOf(o: any, proto: any): any;
/**
* Gets the own property descriptor of the specified object.
* An own property descriptor is one that is defined directly on the object and is not
* inherited from the object's prototype.
* @param o Object that contains the property.
* @param p Name of the property.
*/
getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor;
/**
* Adds a property to an object, or modifies attributes of an existing property.
* @param o Object on which to add or modify the property. This can be a native JavaScript
* object (that is, a user-defined object or a built in object) or a DOM object.
* @param p The property name.
* @param attributes Descriptor for the property. It can be for a data property or an accessor
* property.
*/
defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any;
}
interface RegExp {
/**
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
* The characters in this string are sequenced and concatenated in the following order:
*
* - "g" for global
* - "i" for ignoreCase
* - "m" for multiline
* - "u" for unicode
* - "y" for sticky
*
* If no flags are set, the value is the empty string.
*/
readonly flags: string;
/**
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
* expression. Default is false. Read-only.
*/
readonly sticky: boolean;
/**
* Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
* expression. Default is false. Read-only.
*/
readonly unicode: boolean;
}
interface String {
/**
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
* value of the UTF-16 encoded code point starting at the string element at position pos in
* the String resulting from converting this object to a String.
* If there is no element at that position, the result is undefined.
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
*/
codePointAt(pos: number): number | undefined;
/**
* Returns true if searchString appears as a substring of the result of converting this
* object to a String, at one or more positions that are
* greater than or equal to position; otherwise, returns false.
* @param searchString search string
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
*/
includes(searchString: string, position?: number): boolean;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* endPosition – length(this). Otherwise returns false.
*/
endsWith(searchString: string, endPosition?: number): boolean;
/**
* Returns the String value result of normalizing the string into the normalization form
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
* is "NFC"
*/
normalize(form?: string): string;
/**
* Returns a String value that is made from count copies appended together. If count is 0,
* T is the empty String is returned.
* @param count number of copies to append
*/
repeat(count: number): string;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* position. Otherwise returns false.
*/
startsWith(searchString: string, position?: number): boolean;
/**
* Returns an <a> HTML anchor element and sets the name attribute to the text value
* @param name
*/
anchor(name: string): string;
/** Returns a <big> HTML element */
big(): string;
/** Returns a <blink> HTML element */
blink(): string;
/** Returns a <b> HTML element */
bold(): string;
/** Returns a <tt> HTML element */
fixed(): string
/** Returns a <font> HTML element and sets the color attribute value */
fontcolor(color: string): string
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: number): string;
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: string): string;
/** Returns an <i> HTML element */
italics(): string;
/** Returns an <a> HTML element and sets the href attribute value */
link(url: string): string;
/** Returns a <small> HTML element */
small(): string;
/** Returns a <strike> HTML element */
strike(): string;
/** Returns a <sub> HTML element */
sub(): string;
/** Returns a <sup> HTML element */
sup(): string;
}
interface StringConstructor {
/**
* Return the String value whose elements are, in order, the elements in the List elements.
* If length is 0, the empty string is returned.
*/
fromCodePoint(...codePoints: number[]): string;
/**
* String.raw is intended for use as a tag function of a Tagged Template String. When called
* as such the first argument will be a well formed template call site object and the rest
* parameter will contain the substitution values.
* @param template A well-formed template string call site representation.
* @param substitutions A set of substitution values.
*/
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
}
+1 -7
View File
@@ -1,16 +1,10 @@
/// <reference path="lib.es2015.array.d.ts" />
/// <reference path="lib.es2015.core.d.ts" />
/// <reference path="lib.es2015.collection.d.ts" />
/// <reference path="lib.es2015.function.d.ts" />
/// <reference path="lib.es2015.generator.d.ts" />
/// <reference path="lib.es2015.iterable.d.ts" />
/// <reference path="lib.es2015.math.d.ts" />
/// <reference path="lib.es2015.number.d.ts" />
/// <reference path="lib.es2015.object.d.ts" />
/// <reference path="lib.es2015.promise.d.ts" />
/// <reference path="lib.es2015.proxy.d.ts" />
/// <reference path="lib.es2015.reflect.d.ts" />
/// <reference path="lib.es2015.regexp.d.ts" />
/// <reference path="lib.es2015.string.d.ts" />
/// <reference path="lib.es2015.symbol.d.ts" />
/// <reference path="lib.es2015.symbol.wellknown.d.ts" />
/// <reference path="lib.es5.d.ts" />
-6
View File
@@ -1,6 +0,0 @@
interface Function {
/**
* Returns the name of the function. Function names are read-only and can not be changed.
*/
readonly name: string;
}
-111
View File
@@ -1,111 +0,0 @@
interface Math {
/**
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
* @param x A numeric expression.
*/
clz32(x: number): number;
/**
* Returns the result of 32-bit multiplication of two numbers.
* @param x First number
* @param y Second number
*/
imul(x: number, y: number): number;
/**
* Returns the sign of the x, indicating whether x is positive, negative or zero.
* @param x The numeric expression to test
*/
sign(x: number): number;
/**
* Returns the base 10 logarithm of a number.
* @param x A numeric expression.
*/
log10(x: number): number;
/**
* Returns the base 2 logarithm of a number.
* @param x A numeric expression.
*/
log2(x: number): number;
/**
* Returns the natural logarithm of 1 + x.
* @param x A numeric expression.
*/
log1p(x: number): number;
/**
* Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
* the natural logarithms).
* @param x A numeric expression.
*/
expm1(x: number): number;
/**
* Returns the hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
cosh(x: number): number;
/**
* Returns the hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
sinh(x: number): number;
/**
* Returns the hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
tanh(x: number): number;
/**
* Returns the inverse hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
acosh(x: number): number;
/**
* Returns the inverse hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
asinh(x: number): number;
/**
* Returns the inverse hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
atanh(x: number): number;
/**
* Returns the square root of the sum of squares of its arguments.
* @param values Values to compute the square root for.
* If no arguments are passed, the result is +0.
* If there is only one argument, the result is the absolute value.
* If any argument is +Infinity or -Infinity, the result is +Infinity.
* If any argument is NaN, the result is NaN.
* If all arguments are either +0 or −0, the result is +0.
*/
hypot(...values: number[] ): number;
/**
* Returns the integral part of the a numeric expression, x, removing any fractional digits.
* If x is already an integer, the result is x.
* @param x A numeric expression.
*/
trunc(x: number): number;
/**
* Returns the nearest single precision float representation of a number.
* @param x A numeric expression.
*/
fround(x: number): number;
/**
* Returns an implementation-dependent approximation to the cube root of number.
* @param x A numeric expression.
*/
cbrt(x: number): number;
}
-65
View File
@@ -1,65 +0,0 @@
interface NumberConstructor {
/**
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
* that is representable as a Number value, which is approximately:
* 2.2204460492503130808472633361816 x 10‍−‍16.
*/
readonly EPSILON: number;
/**
* Returns true if passed value is finite.
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
* number. Only finite values of the type number, result in true.
* @param number A numeric value.
*/
isFinite(number: number): boolean;
/**
* Returns true if the value passed is an integer, false otherwise.
* @param number A numeric value.
*/
isInteger(number: number): boolean;
/**
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
* to a number. Only values of the type number, that are also NaN, result in true.
* @param number A numeric value.
*/
isNaN(number: number): boolean;
/**
* Returns true if the value passed is a safe integer.
* @param number A numeric value.
*/
isSafeInteger(number: number): boolean;
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1.
*/
readonly MAX_SAFE_INTEGER: number;
/**
* The value of the smallest integer n such that n and n − 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
*/
readonly MIN_SAFE_INTEGER: number;
/**
* Converts a string to a floating-point number.
* @param string A string that contains a floating-point number.
*/
parseFloat(string: string): number;
/**
* Converts A string to an integer.
* @param s A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
parseInt(string: string, radix?: number): number;
}
-89
View File
@@ -1,89 +0,0 @@
interface Object {
/**
* Determines whether an object has a property with the specified name.
* @param v A property name.
*/
hasOwnProperty(v: PropertyKey): boolean
/**
* Determines whether a specified property is enumerable.
* @param v A property name.
*/
propertyIsEnumerable(v: PropertyKey): boolean;
}
interface ObjectConstructor {
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source The source object from which to copy properties.
*/
assign<T, U>(target: T, source: U): T & U;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source1 The first source object from which to copy properties.
* @param source2 The second source object from which to copy properties.
*/
assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param source1 The first source object from which to copy properties.
* @param source2 The second source object from which to copy properties.
* @param source3 The third source object from which to copy properties.
*/
assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param sources One or more source objects from which to copy properties
*/
assign(target: any, ...sources: any[]): any;
/**
* Returns an array of all symbol properties found directly on object o.
* @param o Object to retrieve the symbols from.
*/
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
is(value1: any, value2: any): boolean;
/**
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
* @param o The object to change its prototype.
* @param proto The value of the new prototype or null.
*/
setPrototypeOf(o: any, proto: any): any;
/**
* Gets the own property descriptor of the specified object.
* An own property descriptor is one that is defined directly on the object and is not
* inherited from the object's prototype.
* @param o Object that contains the property.
* @param p Name of the property.
*/
getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor;
/**
* Adds a property to an object, or modifies attributes of an existing property.
* @param o Object on which to add or modify the property. This can be a native JavaScript
* object (that is, a user-defined object or a built in object) or a DOM object.
* @param p The property name.
* @param attributes Descriptor for the property. It can be for a data property or an accessor
* property.
*/
defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any;
}
-27
View File
@@ -1,27 +0,0 @@
interface RegExp {
/**
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
* The characters in this string are sequenced and concatenated in the following order:
*
* - "g" for global
* - "i" for ignoreCase
* - "m" for multiline
* - "u" for unicode
* - "y" for sticky
*
* If no flags are set, the value is the empty string.
*/
readonly flags: string;
/**
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
* expression. Default is false. Read-only.
*/
readonly sticky: boolean;
/**
* Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
* expression. Default is false. Read-only.
*/
readonly unicode: boolean;
}
-110
View File
@@ -1,110 +0,0 @@
interface String {
/**
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
* value of the UTF-16 encoded code point starting at the string element at position pos in
* the String resulting from converting this object to a String.
* If there is no element at that position, the result is undefined.
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
*/
codePointAt(pos: number): number;
/**
* Returns true if searchString appears as a substring of the result of converting this
* object to a String, at one or more positions that are
* greater than or equal to position; otherwise, returns false.
* @param searchString search string
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
*/
includes(searchString: string, position?: number): boolean;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* endPosition – length(this). Otherwise returns false.
*/
endsWith(searchString: string, endPosition?: number): boolean;
/**
* Returns the String value result of normalizing the string into the normalization form
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
* is "NFC"
*/
normalize(form?: string): string;
/**
* Returns a String value that is made from count copies appended together. If count is 0,
* T is the empty String is returned.
* @param count number of copies to append
*/
repeat(count: number): string;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* position. Otherwise returns false.
*/
startsWith(searchString: string, position?: number): boolean;
/**
* Returns an <a> HTML anchor element and sets the name attribute to the text value
* @param name
*/
anchor(name: string): string;
/** Returns a <big> HTML element */
big(): string;
/** Returns a <blink> HTML element */
blink(): string;
/** Returns a <b> HTML element */
bold(): string;
/** Returns a <tt> HTML element */
fixed(): string
/** Returns a <font> HTML element and sets the color attribute value */
fontcolor(color: string): string
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: number): string;
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: string): string;
/** Returns an <i> HTML element */
italics(): string;
/** Returns an <a> HTML element and sets the href attribute value */
link(url: string): string;
/** Returns a <small> HTML element */
small(): string;
/** Returns a <strike> HTML element */
strike(): string;
/** Returns a <sub> HTML element */
sub(): string;
/** Returns a <sup> HTML element */
sup(): string;
}
interface StringConstructor {
/**
* Return the String value whose elements are, in order, the elements in the List elements.
* If length is 0, the empty string is returned.
*/
fromCodePoint(...codePoints: number[]): string;
/**
* String.raw is intended for use as a tag function of a Tagged Template String. When called
* as such the first argument will be a well formed template call site object and the rest
* parameter will contain the substitution values.
* @param template A well-formed template string call site representation.
* @param substitutions A set of substitution values.
*/
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
}
+1 -1
View File
@@ -30,7 +30,7 @@ interface SymbolConstructor {
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/
keyFor(sym: symbol): string;
keyFor(sym: symbol): string | undefined;
}
declare var Symbol: SymbolConstructor;
+2 -2
View File
@@ -176,7 +176,7 @@ interface RegExp {
* that search.
* @param string A string to search within.
*/
[Symbol.match](string: string): RegExpMatchArray;
[Symbol.match](string: string): RegExpMatchArray | null;
/**
* Replaces text in a string, using this regular expression.
@@ -230,7 +230,7 @@ interface String {
* Matches a string an object that supports being matched against, and returns an array containing the results of that search.
* @param matcher An object that supports being matched against.
*/
match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray;
match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null;
/**
* Replaces text in a string, using an object that supports replacement within a string.
+6 -5
View File
@@ -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<T, U>(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<T, U>(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<T, U>(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;
readonly length: number;
@@ -1247,8 +1250,6 @@ interface TypedPropertyDescriptor<T> {
set?: (value: T) => void;
}
declare type PropertyKey = string | number | symbol;
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
-2217
View File
File diff suppressed because it is too large Load Diff
+265 -265
View File
@@ -13,10 +13,12 @@ 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;
}
@@ -26,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;
@@ -39,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;
}
@@ -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;
@@ -79,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: {
@@ -94,7 +98,7 @@ declare var Coordinates: {
}
interface DOMError {
name: string;
readonly name: string;
toString(): string;
}
@@ -104,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;
@@ -182,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;
}
@@ -196,39 +200,39 @@ 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 {
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: {
@@ -237,8 +241,9 @@ declare var EventTarget: {
}
interface File extends Blob {
lastModifiedDate: any;
name: string;
readonly lastModifiedDate: any;
readonly name: string;
readonly webkitRelativePath: string;
}
declare var File: {
@@ -247,7 +252,7 @@ declare var File: {
}
interface FileList {
length: number;
readonly length: number;
item(index: number): File;
[index: number]: File;
}
@@ -258,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;
@@ -272,31 +277,31 @@ declare var FileReader: {
}
interface IDBCursor {
direction: string;
key: any;
primaryKey: any;
readonly direction: string;
key: IDBKeyRange | IDBValidKey;
readonly 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;
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: {
@@ -305,15 +310,17 @@ 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;
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;
@@ -337,15 +344,15 @@ 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?: 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: {
@@ -354,37 +361,37 @@ 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: {
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 {
indexNames: DOMStringList;
readonly indexNames: DOMStringList;
keyPath: string | string[];
name: string;
transaction: IDBTransaction;
readonly name: string;
readonly 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: {
@@ -408,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;
@@ -426,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;
@@ -446,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: {
@@ -463,8 +470,8 @@ declare var IDBVersionChangeEvent: {
interface ImageData {
data: Uint8ClampedArray;
height: number;
width: number;
readonly height: number;
readonly width: number;
}
declare var ImageData: {
@@ -483,29 +490,29 @@ 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<any>;
getViewId(view: any): any;
isTaskScheduledAtPriorityOrHigher(priority: string): boolean;
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;
@@ -514,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 {
@@ -530,7 +537,7 @@ declare var MSBlobBuilder: {
}
interface MSStream {
type: string;
readonly type: string;
msClose(): void;
msDetachStream(): any;
}
@@ -541,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;
@@ -556,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;
}
@@ -568,8 +575,8 @@ declare var MediaQueryList: {
}
interface MessageChannel {
port1: MessagePort;
port2: MessagePort;
readonly port1: MessagePort;
readonly port2: MessagePort;
}
declare var MessageChannel: {
@@ -578,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;
}
@@ -605,8 +612,8 @@ declare var MessagePort: {
}
interface Position {
coords: Coordinates;
timestamp: number;
readonly coords: Coordinates;
readonly timestamp: number;
}
declare var Position: {
@@ -615,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;
}
@@ -645,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;
@@ -670,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 {
@@ -693,16 +700,15 @@ declare var Worker: {
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
msCaching: string;
onreadystatechange: (ev: ProgressEvent) => any;
readyState: number;
response: any;
responseBody: 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;
@@ -713,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;
@@ -732,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;
}
@@ -762,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;
@@ -778,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 {
@@ -798,7 +804,7 @@ interface WindowBase64 {
}
interface WindowConsole {
console: Console;
readonly console: Console;
}
interface XMLHttpRequestEventTarget {
@@ -832,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;
@@ -849,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;
}
@@ -882,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;
@@ -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<IDBValidKey> {
}
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;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
type IDBValidKey = number | string | Date | IDBArrayKey;
+17 -4
View File
@@ -742,6 +742,7 @@ namespace ts {
declaration: SignatureDeclaration;
typeParameters: TypeParameter[];
parameters: Symbol[];
thisType: Type;
resolvedReturnType: Type;
minArgumentCount: number;
hasRestParameter: boolean;
@@ -4123,6 +4124,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;
@@ -4185,6 +4189,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
@@ -4195,7 +4200,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 = (<PropertyAccessExpression>location.parent).name;
@@ -4306,7 +4311,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)
@@ -4448,11 +4453,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
+1 -1
View File
@@ -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 {
-26
View File
@@ -6,32 +6,6 @@ namespace ts {
list: Node;
}
export function getEndLinePosition(line: number, sourceFile: SourceFile): number {
Debug.assert(line >= 0);
let lineStarts = sourceFile.getLineStarts();
let lineIndex = line;
if (lineIndex + 1 === lineStarts.length) {
// last line - return EOF
return sourceFile.text.length - 1;
}
else {
// current line start
let start = lineStarts[lineIndex];
// take the start position of the next line -1 = it should be some line break
let pos = lineStarts[lineIndex + 1] - 1;
Debug.assert(isLineBreak(sourceFile.text.charCodeAt(pos)));
// walk backwards skipping line breaks, stop the the beginning of current line.
// i.e:
// <some text>
// $ <- end of line for this position should match the start position
while (start <= pos && isLineBreak(sourceFile.text.charCodeAt(pos))) {
pos--;
}
return pos;
}
}
export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number {
let lineStarts = sourceFile.getLineStarts();
let line = sourceFile.getLineAndCharacterOfPosition(position).line;
@@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]];
interface myArray extends Array<Number> { }
>myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
interface myArray2 extends Array<Number|String> { }
>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.string.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[]
>d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3))
@@ -0,0 +1,111 @@
tests/cases/compiler/arrowFunctionErrorSpan.ts(4,3): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(7,3): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(12,3): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(17,3): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(18,5): error TS1200: Line terminator not permitted before arrow.
tests/cases/compiler/arrowFunctionErrorSpan.ts(21,3): error TS2345: Argument of type '(a: any, b: any, c: any, d: any) => void' is not assignable to parameter of type '() => number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(28,7): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(32,7): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(36,7): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(43,5): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(52,3): error TS2345: Argument of type '(_: any) => number' is not assignable to parameter of type '() => number'.
==== tests/cases/compiler/arrowFunctionErrorSpan.ts (11 errors) ====
function f(a: () => number) { }
// oneliner
f(() => { });
~~~~~~~~~
!!! error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
!!! error TS2345: Type 'void' is not assignable to type 'number'.
// multiline, body
f(() => {
~~~~~~~
!!! error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
!!! error TS2345: Type 'void' is not assignable to type 'number'.
});
// multiline 2, body
f(() => {
~~~~~~~
!!! error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
!!! error TS2345: Type 'void' is not assignable to type 'number'.
});
// multiline 3, arrow on a new line
f(()
~~
=> { });
~~~~~~~~~~
!!! error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
!!! error TS2345: Type 'void' is not assignable to type 'number'.
~~
!!! error TS1200: Line terminator not permitted before arrow.
// multiline 4, arguments
f((a,
~~~
b,
~~~~~~
c,
~~~~~~
d) => { });
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: any, b: any, c: any, d: any) => void' is not assignable to parameter of type '() => number'.
// single line with a comment
f(/*
*/() => { });
~~~~~~~~~
!!! error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
!!! error TS2345: Type 'void' is not assignable to type 'number'.
// multi line with a comment
f(/*
*/() => { });
~~~~~~~~~
!!! error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
!!! error TS2345: Type 'void' is not assignable to type 'number'.
// multi line with a comment 2
f(/*
*/() => {
~~~~~~~~
!!! error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
!!! error TS2345: Type 'void' is not assignable to type 'number'.
});
// multi line with a comment 3
f( // comment 1
// comment 2
() =>
~~~~~
!!! error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
!!! error TS2345: Type 'void' is not assignable to type 'number'.
// comment 3
{
// comment 4
}
// comment 5
);
// body is not a block
f(_ => 1 +
~~~~~~~~
2);
~~~~~
!!! error TS2345: Argument of type '(_: any) => number' is not assignable to parameter of type '() => number'.
@@ -0,0 +1,89 @@
//// [arrowFunctionErrorSpan.ts]
function f(a: () => number) { }
// oneliner
f(() => { });
// multiline, body
f(() => {
});
// multiline 2, body
f(() => {
});
// multiline 3, arrow on a new line
f(()
=> { });
// multiline 4, arguments
f((a,
b,
c,
d) => { });
// single line with a comment
f(/*
*/() => { });
// multi line with a comment
f(/*
*/() => { });
// multi line with a comment 2
f(/*
*/() => {
});
// multi line with a comment 3
f( // comment 1
// comment 2
() =>
// comment 3
{
// comment 4
}
// comment 5
);
// body is not a block
f(_ => 1 +
2);
//// [arrowFunctionErrorSpan.js]
function f(a) { }
// oneliner
f(function () { });
// multiline, body
f(function () {
});
// multiline 2, body
f(function () {
});
// multiline 3, arrow on a new line
f(function () { });
// multiline 4, arguments
f(function (a, b, c, d) { });
// single line with a comment
f(/*
*/ function () { });
// multi line with a comment
f(/*
*/ function () { });
// multi line with a comment 2
f(/*
*/ function () {
});
// multi line with a comment 3
f(// comment 1
// comment 2
function () {
// comment 4
});
// body is not a block
f(function (_) { return 1 +
2; });
@@ -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 '{ <T, U>(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'.
!!! error TS2322: Type 'number' is not assignable to type '{ <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }'.
@@ -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)
}
@@ -9,13 +9,13 @@ class C {
>other : () => void
var fn = async () => await other.apply(this, arguments);
>fn : () => Promise<any>
>async () => await other.apply(this, arguments) : () => Promise<any>
>await other.apply(this, arguments) : any
>other.apply(this, arguments) : any
>other.apply : (thisArg: any, argArray?: any) => any
>fn : () => Promise<void>
>async () => await other.apply(this, arguments) : () => Promise<void>
>await other.apply(this, arguments) : void
>other.apply(this, arguments) : void
>other.apply : { <T, U>(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 : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
>this : this
>arguments : IArguments
}
@@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc");
>a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3))
(<Function>xa[1].foo)(...[1, 2, "abc"]);
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.function.d.ts, --, --))
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13))
>xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3))
>foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13))
@@ -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
@@ -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
@@ -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;
}
};
@@ -9,6 +9,7 @@ var v = {
get bar(): number {
>bar : Symbol(bar, Decl(commentsOnObjectLiteral4.ts, 1, 9))
return this._bar;
return 12;
}
}
@@ -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
}
}
@@ -1,11 +1,11 @@
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 '{ (): number; (i: number): number; }' is not assignable to type '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: 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 '{ (): number; (i: number): number; }' is not assignable to type 'string'.
@@ -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;
@@ -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))
};
@@ -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
};
@@ -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))
};
@@ -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
};
@@ -0,0 +1,19 @@
//// [pi.ts]
export default 3.14159;
//// [pi.js]
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters:[],
execute: function() {
exports_1("default",3.14159);
}
}
});
//// [pi.d.ts]
declare var _default: number;
export default _default;
@@ -0,0 +1,3 @@
=== tests/cases/compiler/pi.ts ===
export default 3.14159;
No type information for this code.
@@ -0,0 +1,3 @@
=== tests/cases/compiler/pi.ts ===
export default 3.14159;
No type information for this code.
@@ -0,0 +1,22 @@
//// [pi.ts]
export default 3.14159;
//// [app.js]
System.register("pi", [], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters:[],
execute: function() {
exports_1("default",3.14159);
}
}
});
//// [app.d.ts]
declare module "pi" {
var _default: number;
export default _default;
}
@@ -0,0 +1,4 @@
=== tests/cases/compiler/pi.ts ===
No type information for this code.export default 3.14159;
No type information for this code.
@@ -0,0 +1,4 @@
=== tests/cases/compiler/pi.ts ===
No type information for this code.export default 3.14159;
No type information for this code.
@@ -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: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'.
Property 'a' is missing in type '{ m(): this is Foo; }'.
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts (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: 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;
}
}
@@ -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: Type '{ m(): this is Foo; }' cannot be converted to type 'Foo'.
Property 'a' is missing in type '{ m(): this is Foo; }'.
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (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: 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;
}
}
@@ -8,18 +8,18 @@
type arrayString = Array<String>
>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.string.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
type someArray = Array<String> | number[];
>someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.string.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
type stringOrNumArray = Array<String|Number>;
>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.string.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
function a1(...x: (number|string)[]) { }
@@ -33,8 +33,8 @@ function a2(...a) { }
function a3(...a: Array<String>) { }
>a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21))
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.string.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
function a4(...a: arrayString) { }
>a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36))
@@ -8,18 +8,18 @@
type arrayString = Array<String>
>arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.string.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
type someArray = Array<String> | number[];
>someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.string.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
type stringOrNumArray = Array<String|Number>;
>stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.string.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
function a1(...x: (number|string)[]) { }
@@ -33,8 +33,8 @@ function a2(...a) { }
function a3(...a: Array<String>) { }
>a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21))
>a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.string.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
function a4(...a: arrayString) { }
>a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36))
@@ -5,7 +5,7 @@ function f() {
if (Math.random()) {
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.math.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
let arguments = 100;
@@ -8,7 +8,7 @@ function f() {
if (Math.random()) {
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.math.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
const arguments = 100;
@@ -8,7 +8,7 @@ function f() {
if (Math.random()) {
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.math.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
return () => arguments[0];
@@ -9,7 +9,7 @@ function f() {
if (Math.random()) {
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.math.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
return () => arguments[0];
@@ -10,7 +10,7 @@ function f() {
if (Math.random()) {
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.math.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
return () => arguments;
@@ -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))
},
@@ -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
},
@@ -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, --, --))
@@ -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 : { <T, U>(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 : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; }
>4 : number
@@ -30,13 +30,10 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(70,11): error
};
var f3 = () => {
~~~~~~~
return '';
~~~~~~~~~~~~~~
return 3;
~~~~~~~~~~~~~
};
~
!!! error TS2354: No best common type exists among return expressions.
return '';
return 3;
};
// FunctionExpression with no return type annotation with return branch of number[] and other of string[]
var f4 = function () {
@@ -94,13 +91,10 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(70,11): error
};
var f10 = () => {
~~~~~~~
return new Derived1();
~~~~~~~~~~~~~~~~~~~~~~~~~~
return new Derived2();
~~~~~~~~~~~~~~~~~~~~~~~~~~
};
~
!!! error TS2354: No best common type exists among return expressions.
return new Derived1();
return new Derived2();
};
function f11() {
~~~
!!! error TS2354: No best common type exists among return expressions.
@@ -115,11 +109,8 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(70,11): error
};
var f13 = () => {
~~~~~~~
return new Base();
~~~~~~~~~~~~~~~~~~~~~~
return new AnotherClass();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
};
~
!!! error TS2354: No best common type exists among return expressions.
return new Base();
return new AnotherClass();
};
@@ -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, --, --))
+3 -3
View File
@@ -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 : { <T, U>(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 : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
>"hello" : string
>[] : undefined[]
@@ -24,9 +24,9 @@ function compose<A, B, C>(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))
};
@@ -26,10 +26,10 @@ function compose<A, B, C>(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 : { <T, U>(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 : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
>null : null
>a : A
@@ -15,7 +15,7 @@ export class BrokenClass {
return new Promise<Array<MyModule.MyModel>>((resolve, reject) => {
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))
>MyModel : Symbol(MyModule.MyModel, Decl(mymodule.ts, 0, 0))
>resolve : Symbol(resolve, Decl(file1.ts, 8, 47))
@@ -23,7 +23,7 @@ export class BrokenClass {
let result: Array<MyModule.MyModel> = [];
>result : Symbol(result, Decl(file1.ts, 10, 7))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))
>MyModel : Symbol(MyModule.MyModel, Decl(mymodule.ts, 0, 0))
@@ -72,7 +72,7 @@ export class BrokenClass {
.then((orders: Array<MyModule.MyModel>) => {
>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>orders : Symbol(orders, Decl(file1.ts, 23, 13))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))
>MyModel : Symbol(MyModule.MyModel, Decl(mymodule.ts, 0, 0))
@@ -0,0 +1,66 @@
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'.
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: 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'.
==== tests/cases/conformance/types/thisType/looseThisTypeInFunctions.ts (4 errors) ====
interface I {
n: number;
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 '(this: void, m: number) => number'.
!!! error TS2322: The 'this' types of each signature are incompatible.
!!! error TS2322: Type 'void' is not assignable to type 'C'.
let o = {
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'
~~~~~~
!!! 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
~~~~~
!!! 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
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
~~~~~~
!!! error TS2339: Property 'length' does not exist on type 'number'.
}
@@ -0,0 +1,92 @@
//// [looseThisTypeInFunctions.ts]
interface I {
n: number;
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 = {
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;
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;
i.explicitThis = function(m) {
return this.n.length; // error, this.n: number
}
//// [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 = {
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;
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;
i.explicitThis = function (m) {
return this.n.length; // error, this.n: number
};
@@ -1,20 +1,12 @@
error TS2318: Cannot find global type 'Boolean'.
error TS2318: Cannot find global type 'Function'.
error TS2318: Cannot find global type 'IArguments'.
error TS2318: Cannot find global type 'Number'.
error TS2318: Cannot find global type 'Object'.
error TS2318: Cannot find global type 'RegExp'.
error TS2318: Cannot find global type 'String'.
tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts(4,12): error TS2304: Cannot find name 'Array'.
!!! error TS2318: Cannot find global type 'Boolean'.
!!! error TS2318: Cannot find global type 'Function'.
!!! error TS2318: Cannot find global type 'IArguments'.
!!! error TS2318: Cannot find global type 'Number'.
!!! error TS2318: Cannot find global type 'Object'.
!!! error TS2318: Cannot find global type 'RegExp'.
!!! error TS2318: Cannot find global type 'String'.
==== tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts (1 errors) ====
// Error missing basic JavaScript objects
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 2, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -38,9 +38,9 @@ function Baz() { }
>Baz : Symbol(Baz, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 12, 9))
Baz.name;
>Baz.name : Symbol(Function.name, Decl(lib.es2015.function.d.ts, --, --))
>Baz.name : Symbol(Function.name, Decl(lib.es2015.core.d.ts, --, --))
>Baz : Symbol(Baz, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 12, 9))
>name : Symbol(Function.name, Decl(lib.es2015.function.d.ts, --, --))
>name : Symbol(Function.name, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 generator
function* gen() {
@@ -79,9 +79,9 @@ function* gen2() {
// Using ES6 math
Math.sign(1);
>Math.sign : Symbol(Math.sign, Decl(lib.es2015.math.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.math.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>sign : Symbol(Math.sign, Decl(lib.es2015.math.d.ts, --, --))
>Math.sign : Symbol(Math.sign, Decl(lib.es2015.core.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>sign : Symbol(Math.sign, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 object
var o = {
@@ -100,9 +100,9 @@ var o = {
}
};
o.hasOwnProperty(Symbol.hasInstance);
>o.hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.object.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>o.hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>o : Symbol(o, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 39, 3))
>hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.object.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
@@ -148,21 +148,21 @@ Reflect.isExtensible({});
// Using Es6 regexp
var reg = new RegExp("/s");
>reg : Symbol(reg, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 65, 3))
>RegExp : Symbol(RegExp, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.regexp.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>RegExp : Symbol(RegExp, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
reg.flags;
>reg.flags : Symbol(RegExp.flags, Decl(lib.es2015.regexp.d.ts, --, --))
>reg.flags : Symbol(RegExp.flags, Decl(lib.es2015.core.d.ts, --, --))
>reg : Symbol(reg, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 65, 3))
>flags : Symbol(RegExp.flags, Decl(lib.es2015.regexp.d.ts, --, --))
>flags : Symbol(RegExp.flags, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 string
var str = "Hello world";
>str : Symbol(str, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 69, 3))
str.includes("hello", 0);
>str.includes : Symbol(String.includes, Decl(lib.es2015.string.d.ts, --, --))
>str.includes : Symbol(String.includes, Decl(lib.es2015.core.d.ts, --, --))
>str : Symbol(str, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 69, 3))
>includes : Symbol(String.includes, Decl(lib.es2015.string.d.ts, --, --))
>includes : Symbol(String.includes, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 symbol
var s = Symbol();
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 2, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -38,9 +38,9 @@ function Baz() { }
>Baz : Symbol(Baz, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 12, 9))
Baz.name;
>Baz.name : Symbol(Function.name, Decl(lib.es2015.function.d.ts, --, --))
>Baz.name : Symbol(Function.name, Decl(lib.es2015.core.d.ts, --, --))
>Baz : Symbol(Baz, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 12, 9))
>name : Symbol(Function.name, Decl(lib.es2015.function.d.ts, --, --))
>name : Symbol(Function.name, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 generator
function* gen() {
@@ -79,9 +79,9 @@ function* gen2() {
// Using ES6 math
Math.sign(1);
>Math.sign : Symbol(Math.sign, Decl(lib.es2015.math.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.math.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>sign : Symbol(Math.sign, Decl(lib.es2015.math.d.ts, --, --))
>Math.sign : Symbol(Math.sign, Decl(lib.es2015.core.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>sign : Symbol(Math.sign, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 object
var o = {
@@ -100,9 +100,9 @@ var o = {
}
};
o.hasOwnProperty(Symbol.hasInstance);
>o.hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.object.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>o.hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>o : Symbol(o, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 39, 3))
>hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.object.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
@@ -148,21 +148,21 @@ Reflect.isExtensible({});
// Using Es6 regexp
var reg = new RegExp("/s");
>reg : Symbol(reg, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 65, 3))
>RegExp : Symbol(RegExp, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.regexp.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>RegExp : Symbol(RegExp, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
reg.flags;
>reg.flags : Symbol(RegExp.flags, Decl(lib.es2015.regexp.d.ts, --, --))
>reg.flags : Symbol(RegExp.flags, Decl(lib.es2015.core.d.ts, --, --))
>reg : Symbol(reg, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 65, 3))
>flags : Symbol(RegExp.flags, Decl(lib.es2015.regexp.d.ts, --, --))
>flags : Symbol(RegExp.flags, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 string
var str = "Hello world";
>str : Symbol(str, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 69, 3))
str.includes("hello", 0);
>str.includes : Symbol(String.includes, Decl(lib.es2015.string.d.ts, --, --))
>str.includes : Symbol(String.includes, Decl(lib.es2015.core.d.ts, --, --))
>str : Symbol(str, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 69, 3))
>includes : Symbol(String.includes, Decl(lib.es2015.string.d.ts, --, --))
>includes : Symbol(String.includes, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 symbol
var s = Symbol();
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 2, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -38,9 +38,9 @@ function Baz() { }
>Baz : Symbol(Baz, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 12, 9))
Baz.name;
>Baz.name : Symbol(Function.name, Decl(lib.es2015.function.d.ts, --, --))
>Baz.name : Symbol(Function.name, Decl(lib.es2015.core.d.ts, --, --))
>Baz : Symbol(Baz, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 12, 9))
>name : Symbol(Function.name, Decl(lib.es2015.function.d.ts, --, --))
>name : Symbol(Function.name, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 generator
function* gen() {
@@ -79,9 +79,9 @@ function* gen2() {
// Using ES6 math
Math.sign(1);
>Math.sign : Symbol(Math.sign, Decl(lib.es2015.math.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.math.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>sign : Symbol(Math.sign, Decl(lib.es2015.math.d.ts, --, --))
>Math.sign : Symbol(Math.sign, Decl(lib.es2015.core.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>sign : Symbol(Math.sign, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 object
var o = {
@@ -100,9 +100,9 @@ var o = {
}
};
o.hasOwnProperty(Symbol.hasInstance);
>o.hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.object.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>o.hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>o : Symbol(o, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 39, 3))
>hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.object.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
@@ -148,21 +148,21 @@ Reflect.isExtensible({});
// Using Es6 regexp
var reg = new RegExp("/s");
>reg : Symbol(reg, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 65, 3))
>RegExp : Symbol(RegExp, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.regexp.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>RegExp : Symbol(RegExp, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
reg.flags;
>reg.flags : Symbol(RegExp.flags, Decl(lib.es2015.regexp.d.ts, --, --))
>reg.flags : Symbol(RegExp.flags, Decl(lib.es2015.core.d.ts, --, --))
>reg : Symbol(reg, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 65, 3))
>flags : Symbol(RegExp.flags, Decl(lib.es2015.regexp.d.ts, --, --))
>flags : Symbol(RegExp.flags, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 string
var str = "Hello world";
>str : Symbol(str, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 69, 3))
str.includes("hello", 0);
>str.includes : Symbol(String.includes, Decl(lib.es2015.string.d.ts, --, --))
>str.includes : Symbol(String.includes, Decl(lib.es2015.core.d.ts, --, --))
>str : Symbol(str, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 69, 3))
>includes : Symbol(String.includes, Decl(lib.es2015.string.d.ts, --, --))
>includes : Symbol(String.includes, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 symbol
var s = Symbol();
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 2, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -38,15 +38,15 @@ function Baz() { }
>Baz : Symbol(Baz, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 12, 9))
Baz.name;
>Baz.name : Symbol(Function.name, Decl(lib.es2015.function.d.ts, --, --))
>Baz.name : Symbol(Function.name, Decl(lib.es2015.core.d.ts, --, --))
>Baz : Symbol(Baz, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 12, 9))
>name : Symbol(Function.name, Decl(lib.es2015.function.d.ts, --, --))
>name : Symbol(Function.name, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 math
Math.sign(1);
>Math.sign : Symbol(Math.sign, Decl(lib.es2015.math.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.math.d.ts, --, --))
>sign : Symbol(Math.sign, Decl(lib.es2015.math.d.ts, --, --))
>Math.sign : Symbol(Math.sign, Decl(lib.es2015.core.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>sign : Symbol(Math.sign, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 object
var o = {
@@ -65,9 +65,9 @@ var o = {
}
};
o.hasOwnProperty(Symbol.hasInstance);
>o.hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.object.d.ts, --, --))
>o.hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>o : Symbol(o, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 22, 3))
>hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.object.d.ts, --, --))
>hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
@@ -90,21 +90,21 @@ Reflect.isExtensible({});
// Using Es6 regexp
var reg = new RegExp("/s");
>reg : Symbol(reg, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 38, 3))
>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.regexp.d.ts, --, --))
>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
reg.flags;
>reg.flags : Symbol(RegExp.flags, Decl(lib.es2015.regexp.d.ts, --, --))
>reg.flags : Symbol(RegExp.flags, Decl(lib.es2015.core.d.ts, --, --))
>reg : Symbol(reg, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 38, 3))
>flags : Symbol(RegExp.flags, Decl(lib.es2015.regexp.d.ts, --, --))
>flags : Symbol(RegExp.flags, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 string
var str = "Hello world";
>str : Symbol(str, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 42, 3))
str.includes("hello", 0);
>str.includes : Symbol(String.includes, Decl(lib.es2015.string.d.ts, --, --))
>str.includes : Symbol(String.includes, Decl(lib.es2015.core.d.ts, --, --))
>str : Symbol(str, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 42, 3))
>includes : Symbol(String.includes, Decl(lib.es2015.string.d.ts, --, --))
>includes : Symbol(String.includes, Decl(lib.es2015.core.d.ts, --, --))
// Using ES6 symbol
var s = Symbol();
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_UsingES5LibAndES6ArrayLib.ts, 2, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.ts, 1, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.array.d.ts, --, --), Decl(lib.es2015.array.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -0,0 +1,55 @@
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(1,14): error TS7031: Binding element 'a' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(1,19): error TS7031: Binding element 'b' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(1,23): error TS7006: Parameter 'c' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(1,26): error TS7006: Parameter 'd' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(3,14): error TS7031: Binding element 'a' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(3,31): error TS7031: Binding element 'b' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(3,42): error TS7006: Parameter 'c' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(3,57): error TS7006: Parameter 'd' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(7,20): error TS7008: Member 'b' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(7,30): error TS7008: Member 'b' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,14): error TS7031: Binding element 'a1' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,34): error TS7031: Binding element 'b1' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,54): error TS7006: Parameter 'c1' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,70): error TS7006: Parameter 'd1' implicitly has an 'any' type.
==== tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts (14 errors) ====
function f1([a], {b}, c, d) { // error
~
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
~
!!! error TS7031: Binding element 'b' implicitly has an 'any' type.
~
!!! error TS7006: Parameter 'c' implicitly has an 'any' type.
~
!!! error TS7006: Parameter 'd' implicitly has an 'any' type.
}
function f2([a = undefined], {b = null}, c = undefined, d = null) { // error
~
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
~
!!! error TS7031: Binding element 'b' implicitly has an 'any' type.
~~~~~~~~~~~~~
!!! error TS7006: Parameter 'c' implicitly has an 'any' type.
~~~~~~~~
!!! error TS7006: Parameter 'd' implicitly has an 'any' type.
}
function f3([a]: [any], {b}: { b: any }, c: any, d: any) {
}
function f4({b}: { b }, x: { b }) { // error in type instead
~
!!! error TS7008: Member 'b' implicitly has an 'any' type.
~
!!! error TS7008: Member 'b' implicitly has an 'any' type.
}
function f5([a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null) { // error
~~
!!! error TS7031: Binding element 'a1' implicitly has an 'any' type.
~~
!!! error TS7031: Binding element 'b1' implicitly has an 'any' type.
~~~~~~~~~~~~~~
!!! error TS7006: Parameter 'c1' implicitly has an 'any' type.
~~~~~~~~~
!!! error TS7006: Parameter 'd1' implicitly has an 'any' type.
}
@@ -0,0 +1,36 @@
//// [noImplicitAnyDestructuringParameterDeclaration.ts]
function f1([a], {b}, c, d) { // error
}
function f2([a = undefined], {b = null}, c = undefined, d = null) { // error
}
function f3([a]: [any], {b}: { b: any }, c: any, d: any) {
}
function f4({b}: { b }, x: { b }) { // error in type instead
}
function f5([a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null) { // error
}
//// [noImplicitAnyDestructuringParameterDeclaration.js]
function f1(_a, _b, c, d) {
var a = _a[0];
var b = _b.b;
}
function f2(_a, _b, c, d) {
var _c = _a[0], a = _c === void 0 ? undefined : _c;
var _d = _b.b, b = _d === void 0 ? null : _d;
if (c === void 0) { c = undefined; }
if (d === void 0) { d = null; }
}
function f3(_a, _b, c, d) {
var a = _a[0];
var b = _b.b;
}
function f4(_a, x) {
var b = _a.b;
}
function f5(_a, _b, c1, d1) {
var a1 = (_a === void 0 ? [undefined] : _a)[0];
var b1 = (_b === void 0 ? { b1: null } : _b).b1;
if (c1 === void 0) { c1 = undefined; }
if (d1 === void 0) { d1 = null; }
}
@@ -0,0 +1,69 @@
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(1,5): error TS1182: A destructuring declaration must have an initializer.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(1,6): error TS7031: Binding element 'a' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(1,10): error TS1182: A destructuring declaration must have an initializer.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(1,11): error TS7031: Binding element 'b' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(1,15): error TS7005: Variable 'c' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(1,18): error TS7005: Variable 'd' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(3,5): error TS1182: A destructuring declaration must have an initializer.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(3,6): error TS7031: Binding element 'a1' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(3,23): error TS1182: A destructuring declaration must have an initializer.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(3,24): error TS7031: Binding element 'b1' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(3,36): error TS7005: Variable 'c1' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(3,52): error TS7005: Variable 'd1' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(5,5): error TS1182: A destructuring declaration must have an initializer.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(5,18): error TS1182: A destructuring declaration must have an initializer.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(7,5): error TS1182: A destructuring declaration must have an initializer.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(7,13): error TS7008: Member 'b3' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(7,25): error TS7008: Member 'b3' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,6): error TS7031: Binding element 'a1' implicitly has an 'any' type.
tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,26): error TS7031: Binding element 'b1' implicitly has an 'any' type.
==== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts (19 errors) ====
var [a], {b}, c, d; // error
~~~
!!! error TS1182: A destructuring declaration must have an initializer.
~
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
~~~
!!! error TS1182: A destructuring declaration must have an initializer.
~
!!! error TS7031: Binding element 'b' implicitly has an 'any' type.
~
!!! error TS7005: Variable 'c' implicitly has an 'any' type.
~
!!! error TS7005: Variable 'd' implicitly has an 'any' type.
var [a1 = undefined], {b1 = null}, c1 = undefined, d1 = null; // error
~~~~~~~~~~~~~~~~
!!! error TS1182: A destructuring declaration must have an initializer.
~~
!!! error TS7031: Binding element 'a1' implicitly has an 'any' type.
~~~~~~~~~~~
!!! error TS1182: A destructuring declaration must have an initializer.
~~
!!! error TS7031: Binding element 'b1' implicitly has an 'any' type.
~~
!!! error TS7005: Variable 'c1' implicitly has an 'any' type.
~~
!!! error TS7005: Variable 'd1' implicitly has an 'any' type.
var [a2]: [any], {b2}: { b2: any }, c2: any, d2: any;
~~~~
!!! error TS1182: A destructuring declaration must have an initializer.
~~~~
!!! error TS1182: A destructuring declaration must have an initializer.
var {b3}: { b3 }, c3: { b3 }; // error in type instead
~~~~
!!! error TS1182: A destructuring declaration must have an initializer.
~~
!!! error TS7008: Member 'b3' implicitly has an 'any' type.
~~
!!! error TS7008: Member 'b3' implicitly has an 'any' type.
var [a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null; // error
~~
!!! error TS7031: Binding element 'a1' implicitly has an 'any' type.
~~
!!! error TS7031: Binding element 'b1' implicitly has an 'any' type.
@@ -0,0 +1,17 @@
//// [noImplicitAnyDestructuringVarDeclaration.ts]
var [a], {b}, c, d; // error
var [a1 = undefined], {b1 = null}, c1 = undefined, d1 = null; // error
var [a2]: [any], {b2}: { b2: any }, c2: any, d2: any;
var {b3}: { b3 }, c3: { b3 }; // error in type instead
var [a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null; // error
//// [noImplicitAnyDestructuringVarDeclaration.js]
var a = (void 0)[0], b = (void 0).b, c, d; // error
var _a = (void 0)[0], a1 = _a === void 0 ? undefined : _a, _b = (void 0).b1, b1 = _b === void 0 ? null : _b, c1 = undefined, d1 = null; // error
var a2 = (void 0)[0], b2 = (void 0).b2, c2, d2;
var b3 = (void 0).b3, c3; // error in type instead
var a1 = [undefined][0], b1 = { b1: null }.b1, c1 = undefined, d1 = null; // error
@@ -0,0 +1,28 @@
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) ====
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 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 TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
@@ -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;
}
// error: `this` is `window`, but is still of type `any`
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;
}
// error: `this` is `window`, but is still of type `any`
var f4 = function (b) { return _this.c + b; };
@@ -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, --, --))
@@ -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 : { <T, U>(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 : { <T, U>(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 : { <T, U>(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 : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
@@ -39,16 +39,13 @@ tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,14):
var result3: string = foo(x => { // x has type D
~~~~~~~~~~~~~~~~~~~~~~
var y: G<typeof x>; // error that D does not satisfy constraint, y is of type G<D>, entire call to foo is an error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
return y;
~~~~~~~~~~~~~
});
~
!!! error TS2345: Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
!!! error TS2345: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2345: Type 'B' is not assignable to type 'D'.
!!! error TS2345: Property 'q' is missing in type 'B'.
var y: G<typeof x>; // error that D does not satisfy constraint, y is of type G<D>, entire call to foo is an error
~~~~~~~~
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
return y;
});
@@ -13,8 +13,16 @@ declare var x: any;
//// [reactNamespaceJSXEmit.js]
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
myReactLib.createElement("foo", {data: true});
myReactLib.createElement(Bar, {x: x});
myReactLib.createElement("x-component", null);
myReactLib.createElement(Bar, myReactLib.__spread({}, x));
myReactLib.createElement(Bar, myReactLib.__spread({}, x, {y: 2}));
myReactLib.createElement(Bar, __assign({}, x));
myReactLib.createElement(Bar, __assign({}, x, {y: 2}));
@@ -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))

Some files were not shown because too many files have changed in this diff Show More