Merge pull request #4910 from Microsoft/polymorphicThisType

Polymorphic 'this' type
This commit is contained in:
Anders Hejlsberg 2015-09-30 13:18:33 -07:00
Родитель a4db4be4b6 82c010e12a
Коммит cbe2f3df64
235 изменённых файлов: 4259 добавлений и 2160 удалений

Просмотреть файл

@ -88,6 +88,7 @@ namespace ts {
let container: Node;
let blockScopeContainer: Node;
let lastContainer: Node;
let seenThisKeyword: 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
@ -329,7 +330,14 @@ namespace ts {
blockScopeContainer.locals = undefined;
}
forEachChild(node, bind);
if (node.kind === SyntaxKind.InterfaceDeclaration) {
seenThisKeyword = false;
forEachChild(node, bind);
node.flags = seenThisKeyword ? node.flags | NodeFlags.ContainsThis : node.flags & ~NodeFlags.ContainsThis;
}
else {
forEachChild(node, bind);
}
container = saveContainer;
parent = saveParent;
@ -851,6 +859,9 @@ namespace ts {
return checkStrictModePrefixUnaryExpression(<PrefixUnaryExpression>node);
case SyntaxKind.WithStatement:
return checkStrictModeWithStatement(<WithStatement>node);
case SyntaxKind.ThisKeyword:
seenThisKeyword = true;
return;
case SyntaxKind.TypeParameter:
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes);

Просмотреть файл

@ -38,6 +38,7 @@ namespace ts {
let Signature = objectAllocator.getSignatureConstructor();
let typeCount = 0;
let symbolCount = 0;
let emptyArray: any[] = [];
let emptySymbols: SymbolTable = {};
@ -54,7 +55,7 @@ namespace ts {
let checker: TypeChecker = {
getNodeCount: () => sum(host.getSourceFiles(), "nodeCount"),
getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"),
getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount"),
getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount,
getTypeCount: () => typeCount,
isUndefinedSymbol: symbol => symbol === undefinedSymbol,
isArgumentsSymbol: symbol => symbol === argumentsSymbol,
@ -243,6 +244,7 @@ namespace ts {
}
function createSymbol(flags: SymbolFlags, name: string): Symbol {
symbolCount++;
return new Symbol(flags, name);
}
@ -1587,6 +1589,7 @@ namespace ts {
function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) {
let globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike;
let inObjectTypeLiteral = false;
return writeType(type, globalFlags);
function writeType(type: Type, flags: TypeFormatFlags) {
@ -1597,6 +1600,12 @@ namespace ts {
? "any"
: (<IntrinsicType>type).intrinsicName);
}
else if (type.flags & TypeFlags.ThisType) {
if (inObjectTypeLiteral) {
writer.reportInaccessibleThisError();
}
writer.writeKeyword("this");
}
else if (type.flags & TypeFlags.Reference) {
writeTypeReference(<TypeReference>type, flags);
}
@ -1640,11 +1649,10 @@ namespace ts {
}
}
function writeSymbolTypeReference(symbol: Symbol, typeArguments: Type[], pos: number, end: number) {
// Unnamed function expressions, arrow functions, and unnamed class expressions have reserved names that
// we don't want to display
if (!isReservedMemberName(symbol.name)) {
buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Type);
function writeSymbolTypeReference(symbol: Symbol, typeArguments: Type[], pos: number, end: number, flags: TypeFormatFlags) {
// Unnamed function expressions and arrow functions have reserved names that we don't want to display
if (symbol.flags & SymbolFlags.Class || !isReservedMemberName(symbol.name)) {
buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, flags);
}
if (pos < end) {
writePunctuation(writer, SyntaxKind.LessThanToken);
@ -1659,7 +1667,7 @@ namespace ts {
}
function writeTypeReference(type: TypeReference, flags: TypeFormatFlags) {
let typeArguments = type.typeArguments;
let typeArguments = type.typeArguments || emptyArray;
if (type.target === globalArrayType && !(flags & TypeFormatFlags.WriteArrayAsGenericType)) {
writeType(typeArguments[0], TypeFormatFlags.InElementType);
writePunctuation(writer, SyntaxKind.OpenBracketToken);
@ -1683,12 +1691,13 @@ namespace ts {
// When type parameters are their own type arguments for the whole group (i.e. we have
// the default outer type arguments), we don't show the group.
if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) {
writeSymbolTypeReference(parent, typeArguments, start, i);
writeSymbolTypeReference(parent, typeArguments, start, i, flags);
writePunctuation(writer, SyntaxKind.DotToken);
}
}
}
writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length);
let typeParameterCount = (type.target.typeParameters || emptyArray).length;
writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags);
}
}
@ -1811,6 +1820,8 @@ namespace ts {
}
}
let saveInObjectTypeLiteral = inObjectTypeLiteral;
inObjectTypeLiteral = true;
writePunctuation(writer, SyntaxKind.OpenBraceToken);
writer.writeLine();
writer.increaseIndent();
@ -1883,6 +1894,7 @@ namespace ts {
}
writer.decreaseIndent();
writePunctuation(writer, SyntaxKind.CloseBraceToken);
inObjectTypeLiteral = saveInObjectTypeLiteral;
}
}
@ -2884,6 +2896,31 @@ namespace ts {
}
}
// Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is
// true if the interface itself contains no references to "this" in its body, if all base types are interfaces,
// and if none of the base interfaces have a "this" type.
function isIndependentInterface(symbol: Symbol): boolean {
for (let declaration of symbol.declarations) {
if (declaration.kind === SyntaxKind.InterfaceDeclaration) {
if (declaration.flags & NodeFlags.ContainsThis) {
return false;
}
let baseTypeNodes = getInterfaceBaseTypeNodes(<InterfaceDeclaration>declaration);
if (baseTypeNodes) {
for (let node of baseTypeNodes) {
if (isSupportedExpressionWithTypeArguments(node)) {
let baseSymbol = resolveEntityName(node.expression, SymbolFlags.Type, /*ignoreErrors*/ true);
if (!baseSymbol || !(baseSymbol.flags & SymbolFlags.Interface) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
return false;
}
}
}
}
}
}
return true;
}
function getDeclaredTypeOfClassOrInterface(symbol: Symbol): InterfaceType {
let links = getSymbolLinks(symbol);
if (!links.declaredType) {
@ -2891,7 +2928,12 @@ namespace ts {
let type = links.declaredType = <InterfaceType>createObjectType(kind, symbol);
let outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol);
let localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
if (outerTypeParameters || localTypeParameters) {
// A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type
// because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular,
// property types inferred from initializers and method return types inferred from return statements are very hard
// to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of
// "this" references.
if (outerTypeParameters || localTypeParameters || kind === TypeFlags.Class || !isIndependentInterface(symbol)) {
type.flags |= TypeFlags.Reference;
type.typeParameters = concatenate(outerTypeParameters, localTypeParameters);
type.outerTypeParameters = outerTypeParameters;
@ -2900,6 +2942,9 @@ namespace ts {
(<GenericType>type).instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
(<GenericType>type).target = <GenericType>type;
(<GenericType>type).typeArguments = type.typeParameters;
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
type.thisType.symbol = symbol;
type.thisType.constraint = getTypeWithThisArgument(type);
}
}
return <InterfaceType>links.declaredType;
@ -2984,6 +3029,82 @@ namespace ts {
return unknownType;
}
// A type reference is considered independent if each type argument is considered independent.
function isIndependentTypeReference(node: TypeReferenceNode): boolean {
if (node.typeArguments) {
for (let typeNode of node.typeArguments) {
if (!isIndependentType(typeNode)) {
return false;
}
}
}
return true;
}
// A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string
// literal type, an array with an element type that is considered independent, or a type reference that is
// considered independent.
function isIndependentType(node: TypeNode): boolean {
switch (node.kind) {
case SyntaxKind.AnyKeyword:
case SyntaxKind.StringKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.StringLiteral:
return true;
case SyntaxKind.ArrayType:
return isIndependentType((<ArrayTypeNode>node).elementType);
case SyntaxKind.TypeReference:
return isIndependentTypeReference(<TypeReferenceNode>node);
}
return false;
}
// A variable-like declaration is considered independent (free of this references) if it has a type annotation
// that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any).
function isIndependentVariableLikeDeclaration(node: VariableLikeDeclaration): boolean {
return node.type && isIndependentType(node.type) || !node.type && !node.initializer;
}
// A function-like declaration is considered independent (free of this references) if it has a return type
// annotation that is considered independent and if each parameter is considered independent.
function isIndependentFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean {
if (node.kind !== SyntaxKind.Constructor && (!node.type || !isIndependentType(node.type))) {
return false;
}
for (let parameter of node.parameters) {
if (!isIndependentVariableLikeDeclaration(parameter)) {
return false;
}
}
return true;
}
// Returns true if the class or interface member given by the symbol is free of "this" references. The
// function may return false for symbols that are actually free of "this" references because it is not
// feasible to perform a complete analysis in all cases. In particular, property members with types
// inferred from their initializers and function members with inferred return types are convervatively
// assumed not to be free of "this" references.
function isIndependentMember(symbol: Symbol): boolean {
if (symbol.declarations && symbol.declarations.length === 1) {
let declaration = symbol.declarations[0];
if (declaration) {
switch (declaration.kind) {
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
return isIndependentVariableLikeDeclaration(<VariableLikeDeclaration>declaration);
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.Constructor:
return isIndependentFunctionLikeDeclaration(<FunctionLikeDeclaration>declaration);
}
}
}
return false;
}
function createSymbolTable(symbols: Symbol[]): SymbolTable {
let result: SymbolTable = {};
for (let symbol of symbols) {
@ -2992,10 +3113,12 @@ namespace ts {
return result;
}
function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper): SymbolTable {
// The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true,
// we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation.
function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable {
let result: SymbolTable = {};
for (let symbol of symbols) {
result[symbol.name] = instantiateSymbol(symbol, mapper);
result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper);
}
return result;
}
@ -3028,44 +3151,57 @@ namespace ts {
return <InterfaceTypeWithDeclaredMembers>type;
}
function resolveClassOrInterfaceMembers(type: InterfaceType): void {
let target = resolveDeclaredMembers(type);
let members = target.symbol.members;
let callSignatures = target.declaredCallSignatures;
let constructSignatures = target.declaredConstructSignatures;
let stringIndexType = target.declaredStringIndexType;
let numberIndexType = target.declaredNumberIndexType;
let baseTypes = getBaseTypes(target);
function getTypeWithThisArgument(type: ObjectType, thisArgument?: Type) {
if (type.flags & TypeFlags.Reference) {
return createTypeReference((<TypeReference>type).target,
concatenate((<TypeReference>type).typeArguments, [thisArgument || (<TypeReference>type).target.thisType]));
}
return type;
}
function resolveObjectTypeMembers(type: ObjectType, source: InterfaceTypeWithDeclaredMembers, typeParameters: TypeParameter[], typeArguments: Type[]) {
let mapper = identityMapper;
let members = source.symbol.members;
let callSignatures = source.declaredCallSignatures;
let constructSignatures = source.declaredConstructSignatures;
let stringIndexType = source.declaredStringIndexType;
let numberIndexType = source.declaredNumberIndexType;
if (!rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) {
mapper = createTypeMapper(typeParameters, typeArguments);
members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1);
callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature);
constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature);
stringIndexType = source.declaredStringIndexType ? instantiateType(source.declaredStringIndexType, mapper) : undefined;
numberIndexType = source.declaredNumberIndexType ? instantiateType(source.declaredNumberIndexType, mapper) : undefined;
}
let baseTypes = getBaseTypes(source);
if (baseTypes.length) {
members = createSymbolTable(target.declaredProperties);
if (members === source.symbol.members) {
members = createSymbolTable(source.declaredProperties);
}
let thisArgument = lastOrUndefined(typeArguments);
for (let baseType of baseTypes) {
addInheritedMembers(members, getPropertiesOfObjectType(baseType));
callSignatures = concatenate(callSignatures, getSignaturesOfType(baseType, SignatureKind.Call));
constructSignatures = concatenate(constructSignatures, getSignaturesOfType(baseType, SignatureKind.Construct));
stringIndexType = stringIndexType || getIndexTypeOfType(baseType, IndexKind.String);
numberIndexType = numberIndexType || getIndexTypeOfType(baseType, IndexKind.Number);
let instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType;
addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType));
callSignatures = concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Call));
constructSignatures = concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Construct));
stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.String);
numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.Number);
}
}
setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
}
function resolveClassOrInterfaceMembers(type: InterfaceType): void {
resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray);
}
function resolveTypeReferenceMembers(type: TypeReference): void {
let target = resolveDeclaredMembers(type.target);
let mapper = createTypeMapper(target.typeParameters, type.typeArguments);
let members = createInstantiatedSymbolTable(target.declaredProperties, mapper);
let callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature);
let constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature);
let stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined;
let numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined;
forEach(getBaseTypes(target), baseType => {
let instantiatedBaseType = instantiateType(baseType, mapper);
addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType));
callSignatures = concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Call));
constructSignatures = concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Construct));
stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.String);
numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.Number);
});
setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
let source = resolveDeclaredMembers(type.target);
let typeParameters = concatenate(source.typeParameters, [source.thisType]);
let typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ?
type.typeArguments : concatenate(type.typeArguments, [type]);
resolveObjectTypeMembers(type, source, typeParameters, typeArguments);
}
function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], parameters: Symbol[],
@ -3120,7 +3256,9 @@ namespace ts {
}
function resolveTupleTypeMembers(type: TupleType) {
let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true)));
let arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true);
// Make the tuple type itself the 'this' type by including an extra type argument
let arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type]));
let members = createTupleTypeMemberSymbols(type.elementTypes);
addInheritedMembers(members, arrayType.properties);
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
@ -3279,7 +3417,10 @@ namespace ts {
function resolveStructuredTypeMembers(type: ObjectType): ResolvedType {
if (!(<ResolvedType>type).members) {
if (type.flags & (TypeFlags.Class | TypeFlags.Interface)) {
if (type.flags & TypeFlags.Reference) {
resolveTypeReferenceMembers(<TypeReference>type);
}
else if (type.flags & (TypeFlags.Class | TypeFlags.Interface)) {
resolveClassOrInterfaceMembers(<InterfaceType>type);
}
else if (type.flags & TypeFlags.Anonymous) {
@ -3294,9 +3435,6 @@ namespace ts {
else if (type.flags & TypeFlags.Intersection) {
resolveIntersectionTypeMembers(<IntersectionType>type);
}
else {
resolveTypeReferenceMembers(<TypeReference>type);
}
}
return <ResolvedType>type;
}
@ -3762,22 +3900,24 @@ namespace ts {
}
function getTypeListId(types: Type[]) {
switch (types.length) {
case 1:
return "" + types[0].id;
case 2:
return types[0].id + "," + types[1].id;
default:
let result = "";
for (let i = 0; i < types.length; i++) {
if (i > 0) {
result += ",";
if (types) {
switch (types.length) {
case 1:
return "" + types[0].id;
case 2:
return types[0].id + "," + types[1].id;
default:
let result = "";
for (let i = 0; i < types.length; i++) {
if (i > 0) {
result += ",";
}
result += types[i].id;
}
result += types[i].id;
}
return result;
return result;
}
}
return "";
}
// This function is used to propagate certain flags when creating new object type references and union types.
@ -3796,7 +3936,7 @@ namespace ts {
let id = getTypeListId(typeArguments);
let type = target.instantiations[id];
if (!type) {
let flags = TypeFlags.Reference | getPropagatingFlagsOfTypes(typeArguments);
let flags = TypeFlags.Reference | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0);
type = target.instantiations[id] = <TypeReference>createObjectType(flags, target.symbol);
type.target = target;
type.typeArguments = typeArguments;
@ -3855,8 +3995,8 @@ namespace ts {
// Get type from reference to class or interface
function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments, symbol: Symbol): Type {
let type = getDeclaredTypeOfSymbol(symbol);
let typeParameters = (<InterfaceType>type).localTypeParameters;
let type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
let typeParameters = type.localTypeParameters;
if (typeParameters) {
if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) {
error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length);
@ -3865,8 +4005,7 @@ namespace ts {
// In a type reference, the outer type parameters of the referenced class or interface are automatically
// supplied as type arguments and the type reference only specifies arguments for the local type parameters
// of the class or interface.
return createTypeReference(<GenericType>type, concatenate((<InterfaceType>type).outerTypeParameters,
map(node.typeArguments, getTypeFromTypeNode)));
return createTypeReference(<GenericType>type, concatenate(type.outerTypeParameters, map(node.typeArguments, getTypeFromTypeNode)));
}
if (node.typeArguments) {
error(node, Diagnostics.Type_0_is_not_generic, typeToString(type));
@ -4022,20 +4161,20 @@ namespace ts {
/**
* Instantiates a global type that is generic with some element type, and returns that instantiation.
*/
function createTypeFromGenericGlobalType(genericGlobalType: GenericType, elementType: Type): Type {
return <ObjectType>genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType;
function createTypeFromGenericGlobalType(genericGlobalType: GenericType, typeArguments: Type[]): Type {
return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
}
function createIterableType(elementType: Type): Type {
return createTypeFromGenericGlobalType(globalIterableType, elementType);
return createTypeFromGenericGlobalType(globalIterableType, [elementType]);
}
function createIterableIteratorType(elementType: Type): Type {
return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType);
return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]);
}
function createArrayType(elementType: Type): Type {
return createTypeFromGenericGlobalType(globalArrayType, elementType);
return createTypeFromGenericGlobalType(globalArrayType, [elementType]);
}
function getTypeFromArrayTypeNode(node: ArrayTypeNode): Type {
@ -4224,6 +4363,26 @@ namespace ts {
return links.resolvedType;
}
function getThisType(node: TypeNode): Type {
let container = getThisContainer(node, /*includeArrowFunctions*/ false);
let parent = container && container.parent;
if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) {
if (!(container.flags & NodeFlags.Static)) {
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
}
}
error(node, Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
return unknownType;
}
function getTypeFromThisTypeNode(node: TypeNode): Type {
let links = getNodeLinks(node);
if (!links.resolvedType) {
links.resolvedType = getThisType(node);
}
return links.resolvedType;
}
function getTypeFromTypeNode(node: TypeNode): Type {
switch (node.kind) {
case SyntaxKind.AnyKeyword:
@ -4238,6 +4397,8 @@ namespace ts {
return esSymbolType;
case SyntaxKind.VoidKeyword:
return voidType;
case SyntaxKind.ThisKeyword:
return getTypeFromThisTypeNode(node);
case SyntaxKind.StringLiteral:
return getTypeFromStringLiteral(<StringLiteral>node);
case SyntaxKind.TypeReference:
@ -4692,7 +4853,7 @@ namespace ts {
else {
if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
// We have type references to same target type, see if relationship holds for all type arguments
if (result = typesRelatedTo((<TypeReference>source).typeArguments, (<TypeReference>target).typeArguments, reportErrors)) {
if (result = typeArgumentsRelatedTo(<TypeReference>source, <TypeReference>target, reportErrors)) {
return result;
}
}
@ -4723,7 +4884,7 @@ namespace ts {
if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) {
if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
// We have type references to same target type, see if all type arguments are identical
if (result = typesRelatedTo((<TypeReference>source).typeArguments, (<TypeReference>target).typeArguments, /*reportErrors*/ false)) {
if (result = typeArgumentsRelatedTo(<TypeReference>source, <TypeReference>target, /*reportErrors*/ false)) {
return result;
}
}
@ -4845,9 +5006,14 @@ namespace ts {
return result;
}
function typesRelatedTo(sources: Type[], targets: Type[], reportErrors: boolean): Ternary {
function typeArgumentsRelatedTo(source: TypeReference, target: TypeReference, reportErrors: boolean): Ternary {
let sources = source.typeArguments || emptyArray;
let targets = target.typeArguments || emptyArray;
if (sources.length !== targets.length && relation === identityRelation) {
return Ternary.False;
}
let result = Ternary.True;
for (let i = 0, len = sources.length; i < len; i++) {
for (let i = 0; i < targets.length; i++) {
let related = isRelatedTo(sources[i], targets[i], reportErrors);
if (!related) {
return Ternary.False;
@ -5746,9 +5912,10 @@ namespace ts {
}
else if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
// If source and target are references to the same generic type, infer from type arguments
let sourceTypes = (<TypeReference>source).typeArguments;
let targetTypes = (<TypeReference>target).typeArguments;
for (let i = 0; i < sourceTypes.length; i++) {
let sourceTypes = (<TypeReference>source).typeArguments || emptyArray;
let targetTypes = (<TypeReference>target).typeArguments || emptyArray;
let count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
for (let i = 0; i < count; i++) {
inferFromTypes(sourceTypes[i], targetTypes[i]);
}
}
@ -6450,7 +6617,7 @@ namespace ts {
if (isClassLike(container.parent)) {
let symbol = getSymbolOfNode(container.parent);
return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol);
return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (<InterfaceType>getDeclaredTypeOfSymbol(symbol)).thisType;
}
return anyType;
}
@ -7837,7 +8004,7 @@ namespace ts {
let prop = getPropertyOfType(apparentType, right.text);
if (!prop) {
if (right.text) {
error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type));
error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type.flags & TypeFlags.ThisType ? apparentType : type));
}
return unknownType;
}
@ -7845,7 +8012,7 @@ namespace ts {
getNodeLinks(node).resolvedSymbol = prop;
if (prop.parent && prop.parent.flags & SymbolFlags.Class) {
checkClassPropertyAccess(node, left, type, prop);
checkClassPropertyAccess(node, left, apparentType, prop);
}
return getTypeOfSymbol(prop);
}
@ -12649,6 +12816,7 @@ namespace ts {
checkExportsOnMergedDeclarations(node);
let symbol = getSymbolOfNode(node);
let type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
let typeWithThis = getTypeWithThisArgument(type);
let staticType = <ObjectType>getTypeOfSymbol(symbol);
let baseTypeNode = getClassExtendsHeritageClauseElement(node);
@ -12667,7 +12835,7 @@ namespace ts {
}
}
}
checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1);
checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1);
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node,
Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
@ -12687,7 +12855,7 @@ namespace ts {
let implementedTypeNodes = getClassImplementsHeritageClauseElements(node);
if (implementedTypeNodes) {
forEach(implementedTypeNodes, typeRefNode => {
for (let typeRefNode of implementedTypeNodes) {
if (!isSupportedExpressionWithTypeArguments(typeRefNode)) {
error(typeRefNode.expression, Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
}
@ -12697,14 +12865,14 @@ namespace ts {
if (t !== unknownType) {
let declaredType = (t.flags & TypeFlags.Reference) ? (<TypeReference>t).target : t;
if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) {
checkTypeAssignableTo(type, t, node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1);
checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1);
}
else {
error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface);
}
}
}
});
}
}
if (produceDiagnostics) {
@ -12864,7 +13032,7 @@ namespace ts {
let ok = true;
for (let base of baseTypes) {
let properties = getPropertiesOfObjectType(base);
let properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType));
for (let prop of properties) {
if (!hasProperty(seen, prop.name)) {
seen[prop.name] = { prop: prop, containingType: base };
@ -12909,11 +13077,12 @@ namespace ts {
// Only check this symbol once
if (node === firstInterfaceDecl) {
let type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
let typeWithThis = getTypeWithThisArgument(type);
// run subsequent checks only if first set succeeded
if (checkInheritedPropertiesAreIdentical(type, node.name)) {
forEach(getBaseTypes(type), baseType => {
checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1);
});
for (let baseType of getBaseTypes(type)) {
checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1);
}
checkIndexConstraints(type);
}
}
@ -14146,7 +14315,7 @@ namespace ts {
case SyntaxKind.ThisKeyword:
case SyntaxKind.SuperKeyword:
let type = checkExpression(<Expression>node);
let type = isExpression(node) ? checkExpression(<Expression>node) : getTypeFromTypeNode(<TypeNode>node);
return type.symbol;
case SyntaxKind.ConstructorKeyword:

Просмотреть файл

@ -52,6 +52,7 @@ namespace ts {
let enclosingDeclaration: Node;
let currentSourceFile: SourceFile;
let reportedDeclarationError = false;
let errorNameNode: DeclarationName;
let emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments;
let emit = compilerOptions.stripInternal ? stripInternal : emitNode;
@ -152,6 +153,7 @@ namespace ts {
function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter {
let writer = <EmitTextWriterWithSymbolWriter>createTextWriter(newLine);
writer.trackSymbol = trackSymbol;
writer.reportInaccessibleThisError = reportInaccessibleThisError;
writer.writeKeyword = writer.write;
writer.writeOperator = writer.write;
writer.writePunctuation = writer.write;
@ -257,6 +259,13 @@ namespace ts {
handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning));
}
function reportInaccessibleThisError() {
if (errorNameNode) {
diagnostics.push(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary,
declarationNameToString(errorNameNode)));
}
}
function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, type: TypeNode, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) {
writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic;
write(": ");
@ -265,7 +274,9 @@ namespace ts {
emitType(type);
}
else {
errorNameNode = declaration.name;
resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
errorNameNode = undefined;
}
}
@ -277,7 +288,9 @@ namespace ts {
emitType(signature.type);
}
else {
errorNameNode = signature.name;
resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
errorNameNode = undefined;
}
}
@ -326,6 +339,7 @@ namespace ts {
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.ThisKeyword:
case SyntaxKind.StringLiteral:
return writeTextOfNode(currentSourceFile, type);
case SyntaxKind.ExpressionWithTypeArguments:

Просмотреть файл

@ -1652,6 +1652,14 @@
"category": "Error",
"code": 2525
},
"A 'this' type is available only in a non-static member of a class or interface.": {
"category": "Error",
"code": 2526
},
"The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary.": {
"category": "Error",
"code": 2527
},
"JSX element attributes type '{0}' must be an object type.": {
"category": "Error",
"code": 2600

Просмотреть файл

@ -2360,6 +2360,7 @@ namespace ts {
let node = tryParse(parseKeywordAndNoDot);
return node || parseTypeReferenceOrTypePredicate();
case SyntaxKind.VoidKeyword:
case SyntaxKind.ThisKeyword:
return parseTokenNode<TypeNode>();
case SyntaxKind.TypeOfKeyword:
return parseTypeQuery();
@ -2382,6 +2383,7 @@ namespace ts {
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.ThisKeyword:
case SyntaxKind.TypeOfKeyword:
case SyntaxKind.OpenBraceToken:
case SyntaxKind.OpenBracketToken:

Просмотреть файл

@ -376,6 +376,7 @@ namespace ts {
OctalLiteral = 0x00010000, // Octal numeric literal
Namespace = 0x00020000, // Namespace declaration
ExportContext = 0x00040000, // Export context (initialized by binding)
ContainsThis = 0x00080000, // Interface contains references to "this"
Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async,
AccessibilityModifier = Public | Private | Protected,
@ -1496,6 +1497,7 @@ namespace ts {
// declaration emitter to help determine if it should patch up the final declaration file
// with import statements it previously saw (but chose not to emit).
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
reportInaccessibleThisError(): void;
}
export const enum TypeFormatFlags {
@ -1797,6 +1799,7 @@ namespace ts {
/* @internal */
ContainsAnyFunctionType = 0x00800000, // Type is or contains object literal type
ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6
ThisType = 0x02000000, // This type
/* @internal */
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
@ -1842,6 +1845,7 @@ namespace ts {
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none)
localTypeParameters: TypeParameter[]; // Local type parameters (undefined if none)
thisType: TypeParameter; // The "this" type (undefined if none)
/* @internal */
resolvedBaseConstructorType?: Type; // Resolved base constructor type of class
/* @internal */
@ -1856,10 +1860,17 @@ namespace ts {
declaredNumberIndexType: Type; // Declared numeric index type
}
// Type references (TypeFlags.Reference)
// Type references (TypeFlags.Reference). When a class or interface has type parameters or
// a "this" type, references to the class or interface are made using type references. The
// typeArguments property specififes the types to substitute for the type parameters of the
// class or interface and optionally includes an extra element that specifies the type to
// substitute for "this" in the resulting instantiation. When no extra argument is present,
// the type reference itself is substituted for "this". The typeArguments property is undefined
// if the class or interface has no type parameters and the reference isn't specifying an
// explicit "this" argument.
export interface TypeReference extends ObjectType {
target: GenericType; // Type reference target
typeArguments: Type[]; // Type reference type arguments
typeArguments: Type[]; // Type reference type arguments (undefined if none)
}
// Generic class and interface types

Просмотреть файл

@ -65,7 +65,8 @@ namespace ts {
increaseIndent: () => { },
decreaseIndent: () => { },
clear: () => str = "",
trackSymbol: () => { }
trackSymbol: () => { },
reportInaccessibleThisError: () => { }
};
}
@ -468,13 +469,12 @@ namespace ts {
else if (node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node) {
node = node.parent;
}
// fall through
case SyntaxKind.QualifiedName:
case SyntaxKind.PropertyAccessExpression:
// At this point, node is either a qualified name or an identifier
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression,
"'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'.");
case SyntaxKind.QualifiedName:
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.ThisKeyword:
let parent = node.parent;
if (parent.kind === SyntaxKind.TypeQuery) {
return false;
@ -733,6 +733,9 @@ namespace ts {
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.SourceFile:
return node;
@ -895,7 +898,6 @@ namespace ts {
export function isExpression(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ThisKeyword:
case SyntaxKind.SuperKeyword:
case SyntaxKind.NullKeyword:
case SyntaxKind.TrueKeyword:
@ -928,6 +930,7 @@ namespace ts {
case SyntaxKind.JsxElement:
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.YieldExpression:
case SyntaxKind.AwaitExpression:
return true;
case SyntaxKind.QualifiedName:
while (node.parent.kind === SyntaxKind.QualifiedName) {
@ -941,6 +944,7 @@ namespace ts {
// fall through
case SyntaxKind.NumericLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.ThisKeyword:
let parent = node.parent;
switch (parent.kind) {
case SyntaxKind.VariableDeclaration:

Просмотреть файл

@ -725,7 +725,7 @@ namespace ts {
}
getBaseTypes(): ObjectType[] {
return this.flags & (TypeFlags.Class | TypeFlags.Interface)
? this.checker.getBaseTypes(<TypeObject & InterfaceType>this)
? this.checker.getBaseTypes(<InterfaceType><Type>this)
: undefined;
}
}
@ -6252,7 +6252,8 @@ namespace ts {
}
return node.parent.kind === SyntaxKind.TypeReference ||
(node.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isExpressionWithTypeArgumentsInClassExtendsClause(<ExpressionWithTypeArguments>node.parent));
(node.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isExpressionWithTypeArgumentsInClassExtendsClause(<ExpressionWithTypeArguments>node.parent)) ||
node.kind === SyntaxKind.ThisKeyword && !isExpression(node);
}
function isNamespaceReference(node: Node): boolean {

Просмотреть файл

@ -636,7 +636,8 @@ namespace ts {
increaseIndent: () => { indent++; },
decreaseIndent: () => { indent--; },
clear: resetWriter,
trackSymbol: () => { }
trackSymbol: () => { },
reportInaccessibleThisError: () => { }
};
function writeIndent() {

Просмотреть файл

@ -28,7 +28,7 @@ class Board {
>this.ships.every(function (val) { return val.isSunk; }) : boolean
>this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean
>this.ships : Ship[]
>this : Board
>this : this
>ships : Ship[]
>every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean
>function (val) { return val.isSunk; } : (val: Ship) => boolean

Просмотреть файл

@ -15,11 +15,11 @@ class Point {
>"x=" + this.x : string
>"x=" : string
>this.x : number
>this : Point
>this : this
>x : number
>" y=" : string
>this.y : number
>this : Point
>this : this
>y : number
}
}
@ -50,7 +50,7 @@ class ColoredPoint extends Point {
>toString : () => string
>" color=" : string
>this.color : string
>this : ColoredPoint
>this : this
>color : string
}
}

Просмотреть файл

@ -26,7 +26,7 @@ class C2 {
return this.x;
>this.x : IHasVisualizationModel
>this : C2
>this : this
>x : IHasVisualizationModel
}
set A(x) {

Просмотреть файл

@ -31,7 +31,7 @@ class TestClass {
this.bar(x); // should not error
>this.bar(x) : void
>this.bar : { (x: string): void; (x: string[]): void; }
>this : TestClass
>this : this
>bar : { (x: string): void; (x: string[]): void; }
>x : any
}
@ -71,7 +71,7 @@ class TestClass2 {
return this.bar(x); // should not error
>this.bar(x) : number
>this.bar : { (x: string): number; (x: string[]): number; }
>this : TestClass2
>this : this
>bar : { (x: string): number; (x: string[]): number; }
>x : any
}

Просмотреть файл

@ -10,7 +10,7 @@ class Foo {
this.x = 5;
>this.x = 5 : number
>this.x : number
>this : Foo
>this : this
>x : number
>5 : number
}

Просмотреть файл

@ -34,6 +34,8 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(25,5): error
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error TS2322: Type 'StrNum' is not assignable to type '[string]'.
Types of property 'pop' are incompatible.
Type '() => string | number' is not assignable to type '() => string'.
Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'.
Property 'length' is missing in type '{ 0: string; 1: number; }'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'.
@ -125,6 +127,8 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error
!!! error TS2322: Type 'StrNum' is not assignable to type '[string]'.
!!! error TS2322: Types of property 'pop' are incompatible.
!!! error TS2322: Type '() => string | number' is not assignable to type '() => string'.
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
var m3: [string] = z;
~~
!!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'.

Просмотреть файл

@ -51,7 +51,7 @@ module EmptyTypes {
>(this.voidIfAny([4, 2][0])) : number
>this.voidIfAny([4, 2][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2][0] : number
>[4, 2] : number[]
@ -64,7 +64,7 @@ module EmptyTypes {
>(this.voidIfAny([4, 2, undefined][0])) : number
>this.voidIfAny([4, 2, undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2, undefined][0] : number
>[4, 2, undefined] : number[]
@ -78,7 +78,7 @@ module EmptyTypes {
>(this.voidIfAny([undefined, 2, 4][0])) : number
>this.voidIfAny([undefined, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 2, 4][0] : number
>[undefined, 2, 4] : number[]
@ -92,7 +92,7 @@ module EmptyTypes {
>(this.voidIfAny([null, 2, 4][0])) : number
>this.voidIfAny([null, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, 2, 4][0] : number
>[null, 2, 4] : number[]
@ -106,7 +106,7 @@ module EmptyTypes {
>(this.voidIfAny([2, 4, null][0])) : number
>this.voidIfAny([2, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[2, 4, null][0] : number
>[2, 4, null] : number[]
@ -120,7 +120,7 @@ module EmptyTypes {
>(this.voidIfAny([undefined, 4, null][0])) : number
>this.voidIfAny([undefined, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 4, null][0] : number
>[undefined, 4, null] : number[]
@ -134,7 +134,7 @@ module EmptyTypes {
>(this.voidIfAny(['', "q"][0])) : number
>this.voidIfAny(['', "q"][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q"][0] : string
>['', "q"] : string[]
@ -147,7 +147,7 @@ module EmptyTypes {
>(this.voidIfAny(['', "q", undefined][0])) : number
>this.voidIfAny(['', "q", undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q", undefined][0] : string
>['', "q", undefined] : string[]
@ -161,7 +161,7 @@ module EmptyTypes {
>(this.voidIfAny([undefined, "q", ''][0])) : number
>this.voidIfAny([undefined, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, "q", ''][0] : string
>[undefined, "q", ''] : string[]
@ -175,7 +175,7 @@ module EmptyTypes {
>(this.voidIfAny([null, "q", ''][0])) : number
>this.voidIfAny([null, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, "q", ''][0] : string
>[null, "q", ''] : string[]
@ -189,7 +189,7 @@ module EmptyTypes {
>(this.voidIfAny(["q", '', null][0])) : number
>this.voidIfAny(["q", '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>["q", '', null][0] : string
>["q", '', null] : string[]
@ -203,7 +203,7 @@ module EmptyTypes {
>(this.voidIfAny([undefined, '', null][0])) : number
>this.voidIfAny([undefined, '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, '', null][0] : string
>[undefined, '', null] : string[]
@ -217,7 +217,7 @@ module EmptyTypes {
>(this.voidIfAny([[3, 4], [null]][0][0])) : number
>this.voidIfAny([[3, 4], [null]][0][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[[3, 4], [null]][0][0] : number
>[[3, 4], [null]][0] : number[]
@ -454,7 +454,7 @@ module NonEmptyTypes {
>(this.voidIfAny([4, 2][0])) : number
>this.voidIfAny([4, 2][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2][0] : number
>[4, 2] : number[]
@ -467,7 +467,7 @@ module NonEmptyTypes {
>(this.voidIfAny([4, 2, undefined][0])) : number
>this.voidIfAny([4, 2, undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2, undefined][0] : number
>[4, 2, undefined] : number[]
@ -481,7 +481,7 @@ module NonEmptyTypes {
>(this.voidIfAny([undefined, 2, 4][0])) : number
>this.voidIfAny([undefined, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 2, 4][0] : number
>[undefined, 2, 4] : number[]
@ -495,7 +495,7 @@ module NonEmptyTypes {
>(this.voidIfAny([null, 2, 4][0])) : number
>this.voidIfAny([null, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, 2, 4][0] : number
>[null, 2, 4] : number[]
@ -509,7 +509,7 @@ module NonEmptyTypes {
>(this.voidIfAny([2, 4, null][0])) : number
>this.voidIfAny([2, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[2, 4, null][0] : number
>[2, 4, null] : number[]
@ -523,7 +523,7 @@ module NonEmptyTypes {
>(this.voidIfAny([undefined, 4, null][0])) : number
>this.voidIfAny([undefined, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 4, null][0] : number
>[undefined, 4, null] : number[]
@ -537,7 +537,7 @@ module NonEmptyTypes {
>(this.voidIfAny(['', "q"][0])) : number
>this.voidIfAny(['', "q"][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q"][0] : string
>['', "q"] : string[]
@ -550,7 +550,7 @@ module NonEmptyTypes {
>(this.voidIfAny(['', "q", undefined][0])) : number
>this.voidIfAny(['', "q", undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q", undefined][0] : string
>['', "q", undefined] : string[]
@ -564,7 +564,7 @@ module NonEmptyTypes {
>(this.voidIfAny([undefined, "q", ''][0])) : number
>this.voidIfAny([undefined, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, "q", ''][0] : string
>[undefined, "q", ''] : string[]
@ -578,7 +578,7 @@ module NonEmptyTypes {
>(this.voidIfAny([null, "q", ''][0])) : number
>this.voidIfAny([null, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, "q", ''][0] : string
>[null, "q", ''] : string[]
@ -592,7 +592,7 @@ module NonEmptyTypes {
>(this.voidIfAny(["q", '', null][0])) : number
>this.voidIfAny(["q", '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>["q", '', null][0] : string
>["q", '', null] : string[]
@ -606,7 +606,7 @@ module NonEmptyTypes {
>(this.voidIfAny([undefined, '', null][0])) : number
>this.voidIfAny([undefined, '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, '', null][0] : string
>[undefined, '', null] : string[]
@ -620,7 +620,7 @@ module NonEmptyTypes {
>(this.voidIfAny([[3, 4], [null]][0][0])) : number
>this.voidIfAny([[3, 4], [null]][0][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>this : this
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[[3, 4], [null]][0][0] : number
>[[3, 4], [null]][0] : number[]

Просмотреть файл

@ -18,7 +18,7 @@ class Road {
this.cars = cars;
>this.cars = cars : Car[]
>this.cars : Car[]
>this : Road
>this : this
>cars : Car[]
>cars : Car[]
}

Просмотреть файл

@ -38,12 +38,12 @@ class parser {
this.options = this.options.sort(function(a, b) {
>this.options = this.options.sort(function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } }) : IOptions[]
>this.options : IOptions[]
>this : parser
>this : this
>options : IOptions[]
>this.options.sort(function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } }) : IOptions[]
>this.options.sort : (compareFn?: (a: IOptions, b: IOptions) => number) => IOptions[]
>this.options : IOptions[]
>this : parser
>this : this
>options : IOptions[]
>sort : (compareFn?: (a: IOptions, b: IOptions) => number) => IOptions[]
>function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } } : (a: IOptions, b: IOptions) => number

Просмотреть файл

@ -129,12 +129,12 @@ class MyClass {
>1 : number
p = (n) => n && this;
>p : (n: any) => MyClass
>(n) => n && this : (n: any) => MyClass
>p : (n: any) => this
>(n) => n && this : (n: any) => this
>n : any
>n && this : MyClass
>n && this : this
>n : any
>this : MyClass
>this : this
fn() {
>fn : () => void
@ -148,12 +148,12 @@ class MyClass {
>1 : number
var p = (n) => n && this;
>p : (n: any) => MyClass
>(n) => n && this : (n: any) => MyClass
>p : (n: any) => this
>(n) => n && this : (n: any) => this
>n : any
>n && this : MyClass
>n && this : this
>n : any
>this : MyClass
>this : this
}
}

Просмотреть файл

@ -11,11 +11,12 @@ class C {
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
>other : () => void
>apply : (thisArg: any, argArray?: any) => any
>this : C
>this : this
>arguments : IArguments
}
}

Просмотреть файл

@ -6,9 +6,10 @@ class C {
>method : () => void
var fn = async () => await this;
>fn : () => Promise<C>
>async () => await this : () => Promise<C>
>this : C
>fn : () => Promise<this>
>async () => await this : () => Promise<this>
>await this : this
>this : this
}
}

Просмотреть файл

@ -13,6 +13,7 @@ async function func(): Promise<void> {
"before";
var b = await p || a;
>b : Symbol(b, Decl(awaitBinaryExpression1_es6.ts, 4, 7))
>p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11))
>a : Symbol(a, Decl(awaitBinaryExpression1_es6.ts, 0, 11))
"after";

Просмотреть файл

@ -16,7 +16,8 @@ async function func(): Promise<void> {
var b = await p || a;
>b : boolean
>await p || a : boolean
>p : any
>await p : boolean
>p : Promise<boolean>
>a : boolean
"after";

Просмотреть файл

@ -13,6 +13,7 @@ async function func(): Promise<void> {
"before";
var b = await p && a;
>b : Symbol(b, Decl(awaitBinaryExpression2_es6.ts, 4, 7))
>p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11))
>a : Symbol(a, Decl(awaitBinaryExpression2_es6.ts, 0, 11))
"after";

Просмотреть файл

@ -16,7 +16,8 @@ async function func(): Promise<void> {
var b = await p && a;
>b : boolean
>await p && a : boolean
>p : any
>await p : boolean
>p : Promise<boolean>
>a : boolean
"after";

Просмотреть файл

@ -13,6 +13,7 @@ async function func(): Promise<void> {
"before";
var b = await p + a;
>b : Symbol(b, Decl(awaitBinaryExpression3_es6.ts, 4, 7))
>p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11))
>a : Symbol(a, Decl(awaitBinaryExpression3_es6.ts, 0, 11))
"after";

Просмотреть файл

@ -16,7 +16,8 @@ async function func(): Promise<void> {
var b = await p + a;
>b : number
>await p + a : number
>p : any
>await p : number
>p : Promise<number>
>a : number
"after";

Просмотреть файл

@ -13,6 +13,7 @@ async function func(): Promise<void> {
"before";
var b = await p, a;
>b : Symbol(b, Decl(awaitBinaryExpression4_es6.ts, 4, 7))
>p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11))
>a : Symbol(a, Decl(awaitBinaryExpression4_es6.ts, 4, 20))
"after";

Просмотреть файл

@ -15,7 +15,8 @@ async function func(): Promise<void> {
var b = await p, a;
>b : boolean
>p : any
>await p : boolean
>p : Promise<boolean>
>a : any
"after";

Просмотреть файл

@ -19,6 +19,7 @@ async function func(): Promise<void> {
>o.a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12))
>o : Symbol(o, Decl(awaitBinaryExpression5_es6.ts, 4, 7))
>a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12))
>p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11))
"after";
}

Просмотреть файл

@ -22,7 +22,8 @@ async function func(): Promise<void> {
>o.a : boolean
>o : { a: boolean; }
>a : boolean
>p : any
>await p : boolean
>p : Promise<boolean>
"after";
>"after" : string

Просмотреть файл

@ -42,6 +42,7 @@ async function func(): Promise<void> {
var b = fn(await p, a, a);
>b : Symbol(b, Decl(awaitCallExpression2_es6.ts, 8, 7))
>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32))
>p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11))
>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11))
>a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11))

Просмотреть файл

@ -45,7 +45,8 @@ async function func(): Promise<void> {
>b : void
>fn(await p, a, a) : void
>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void
>p : any
>await p : boolean
>p : Promise<boolean>
>a : boolean
>a : boolean

Просмотреть файл

@ -43,6 +43,7 @@ async function func(): Promise<void> {
>b : Symbol(b, Decl(awaitCallExpression3_es6.ts, 8, 7))
>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32))
>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11))
>p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11))
>a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11))
"after";

Просмотреть файл

@ -46,7 +46,8 @@ async function func(): Promise<void> {
>fn(a, await p, a) : void
>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void
>a : boolean
>p : any
>await p : boolean
>p : Promise<boolean>
>a : boolean
"after";

Просмотреть файл

@ -41,6 +41,7 @@ async function func(): Promise<void> {
"before";
var b = (await pfn)(a, a, a);
>b : Symbol(b, Decl(awaitCallExpression4_es6.ts, 8, 7))
>pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11))
>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11))
>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11))
>a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11))

Просмотреть файл

@ -45,7 +45,8 @@ async function func(): Promise<void> {
>b : void
>(await pfn)(a, a, a) : void
>(await pfn) : (arg0: boolean, arg1: boolean, arg2: boolean) => void
>pfn : any
>await pfn : (arg0: boolean, arg1: boolean, arg2: boolean) => void
>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void>
>a : boolean
>a : boolean
>a : boolean

Просмотреть файл

@ -44,6 +44,7 @@ async function func(): Promise<void> {
>o.fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16))
>o : Symbol(o, Decl(awaitCallExpression6_es6.ts, 3, 11))
>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16))
>p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11))
>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11))
>a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11))

Просмотреть файл

@ -47,7 +47,8 @@ async function func(): Promise<void> {
>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void
>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }
>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void
>p : any
>await p : boolean
>p : Promise<boolean>
>a : boolean
>a : boolean

Просмотреть файл

@ -45,6 +45,7 @@ async function func(): Promise<void> {
>o : Symbol(o, Decl(awaitCallExpression7_es6.ts, 3, 11))
>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16))
>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11))
>p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11))
>a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11))
"after";

Просмотреть файл

@ -48,7 +48,8 @@ async function func(): Promise<void> {
>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }
>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void
>a : boolean
>p : any
>await p : boolean
>p : Promise<boolean>
>a : boolean
"after";

Просмотреть файл

@ -42,6 +42,7 @@ async function func(): Promise<void> {
var b = (await po).fn(a, a, a);
>b : Symbol(b, Decl(awaitCallExpression8_es6.ts, 8, 7))
>(await po).fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25))
>po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11))
>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25))
>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11))
>a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11))

Просмотреть файл

@ -46,7 +46,8 @@ async function func(): Promise<void> {
>(await po).fn(a, a, a) : void
>(await po).fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void
>(await po) : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }
>po : any
>await po : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }
>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>
>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void
>a : boolean
>a : boolean

Просмотреть файл

@ -24,16 +24,21 @@ async function f() {
let await_a = await a;
>await_a : Symbol(await_a, Decl(awaitUnion_es6.ts, 6, 4))
>a : Symbol(a, Decl(awaitUnion_es6.ts, 0, 11))
let await_b = await b;
>await_b : Symbol(await_b, Decl(awaitUnion_es6.ts, 7, 4))
>b : Symbol(b, Decl(awaitUnion_es6.ts, 1, 11))
let await_c = await c;
>await_c : Symbol(await_c, Decl(awaitUnion_es6.ts, 8, 4))
>c : Symbol(c, Decl(awaitUnion_es6.ts, 2, 11))
let await_d = await d;
>await_d : Symbol(await_d, Decl(awaitUnion_es6.ts, 9, 4))
>d : Symbol(d, Decl(awaitUnion_es6.ts, 3, 11))
let await_e = await e;
>await_e : Symbol(await_e, Decl(awaitUnion_es6.ts, 10, 4))
>e : Symbol(e, Decl(awaitUnion_es6.ts, 4, 11))
}

Просмотреть файл

@ -24,21 +24,26 @@ async function f() {
let await_a = await a;
>await_a : number | string
>a : any
>await a : number | string
>a : number | string
let await_b = await b;
>await_b : number | string
>b : any
>await b : number | string
>b : PromiseLike<number> | PromiseLike<string>
let await_c = await c;
>await_c : number | string
>c : any
>await c : number | string
>c : PromiseLike<number | string>
let await_d = await d;
>await_d : number | string
>d : any
>await d : number | string
>d : number | PromiseLike<string>
let await_e = await e;
>await_e : number | string
>e : any
>await e : number | string
>e : number | PromiseLike<number | string>
}

Просмотреть файл

@ -22,8 +22,8 @@ class Greeter {
>() => { var x = this; } : () => void
var x = this;
>x : Greeter
>this : Greeter
>x : this
>this : this
});
});

Просмотреть файл

@ -13,7 +13,7 @@ class C<T1> extends CBase<T1> {
>CBaseBase : typeof CBaseBase
>Wrapper : Wrapper<T5>
>T1 : T1
>this : C<T1>
>this : this
}
public alsoWorks() {
>alsoWorks : () => void
@ -22,7 +22,7 @@ class C<T1> extends CBase<T1> {
>new CBase<T1>(this) : CBase<T1>
>CBase : typeof CBase
>T1 : T1
>this : C<T1>
>this : this
}
public method(t: Wrapper<T1>) { }

Просмотреть файл

@ -32,7 +32,7 @@ module Test {
>name : string
>this.getName() : string
>this.getName : () => string
>this : Bug
>this : this
>getName : () => string
>length : number
>0 : number

Просмотреть файл

@ -180,7 +180,7 @@ class C {
this.foo(x, y);
>this.foo(x, y) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : C
>this : this
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
@ -188,7 +188,7 @@ class C {
this.foo(x, y, ...z);
>this.foo(x, y, ...z) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : C
>this : this
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number

Просмотреть файл

@ -181,7 +181,7 @@ class C {
this.foo(x, y);
>this.foo(x, y) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : C
>this : this
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
@ -189,7 +189,7 @@ class C {
this.foo(x, y, ...z);
>this.foo(x, y, ...z) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : C
>this : this
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number

Просмотреть файл

@ -18,7 +18,7 @@ class B extends A {
>() => this.someMethod() : () => void
>this.someMethod() : void
>this.someMethod : () => void
>this : B
>this : this
>someMethod : () => void
someMethod() {}

Просмотреть файл

@ -20,7 +20,7 @@ class Derived extends Base {
this.p; // OK
>this.p : number
>this : Derived
>this : this
>p : number
}
}

Просмотреть файл

@ -8,7 +8,7 @@ class A extends B {
>foo : () => void
>this.bar() : void
>this.bar : () => void
>this : A
>this : this
>bar : () => void
}

Просмотреть файл

@ -11,7 +11,7 @@ class bar {
this.baz = new foo();
>this.baz = new foo() : foo
>this.baz : foo
>this : bar
>this : this
>baz : foo
>new foo() : foo
>foo : typeof foo

Просмотреть файл

@ -41,7 +41,7 @@ class TextBase implements IText {
return new SubText(this, span);
>new SubText(this, span) : SubText
>SubText : typeof SubText
>this : TextBase
>this : this
>span : TextSpan
}
}

Просмотреть файл

@ -16,7 +16,7 @@ class c1 {
return this.p1 + b;
>this.p1 + b : number
>this.p1 : number
>this : c1
>this : this
>p1 : number
>b : number
@ -28,10 +28,10 @@ class c1 {
return this.p2(this.p1);
>this.p2(this.p1) : number
>this.p2 : (b: number) => number
>this : c1
>this : this
>p2 : (b: number) => number
>this.p1 : number
>this : c1
>this : this
>p1 : number
}// trailing comment Getter
@ -43,11 +43,11 @@ class c1 {
this.p1 = this.p2(value);
>this.p1 = this.p2(value) : number
>this.p1 : number
>this : c1
>this : this
>p1 : number
>this.p2(value) : number
>this.p2 : (b: number) => number
>this : c1
>this : this
>p2 : (b: number) => number
>value : number
@ -64,7 +64,7 @@ class c1 {
return this.p1 + b;
>this.p1 + b : number
>this.p1 : number
>this : c1
>this : this
>p1 : number
>b : number
@ -76,10 +76,10 @@ class c1 {
return this.pp2(this.pp1);
>this.pp2(this.pp1) : number
>this.pp2 : (b: number) => number
>this : c1
>this : this
>pp2 : (b: number) => number
>this.pp1 : number
>this : c1
>this : this
>pp1 : number
}
/** setter property*/
@ -90,11 +90,11 @@ class c1 {
this.pp1 = this.pp2(value);
>this.pp1 = this.pp2(value) : number
>this.pp1 : number
>this : c1
>this : this
>pp1 : number
>this.pp2(value) : number
>this.pp2 : (b: number) => number
>this : c1
>this : this
>pp2 : (b: number) => number
>value : number
}
@ -158,7 +158,7 @@ class c1 {
return this.nc_p1 + b;
>this.nc_p1 + b : number
>this.nc_p1 : number
>this : c1
>this : this
>nc_p1 : number
>b : number
}
@ -168,10 +168,10 @@ class c1 {
return this.nc_p2(this.nc_p1);
>this.nc_p2(this.nc_p1) : number
>this.nc_p2 : (b: number) => number
>this : c1
>this : this
>nc_p2 : (b: number) => number
>this.nc_p1 : number
>this : c1
>this : this
>nc_p1 : number
}
public set nc_p3(value: number) {
@ -181,11 +181,11 @@ class c1 {
this.nc_p1 = this.nc_p2(value);
>this.nc_p1 = this.nc_p2(value) : number
>this.nc_p1 : number
>this : c1
>this : this
>nc_p1 : number
>this.nc_p2(value) : number
>this.nc_p2 : (b: number) => number
>this : c1
>this : this
>nc_p2 : (b: number) => number
>value : number
}
@ -199,7 +199,7 @@ class c1 {
return this.nc_pp1 + b;
>this.nc_pp1 + b : number
>this.nc_pp1 : number
>this : c1
>this : this
>nc_pp1 : number
>b : number
}
@ -209,10 +209,10 @@ class c1 {
return this.nc_pp2(this.nc_pp1);
>this.nc_pp2(this.nc_pp1) : number
>this.nc_pp2 : (b: number) => number
>this : c1
>this : this
>nc_pp2 : (b: number) => number
>this.nc_pp1 : number
>this : c1
>this : this
>nc_pp1 : number
}
private set nc_pp3(value: number) {
@ -222,11 +222,11 @@ class c1 {
this.nc_pp1 = this.nc_pp2(value);
>this.nc_pp1 = this.nc_pp2(value) : number
>this.nc_pp1 : number
>this : c1
>this : this
>nc_pp1 : number
>this.nc_pp2(value) : number
>this.nc_pp2 : (b: number) => number
>this : c1
>this : this
>nc_pp2 : (b: number) => number
>value : number
}
@ -284,7 +284,7 @@ class c1 {
return this.a_p1 + b;
>this.a_p1 + b : number
>this.a_p1 : number
>this : c1
>this : this
>a_p1 : number
>b : number
}
@ -295,10 +295,10 @@ class c1 {
return this.a_p2(this.a_p1);
>this.a_p2(this.a_p1) : number
>this.a_p2 : (b: number) => number
>this : c1
>this : this
>a_p2 : (b: number) => number
>this.a_p1 : number
>this : c1
>this : this
>a_p1 : number
}
// setter property
@ -309,11 +309,11 @@ class c1 {
this.a_p1 = this.a_p2(value);
>this.a_p1 = this.a_p2(value) : number
>this.a_p1 : number
>this : c1
>this : this
>a_p1 : number
>this.a_p2(value) : number
>this.a_p2 : (b: number) => number
>this : c1
>this : this
>a_p2 : (b: number) => number
>value : number
}
@ -329,7 +329,7 @@ class c1 {
return this.a_p1 + b;
>this.a_p1 + b : number
>this.a_p1 : number
>this : c1
>this : this
>a_p1 : number
>b : number
}
@ -340,10 +340,10 @@ class c1 {
return this.a_pp2(this.a_pp1);
>this.a_pp2(this.a_pp1) : number
>this.a_pp2 : (b: number) => number
>this : c1
>this : this
>a_pp2 : (b: number) => number
>this.a_pp1 : number
>this : c1
>this : this
>a_pp1 : number
}
// setter property
@ -354,11 +354,11 @@ class c1 {
this.a_pp1 = this.a_pp2(value);
>this.a_pp1 = this.a_pp2(value) : number
>this.a_pp1 : number
>this : c1
>this : this
>a_pp1 : number
>this.a_pp2(value) : number
>this.a_pp2 : (b: number) => number
>this : c1
>this : this
>a_pp2 : (b: number) => number
>value : number
}
@ -422,7 +422,7 @@ class c1 {
return this.b_p1 + b;
>this.b_p1 + b : number
>this.b_p1 : number
>this : c1
>this : this
>b_p1 : number
>b : number
}
@ -433,10 +433,10 @@ class c1 {
return this.b_p2(this.b_p1);
>this.b_p2(this.b_p1) : number
>this.b_p2 : (b: number) => number
>this : c1
>this : this
>b_p2 : (b: number) => number
>this.b_p1 : number
>this : c1
>this : this
>b_p1 : number
}
/** setter property */
@ -447,11 +447,11 @@ class c1 {
this.b_p1 = this.b_p2(value);
>this.b_p1 = this.b_p2(value) : number
>this.b_p1 : number
>this : c1
>this : this
>b_p1 : number
>this.b_p2(value) : number
>this.b_p2 : (b: number) => number
>this : c1
>this : this
>b_p2 : (b: number) => number
>value : number
}
@ -467,7 +467,7 @@ class c1 {
return this.b_p1 + b;
>this.b_p1 + b : number
>this.b_p1 : number
>this : c1
>this : this
>b_p1 : number
>b : number
}
@ -478,10 +478,10 @@ class c1 {
return this.b_pp2(this.b_pp1);
>this.b_pp2(this.b_pp1) : number
>this.b_pp2 : (b: number) => number
>this : c1
>this : this
>b_pp2 : (b: number) => number
>this.b_pp1 : number
>this : c1
>this : this
>b_pp1 : number
}
/** setter property */
@ -492,11 +492,11 @@ class c1 {
this.b_pp1 = this.b_pp2(value);
>this.b_pp1 = this.b_pp2(value) : number
>this.b_pp1 : number
>this : c1
>this : this
>b_pp1 : number
>this.b_pp2(value) : number
>this.b_pp2 : (b: number) => number
>this : c1
>this : this
>b_pp2 : (b: number) => number
>value : number
}
@ -704,7 +704,7 @@ class cProperties {
return this.val;
>this.val : number
>this : cProperties
>this : this
>val : number
} // trailing comment of only getter
@ -713,7 +713,7 @@ class cProperties {
return this.val;
>this.val : number
>this : cProperties
>this : this
>val : number
}
/**setter only property*/
@ -724,7 +724,7 @@ class cProperties {
this.val = value;
>this.val = value : number
>this.val : number
>this : cProperties
>this : this
>val : number
>value : number
}
@ -735,7 +735,7 @@ class cProperties {
this.val = value;
>this.val = value : number
>this.val : number
>this : cProperties
>this : this
>val : number
>value : number

Просмотреть файл

@ -170,7 +170,7 @@ class c2 {
this.c2_p1 = a;
>this.c2_p1 = a : number
>this.c2_p1 : number
>this : c2
>this : this
>c2_p1 : number
>a : number
}

Просмотреть файл

@ -43,7 +43,7 @@ class c {
return this.b;
>this.b : number
>this : c
>this : this
>b : number
}
@ -53,7 +53,7 @@ class c {
return this.b;
>this.b : number
>this : c
>this : this
>b : number
}
@ -65,7 +65,7 @@ class c {
this.b = val;
>this.b = val : number
>this.b : number
>this : c
>this : this
>b : number
>val : number
}

Просмотреть файл

@ -43,7 +43,7 @@ class c {
return this.b;
>this.b : number
>this : c
>this : this
>b : number
}
@ -53,7 +53,7 @@ class c {
return this.b;
>this.b : number
>this : c
>this : this
>b : number
}
@ -65,7 +65,7 @@ class c {
this.b = val;
>this.b = val : number
>this.b : number
>this : c
>this : this
>b : number
>val : number
}

Просмотреть файл

@ -79,14 +79,14 @@ class Foo {
return new GenericType<string>(this);
>new GenericType<string>(this) : GenericType<string>
>GenericType : typeof GenericType
>this : Foo
>this : this
}
public populate() {
>populate : () => void
this.prop2;
>this.prop2 : BaseCollection<Derived>
>this : Foo
>this : this
>prop2 : BaseCollection<Derived>
}
public get prop2(): BaseCollection<Derived> {

Просмотреть файл

@ -12,7 +12,7 @@ class C {
[this.bar()]() { }
>this.bar() : number
>this.bar : () => number
>this : C
>this : this
>bar : () => number
};

Просмотреть файл

@ -12,7 +12,7 @@ class C {
[this.bar()]() { }
>this.bar() : number
>this.bar : () => number
>this : C
>this : this
>bar : () => number
};

Просмотреть файл

@ -15,7 +15,7 @@ class C {
[this.bar()]() { } // needs capture
>this.bar() : number
>this.bar : () => number
>this : C
>this : this
>bar : () => number
};

Просмотреть файл

@ -15,7 +15,7 @@ class C {
[this.bar()]() { } // needs capture
>this.bar() : number
>this.bar : () => number
>this : C
>this : this
>bar : () => number
};

Просмотреть файл

@ -20,7 +20,7 @@ class Rule {
this.name = name;
>this.name = name : string
>this.name : string
>this : Rule
>this : this
>name : string
>name : string
}

Просмотреть файл

@ -0,0 +1,24 @@
//// [contextualThisType.ts]
interface X {
a: (p: this) => this;
}
interface Y extends X {
}
var x: Y = {
a(p) {
return p;
}
}
var y = x.a(x);
//// [contextualThisType.js]
var x = {
a: function (p) {
return p;
}
};
var y = x.a(x);

Просмотреть файл

@ -0,0 +1,34 @@
=== tests/cases/conformance/types/thisType/contextualThisType.ts ===
interface X {
>X : Symbol(X, Decl(contextualThisType.ts, 0, 0))
a: (p: this) => this;
>a : Symbol(a, Decl(contextualThisType.ts, 0, 13))
>p : Symbol(p, Decl(contextualThisType.ts, 1, 8))
}
interface Y extends X {
>Y : Symbol(Y, Decl(contextualThisType.ts, 2, 1))
>X : Symbol(X, Decl(contextualThisType.ts, 0, 0))
}
var x: Y = {
>x : Symbol(x, Decl(contextualThisType.ts, 7, 3))
>Y : Symbol(Y, Decl(contextualThisType.ts, 2, 1))
a(p) {
>a : Symbol(a, Decl(contextualThisType.ts, 7, 12))
>p : Symbol(p, Decl(contextualThisType.ts, 8, 6))
return p;
>p : Symbol(p, Decl(contextualThisType.ts, 8, 6))
}
}
var y = x.a(x);
>y : Symbol(y, Decl(contextualThisType.ts, 13, 3))
>x.a : Symbol(X.a, Decl(contextualThisType.ts, 0, 13))
>x : Symbol(x, Decl(contextualThisType.ts, 7, 3))
>a : Symbol(X.a, Decl(contextualThisType.ts, 0, 13))
>x : Symbol(x, Decl(contextualThisType.ts, 7, 3))

Просмотреть файл

@ -0,0 +1,36 @@
=== tests/cases/conformance/types/thisType/contextualThisType.ts ===
interface X {
>X : X
a: (p: this) => this;
>a : (p: this) => this
>p : this
}
interface Y extends X {
>Y : Y
>X : X
}
var x: Y = {
>x : Y
>Y : Y
>{ a(p) { return p; }} : { a(p: Y): Y; }
a(p) {
>a : (p: Y) => Y
>p : Y
return p;
>p : Y
}
}
var y = x.a(x);
>y : Y
>x.a(x) : Y
>x.a : (p: Y) => Y
>x : Y
>a : (p: Y) => Y
>x : Y

Просмотреть файл

@ -21,7 +21,7 @@ class Foo{
delegate(this, function (source, args2)
>delegate(this, function (source, args2) { var a = source.node; var b = args2.node; } ) : (...args: any[]) => any
>delegate : (instance: any, method: (...args: any[]) => any, data?: any) => (...args: any[]) => any
>this : Foo
>this : this
>function (source, args2) { var a = source.node; var b = args2.node; } : (source: any, args2: any) => void
>source : any
>args2 : any

Просмотреть файл

@ -16,7 +16,7 @@ class C<T> {
return this.x;
>this.x : T
>this : C<T>
>this : this
>x : T
}
}

Просмотреть файл

@ -142,7 +142,7 @@ module templa.dom.mvc.composite {
this._controllers = [];
>this._controllers = [] : undefined[]
>this._controllers : templa.mvc.IController<templa.mvc.IModel>[]
>this : AbstractCompositeElementController<ModelType>
>this : this
>_controllers : templa.mvc.IController<templa.mvc.IModel>[]
>[] : undefined[]
}

Просмотреть файл

@ -12,7 +12,7 @@ class C1 {
return this.x;
>this.x : number
>this : C1
>this : this
>x : number
}
@ -60,7 +60,7 @@ class C2 extends C1 {
>super : C1
>f : () => number
>this.x : number
>this : C2
>this : this
>x : number
}
protected static sf() {

Просмотреть файл

@ -0,0 +1,63 @@
tests/cases/conformance/types/thisType/declarationFiles.ts(31,5): error TS2527: The inferred type of 'x1' references an inaccessible 'this' type. A type annotation is necessary.
tests/cases/conformance/types/thisType/declarationFiles.ts(33,5): error TS2527: The inferred type of 'x3' references an inaccessible 'this' type. A type annotation is necessary.
tests/cases/conformance/types/thisType/declarationFiles.ts(35,5): error TS2527: The inferred type of 'f1' references an inaccessible 'this' type. A type annotation is necessary.
tests/cases/conformance/types/thisType/declarationFiles.ts(41,5): error TS2527: The inferred type of 'f3' references an inaccessible 'this' type. A type annotation is necessary.
==== tests/cases/conformance/types/thisType/declarationFiles.ts (4 errors) ====
class C1 {
x: this;
f(x: this): this { return undefined; }
constructor(x: this) { }
}
class C2 {
[x: string]: this;
}
interface Foo<T> {
x: T;
y: this;
}
class C3 {
a: this[];
b: [this, this];
c: this | Date;
d: this & Date;
e: (((this)));
f: (x: this) => this;
g: new (x: this) => this;
h: Foo<this>;
i: Foo<this | (() => this)>;
j: (x: any) => x is this;
}
class C4 {
x1 = { a: this };
~~
!!! error TS2527: The inferred type of 'x1' references an inaccessible 'this' type. A type annotation is necessary.
x2 = [this];
x3 = [{ a: this }];
~~
!!! error TS2527: The inferred type of 'x3' references an inaccessible 'this' type. A type annotation is necessary.
x4 = () => this;
f1() {
~~
!!! error TS2527: The inferred type of 'f1' references an inaccessible 'this' type. A type annotation is necessary.
return { a: this };
}
f2() {
return [this];
}
f3() {
~~
!!! error TS2527: The inferred type of 'f3' references an inaccessible 'this' type. A type annotation is necessary.
return [{ a: this }];
}
f4() {
return () => this;
}
}

Просмотреть файл

@ -0,0 +1,135 @@
//// [declarationFiles.ts]
class C1 {
x: this;
f(x: this): this { return undefined; }
constructor(x: this) { }
}
class C2 {
[x: string]: this;
}
interface Foo<T> {
x: T;
y: this;
}
class C3 {
a: this[];
b: [this, this];
c: this | Date;
d: this & Date;
e: (((this)));
f: (x: this) => this;
g: new (x: this) => this;
h: Foo<this>;
i: Foo<this | (() => this)>;
j: (x: any) => x is this;
}
class C4 {
x1 = { a: this };
x2 = [this];
x3 = [{ a: this }];
x4 = () => this;
f1() {
return { a: this };
}
f2() {
return [this];
}
f3() {
return [{ a: this }];
}
f4() {
return () => this;
}
}
//// [declarationFiles.js]
var C1 = (function () {
function C1(x) {
}
C1.prototype.f = function (x) { return undefined; };
return C1;
})();
var C2 = (function () {
function C2() {
}
return C2;
})();
var C3 = (function () {
function C3() {
}
return C3;
})();
var C4 = (function () {
function C4() {
var _this = this;
this.x1 = { a: this };
this.x2 = [this];
this.x3 = [{ a: this }];
this.x4 = function () { return _this; };
}
C4.prototype.f1 = function () {
return { a: this };
};
C4.prototype.f2 = function () {
return [this];
};
C4.prototype.f3 = function () {
return [{ a: this }];
};
C4.prototype.f4 = function () {
var _this = this;
return function () { return _this; };
};
return C4;
})();
//// [declarationFiles.d.ts]
declare class C1 {
x: this;
f(x: this): this;
constructor(x: this);
}
declare class C2 {
[x: string]: this;
}
interface Foo<T> {
x: T;
y: this;
}
declare class C3 {
a: this[];
b: [this, this];
c: this | Date;
d: this & Date;
e: (((this)));
f: (x: this) => this;
g: new (x: this) => this;
h: Foo<this>;
i: Foo<this | (() => this)>;
j: (x: any) => x is this;
}
declare class C4 {
x1: {
a: this;
};
x2: this[];
x3: {
a: this;
}[];
x4: () => this;
f1(): {
a: this;
};
f2(): this[];
f3(): {
a: this;
}[];
f4(): () => this;
}

Просмотреть файл

@ -35,7 +35,7 @@ class MyClass {
this.db = db;
>this.db = db : db
>this.db : db
>this : MyClass
>this : this
>db : db
>db : db
@ -43,7 +43,7 @@ class MyClass {
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : db
>this : MyClass
>this : this
>db : db
>doSomething : () => void
}

Просмотреть файл

@ -36,7 +36,7 @@ class MyClass {
this.db = db;
>this.db = db : Database
>this.db : Database
>this : MyClass
>this : this
>db : Database
>db : Database
@ -44,7 +44,7 @@ class MyClass {
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : Database
>this : MyClass
>this : this
>db : Database
>doSomething : () => void
}

Просмотреть файл

@ -28,7 +28,7 @@ class MyClass {
this.db = db;
>this.db = db : db.db
>this.db : db.db
>this : MyClass
>this : this
>db : db.db
>db : db.db
@ -36,7 +36,7 @@ class MyClass {
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : db.db
>this : MyClass
>this : this
>db : db.db
>doSomething : () => void
}

Просмотреть файл

@ -35,7 +35,7 @@ class MyClass {
this.db = db;
>this.db = db : db
>this.db : db
>this : MyClass
>this : this
>db : db
>db : db
@ -43,7 +43,7 @@ class MyClass {
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : db
>this : MyClass
>this : this
>db : db
>doSomething : () => void
}

Просмотреть файл

@ -35,7 +35,7 @@ class MyClass {
this.db = db;
>this.db = db : database
>this.db : database
>this : MyClass
>this : this
>db : database
>db : database
@ -43,7 +43,7 @@ class MyClass {
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : database
>this : MyClass
>this : this
>db : database
>doSomething : () => void
}

Просмотреть файл

@ -28,7 +28,7 @@ class MyClass {
this.db = db;
>this.db = db : database.db
>this.db : database.db
>this : MyClass
>this : this
>db : database.db
>db : database.db
@ -36,7 +36,7 @@ class MyClass {
>this.db.doSomething() : void
>this.db.doSomething : () => void
>this.db : database.db
>this : MyClass
>this : this
>db : database.db
>doSomething : () => void
}

Просмотреть файл

@ -11,7 +11,7 @@ class Red extends Color {
>() => { return this.hue(); } : () => string
>this.hue() : string
>this.hue : () => string
>this : Red
>this : this
>hue : () => string
return getHue() + " red";
@ -46,7 +46,7 @@ class Blue extends Color {
>() => { return this.hue(); } : () => string
>this.hue() : string
>this.hue : () => string
>this : Blue
>this : this
>hue : () => string
return getHue() + " blue";

Просмотреть файл

@ -19,13 +19,13 @@ class TestFile {
>message + this.name : string
>message : string
>this.name : any
>this : TestFile
>this : this
>name : any
this.message = getMessage();
>this.message = getMessage() : string
>this.message : string
>this : TestFile
>this : this
>message : string
>getMessage() : string
>getMessage : () => string

Просмотреть файл

@ -20,13 +20,13 @@ class TestFile {
>message + this.name : string
>message : string
>this.name : string
>this : TestFile
>this : this
>name : string
this.message = getMessage();
>this.message = getMessage() : string
>this.message : string
>this : TestFile
>this : this
>message : string
>getMessage() : string
>getMessage : () => string

Просмотреть файл

@ -20,7 +20,7 @@ class TestFile {
>message + this.name : string
>message : string
>this.name : string
>this : TestFile
>this : this
>name : string
}
}

Просмотреть файл

@ -21,7 +21,7 @@ class TestFile {
>message + this.name : string
>message : string
>this.name : string
>this : TestFile
>this : this
>name : string
}
}

Просмотреть файл

@ -38,7 +38,7 @@ class B {
this.y = 10;
>this.y = 10 : number
>this.y : number
>this : B
>this : this
>y : number
>10 : number
}
@ -53,7 +53,7 @@ class B {
return this._bar;
>this._bar : string
>this : B
>this : this
>_bar : string
}
}

Просмотреть файл

@ -10,7 +10,7 @@ class C {
return this._name;
>this._name : string
>this : C
>this : this
>_name : string
}
static get name2(): string {

Просмотреть файл

@ -25,7 +25,7 @@ class D {
return this._bar;
>this._bar : string
>this : D
>this : this
>_bar : string
}
baz(a: any, x: string): string {

Просмотреть файл

@ -21,7 +21,7 @@ class D {
this.y = 10;
>this.y = 10 : number
>this.y : number
>this : D
>this : this
>y : number
>10 : number
}
@ -55,7 +55,7 @@ class F extends D{
this.j = "HI";
>this.j = "HI" : string
>this.j : string
>this : F
>this : this
>j : string
>"HI" : string
}

Просмотреть файл

@ -10,7 +10,7 @@ class B {
this.x = 10;
>this.x = 10 : number
>this.x : number
>this : B
>this : this
>x : number
>10 : number
}
@ -27,7 +27,7 @@ class B {
>B : typeof B
>log : (a: number) => void
>this.x : number
>this : B
>this : this
>x : number
}
@ -36,7 +36,7 @@ class B {
return this.x;
>this.x : number
>this : B
>this : this
>x : number
}
@ -47,7 +47,7 @@ class B {
this.x = y;
>this.x = y : number
>this.x : number
>this : B
>this : this
>x : number
>y : number
}

Просмотреть файл

@ -24,7 +24,7 @@ class B<T> {
>T : T
>this.B = a : T
>this.B : T
>this : B<T>
>this : this
>B : T
>a : T
@ -47,7 +47,7 @@ class B<T> {
return this.x;
>this.x : T
>this : B<T>
>this : this
>x : T
}
@ -57,7 +57,7 @@ class B<T> {
return this.B;
>this.B : T
>this : B<T>
>this : this
>B : T
}
set BBWith(c: T) {
@ -68,7 +68,7 @@ class B<T> {
this.B = c;
>this.B = c : T
>this.B : T
>this : B<T>
>this : this
>B : T
>c : T
}

Просмотреть файл

@ -16,7 +16,7 @@ class B<T> {
>T : T
>this.B = a : T
>this.B : T
>this : B<T>
>this : this
>B : T
>a : T
@ -26,7 +26,7 @@ class B<T> {
return this.x;
>this.x : T
>this : B<T>
>this : this
>x : T
}
get BB(): T {
@ -35,7 +35,7 @@ class B<T> {
return this.B;
>this.B : T
>this : B<T>
>this : this
>B : T
}
set BBWith(c: T) {
@ -46,7 +46,7 @@ class B<T> {
this.B = c;
>this.B = c : T
>this.B : T
>this : B<T>
>this : this
>B : T
>c : T
}

Просмотреть файл

@ -24,14 +24,14 @@ module M {
this.x = 1;
>this.x = 1 : number
>this.x : number
>this : Visibility
>this : this
>x : number
>1 : number
this.y = 2;
>this.y = 2 : number
>this.y : number
>this : Visibility
>this : this
>y : number
>2 : number
}

Просмотреть файл

@ -119,7 +119,7 @@ class Camera {
this.forward = Vector.norm(Vector.minus(lookAt,this.pos));
>this.forward = Vector.norm(Vector.minus(lookAt,this.pos)) : Vector
>this.forward : Vector
>this : Camera
>this : this
>forward : Vector
>Vector.norm(Vector.minus(lookAt,this.pos)) : Vector
>Vector.norm : (v: Vector) => Vector
@ -131,13 +131,13 @@ class Camera {
>minus : (v1: Vector, v2: Vector) => Vector
>lookAt : Vector
>this.pos : Vector
>this : Camera
>this : this
>pos : Vector
this.right = Vector.times(down, Vector.norm(Vector.cross(this.forward, down)));
>this.right = Vector.times(down, Vector.norm(Vector.cross(this.forward, down))) : Vector
>this.right : Vector
>this : Camera
>this : this
>right : Vector
>Vector.times(down, Vector.norm(Vector.cross(this.forward, down))) : Vector
>Vector.times : (v1: Vector, v2: Vector) => Vector
@ -153,14 +153,14 @@ class Camera {
>Vector : typeof Vector
>cross : (v1: Vector, v2: Vector) => Vector
>this.forward : Vector
>this : Camera
>this : this
>forward : Vector
>down : Vector
this.up = Vector.times(down, Vector.norm(Vector.cross(this.forward, this.right)));
>this.up = Vector.times(down, Vector.norm(Vector.cross(this.forward, this.right))) : Vector
>this.up : Vector
>this : Camera
>this : this
>up : Vector
>Vector.times(down, Vector.norm(Vector.cross(this.forward, this.right))) : Vector
>Vector.times : (v1: Vector, v2: Vector) => Vector
@ -176,10 +176,10 @@ class Camera {
>Vector : typeof Vector
>cross : (v1: Vector, v2: Vector) => Vector
>this.forward : Vector
>this : Camera
>this : this
>forward : Vector
>this.right : Vector
>this : Camera
>this : this
>right : Vector
}
}

Просмотреть файл

@ -38,7 +38,7 @@ module Consumer {
>this.emitter.addListener('change', (e) => { this.changed(); }) : void
>this.emitter.addListener : (type: string, listener: Events.ListenerCallback) => void
>this.emitter : Events.EventEmitter
>this : EventEmitterConsummer
>this : this
>emitter : Events.EventEmitter
>addListener : (type: string, listener: Events.ListenerCallback) => void
>'change' : string
@ -48,7 +48,7 @@ module Consumer {
this.changed();
>this.changed() : void
>this.changed : () => void
>this : EventEmitterConsummer
>this : this
>changed : () => void
});

Просмотреть файл

@ -0,0 +1,56 @@
//// [fluentClasses.ts]
class A {
foo() {
return this;
}
}
class B extends A {
bar() {
return this;
}
}
class C extends B {
baz() {
return this;
}
}
var c: C;
var z = c.foo().bar().baz(); // Fluent pattern
//// [fluentClasses.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var A = (function () {
function A() {
}
A.prototype.foo = function () {
return this;
};
return A;
})();
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
B.prototype.bar = function () {
return this;
};
return B;
})(A);
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
C.prototype.baz = function () {
return this;
};
return C;
})(B);
var c;
var z = c.foo().bar().baz(); // Fluent pattern

Просмотреть файл

@ -0,0 +1,47 @@
=== tests/cases/conformance/types/thisType/fluentClasses.ts ===
class A {
>A : Symbol(A, Decl(fluentClasses.ts, 0, 0))
foo() {
>foo : Symbol(foo, Decl(fluentClasses.ts, 0, 9))
return this;
>this : Symbol(A, Decl(fluentClasses.ts, 0, 0))
}
}
class B extends A {
>B : Symbol(B, Decl(fluentClasses.ts, 4, 1))
>A : Symbol(A, Decl(fluentClasses.ts, 0, 0))
bar() {
>bar : Symbol(bar, Decl(fluentClasses.ts, 5, 19))
return this;
>this : Symbol(B, Decl(fluentClasses.ts, 4, 1))
}
}
class C extends B {
>C : Symbol(C, Decl(fluentClasses.ts, 9, 1))
>B : Symbol(B, Decl(fluentClasses.ts, 4, 1))
baz() {
>baz : Symbol(baz, Decl(fluentClasses.ts, 10, 19))
return this;
>this : Symbol(C, Decl(fluentClasses.ts, 9, 1))
}
}
var c: C;
>c : Symbol(c, Decl(fluentClasses.ts, 15, 3))
>C : Symbol(C, Decl(fluentClasses.ts, 9, 1))
var z = c.foo().bar().baz(); // Fluent pattern
>z : Symbol(z, Decl(fluentClasses.ts, 16, 3))
>c.foo().bar().baz : Symbol(C.baz, Decl(fluentClasses.ts, 10, 19))
>c.foo().bar : Symbol(B.bar, Decl(fluentClasses.ts, 5, 19))
>c.foo : Symbol(A.foo, Decl(fluentClasses.ts, 0, 9))
>c : Symbol(c, Decl(fluentClasses.ts, 15, 3))
>foo : Symbol(A.foo, Decl(fluentClasses.ts, 0, 9))
>bar : Symbol(B.bar, Decl(fluentClasses.ts, 5, 19))
>baz : Symbol(C.baz, Decl(fluentClasses.ts, 10, 19))

Просмотреть файл

@ -0,0 +1,50 @@
=== tests/cases/conformance/types/thisType/fluentClasses.ts ===
class A {
>A : A
foo() {
>foo : () => this
return this;
>this : this
}
}
class B extends A {
>B : B
>A : A
bar() {
>bar : () => this
return this;
>this : this
}
}
class C extends B {
>C : C
>B : B
baz() {
>baz : () => this
return this;
>this : this
}
}
var c: C;
>c : C
>C : C
var z = c.foo().bar().baz(); // Fluent pattern
>z : C
>c.foo().bar().baz() : C
>c.foo().bar().baz : () => C
>c.foo().bar() : C
>c.foo().bar : () => C
>c.foo() : C
>c.foo : () => C
>c : C
>foo : () => C
>bar : () => C
>baz : () => C

Просмотреть файл

@ -0,0 +1,17 @@
//// [fluentInterfaces.ts]
interface A {
foo(): this;
}
interface B extends A {
bar(): this;
}
interface C extends B {
baz(): this;
}
var c: C;
var z = c.foo().bar().baz(); // Fluent pattern
//// [fluentInterfaces.js]
var c;
var z = c.foo().bar().baz(); // Fluent pattern

Просмотреть файл

@ -0,0 +1,35 @@
=== tests/cases/conformance/types/thisType/fluentInterfaces.ts ===
interface A {
>A : Symbol(A, Decl(fluentInterfaces.ts, 0, 0))
foo(): this;
>foo : Symbol(foo, Decl(fluentInterfaces.ts, 0, 13))
}
interface B extends A {
>B : Symbol(B, Decl(fluentInterfaces.ts, 2, 1))
>A : Symbol(A, Decl(fluentInterfaces.ts, 0, 0))
bar(): this;
>bar : Symbol(bar, Decl(fluentInterfaces.ts, 3, 23))
}
interface C extends B {
>C : Symbol(C, Decl(fluentInterfaces.ts, 5, 1))
>B : Symbol(B, Decl(fluentInterfaces.ts, 2, 1))
baz(): this;
>baz : Symbol(baz, Decl(fluentInterfaces.ts, 6, 23))
}
var c: C;
>c : Symbol(c, Decl(fluentInterfaces.ts, 9, 3))
>C : Symbol(C, Decl(fluentInterfaces.ts, 5, 1))
var z = c.foo().bar().baz(); // Fluent pattern
>z : Symbol(z, Decl(fluentInterfaces.ts, 10, 3))
>c.foo().bar().baz : Symbol(C.baz, Decl(fluentInterfaces.ts, 6, 23))
>c.foo().bar : Symbol(B.bar, Decl(fluentInterfaces.ts, 3, 23))
>c.foo : Symbol(A.foo, Decl(fluentInterfaces.ts, 0, 13))
>c : Symbol(c, Decl(fluentInterfaces.ts, 9, 3))
>foo : Symbol(A.foo, Decl(fluentInterfaces.ts, 0, 13))
>bar : Symbol(B.bar, Decl(fluentInterfaces.ts, 3, 23))
>baz : Symbol(C.baz, Decl(fluentInterfaces.ts, 6, 23))

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше