diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4540a4409d65b..205ef1a9680f8 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -98,6 +98,8 @@ namespace ts { HasLocals = 1 << 5, IsInterface = 1 << 6, IsObjectLiteralOrClassExpressionMethod = 1 << 7, + // Indicates that the container isn't stored as a local/export in its parent, but is stored as a local within itself + IsSelfContained = 1 << 8, } let flowNodeCreated: (node: T) => T = identity; @@ -502,6 +504,15 @@ namespace ts { } } + function bindSelfContainedDeclaration(node: Declaration) { + switch (node.kind) { + case SyntaxKind.InlineTypeAliasDeclaration: + return declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); + default: + return Debug.fail("Unhandled self-containing declaration kind"); + } + } + // All container nodes are kept on a linked list in declaration order. This list is used by // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. @@ -539,6 +550,10 @@ namespace ts { container.locals = createSymbolTable(); } addToContainerChain(container); + if (containerFlags & ContainerFlags.IsSelfContained) { + // We have to bind self-contained structures _after_ setting up the container symbol tables, but _before_ binding children + bindSelfContainedDeclaration(container); + } } else if (containerFlags & ContainerFlags.IsBlockScopedContainer) { blockScopeContainer = node; @@ -1483,6 +1498,9 @@ namespace ts { case SyntaxKind.MappedType: return ContainerFlags.IsContainer | ContainerFlags.HasLocals; + case SyntaxKind.InlineTypeAliasDeclaration: + return ContainerFlags.IsContainer | ContainerFlags.HasLocals | ContainerFlags.IsSelfContained; + case SyntaxKind.SourceFile: return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals; @@ -1601,6 +1619,7 @@ namespace ts { case SyntaxKind.JSDocTypedefTag: case SyntaxKind.JSDocCallbackTag: case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.InlineTypeAliasDeclaration: case SyntaxKind.MappedType: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, @@ -2183,6 +2202,8 @@ namespace ts { return; case SyntaxKind.TypePredicate: break; // Binding the children will handle everything + case SyntaxKind.InlineTypeAliasDeclaration: + break; // Container binding should have handled everything case SyntaxKind.TypeParameter: return bindTypeParameter(node as TypeParameterDeclaration); case SyntaxKind.Parameter: @@ -3751,6 +3772,7 @@ namespace ts { case SyntaxKind.ParenthesizedType: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.InlineTypeAliasDeclaration: case SyntaxKind.ThisType: case SyntaxKind.TypeOperator: case SyntaxKind.IndexedAccessType: @@ -3920,6 +3942,7 @@ namespace ts { case SyntaxKind.IndexSignature: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.InlineTypeAliasDeclaration: return TransformFlags.TypeExcludes; case SyntaxKind.ObjectLiteralExpression: return TransformFlags.ObjectLiteralExcludes; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5091f5f03063a..b7137595a4445 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3606,6 +3606,12 @@ namespace ts { ? symbolToTypeNode(type.symbol, context, SymbolFlags.Type) : createTypeReferenceNode(createIdentifier("?"), /*typeArguments*/ undefined); } + if (context.visitedTypes && context.visitedTypes.has("" + getTypeId(type))) { + // _Within_ an alias symbol declaration, references to the alias type should be the alias name + // If this is done, we need to mark the type as needing to preserve the alias when we get back up to it. + context.visitedTypes.set("" + getTypeId(type), true); + return createTypeReferenceNode(getNameForInlineTypeAliasCreation(type, context), /*typeArguments*/ undefined); + } if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return createTypeReferenceNode(createIdentifier(""), typeArgumentNodes); @@ -3715,7 +3721,7 @@ namespace ts { // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead // of types allows us to catch circular references to instantiations of the same anonymous type if (!context.visitedTypes) { - context.visitedTypes = createMap(); + context.visitedTypes = createMap(); } if (!context.symbolDepth) { context.symbolDepth = createMap(); @@ -3726,8 +3732,13 @@ namespace ts { return createElidedInformationPlaceholder(context); } context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - const result = createTypeNodeFromObjectType(type); + Debug.assert(!context.visitedTypes.has(typeId)); + context.visitedTypes.set(typeId, false); + let result = createTypeNodeFromObjectType(type); + if (context.visitedTypes.get(typeId) === true) { + // Circular reference is required - emit an inline type alias + result = createInlineTypeAliasDeclaration(getNameForInlineTypeAliasCreation(type, context), result); + } context.visitedTypes.delete(typeId); context.symbolDepth.set(id, depth); return result; @@ -3752,6 +3763,35 @@ namespace ts { } } + function nameShadowsNameInScope(escapedName: __String, context: NodeBuilderContext) { + return !!resolveName(context.enclosingDeclaration, escapedName, SymbolFlags.Type, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + } + + function getSyntheticTypeNameForType(type: Type, context: NodeBuilderContext, seed: string): string { + const typeId = "" + getTypeId(type); + if (context.syntheticTypeNames && context.syntheticTypeNames.get(typeId)) { + return context.syntheticTypeNames.get(typeId)!; + } + let i = 0; + let text = seed; + while ((context.usedSyntheticTypeNames && context.usedSyntheticTypeNames.get(text)) || nameShadowsNameInScope(escapeLeadingUnderscores(text), context)) { + i++; + text = `${seed}_${i}`; + } + (context.usedSyntheticTypeNames || (context.usedSyntheticTypeNames = createMap())).set(text, true); + (context.syntheticTypeNames || (context.syntheticTypeNames = createMap())).set(typeId, text); + return text; + } + + function getNameForInlineTypeAliasCreation(type: Type, context: NodeBuilderContext): Identifier { + // If it was originally made using an inline type alias, reuse that name, otherwise + // get a generated name for the (usually anonymous) type node which contains the + // circular reference + return type.aliasSymbol && some(type.aliasSymbol.declarations, isInlineTypeAlias) + ? createIdentifier(unescapeLeadingUnderscores(type.aliasSymbol.escapedName)) + : createIdentifier(getSyntheticTypeNameForType(type, context, "Anon")); + } + function createTypeNodeFromObjectType(type: ObjectType): TypeNode { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -4632,12 +4672,18 @@ namespace ts { // State encounteredError: boolean; - visitedTypes: Map | undefined; + /** + * Entry is set to `false` when first encountered, and `true` if a circular reference + * was emitted (and thus needs to has its a name emitted) + */ + visitedTypes: Map | undefined; symbolDepth: Map | undefined; inferTypeParameters: TypeParameter[] | undefined; approximateLength: number; truncating?: boolean; typeParameterSymbolList?: Map; + usedSyntheticTypeNames?: Map; + syntheticTypeNames?: Map; } function isDefaultBindingContext(location: Node) { @@ -4723,6 +4769,8 @@ namespace ts { function determineIfDeclarationIsVisible() { switch (node.kind) { + case SyntaxKind.InlineTypeAliasDeclaration: + return true; // Always consider inline type alias declaration as "visible" when they were reachable (since they can only be referenced from a child) case SyntaxKind.JSDocCallbackTag: case SyntaxKind.JSDocTypedefTag: // Top-level jsdoc type aliases are considered exported @@ -6339,8 +6387,8 @@ namespace ts { return errorType; } - const declaration = find(symbol.declarations, d => - isJSDocTypeAlias(d) || d.kind === SyntaxKind.TypeAliasDeclaration); + const declaration = find(symbol.declarations, d => + isJSDocTypeAlias(d) || d.kind === SyntaxKind.TypeAliasDeclaration || d.kind === SyntaxKind.InlineTypeAliasDeclaration); const typeNode = isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. let type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -10673,7 +10721,7 @@ namespace ts { } function getAliasSymbolForTypeNode(node: TypeNode) { - return isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + return isTypeAlias(node.parent) || isInlineTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; } function getTypeArgumentsForAliasSymbol(symbol: Symbol | undefined) { @@ -10684,6 +10732,14 @@ namespace ts { return !!(type.flags & TypeFlags.Object) && !isGenericMappedType(type); } + function getTypeFromInlineTypeAliasDeclaration(node: InlineTypeAliasDeclaration): Type { + const links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getDeclaredTypeOfTypeAlias(node.symbol); + } + return links.resolvedType; + } + /** * Since the source of spread types are object literals, which are not binary, * this function should be called in a left folding style, with left = previous result of getSpreadType @@ -10985,6 +11041,8 @@ namespace ts { return getTypeFromInferTypeNode(node); case SyntaxKind.ImportType: return getTypeFromImportTypeNode(node); + case SyntaxKind.InlineTypeAliasDeclaration: + return getTypeFromInlineTypeAliasDeclaration(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case SyntaxKind.Identifier: @@ -11251,7 +11309,7 @@ namespace ts { return !!tp.isThisType; case SyntaxKind.Identifier: return !tp.isThisType && isPartOfTypeNode(node) && maybeTypeParameterReference(node) && - getTypeFromTypeNode(node) === tp; + getSymbolAtLocation(node) === tp.symbol; case SyntaxKind.TypeQuery: return true; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 07b1208688fab..713960e346154 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1221,6 +1221,8 @@ namespace ts { return emitLiteralType(node); case SyntaxKind.ImportType: return emitImportTypeNode(node); + case SyntaxKind.InlineTypeAliasDeclaration: + return emitInlineTypeAliasDeclaration(node); case SyntaxKind.JSDocAllType: writePunctuation("*"); return; @@ -2074,6 +2076,16 @@ namespace ts { emitTypeArguments(node, node.typeArguments); } + function emitInlineTypeAliasDeclaration(node: InlineTypeAliasDeclaration) { + writeKeyword("type"); + writeSpace(); + emit(node.name); + writeSpace(); + writePunctuation("="); + writeSpace(); + emit(node.type); + } + // // Binding patterns // diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 517ebacb89dfb..7bbb2b239bf9c 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -932,6 +932,20 @@ namespace ts { : node; } + export function createInlineTypeAliasDeclaration(name: Identifier | string, type: TypeNode) { + const node = createSynthesizedNode(SyntaxKind.InlineTypeAliasDeclaration) as InlineTypeAliasDeclaration; + node.name = asName(name); + node.type = type; + return node; + } + + export function updateInlineTypeAliasDeclaration(node: InlineTypeAliasDeclaration, name: Identifier | string, type: TypeNode) { + return node.name !== name + || node.type !== type + ? updateNode(createInlineTypeAliasDeclaration(name, type), node) + : node; + } + // Binding Patterns export function createObjectBindingPattern(elements: ReadonlyArray) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c38e4f67fe287..357e6fe6c4cfe 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -204,6 +204,9 @@ namespace ts { visitNode(cbNode, (node).type); case SyntaxKind.LiteralType: return visitNode(cbNode, (node).literal); + case SyntaxKind.InlineTypeAliasDeclaration: + return visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).type); case SyntaxKind.ObjectBindingPattern: case SyntaxKind.ArrayBindingPattern: return visitNodes(cbNode, cbNodes, (node).elements); @@ -3030,6 +3033,7 @@ namespace ts { case SyntaxKind.DotDotDotToken: case SyntaxKind.InferKeyword: case SyntaxKind.ImportKeyword: + case SyntaxKind.TypeKeyword: return true; case SyntaxKind.FunctionKeyword: return !inStartOfParameter; @@ -3119,6 +3123,8 @@ namespace ts { return parseTypeOperator(operator); case SyntaxKind.InferKeyword: return parseInferType(); + case SyntaxKind.TypeKeyword: + return parseInlineTypeAliasDeclaration(); } return parsePostfixTypeOrHigher(); } @@ -5996,6 +6002,15 @@ namespace ts { return finishNode(node); } + function parseInlineTypeAliasDeclaration(): InlineTypeAliasDeclaration { + const node = createNode(SyntaxKind.InlineTypeAliasDeclaration); + parseExpected(SyntaxKind.TypeKeyword); + node.name = parseIdentifier(); + parseExpected(SyntaxKind.EqualsToken); + node.type = parseType(); + return finishNode(node); + } + // In an ambient declaration, the grammar only allows integer literals as initializers. // In a non-ambient declaration, the grammar allows uninitialized members only in a // ConstantEnumMemberSection, which starts at the beginning of an enum declaration diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 20aac7d4936e5..f649d97dba401 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -542,7 +542,8 @@ namespace ts { || isInterfaceDeclaration(node) || isFunctionLike(node) || isIndexSignatureDeclaration(node) - || isMappedTypeNode(node); + || isMappedTypeNode(node) + || isInlineTypeAlias(node); } function checkEntityNameVisibility(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 03ca196a8608c..82509ba47fa43 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -320,6 +320,7 @@ namespace ts { MappedType, LiteralType, ImportType, + InlineTypeAliasDeclaration, // Binding patterns ObjectBindingPattern, ArrayBindingPattern, @@ -495,7 +496,7 @@ namespace ts { FirstFutureReservedWord = ImplementsKeyword, LastFutureReservedWord = YieldKeyword, FirstTypeNode = TypePredicate, - LastTypeNode = ImportType, + LastTypeNode = InlineTypeAliasDeclaration, FirstPunctuation = OpenBraceToken, LastPunctuation = CaretEqualsToken, FirstToken = Unknown, @@ -2204,6 +2205,12 @@ namespace ts { type: TypeNode; } + export interface InlineTypeAliasDeclaration extends TypeNode, Declaration, JSDocContainer { + kind: SyntaxKind.InlineTypeAliasDeclaration; + name: Identifier; + type: TypeNode; + } + export interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent: EnumDeclaration; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0ec81502cf799..be37c2532dbc0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2155,6 +2155,10 @@ namespace ts { return isJSDocTypeAlias(node) || isTypeAliasDeclaration(node); } + export function isInlineTypeAlias(node: Node): node is InlineTypeAliasDeclaration { + return node.kind === SyntaxKind.InlineTypeAliasDeclaration; + } + function getSourceOfAssignment(node: Node): Node | undefined { return isExpressionStatement(node) && node.expression && isBinaryExpression(node.expression) && @@ -6733,6 +6737,7 @@ namespace ts { || kind === SyntaxKind.PropertySignature || kind === SyntaxKind.SetAccessor || kind === SyntaxKind.ShorthandPropertyAssignment + || kind === SyntaxKind.InlineTypeAliasDeclaration || kind === SyntaxKind.TypeAliasDeclaration || kind === SyntaxKind.TypeParameter || kind === SyntaxKind.VariableDeclaration diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 53ccd81f7a6a3..f675e0cf8470b 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -435,6 +435,11 @@ namespace ts { return updateLiteralTypeNode(node, visitNode((node).literal, visitor, isExpression)); + case SyntaxKind.InlineTypeAliasDeclaration: + return updateInlineTypeAliasDeclaration(node, + visitNode((node).name, visitor, isIdentifier), + visitNode((node).type, visitor, isTypeNode)); + // Binding patterns case SyntaxKind.ObjectBindingPattern: diff --git a/tests/baselines/reference/YieldExpression7_es6.types b/tests/baselines/reference/YieldExpression7_es6.types index 44dcc196c3bdc..e5729db8aed0c 100644 --- a/tests/baselines/reference/YieldExpression7_es6.types +++ b/tests/baselines/reference/YieldExpression7_es6.types @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts === function* foo() { ->foo : () => IterableIterator +>foo : type Anon = () => IterableIterator yield foo >yield foo : any ->foo : () => IterableIterator +>foo : type Anon = () => IterableIterator } diff --git a/tests/baselines/reference/YieldExpression8_es6.types b/tests/baselines/reference/YieldExpression8_es6.types index 67343e3fbfcc8..01f4fb8696d51 100644 --- a/tests/baselines/reference/YieldExpression8_es6.types +++ b/tests/baselines/reference/YieldExpression8_es6.types @@ -2,13 +2,13 @@ yield(foo); >yield(foo) : any >yield : any ->foo : () => IterableIterator +>foo : type Anon = () => IterableIterator function* foo() { ->foo : () => IterableIterator +>foo : type Anon = () => IterableIterator yield(foo); >yield(foo) : any ->(foo) : () => IterableIterator ->foo : () => IterableIterator +>(foo) : type Anon = () => IterableIterator +>foo : type Anon = () => IterableIterator } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index d10aa28ffe40f..8b55dd77671be 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -262,140 +262,141 @@ declare namespace ts { MappedType = 182, LiteralType = 183, ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocComment = 297, - JSDocTypeLiteral = 298, - JSDocSignature = 299, - JSDocTag = 300, - JSDocAugmentsTag = 301, - JSDocClassTag = 302, - JSDocCallbackTag = 303, - JSDocEnumTag = 304, - JSDocParameterTag = 305, - JSDocReturnTag = 306, - JSDocThisTag = 307, - JSDocTypeTag = 308, - JSDocTemplateTag = 309, - JSDocTypedefTag = 310, - JSDocPropertyTag = 311, - SyntaxList = 312, - NotEmittedStatement = 313, - PartiallyEmittedExpression = 314, - CommaListExpression = 315, - MergeDeclarationMarker = 316, - EndOfDeclarationMarker = 317, - Count = 318, + InlineTypeAliasDeclaration = 185, + ObjectBindingPattern = 186, + ArrayBindingPattern = 187, + BindingElement = 188, + ArrayLiteralExpression = 189, + ObjectLiteralExpression = 190, + PropertyAccessExpression = 191, + ElementAccessExpression = 192, + CallExpression = 193, + NewExpression = 194, + TaggedTemplateExpression = 195, + TypeAssertionExpression = 196, + ParenthesizedExpression = 197, + FunctionExpression = 198, + ArrowFunction = 199, + DeleteExpression = 200, + TypeOfExpression = 201, + VoidExpression = 202, + AwaitExpression = 203, + PrefixUnaryExpression = 204, + PostfixUnaryExpression = 205, + BinaryExpression = 206, + ConditionalExpression = 207, + TemplateExpression = 208, + YieldExpression = 209, + SpreadElement = 210, + ClassExpression = 211, + OmittedExpression = 212, + ExpressionWithTypeArguments = 213, + AsExpression = 214, + NonNullExpression = 215, + MetaProperty = 216, + SyntheticExpression = 217, + TemplateSpan = 218, + SemicolonClassElement = 219, + Block = 220, + VariableStatement = 221, + EmptyStatement = 222, + ExpressionStatement = 223, + IfStatement = 224, + DoStatement = 225, + WhileStatement = 226, + ForStatement = 227, + ForInStatement = 228, + ForOfStatement = 229, + ContinueStatement = 230, + BreakStatement = 231, + ReturnStatement = 232, + WithStatement = 233, + SwitchStatement = 234, + LabeledStatement = 235, + ThrowStatement = 236, + TryStatement = 237, + DebuggerStatement = 238, + VariableDeclaration = 239, + VariableDeclarationList = 240, + FunctionDeclaration = 241, + ClassDeclaration = 242, + InterfaceDeclaration = 243, + TypeAliasDeclaration = 244, + EnumDeclaration = 245, + ModuleDeclaration = 246, + ModuleBlock = 247, + CaseBlock = 248, + NamespaceExportDeclaration = 249, + ImportEqualsDeclaration = 250, + ImportDeclaration = 251, + ImportClause = 252, + NamespaceImport = 253, + NamedImports = 254, + ImportSpecifier = 255, + ExportAssignment = 256, + ExportDeclaration = 257, + NamedExports = 258, + ExportSpecifier = 259, + MissingDeclaration = 260, + ExternalModuleReference = 261, + JsxElement = 262, + JsxSelfClosingElement = 263, + JsxOpeningElement = 264, + JsxClosingElement = 265, + JsxFragment = 266, + JsxOpeningFragment = 267, + JsxClosingFragment = 268, + JsxAttribute = 269, + JsxAttributes = 270, + JsxSpreadAttribute = 271, + JsxExpression = 272, + CaseClause = 273, + DefaultClause = 274, + HeritageClause = 275, + CatchClause = 276, + PropertyAssignment = 277, + ShorthandPropertyAssignment = 278, + SpreadAssignment = 279, + EnumMember = 280, + UnparsedPrologue = 281, + UnparsedPrepend = 282, + UnparsedText = 283, + UnparsedInternalText = 284, + UnparsedSyntheticReference = 285, + SourceFile = 286, + Bundle = 287, + UnparsedSource = 288, + InputFiles = 289, + JSDocTypeExpression = 290, + JSDocAllType = 291, + JSDocUnknownType = 292, + JSDocNullableType = 293, + JSDocNonNullableType = 294, + JSDocOptionalType = 295, + JSDocFunctionType = 296, + JSDocVariadicType = 297, + JSDocComment = 298, + JSDocTypeLiteral = 299, + JSDocSignature = 300, + JSDocTag = 301, + JSDocAugmentsTag = 302, + JSDocClassTag = 303, + JSDocCallbackTag = 304, + JSDocEnumTag = 305, + JSDocParameterTag = 306, + JSDocReturnTag = 307, + JSDocThisTag = 308, + JSDocTypeTag = 309, + JSDocTemplateTag = 310, + JSDocTypedefTag = 311, + JSDocPropertyTag = 312, + SyntaxList = 313, + NotEmittedStatement = 314, + PartiallyEmittedExpression = 315, + CommaListExpression = 316, + MergeDeclarationMarker = 317, + EndOfDeclarationMarker = 318, + Count = 319, FirstAssignment = 60, LastAssignment = 72, FirstCompoundAssignment = 61, @@ -407,7 +408,7 @@ declare namespace ts { FirstFutureReservedWord = 110, LastFutureReservedWord = 118, FirstTypeNode = 164, - LastTypeNode = 184, + LastTypeNode = 185, FirstPunctuation = 18, LastPunctuation = 72, FirstToken = 0, @@ -421,10 +422,10 @@ declare namespace ts { FirstBinaryOperator = 28, LastBinaryOperator = 72, FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 311, - FirstJSDocTagNode = 300, - LastJSDocTagNode = 311, + FirstJSDocNode = 290, + LastJSDocNode = 312, + FirstJSDocTagNode = 301, + LastJSDocTagNode = 312, } enum NodeFlags { None = 0, @@ -1392,6 +1393,11 @@ declare namespace ts { typeParameters?: NodeArray; type: TypeNode; } + interface InlineTypeAliasDeclaration extends TypeNode, Declaration, JSDocContainer { + kind: SyntaxKind.InlineTypeAliasDeclaration; + name: Identifier; + type: TypeNode; + } interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent: EnumDeclaration; @@ -3853,6 +3859,8 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; + function createInlineTypeAliasDeclaration(name: Identifier | string, type: TypeNode): InlineTypeAliasDeclaration; + function updateInlineTypeAliasDeclaration(node: InlineTypeAliasDeclaration, name: Identifier | string, type: TypeNode): InlineTypeAliasDeclaration; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 58ccd42344b00..64c08615eb428 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -262,140 +262,141 @@ declare namespace ts { MappedType = 182, LiteralType = 183, ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocComment = 297, - JSDocTypeLiteral = 298, - JSDocSignature = 299, - JSDocTag = 300, - JSDocAugmentsTag = 301, - JSDocClassTag = 302, - JSDocCallbackTag = 303, - JSDocEnumTag = 304, - JSDocParameterTag = 305, - JSDocReturnTag = 306, - JSDocThisTag = 307, - JSDocTypeTag = 308, - JSDocTemplateTag = 309, - JSDocTypedefTag = 310, - JSDocPropertyTag = 311, - SyntaxList = 312, - NotEmittedStatement = 313, - PartiallyEmittedExpression = 314, - CommaListExpression = 315, - MergeDeclarationMarker = 316, - EndOfDeclarationMarker = 317, - Count = 318, + InlineTypeAliasDeclaration = 185, + ObjectBindingPattern = 186, + ArrayBindingPattern = 187, + BindingElement = 188, + ArrayLiteralExpression = 189, + ObjectLiteralExpression = 190, + PropertyAccessExpression = 191, + ElementAccessExpression = 192, + CallExpression = 193, + NewExpression = 194, + TaggedTemplateExpression = 195, + TypeAssertionExpression = 196, + ParenthesizedExpression = 197, + FunctionExpression = 198, + ArrowFunction = 199, + DeleteExpression = 200, + TypeOfExpression = 201, + VoidExpression = 202, + AwaitExpression = 203, + PrefixUnaryExpression = 204, + PostfixUnaryExpression = 205, + BinaryExpression = 206, + ConditionalExpression = 207, + TemplateExpression = 208, + YieldExpression = 209, + SpreadElement = 210, + ClassExpression = 211, + OmittedExpression = 212, + ExpressionWithTypeArguments = 213, + AsExpression = 214, + NonNullExpression = 215, + MetaProperty = 216, + SyntheticExpression = 217, + TemplateSpan = 218, + SemicolonClassElement = 219, + Block = 220, + VariableStatement = 221, + EmptyStatement = 222, + ExpressionStatement = 223, + IfStatement = 224, + DoStatement = 225, + WhileStatement = 226, + ForStatement = 227, + ForInStatement = 228, + ForOfStatement = 229, + ContinueStatement = 230, + BreakStatement = 231, + ReturnStatement = 232, + WithStatement = 233, + SwitchStatement = 234, + LabeledStatement = 235, + ThrowStatement = 236, + TryStatement = 237, + DebuggerStatement = 238, + VariableDeclaration = 239, + VariableDeclarationList = 240, + FunctionDeclaration = 241, + ClassDeclaration = 242, + InterfaceDeclaration = 243, + TypeAliasDeclaration = 244, + EnumDeclaration = 245, + ModuleDeclaration = 246, + ModuleBlock = 247, + CaseBlock = 248, + NamespaceExportDeclaration = 249, + ImportEqualsDeclaration = 250, + ImportDeclaration = 251, + ImportClause = 252, + NamespaceImport = 253, + NamedImports = 254, + ImportSpecifier = 255, + ExportAssignment = 256, + ExportDeclaration = 257, + NamedExports = 258, + ExportSpecifier = 259, + MissingDeclaration = 260, + ExternalModuleReference = 261, + JsxElement = 262, + JsxSelfClosingElement = 263, + JsxOpeningElement = 264, + JsxClosingElement = 265, + JsxFragment = 266, + JsxOpeningFragment = 267, + JsxClosingFragment = 268, + JsxAttribute = 269, + JsxAttributes = 270, + JsxSpreadAttribute = 271, + JsxExpression = 272, + CaseClause = 273, + DefaultClause = 274, + HeritageClause = 275, + CatchClause = 276, + PropertyAssignment = 277, + ShorthandPropertyAssignment = 278, + SpreadAssignment = 279, + EnumMember = 280, + UnparsedPrologue = 281, + UnparsedPrepend = 282, + UnparsedText = 283, + UnparsedInternalText = 284, + UnparsedSyntheticReference = 285, + SourceFile = 286, + Bundle = 287, + UnparsedSource = 288, + InputFiles = 289, + JSDocTypeExpression = 290, + JSDocAllType = 291, + JSDocUnknownType = 292, + JSDocNullableType = 293, + JSDocNonNullableType = 294, + JSDocOptionalType = 295, + JSDocFunctionType = 296, + JSDocVariadicType = 297, + JSDocComment = 298, + JSDocTypeLiteral = 299, + JSDocSignature = 300, + JSDocTag = 301, + JSDocAugmentsTag = 302, + JSDocClassTag = 303, + JSDocCallbackTag = 304, + JSDocEnumTag = 305, + JSDocParameterTag = 306, + JSDocReturnTag = 307, + JSDocThisTag = 308, + JSDocTypeTag = 309, + JSDocTemplateTag = 310, + JSDocTypedefTag = 311, + JSDocPropertyTag = 312, + SyntaxList = 313, + NotEmittedStatement = 314, + PartiallyEmittedExpression = 315, + CommaListExpression = 316, + MergeDeclarationMarker = 317, + EndOfDeclarationMarker = 318, + Count = 319, FirstAssignment = 60, LastAssignment = 72, FirstCompoundAssignment = 61, @@ -407,7 +408,7 @@ declare namespace ts { FirstFutureReservedWord = 110, LastFutureReservedWord = 118, FirstTypeNode = 164, - LastTypeNode = 184, + LastTypeNode = 185, FirstPunctuation = 18, LastPunctuation = 72, FirstToken = 0, @@ -421,10 +422,10 @@ declare namespace ts { FirstBinaryOperator = 28, LastBinaryOperator = 72, FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 311, - FirstJSDocTagNode = 300, - LastJSDocTagNode = 311, + FirstJSDocNode = 290, + LastJSDocNode = 312, + FirstJSDocTagNode = 301, + LastJSDocTagNode = 312, } enum NodeFlags { None = 0, @@ -1392,6 +1393,11 @@ declare namespace ts { typeParameters?: NodeArray; type: TypeNode; } + interface InlineTypeAliasDeclaration extends TypeNode, Declaration, JSDocContainer { + kind: SyntaxKind.InlineTypeAliasDeclaration; + name: Identifier; + type: TypeNode; + } interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent: EnumDeclaration; @@ -3853,6 +3859,8 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; + function createInlineTypeAliasDeclaration(name: Identifier | string, type: TypeNode): InlineTypeAliasDeclaration; + function updateInlineTypeAliasDeclaration(node: InlineTypeAliasDeclaration, name: Identifier | string, type: TypeNode): InlineTypeAliasDeclaration; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers.types b/tests/baselines/reference/assignmentCompatWithObjectMembers.types index 539fe1ed809e0..cad73da8d582e 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers.types +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers.types @@ -177,14 +177,14 @@ module ObjectTypes { >t2 : T2 var a: { foo: typeof a; } ->a : { foo: any; } ->foo : { foo: any; } ->a : { foo: any; } +>a : type Anon = { foo: Anon; } +>foo : type Anon = { foo: Anon; } +>a : type Anon = { foo: Anon; } var b: { foo: typeof b; } ->b : { foo: any; } ->foo : { foo: any; } ->b : { foo: any; } +>b : type Anon = { foo: Anon; } +>foo : type Anon = { foo: Anon; } +>b : type Anon = { foo: Anon; } var a2 = { foo: a2 }; >a2 : any @@ -234,9 +234,9 @@ module ObjectTypes { >t : T s2 = b; ->s2 = b : { foo: any; } +>s2 = b : type Anon = { foo: Anon; } >s2 : S2 ->b : { foo: any; } +>b : type Anon = { foo: Anon; } s2 = a2; >s2 = a2 : any @@ -244,28 +244,28 @@ module ObjectTypes { >a2 : any a = b; ->a = b : { foo: any; } ->a : { foo: any; } ->b : { foo: any; } +>a = b : type Anon = { foo: Anon; } +>a : type Anon = { foo: Anon; } +>b : type Anon = { foo: Anon; } b = a; ->b = a : { foo: any; } ->b : { foo: any; } ->a : { foo: any; } +>b = a : type Anon = { foo: Anon; } +>b : type Anon = { foo: Anon; } +>a : type Anon = { foo: Anon; } a = s; >a = s : S ->a : { foo: any; } +>a : type Anon = { foo: Anon; } >s : S a = s2; >a = s2 : S2 ->a : { foo: any; } +>a : type Anon = { foo: Anon; } >s2 : S2 a = a2; >a = a2 : any ->a : { foo: any; } +>a : type Anon = { foo: Anon; } >a2 : any a2 = b2; @@ -279,9 +279,9 @@ module ObjectTypes { >a2 : any a2 = b; ->a2 = b : { foo: any; } +>a2 = b : type Anon = { foo: Anon; } >a2 : any ->b : { foo: any; } +>b : type Anon = { foo: Anon; } a2 = t2; >a2 = t2 : T2 diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types index 3098b8c0f91e0..24d39ae728a83 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types @@ -68,14 +68,14 @@ function foo5() { >foo5 : () => void let x = () => y; ->x : () => () => any ->() => y : () => () => any ->y : () => () => any +>x : type Anon = () => () => Anon +>() => y : type Anon = () => () => Anon +>y : type Anon = () => () => Anon let y = () => x; ->y : () => () => any ->() => x : () => () => any ->x : () => () => any +>y : type Anon = () => () => Anon +>() => x : type Anon = () => () => Anon +>x : type Anon = () => () => Anon } function foo6() { diff --git a/tests/baselines/reference/classExpressionInClassStaticDeclarations.js b/tests/baselines/reference/classExpressionInClassStaticDeclarations.js index cb635f9eee21d..3d7ec21db01e2 100644 --- a/tests/baselines/reference/classExpressionInClassStaticDeclarations.js +++ b/tests/baselines/reference/classExpressionInClassStaticDeclarations.js @@ -33,8 +33,8 @@ var C = /** @class */ (function () { //// [classExpressionInClassStaticDeclarations.d.ts] declare class C { - static D: { + static D: type Anon = { new (): {}; - D: any; + D: Anon; }; } diff --git a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.errors.txt b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.errors.txt index 2fd1cc7e831c3..e15ee84dc00d7 100644 --- a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.errors.txt +++ b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts(9,5): error TS2741: Property 'x' is missing in type '(x: "hi", items: string[]) => typeof foo' but required in type 'D'. +tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts(9,5): error TS2741: Property 'x' is missing in type 'type Anon = (x: "hi", items: string[]) => Anon' but required in type 'D'. ==== tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts (1 errors) ==== @@ -12,6 +12,6 @@ tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts(9,5): e } var a: D = foo("hi", []); ~ -!!! error TS2741: Property 'x' is missing in type '(x: "hi", items: string[]) => typeof foo' but required in type 'D'. +!!! error TS2741: Property 'x' is missing in type 'type Anon = (x: "hi", items: string[]) => Anon' but required in type 'D'. !!! related TS2728 tests/cases/compiler/crashInsourcePropertyIsRelatableToTargetProperty.ts:2:13: 'x' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.types b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.types index 9237416d0dee7..2430e4ef9319e 100644 --- a/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.types +++ b/tests/baselines/reference/crashInsourcePropertyIsRelatableToTargetProperty.types @@ -11,24 +11,24 @@ class D extends C { } >C : C function foo(x: "hi", items: string[]): typeof foo; ->foo : (x: "hi", items: string[]) => typeof foo +>foo : type Anon = (x: "hi", items: string[]) => Anon >x : "hi" >items : string[] ->foo : (x: "hi", items: string[]) => typeof foo +>foo : type Anon = (x: "hi", items: string[]) => Anon function foo(x: string, items: string[]): typeof foo { ->foo : (x: "hi", items: string[]) => typeof foo +>foo : type Anon = (x: "hi", items: string[]) => Anon >x : string >items : string[] ->foo : (x: "hi", items: string[]) => typeof foo +>foo : type Anon = (x: "hi", items: string[]) => Anon return null; >null : null } var a: D = foo("hi", []); >a : D ->foo("hi", []) : (x: "hi", items: string[]) => typeof foo ->foo : (x: "hi", items: string[]) => typeof foo +>foo("hi", []) : type Anon = (x: "hi", items: string[]) => Anon +>foo : type Anon = (x: "hi", items: string[]) => Anon >"hi" : "hi" >[] : undefined[] diff --git a/tests/baselines/reference/cyclicTypeInstantiation.types b/tests/baselines/reference/cyclicTypeInstantiation.types index c643dd3cfeb68..1559415d7b4a7 100644 --- a/tests/baselines/reference/cyclicTypeInstantiation.types +++ b/tests/baselines/reference/cyclicTypeInstantiation.types @@ -1,53 +1,53 @@ === tests/cases/compiler/cyclicTypeInstantiation.ts === function foo() { ->foo : () => { a: T; b: any; } +>foo : () => type Anon = { a: T; b: Anon; } var x: { ->x : { a: T; b: any; } +>x : type Anon = { a: T; b: Anon; } a: T; >a : T b: typeof x; ->b : { a: T; b: any; } ->x : { a: T; b: any; } +>b : type Anon = { a: T; b: Anon; } +>x : type Anon = { a: T; b: Anon; } }; return x; ->x : { a: T; b: any; } +>x : type Anon = { a: T; b: Anon; } } function bar() { ->bar : () => { a: T; b: any; } +>bar : () => type Anon = { a: T; b: Anon; } var x: { ->x : { a: T; b: any; } +>x : type Anon = { a: T; b: Anon; } a: T; >a : T b: typeof x; ->b : { a: T; b: any; } ->x : { a: T; b: any; } +>b : type Anon = { a: T; b: Anon; } +>x : type Anon = { a: T; b: Anon; } }; return x; ->x : { a: T; b: any; } +>x : type Anon = { a: T; b: Anon; } } var a = foo(); ->a : { a: string; b: any; } ->foo() : { a: string; b: any; } ->foo : () => { a: T; b: any; } +>a : type Anon = { a: string; b: Anon; } +>foo() : type Anon = { a: string; b: Anon; } +>foo : () => type Anon = { a: T; b: Anon; } var b = bar(); ->b : { a: string; b: any; } ->bar() : { a: string; b: any; } ->bar : () => { a: T; b: any; } +>b : type Anon = { a: string; b: Anon; } +>bar() : type Anon = { a: string; b: Anon; } +>bar : () => type Anon = { a: T; b: Anon; } // Relating types of a and b produces instantiations of the cyclic anonymous types in foo and bar a = b; ->a = b : { a: string; b: any; } ->a : { a: string; b: any; } ->b : { a: string; b: any; } +>a = b : type Anon = { a: string; b: Anon; } +>a : type Anon = { a: string; b: Anon; } +>b : type Anon = { a: string; b: Anon; } diff --git a/tests/baselines/reference/declFileTypeofFunction.js b/tests/baselines/reference/declFileTypeofFunction.js index ae1f1b0fcf207..189d6b1303f9d 100644 --- a/tests/baselines/reference/declFileTypeofFunction.js +++ b/tests/baselines/reference/declFileTypeofFunction.js @@ -68,6 +68,6 @@ declare function b1(): typeof b1; declare function foo(): typeof foo; declare var foo1: typeof foo; declare var foo2: typeof foo; -declare var foo3: () => any; -declare var x: () => any; +declare var foo3: type Anon = () => Anon; +declare var x: type Anon = () => Anon; declare function foo5(x: number): (x: number) => number; diff --git a/tests/baselines/reference/declFileTypeofFunction.types b/tests/baselines/reference/declFileTypeofFunction.types index fdc06020663ba..4ca8044b73e4e 100644 --- a/tests/baselines/reference/declFileTypeofFunction.types +++ b/tests/baselines/reference/declFileTypeofFunction.types @@ -1,71 +1,71 @@ === tests/cases/compiler/declFileTypeofFunction.ts === function f(n: typeof f): string; ->f : { (n: typeof f): string; (n: { (n: typeof g): number; (n: typeof f): number; }): string; } ->n : { (n: typeof f): string; (n: { (n: typeof g): number; (n: typeof f): number; }): string; } ->f : { (n: typeof f): string; (n: { (n: typeof g): number; (n: typeof f): number; }): string; } +>f : type Anon = { (n: Anon): string; (n: type Anon_1 = { (n: Anon_1): number; (n: Anon): number; }): string; } +>n : type Anon = { (n: Anon): string; (n: type Anon_1 = { (n: Anon_1): number; (n: Anon): number; }): string; } +>f : type Anon = { (n: Anon): string; (n: type Anon_1 = { (n: Anon_1): number; (n: Anon): number; }): string; } function f(n: typeof g): string; ->f : { (n: typeof f): string; (n: { (n: typeof g): number; (n: typeof f): number; }): string; } ->n : { (n: typeof g): number; (n: { (n: typeof f): string; (n: typeof g): string; }): number; } ->g : { (n: typeof g): number; (n: { (n: typeof f): string; (n: typeof g): string; }): number; } +>f : type Anon = { (n: Anon): string; (n: type Anon_1 = { (n: Anon_1): number; (n: Anon): number; }): string; } +>n : type Anon = { (n: Anon): number; (n: type Anon_1 = { (n: Anon_1): string; (n: Anon): string; }): number; } +>g : type Anon = { (n: Anon): number; (n: type Anon_1 = { (n: Anon_1): string; (n: Anon): string; }): number; } function f() { return undefined; } ->f : { (n: typeof f): string; (n: { (n: typeof g): number; (n: typeof f): number; }): string; } +>f : type Anon = { (n: Anon): string; (n: type Anon_1 = { (n: Anon_1): number; (n: Anon): number; }): string; } >undefined : undefined function g(n: typeof g): number; ->g : { (n: typeof g): number; (n: { (n: typeof f): string; (n: typeof g): string; }): number; } ->n : { (n: typeof g): number; (n: { (n: typeof f): string; (n: typeof g): string; }): number; } ->g : { (n: typeof g): number; (n: { (n: typeof f): string; (n: typeof g): string; }): number; } +>g : type Anon = { (n: Anon): number; (n: type Anon_1 = { (n: Anon_1): string; (n: Anon): string; }): number; } +>n : type Anon = { (n: Anon): number; (n: type Anon_1 = { (n: Anon_1): string; (n: Anon): string; }): number; } +>g : type Anon = { (n: Anon): number; (n: type Anon_1 = { (n: Anon_1): string; (n: Anon): string; }): number; } function g(n: typeof f): number; ->g : { (n: typeof g): number; (n: { (n: typeof f): string; (n: typeof g): string; }): number; } ->n : { (n: typeof f): string; (n: { (n: typeof g): number; (n: typeof f): number; }): string; } ->f : { (n: typeof f): string; (n: { (n: typeof g): number; (n: typeof f): number; }): string; } +>g : type Anon = { (n: Anon): number; (n: type Anon_1 = { (n: Anon_1): string; (n: Anon): string; }): number; } +>n : type Anon = { (n: Anon): string; (n: type Anon_1 = { (n: Anon_1): number; (n: Anon): number; }): string; } +>f : type Anon = { (n: Anon): string; (n: type Anon_1 = { (n: Anon_1): number; (n: Anon): number; }): string; } function g() { return undefined; } ->g : { (n: typeof g): number; (n: { (n: typeof f): string; (n: typeof g): string; }): number; } +>g : type Anon = { (n: Anon): number; (n: type Anon_1 = { (n: Anon_1): string; (n: Anon): string; }): number; } >undefined : undefined var b: () => typeof b; ->b : () => any ->b : () => any +>b : type Anon = () => Anon +>b : type Anon = () => Anon function b1() { ->b1 : () => typeof b1 +>b1 : type Anon = () => Anon return b1; ->b1 : () => typeof b1 +>b1 : type Anon = () => Anon } function foo(): typeof foo { ->foo : () => typeof foo ->foo : () => typeof foo +>foo : type Anon = () => Anon +>foo : type Anon = () => Anon return null; >null : null } var foo1: typeof foo; ->foo1 : () => typeof foo ->foo : () => typeof foo +>foo1 : type Anon = () => Anon +>foo : type Anon = () => Anon var foo2 = foo; ->foo2 : () => typeof foo ->foo : () => typeof foo +>foo2 : type Anon = () => Anon +>foo : type Anon = () => Anon var foo3 = function () { ->foo3 : () => any ->function () { return foo3;} : () => any +>foo3 : type Anon = () => Anon +>function () { return foo3;} : type Anon = () => Anon return foo3; ->foo3 : () => any +>foo3 : type Anon = () => Anon } var x = () => { ->x : () => any ->() => { return x;} : () => any +>x : type Anon = () => Anon +>() => { return x;} : type Anon = () => Anon return x; ->x : () => any +>x : type Anon = () => Anon } function foo5(x: number) { diff --git a/tests/baselines/reference/declarationEmitInferredTypeAlias4.js b/tests/baselines/reference/declarationEmitInferredTypeAlias4.js index 3200c6b8b2541..982787e26f662 100644 --- a/tests/baselines/reference/declarationEmitInferredTypeAlias4.js +++ b/tests/baselines/reference/declarationEmitInferredTypeAlias4.js @@ -13,6 +13,6 @@ function f() { //// [declarationEmitInferredTypeAlias4.d.ts] -declare function f(): A[] | { - x: A[] | any; +declare function f(): A[] | type Anon = { + x: A[] | Anon; }; diff --git a/tests/baselines/reference/declarationEmitInferredTypeAlias4.types b/tests/baselines/reference/declarationEmitInferredTypeAlias4.types index 74fc4266bfc46..c29b72898e28a 100644 --- a/tests/baselines/reference/declarationEmitInferredTypeAlias4.types +++ b/tests/baselines/reference/declarationEmitInferredTypeAlias4.types @@ -1,14 +1,14 @@ === tests/cases/compiler/declarationEmitInferredTypeAlias4.ts === function f() { ->f : () => A[] | { x: A[] | any; } +>f : () => A[] | type Anon = { x: A[] | Anon; } type Foo = T | { x: Foo }; ->Foo : T | { x: T | any; } ->x : T | { x: T | any; } +>Foo : T | type Anon = { x: T | Anon; } +>x : T | type Anon = { x: T | Anon; } var x: Foo; ->x : A[] | { x: A[] | any; } +>x : A[] | type Anon = { x: A[] | Anon; } return x; ->x : A[] | { x: A[] | any; } +>x : A[] | type Anon = { x: A[] | Anon; } } diff --git a/tests/baselines/reference/declarationEmitModuleWithScopeMarker.types b/tests/baselines/reference/declarationEmitModuleWithScopeMarker.types index 2135a392dfcdb..c96a2ddb0da3b 100644 --- a/tests/baselines/reference/declarationEmitModuleWithScopeMarker.types +++ b/tests/baselines/reference/declarationEmitModuleWithScopeMarker.types @@ -3,19 +3,19 @@ declare module "bar" { >"bar" : typeof import("bar") var before: typeof func; ->before : () => typeof func ->func : () => typeof func +>before : type Anon = () => Anon +>func : type Anon = () => Anon export function normal(): void; >normal : () => void export default function func(): typeof func; ->func : () => typeof func ->func : () => typeof func +>func : type Anon = () => Anon +>func : type Anon = () => Anon var after: typeof func; ->after : () => typeof func ->func : () => typeof func +>after : type Anon = () => Anon +>func : type Anon = () => Anon export {} } diff --git a/tests/baselines/reference/directDependenceBetweenTypeAliases.types b/tests/baselines/reference/directDependenceBetweenTypeAliases.types index 3363b20b85199..59d08daf0168f 100644 --- a/tests/baselines/reference/directDependenceBetweenTypeAliases.types +++ b/tests/baselines/reference/directDependenceBetweenTypeAliases.types @@ -72,17 +72,17 @@ type T10 = { x: T10 } | { new(v: T10): string } >v : T10 type T11 = T12[] ->T11 : [{ x: [any, string][]; }, string][] +>T11 : [type Anon = { x: [Anon, string][]; }, string][] type T12 = [T13, string] ->T12 : [{ x: [any, string][]; }, string] +>T12 : [type Anon = { x: [Anon, string][]; }, string] type T13 = typeof zz ->T13 : { x: [any, string][]; } ->zz : { x: [any, string][]; } +>T13 : type Anon = { x: [Anon, string][]; } +>zz : type Anon = { x: [Anon, string][]; } var zz: { x: T11 } ->zz : { x: [any, string][]; } ->x : [{ x: [any, string][]; }, string][] +>zz : type Anon = { x: [Anon, string][]; } +>x : [type Anon = { x: [Anon, string][]; }, string][] diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.types b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.types index 7d8f15719ca08..920ec66f74963 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.types +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration3.types @@ -1,21 +1,21 @@ === tests/cases/compiler/es5ExportDefaultFunctionDeclaration3.ts === var before: typeof func = func(); ->before : () => typeof func ->func : () => typeof func ->func() : () => typeof func ->func : () => typeof func +>before : type Anon = () => Anon +>func : type Anon = () => Anon +>func() : type Anon = () => Anon +>func : type Anon = () => Anon export default function func(): typeof func { ->func : () => typeof func ->func : () => typeof func +>func : type Anon = () => Anon +>func : type Anon = () => Anon return func; ->func : () => typeof func +>func : type Anon = () => Anon } var after: typeof func = func(); ->after : () => typeof func ->func : () => typeof func ->func() : () => typeof func ->func : () => typeof func +>after : type Anon = () => Anon +>func : type Anon = () => Anon +>func() : type Anon = () => Anon +>func : type Anon = () => Anon diff --git a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration4.types b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration4.types index fd44fcdfb4fb1..66080e3945570 100644 --- a/tests/baselines/reference/es5ExportDefaultFunctionDeclaration4.types +++ b/tests/baselines/reference/es5ExportDefaultFunctionDeclaration4.types @@ -3,14 +3,14 @@ declare module "bar" { >"bar" : typeof import("bar") var before: typeof func; ->before : () => typeof func ->func : () => typeof func +>before : type Anon = () => Anon +>func : type Anon = () => Anon export default function func(): typeof func; ->func : () => typeof func ->func : () => typeof func +>func : type Anon = () => Anon +>func : type Anon = () => Anon var after: typeof func; ->after : () => typeof func ->func : () => typeof func +>after : type Anon = () => Anon +>func : type Anon = () => Anon } diff --git a/tests/baselines/reference/functionExpressionReturningItself.js b/tests/baselines/reference/functionExpressionReturningItself.js index 9485100164ea9..c877faf53de94 100644 --- a/tests/baselines/reference/functionExpressionReturningItself.js +++ b/tests/baselines/reference/functionExpressionReturningItself.js @@ -6,4 +6,4 @@ var x = function somefn() { return somefn; }; //// [functionExpressionReturningItself.d.ts] -declare var x: () => any; +declare var x: type Anon = () => Anon; diff --git a/tests/baselines/reference/functionExpressionReturningItself.types b/tests/baselines/reference/functionExpressionReturningItself.types index 409f4adea2ea0..ffa1c9659e686 100644 --- a/tests/baselines/reference/functionExpressionReturningItself.types +++ b/tests/baselines/reference/functionExpressionReturningItself.types @@ -1,7 +1,7 @@ === tests/cases/compiler/functionExpressionReturningItself.ts === var x = function somefn() { return somefn; }; ->x : () => any ->function somefn() { return somefn; } : () => any ->somefn : () => any ->somefn : () => any +>x : type Anon = () => Anon +>function somefn() { return somefn; } : type Anon = () => Anon +>somefn : type Anon = () => Anon +>somefn : type Anon = () => Anon diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types index f541225a61ac9..4cdc6cdebc69e 100644 --- a/tests/baselines/reference/functionImplementations.types +++ b/tests/baselines/reference/functionImplementations.types @@ -8,11 +8,11 @@ var v: void = function () { } (); // FunctionExpression f with no return type annotation and directly references f in its body returns any var a: any = function f() { >a : any ->function f() { return f;} : () => any ->f : () => any +>function f() { return f;} : type Anon = () => Anon +>f : type Anon = () => Anon return f; ->f : () => any +>f : type Anon = () => Anon }; var a: any = function f() { @@ -29,15 +29,15 @@ var a: any = function f() { // FunctionExpression f with no return type annotation and indirectly references f in its body returns any var a: any = function f() { >a : any ->function f() { var x = f; return x;} : () => any ->f : () => any +>function f() { var x = f; return x;} : type Anon = () => Anon +>f : type Anon = () => Anon var x = f; ->x : () => any ->f : () => any +>x : type Anon = () => Anon +>f : type Anon = () => Anon return x; ->x : () => any +>x : type Anon = () => Anon }; diff --git a/tests/baselines/reference/functionReturningItself.types b/tests/baselines/reference/functionReturningItself.types index 597202a55e286..8f8e02677b54c 100644 --- a/tests/baselines/reference/functionReturningItself.types +++ b/tests/baselines/reference/functionReturningItself.types @@ -1,7 +1,7 @@ === tests/cases/compiler/functionReturningItself.ts === function somefn() { ->somefn : () => typeof somefn +>somefn : type Anon = () => Anon return somefn; ->somefn : () => typeof somefn +>somefn : type Anon = () => Anon } diff --git a/tests/baselines/reference/genericTypeAliases.types b/tests/baselines/reference/genericTypeAliases.types index 308c61da72501..09ece76f391d6 100644 --- a/tests/baselines/reference/genericTypeAliases.types +++ b/tests/baselines/reference/genericTypeAliases.types @@ -175,46 +175,46 @@ p.tag = "test"; >"test" : "test" function f() { ->f : () => A[] | { x: A[] | any; } +>f : () => A[] | type Anon = { x: A[] | Anon; } type Foo = T | { x: Foo }; ->Foo : T | { x: T | any; } ->x : T | { x: T | any; } +>Foo : T | type Anon = { x: T | Anon; } +>x : T | type Anon = { x: T | Anon; } var x: Foo; ->x : A[] | { x: A[] | any; } +>x : A[] | type Anon = { x: A[] | Anon; } return x; ->x : A[] | { x: A[] | any; } +>x : A[] | type Anon = { x: A[] | Anon; } } function g() { ->g : () => B[] | { x: B[] | any; } +>g : () => B[] | type Anon = { x: B[] | Anon; } type Bar = U | { x: Bar }; ->Bar : U | { x: U | any; } ->x : U | { x: U | any; } +>Bar : U | type Anon = { x: U | Anon; } +>x : U | type Anon = { x: U | Anon; } var x: Bar; ->x : B[] | { x: B[] | any; } +>x : B[] | type Anon = { x: B[] | Anon; } return x; ->x : B[] | { x: B[] | any; } +>x : B[] | type Anon = { x: B[] | Anon; } } // Deeply instantiated generics var a = f(); ->a : string[] | { x: string[] | any; } ->f() : string[] | { x: string[] | any; } ->f : () => A[] | { x: A[] | any; } +>a : string[] | type Anon = { x: string[] | Anon; } +>f() : string[] | type Anon = { x: string[] | Anon; } +>f : () => A[] | type Anon = { x: A[] | Anon; } var b = g(); ->b : string[] | { x: string[] | any; } ->g() : string[] | { x: string[] | any; } ->g : () => B[] | { x: B[] | any; } +>b : string[] | type Anon = { x: string[] | Anon; } +>g() : string[] | type Anon = { x: string[] | Anon; } +>g : () => B[] | type Anon = { x: B[] | Anon; } a = b; ->a = b : string[] | { x: string[] | any; } ->a : string[] | { x: string[] | any; } ->b : string[] | { x: string[] | any; } +>a = b : string[] | type Anon = { x: string[] | Anon; } +>a : string[] | type Anon = { x: string[] | Anon; } +>b : string[] | type Anon = { x: string[] | Anon; } diff --git a/tests/baselines/reference/implicitAnyFromCircularInference.types b/tests/baselines/reference/implicitAnyFromCircularInference.types index c4ecb84141f67..55ac6cea615d2 100644 --- a/tests/baselines/reference/implicitAnyFromCircularInference.types +++ b/tests/baselines/reference/implicitAnyFromCircularInference.types @@ -19,8 +19,8 @@ var d: Array; >d : any function f() { return f; } ->f : () => typeof f ->f : () => typeof f +>f : type Anon = () => Anon +>f : type Anon = () => Anon // Error expected function g() { return g(); } diff --git a/tests/baselines/reference/inlineTypeAliasNoSpuriousCircularityError.js b/tests/baselines/reference/inlineTypeAliasNoSpuriousCircularityError.js new file mode 100644 index 0000000000000..12848eb610639 --- /dev/null +++ b/tests/baselines/reference/inlineTypeAliasNoSpuriousCircularityError.js @@ -0,0 +1,7 @@ +//// [inlineTypeAliasNoSpuriousCircularityError.ts] +type Something = type Q = T extends number ? {x: Q} : never; + +type Foo = Something; + + +//// [inlineTypeAliasNoSpuriousCircularityError.js] diff --git a/tests/baselines/reference/inlineTypeAliasNoSpuriousCircularityError.symbols b/tests/baselines/reference/inlineTypeAliasNoSpuriousCircularityError.symbols new file mode 100644 index 0000000000000..03410c01b3d24 --- /dev/null +++ b/tests/baselines/reference/inlineTypeAliasNoSpuriousCircularityError.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliasNoSpuriousCircularityError.ts === +type Something = type Q = T extends number ? {x: Q} : never; +>Something : Symbol(Something, Decl(inlineTypeAliasNoSpuriousCircularityError.ts, 0, 0)) +>T : Symbol(T, Decl(inlineTypeAliasNoSpuriousCircularityError.ts, 0, 15)) +>Q : Symbol(Q, Decl(inlineTypeAliasNoSpuriousCircularityError.ts, 0, 19)) +>T : Symbol(T, Decl(inlineTypeAliasNoSpuriousCircularityError.ts, 0, 15)) +>x : Symbol(x, Decl(inlineTypeAliasNoSpuriousCircularityError.ts, 0, 49)) +>Q : Symbol(Q, Decl(inlineTypeAliasNoSpuriousCircularityError.ts, 0, 19)) + +type Foo = Something; +>Foo : Symbol(Foo, Decl(inlineTypeAliasNoSpuriousCircularityError.ts, 0, 63)) +>Something : Symbol(Something, Decl(inlineTypeAliasNoSpuriousCircularityError.ts, 0, 0)) + diff --git a/tests/baselines/reference/inlineTypeAliasNoSpuriousCircularityError.types b/tests/baselines/reference/inlineTypeAliasNoSpuriousCircularityError.types new file mode 100644 index 0000000000000..b0a233c495adf --- /dev/null +++ b/tests/baselines/reference/inlineTypeAliasNoSpuriousCircularityError.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliasNoSpuriousCircularityError.ts === +type Something = type Q = T extends number ? {x: Q} : never; +>Something : T extends number ? type Anon = { x: T extends number ? Anon : never; } : never +>x : Q + +type Foo = Something; +>Foo : type Anon = { x: T extends number ? Anon : never; } + diff --git a/tests/baselines/reference/inlineTypeAliases.js b/tests/baselines/reference/inlineTypeAliases.js new file mode 100644 index 0000000000000..61dec99c8cd26 --- /dev/null +++ b/tests/baselines/reference/inlineTypeAliases.js @@ -0,0 +1,56 @@ +//// [inlineTypeAliases.ts] +export declare const x: type T = { x: T }; + +export const y = (null as type T = { x: T }); + +export function f() { + return (null as any as (type T = {x: T})).x; +} + +export declare const xx: type T = ({ x: {y: T} } & {y: string})["x"]; + +export const yy = (null as any as type T = ({ x: {y: T} } & {y: string})["x"]); + +export function ff() { + return (null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y.y.y; +} + + +//// [inlineTypeAliases.js] +"use strict"; +exports.__esModule = true; +exports.y = null; +function f() { + return null.x; +} +exports.f = f; +exports.yy = null; +function ff() { + return null.y.y.y.y.y.y; +} +exports.ff = ff; + + +//// [inlineTypeAliases.d.ts] +export declare const x: type T = { + x: T; +}; +export declare const y: type T = { + x: T; +}; +export declare function f(): type T = { + x: T; +}; +export declare const xx: type T = ({ + x: { + y: T; + }; +} & { + y: string; +})["x"]; +export declare const yy: type Anon = { + y: Anon; +}; +export declare function ff(): type Anon = { + y: Anon; +}; diff --git a/tests/baselines/reference/inlineTypeAliases.symbols b/tests/baselines/reference/inlineTypeAliases.symbols new file mode 100644 index 0000000000000..de8a10b3ea854 --- /dev/null +++ b/tests/baselines/reference/inlineTypeAliases.symbols @@ -0,0 +1,63 @@ +=== tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliases.ts === +export declare const x: type T = { x: T }; +>x : Symbol(x, Decl(inlineTypeAliases.ts, 0, 20)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 0, 23)) +>x : Symbol(x, Decl(inlineTypeAliases.ts, 0, 34)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 0, 23)) + +export const y = (null as type T = { x: T }); +>y : Symbol(y, Decl(inlineTypeAliases.ts, 2, 12)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 2, 25)) +>x : Symbol(x, Decl(inlineTypeAliases.ts, 2, 36)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 2, 25)) + +export function f() { +>f : Symbol(f, Decl(inlineTypeAliases.ts, 2, 45)) + + return (null as any as (type T = {x: T})).x; +>(null as any as (type T = {x: T})).x : Symbol(x, Decl(inlineTypeAliases.ts, 5, 38)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 5, 28)) +>x : Symbol(x, Decl(inlineTypeAliases.ts, 5, 38)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 5, 28)) +>x : Symbol(x, Decl(inlineTypeAliases.ts, 5, 38)) +} + +export declare const xx: type T = ({ x: {y: T} } & {y: string})["x"]; +>xx : Symbol(xx, Decl(inlineTypeAliases.ts, 8, 20)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 8, 24)) +>x : Symbol(x, Decl(inlineTypeAliases.ts, 8, 36)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 8, 41)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 8, 24)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 8, 52)) + +export const yy = (null as any as type T = ({ x: {y: T} } & {y: string})["x"]); +>yy : Symbol(yy, Decl(inlineTypeAliases.ts, 10, 12)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 10, 33)) +>x : Symbol(x, Decl(inlineTypeAliases.ts, 10, 45)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 10, 50)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 10, 33)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 10, 61)) + +export function ff() { +>ff : Symbol(ff, Decl(inlineTypeAliases.ts, 10, 79)) + + return (null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y.y.y; +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y.y.y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y.y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 13, 26)) +>x : Symbol(x, Decl(inlineTypeAliases.ts, 13, 38)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>T : Symbol(T, Decl(inlineTypeAliases.ts, 13, 26)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 54)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +>y : Symbol(y, Decl(inlineTypeAliases.ts, 13, 43)) +} + diff --git a/tests/baselines/reference/inlineTypeAliases.types b/tests/baselines/reference/inlineTypeAliases.types new file mode 100644 index 0000000000000..10dca6fca0e61 --- /dev/null +++ b/tests/baselines/reference/inlineTypeAliases.types @@ -0,0 +1,66 @@ +=== tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliases.ts === +export declare const x: type T = { x: T }; +>x : type T = { x: T; } +>x : T + +export const y = (null as type T = { x: T }); +>y : type T = { x: T; } +>(null as type T = { x: T }) : type T = { x: T; } +>null as type T = { x: T } : type T = { x: T; } +>null : null +>x : T + +export function f() { +>f : () => type T = { x: T; } + + return (null as any as (type T = {x: T})).x; +>(null as any as (type T = {x: T})).x : type T = { x: T; } +>(null as any as (type T = {x: T})) : type T = { x: T; } +>null as any as (type T = {x: T}) : type T = { x: T; } +>null as any : any +>null : null +>x : T +>x : type T = { x: T; } +} + +export declare const xx: type T = ({ x: {y: T} } & {y: string})["x"]; +>xx : type Anon = { y: Anon; } +>x : type Anon = { y: Anon; } +>y : type Anon = { y: Anon; } +>y : string + +export const yy = (null as any as type T = ({ x: {y: T} } & {y: string})["x"]); +>yy : type Anon = { y: Anon; } +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]) : type Anon = { y: Anon; } +>null as any as type T = ({ x: {y: T} } & {y: string})["x"] : type Anon = { y: Anon; } +>null as any : any +>null : null +>x : type Anon = { y: Anon; } +>y : type Anon = { y: Anon; } +>y : string + +export function ff() { +>ff : () => type Anon = { y: Anon; } + + return (null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y.y.y; +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y.y.y : type Anon = { y: Anon; } +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y.y : type Anon = { y: Anon; } +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y : type Anon = { y: Anon; } +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y : type Anon = { y: Anon; } +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y : type Anon = { y: Anon; } +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y : type Anon = { y: Anon; } +>(null as any as type T = ({ x: {y: T} } & {y: string})["x"]) : type Anon = { y: Anon; } +>null as any as type T = ({ x: {y: T} } & {y: string})["x"] : type Anon = { y: Anon; } +>null as any : any +>null : null +>x : type Anon = { y: Anon; } +>y : type Anon = { y: Anon; } +>y : string +>y : type Anon = { y: Anon; } +>y : type Anon = { y: Anon; } +>y : type Anon = { y: Anon; } +>y : type Anon = { y: Anon; } +>y : type Anon = { y: Anon; } +>y : type Anon = { y: Anon; } +} + diff --git a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types index a2f69a87f280b..8a85f11138365 100644 --- a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types +++ b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types @@ -1,21 +1,21 @@ === tests/cases/conformance/salsa/axios.js === var axios = {} ->axios : { default: { default: any; }; } +>axios : { default: type Anon = { default: Anon; }; } >{} : {} module.exports = axios // both assignments should be ok ->module.exports = axios : { default: { default: any; }; } ->module.exports : { default: { default: any; }; } ->module : { "tests/cases/conformance/salsa/axios": { default: { default: any; }; }; } ->exports : { default: { default: any; }; } ->axios : { default: { default: any; }; } +>module.exports = axios : { default: type Anon = { default: Anon; }; } +>module.exports : { default: type Anon = { default: Anon; }; } +>module : { "tests/cases/conformance/salsa/axios": { default: type Anon = { default: Anon; }; }; } +>exports : { default: type Anon = { default: Anon; }; } +>axios : { default: type Anon = { default: Anon; }; } module.exports.default = axios ->module.exports.default = axios : { default: { default: any; }; } ->module.exports.default : { default: any; } ->module.exports : { default: { default: any; }; } ->module : { "tests/cases/conformance/salsa/axios": { default: { default: any; }; }; } ->exports : { default: { default: any; }; } ->default : { default: any; } ->axios : { default: { default: any; }; } +>module.exports.default = axios : { default: type Anon = { default: Anon; }; } +>module.exports.default : type Anon = { default: Anon; } +>module.exports : { default: type Anon = { default: Anon; }; } +>module : { "tests/cases/conformance/salsa/axios": { default: type Anon = { default: Anon; }; }; } +>exports : { default: type Anon = { default: Anon; }; } +>default : type Anon = { default: Anon; } +>axios : { default: type Anon = { default: Anon; }; } diff --git a/tests/baselines/reference/newTarget.es5.types b/tests/baselines/reference/newTarget.es5.types index ddbe78537b2d6..d73b299df563e 100644 --- a/tests/baselines/reference/newTarget.es5.types +++ b/tests/baselines/reference/newTarget.es5.types @@ -15,15 +15,15 @@ class A { >target : any } static c = function () { return new.target; } ->c : () => any ->function () { return new.target; } : () => any ->new.target : () => any +>c : type Anon = () => Anon +>function () { return new.target; } : type Anon = () => Anon +>new.target : type Anon = () => Anon >target : any d = function () { return new.target; } ->d : () => any ->function () { return new.target; } : () => any ->new.target : () => any +>d : type Anon = () => Anon +>function () { return new.target; } : type Anon = () => Anon +>new.target : type Anon = () => Anon >target : any } @@ -81,13 +81,13 @@ const f2 = function () { } const O = { ->O : { k: () => any; } ->{ k: function () { return new.target; }} : { k: () => any; } +>O : { k: type Anon = () => Anon; } +>{ k: function () { return new.target; }} : { k: type Anon = () => Anon; } k: function () { return new.target; } ->k : () => any ->function () { return new.target; } : () => any ->new.target : () => any +>k : type Anon = () => Anon +>function () { return new.target; } : type Anon = () => Anon +>new.target : type Anon = () => Anon >target : any }; diff --git a/tests/baselines/reference/newTarget.es6.types b/tests/baselines/reference/newTarget.es6.types index 08ef8429b3cbd..455fe9c36063b 100644 --- a/tests/baselines/reference/newTarget.es6.types +++ b/tests/baselines/reference/newTarget.es6.types @@ -15,15 +15,15 @@ class A { >target : any } static c = function () { return new.target; } ->c : () => any ->function () { return new.target; } : () => any ->new.target : () => any +>c : type Anon = () => Anon +>function () { return new.target; } : type Anon = () => Anon +>new.target : type Anon = () => Anon >target : any d = function () { return new.target; } ->d : () => any ->function () { return new.target; } : () => any ->new.target : () => any +>d : type Anon = () => Anon +>function () { return new.target; } : type Anon = () => Anon +>new.target : type Anon = () => Anon >target : any } @@ -81,13 +81,13 @@ const f2 = function () { } const O = { ->O : { k: () => any; } ->{ k: function () { return new.target; }} : { k: () => any; } +>O : { k: type Anon = () => Anon; } +>{ k: function () { return new.target; }} : { k: type Anon = () => Anon; } k: function () { return new.target; } ->k : () => any ->function () { return new.target; } : () => any ->new.target : () => any +>k : type Anon = () => Anon +>function () { return new.target; } : type Anon = () => Anon +>new.target : type Anon = () => Anon >target : any }; diff --git a/tests/baselines/reference/normalizedIntersectionTooComplex.types b/tests/baselines/reference/normalizedIntersectionTooComplex.types index 6750b0b0c73c6..d13a16a0bf7ca 100644 --- a/tests/baselines/reference/normalizedIntersectionTooComplex.types +++ b/tests/baselines/reference/normalizedIntersectionTooComplex.types @@ -20,112 +20,112 @@ type CtorOf = (arg: UnionToIntersection) => T; interface Big { "0": { common?: string; "0"?: number, ref?: Obj | Func; } ->"0" : { common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } +>"0" : type Anon = { common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"0" : number | undefined ->ref : Obj<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "1": { common?: string; "1"?: number, ref?: Obj | Func; } ->"1" : { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } +>"1" : type Anon = { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"1" : number | undefined ->ref : Obj<{ common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "2": { common?: string; "2"?: number, ref?: Obj | Func; } ->"2" : { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } +>"2" : type Anon = { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"2" : number | undefined ->ref : Obj<{ common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "3": { common?: string; "3"?: number, ref?: Obj | Func; } ->"3" : { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } +>"3" : type Anon = { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"3" : number | undefined ->ref : Obj<{ common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "4": { common?: string; "4"?: number, ref?: Obj | Func; } ->"4" : { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } +>"4" : type Anon = { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"4" : number | undefined ->ref : Obj<{ common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "5": { common?: string; "5"?: number, ref?: Obj | Func; } ->"5" : { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } +>"5" : type Anon = { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"5" : number | undefined ->ref : Obj<{ common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "6": { common?: string; "6"?: number, ref?: Obj | Func; } ->"6" : { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } +>"6" : type Anon = { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"6" : number | undefined ->ref : Obj<{ common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "7": { common?: string; "7"?: number, ref?: Obj | Func; } ->"7" : { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } +>"7" : type Anon = { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"7" : number | undefined ->ref : Obj<{ common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "8": { common?: string; "8"?: number, ref?: Obj | Func; } ->"8" : { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } +>"8" : type Anon = { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"8" : number | undefined ->ref : Obj<{ common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "9": { common?: string; "9"?: number, ref?: Obj | Func; } ->"9" : { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } +>"9" : type Anon = { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"9" : number | undefined ->ref : Obj<{ common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "10": { common?: string; "10"?: number, ref?: Obj | Func; } ->"10" : { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } +>"10" : type Anon = { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"10" : number | undefined ->ref : Obj<{ common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "11": { common?: string; "11"?: number, ref?: Obj | Func; } ->"11" : { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } +>"11" : type Anon = { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"11" : number | undefined ->ref : Obj<{ common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "12": { common?: string; "12"?: number, ref?: Obj | Func; } ->"12" : { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } +>"12" : type Anon = { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"12" : number | undefined ->ref : Obj<{ common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "13": { common?: string; "13"?: number, ref?: Obj | Func; } ->"13" : { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } +>"13" : type Anon = { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"13" : number | undefined ->ref : Obj<{ common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "14": { common?: string; "14"?: number, ref?: Obj | Func; } ->"14" : { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } +>"14" : type Anon = { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"14" : number | undefined ->ref : Obj<{ common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "15": { common?: string; "15"?: number, ref?: Obj | Func; } ->"15" : { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } +>"15" : type Anon = { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"15" : number | undefined ->ref : Obj<{ common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "16": { common?: string; "16"?: number, ref?: Obj | Func; } ->"16" : { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } +>"16" : type Anon = { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"16" : number | undefined ->ref : Obj<{ common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined "17": { common?: string; "17"?: number, ref?: Obj | Func; } ->"17" : { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; } +>"17" : type Anon = { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"17" : number | undefined ->ref : Obj<{ common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined +>ref : Obj | Func | undefined; }> | Func | Func | undefined; }> | undefined } declare function getCtor(comp: T): CtorOf >getCtor : (comp: T) => CtorOf @@ -135,15 +135,15 @@ declare var all: keyof Big; >all : "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" const ctor = getCtor(all); ->ctor : CtorOf<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> ->getCtor(all) : CtorOf<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> +>ctor : CtorOf | Func | undefined; } | type Anon_1 = { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_2 = { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_3 = { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_4 = { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_5 = { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_6 = { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_7 = { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_8 = { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_9 = { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_10 = { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_11 = { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_12 = { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_13 = { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_14 = { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_15 = { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_16 = { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_17 = { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> +>getCtor(all) : CtorOf | Func | undefined; } | type Anon_1 = { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_2 = { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_3 = { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_4 = { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_5 = { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_6 = { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_7 = { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_8 = { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_9 = { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_10 = { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_11 = { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_12 = { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_13 = { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_14 = { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_15 = { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_16 = { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_17 = { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> >getCtor : (comp: T) => CtorOf >all : "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" const comp = ctor({ common: "ok", ref: x => console.log(x) }); ->comp : { common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; } ->ctor({ common: "ok", ref: x => console.log(x) }) : { common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; } ->ctor : CtorOf<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> +>comp : type Anon = { common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_1 = { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_2 = { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_3 = { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_4 = { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_5 = { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_6 = { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_7 = { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_8 = { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_9 = { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_10 = { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_11 = { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_12 = { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_13 = { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_14 = { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_15 = { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_16 = { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_17 = { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; } +>ctor({ common: "ok", ref: x => console.log(x) }) : type Anon = { common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_1 = { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_2 = { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_3 = { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_4 = { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_5 = { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_6 = { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_7 = { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_8 = { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_9 = { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_10 = { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_11 = { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_12 = { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_13 = { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_14 = { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_15 = { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_16 = { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_17 = { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; } +>ctor : CtorOf | Func | undefined; } | type Anon_1 = { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_2 = { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_3 = { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_4 = { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_5 = { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_6 = { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_7 = { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_8 = { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_9 = { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_10 = { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_11 = { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_12 = { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_13 = { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_14 = { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_15 = { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_16 = { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | type Anon_17 = { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> >{ common: "ok", ref: x => console.log(x) } : { common: string; ref: (x: any) => void; } >common : string >"ok" : "ok" diff --git a/tests/baselines/reference/privateClassPropertyAccessibleWithinClass.types b/tests/baselines/reference/privateClassPropertyAccessibleWithinClass.types index 56aedbe253545..3e52ddb877111 100644 --- a/tests/baselines/reference/privateClassPropertyAccessibleWithinClass.types +++ b/tests/baselines/reference/privateClassPropertyAccessibleWithinClass.types @@ -25,10 +25,10 @@ class C { >x : string private foo() { return this.foo; } ->foo : () => any ->this.foo : () => any +>foo : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : this ->foo : () => any +>foo : type Anon = () => Anon private static x: string; >x : string @@ -51,17 +51,17 @@ class C { >x : string private static foo() { return this.foo; } ->foo : () => typeof C.foo ->this.foo : () => typeof C.foo +>foo : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon private static bar() { this.foo(); } >bar : () => void ->this.foo() : () => typeof C.foo ->this.foo : () => typeof C.foo +>this.foo() : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon } // added level of function nesting diff --git a/tests/baselines/reference/privateClassPropertyAccessibleWithinNestedClass.types b/tests/baselines/reference/privateClassPropertyAccessibleWithinNestedClass.types index c5338b68c41e5..2de3a5d5be2f9 100644 --- a/tests/baselines/reference/privateClassPropertyAccessibleWithinNestedClass.types +++ b/tests/baselines/reference/privateClassPropertyAccessibleWithinNestedClass.types @@ -25,10 +25,10 @@ class C { >x : string private foo() { return this.foo; } ->foo : () => any ->this.foo : () => any +>foo : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : this ->foo : () => any +>foo : type Anon = () => Anon private static x: string; >x : string @@ -51,17 +51,17 @@ class C { >x : string private static foo() { return this.foo; } ->foo : () => typeof C.foo ->this.foo : () => typeof C.foo +>foo : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon private static bar() { this.foo(); } >bar : () => void ->this.foo() : () => typeof C.foo ->this.foo : () => typeof C.foo +>this.foo() : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon private bar() { >bar : () => void @@ -76,10 +76,10 @@ class C { >x : C var x1 = x.foo; ->x1 : () => any ->x.foo : () => any +>x1 : type Anon = () => Anon +>x.foo : type Anon = () => Anon >x : C ->foo : () => any +>foo : type Anon = () => Anon var x2 = x.bar; >x2 : () => void @@ -118,10 +118,10 @@ class C { >bar : () => void var sx4 = C.foo; ->sx4 : () => typeof C.foo ->C.foo : () => typeof C.foo +>sx4 : type Anon = () => Anon +>C.foo : type Anon = () => Anon >C : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon let y = new C(); >y : C @@ -129,10 +129,10 @@ class C { >C : typeof C var y1 = y.foo; ->y1 : () => any ->y.foo : () => any +>y1 : type Anon = () => Anon +>y.foo : type Anon = () => Anon >y : C ->foo : () => any +>foo : type Anon = () => Anon var y2 = y.bar; >y2 : () => void diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types b/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types index 1e325d1d6f5e1..ae8e4ccd47d14 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types @@ -25,10 +25,10 @@ class C { >x : string protected foo() { return this.foo; } ->foo : () => any ->this.foo : () => any +>foo : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : this ->foo : () => any +>foo : type Anon = () => Anon protected static x: string; >x : string @@ -51,17 +51,17 @@ class C { >x : string protected static foo() { return this.foo; } ->foo : () => typeof C.foo ->this.foo : () => typeof C.foo +>foo : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon protected static bar() { this.foo(); } >bar : () => void ->this.foo() : () => typeof C.foo ->this.foo : () => typeof C.foo +>this.foo() : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon } // added level of function nesting diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedClass.types b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedClass.types index 6b6bf6edfc9fb..a8851c31e3a59 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedClass.types +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinNestedClass.types @@ -25,10 +25,10 @@ class C { >x : string protected foo() { return this.foo; } ->foo : () => any ->this.foo : () => any +>foo : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : this ->foo : () => any +>foo : type Anon = () => Anon protected static x: string; >x : string @@ -51,17 +51,17 @@ class C { >x : string protected static foo() { return this.foo; } ->foo : () => typeof C.foo ->this.foo : () => typeof C.foo +>foo : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon protected static bar() { this.foo(); } >bar : () => void ->this.foo() : () => typeof C.foo ->this.foo : () => typeof C.foo +>this.foo() : type Anon = () => Anon +>this.foo : type Anon = () => Anon >this : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon protected bar() { >bar : () => void @@ -76,10 +76,10 @@ class C { >x : C var x1 = x.foo; ->x1 : () => any ->x.foo : () => any +>x1 : type Anon = () => Anon +>x.foo : type Anon = () => Anon >x : C ->foo : () => any +>foo : type Anon = () => Anon var x2 = x.bar; >x2 : () => void @@ -118,10 +118,10 @@ class C { >bar : () => void var sx4 = C.foo; ->sx4 : () => typeof C.foo ->C.foo : () => typeof C.foo +>sx4 : type Anon = () => Anon +>C.foo : type Anon = () => Anon >C : typeof C ->foo : () => typeof C.foo +>foo : type Anon = () => Anon let y = new C(); >y : C @@ -129,10 +129,10 @@ class C { >C : typeof C var y1 = y.foo; ->y1 : () => any ->y.foo : () => any +>y1 : type Anon = () => Anon +>y.foo : type Anon = () => Anon >y : C ->foo : () => any +>foo : type Anon = () => Anon var y2 = y.bar; >y2 : () => void diff --git a/tests/baselines/reference/rectype.types b/tests/baselines/reference/rectype.types index 850fa4c8c83e9..7bddb7d4f06fc 100644 --- a/tests/baselines/reference/rectype.types +++ b/tests/baselines/reference/rectype.types @@ -6,33 +6,33 @@ module M { >i : I export function f(p: I) { return f }; ->f : (p: I) => typeof f +>f : type Anon = (p: I) => Anon >p : I ->f : (p: I) => typeof f +>f : type Anon = (p: I) => Anon var i:I; >i : I f(i); ->f(i) : (p: I) => typeof f ->f : (p: I) => typeof f +>f(i) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon >i : I f(f(i)); ->f(f(i)) : (p: I) => typeof f ->f : (p: I) => typeof f ->f(i) : (p: I) => typeof f ->f : (p: I) => typeof f +>f(f(i)) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon +>f(i) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon >i : I f((f(f(i)))); ->f((f(f(i)))) : (p: I) => typeof f ->f : (p: I) => typeof f ->(f(f(i))) : (p: I) => typeof f ->f(f(i)) : (p: I) => typeof f ->f : (p: I) => typeof f ->f(i) : (p: I) => typeof f ->f : (p: I) => typeof f +>f((f(f(i)))) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon +>(f(f(i))) : type Anon = (p: I) => Anon +>f(f(i)) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon +>f(i) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon >i : I } diff --git a/tests/baselines/reference/recursiveFunctionTypes.errors.txt b/tests/baselines/reference/recursiveFunctionTypes.errors.txt index c58b98b394932..34f2b085ade01 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.errors.txt +++ b/tests/baselines/reference/recursiveFunctionTypes.errors.txt @@ -1,31 +1,31 @@ -tests/cases/compiler/recursiveFunctionTypes.ts(1,28): error TS2322: Type '1' is not assignable to type '() => typeof fn'. -tests/cases/compiler/recursiveFunctionTypes.ts(3,5): error TS2322: Type '() => typeof fn' is not assignable to type 'number'. -tests/cases/compiler/recursiveFunctionTypes.ts(4,5): error TS2322: Type '() => typeof fn' is not assignable to type '() => number'. - Type '() => typeof fn' is not assignable to type 'number'. +tests/cases/compiler/recursiveFunctionTypes.ts(1,28): error TS2322: Type '1' is not assignable to type 'type Anon = () => Anon'. +tests/cases/compiler/recursiveFunctionTypes.ts(3,5): error TS2322: Type 'type Anon = () => Anon' is not assignable to type 'number'. +tests/cases/compiler/recursiveFunctionTypes.ts(4,5): error TS2322: Type 'type Anon = () => Anon' is not assignable to type '() => number'. + Type 'type Anon = () => Anon' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(11,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/recursiveFunctionTypes.ts(12,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/compiler/recursiveFunctionTypes.ts(17,5): error TS2322: Type '() => I' is not assignable to type 'number'. -tests/cases/compiler/recursiveFunctionTypes.ts(22,5): error TS2345: Argument of type '3' is not assignable to parameter of type '(t: typeof g) => void'. -tests/cases/compiler/recursiveFunctionTypes.ts(25,1): error TS2322: Type '3' is not assignable to type '() => any'. +tests/cases/compiler/recursiveFunctionTypes.ts(17,5): error TS2322: Type 'type Anon = () => I' is not assignable to type 'number'. +tests/cases/compiler/recursiveFunctionTypes.ts(22,5): error TS2345: Argument of type '3' is not assignable to parameter of type 'type Anon = (t: Anon) => void'. +tests/cases/compiler/recursiveFunctionTypes.ts(25,1): error TS2322: Type '3' is not assignable to type 'type Anon = () => Anon'. tests/cases/compiler/recursiveFunctionTypes.ts(30,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/compiler/recursiveFunctionTypes.ts(33,8): error TS2554: Expected 0-1 arguments, but got 2. -tests/cases/compiler/recursiveFunctionTypes.ts(34,4): error TS2345: Argument of type '""' is not assignable to parameter of type '{ (): typeof f6; (a: typeof f6): () => number; }'. +tests/cases/compiler/recursiveFunctionTypes.ts(34,4): error TS2345: Argument of type '""' is not assignable to parameter of type 'type Anon = { (): Anon; (a: Anon): () => number; }'. tests/cases/compiler/recursiveFunctionTypes.ts(42,8): error TS2554: Expected 0-1 arguments, but got 2. -tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of type '""' is not assignable to parameter of type '{ (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; }'. +tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of type '""' is not assignable to parameter of type 'type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; }'. ==== tests/cases/compiler/recursiveFunctionTypes.ts (13 errors) ==== function fn(): typeof fn { return 1; } ~~~~~~~~~ -!!! error TS2322: Type '1' is not assignable to type '() => typeof fn'. +!!! error TS2322: Type '1' is not assignable to type 'type Anon = () => Anon'. var x: number = fn; // error ~ -!!! error TS2322: Type '() => typeof fn' is not assignable to type 'number'. +!!! error TS2322: Type 'type Anon = () => Anon' is not assignable to type 'number'. var y: () => number = fn; // ok ~ -!!! error TS2322: Type '() => typeof fn' is not assignable to type '() => number'. -!!! error TS2322: Type '() => typeof fn' is not assignable to type 'number'. +!!! error TS2322: Type 'type Anon = () => Anon' is not assignable to type '() => number'. +!!! error TS2322: Type 'type Anon = () => Anon' is not assignable to type 'number'. var f: () => typeof g; var g: () => typeof f; @@ -44,19 +44,19 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of var a: number = f3; // error ~ -!!! error TS2322: Type '() => I' is not assignable to type 'number'. +!!! error TS2322: Type 'type Anon = () => I' is not assignable to type 'number'. class C { static g(t: typeof C.g){ } } C.g(3); // error ~ -!!! error TS2345: Argument of type '3' is not assignable to parameter of type '(t: typeof g) => void'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'type Anon = (t: Anon) => void'. var f4: () => typeof f4; f4 = 3; // error ~~ -!!! error TS2322: Type '3' is not assignable to type '() => any'. +!!! error TS2322: Type '3' is not assignable to type 'type Anon = () => Anon'. function f5() { return f5; } @@ -72,7 +72,7 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of !!! error TS2554: Expected 0-1 arguments, but got 2. f6(""); // ok (function takes an any param) ~~ -!!! error TS2345: Argument of type '""' is not assignable to parameter of type '{ (): typeof f6; (a: typeof f6): () => number; }'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'type Anon = { (): Anon; (a: Anon): () => number; }'. f6(); // ok declare function f7(): typeof f7; @@ -85,5 +85,5 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of !!! error TS2554: Expected 0-1 arguments, but got 2. f7(""); // ok (function takes an any param) ~~ -!!! error TS2345: Argument of type '""' is not assignable to parameter of type '{ (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; }'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; }'. f7(); // ok \ No newline at end of file diff --git a/tests/baselines/reference/recursiveFunctionTypes.types b/tests/baselines/reference/recursiveFunctionTypes.types index 72ba77b48f6f9..dee48c25629bb 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.types +++ b/tests/baselines/reference/recursiveFunctionTypes.types @@ -1,138 +1,138 @@ === tests/cases/compiler/recursiveFunctionTypes.ts === function fn(): typeof fn { return 1; } ->fn : () => typeof fn ->fn : () => typeof fn +>fn : type Anon = () => Anon +>fn : type Anon = () => Anon >1 : 1 var x: number = fn; // error >x : number ->fn : () => typeof fn +>fn : type Anon = () => Anon var y: () => number = fn; // ok >y : () => number ->fn : () => typeof fn +>fn : type Anon = () => Anon var f: () => typeof g; ->f : () => () => any ->g : () => () => any +>f : type Anon = () => () => Anon +>g : type Anon = () => () => Anon var g: () => typeof f; ->g : () => () => any ->f : () => () => any +>g : type Anon = () => () => Anon +>f : type Anon = () => () => Anon function f1(d: typeof f1) { } ->f1 : (d: typeof f1) => void ->d : (d: typeof f1) => void ->f1 : (d: typeof f1) => void +>f1 : type Anon = (d: Anon) => void +>d : type Anon = (d: Anon) => void +>f1 : type Anon = (d: Anon) => void function f2(): typeof g2 { } ->f2 : () => () => typeof f2 ->g2 : () => () => typeof g2 +>f2 : type Anon = () => () => Anon +>g2 : type Anon = () => () => Anon function g2(): typeof f2 { } ->g2 : () => () => typeof g2 ->f2 : () => () => typeof f2 +>g2 : type Anon = () => () => Anon +>f2 : type Anon = () => () => Anon interface I { } function f3(): I { return f3; } ->f3 : () => I ->f3 : () => I ->f3 : () => I +>f3 : type Anon = () => I +>f3 : type Anon = () => I +>f3 : type Anon = () => I var a: number = f3; // error >a : number ->f3 : () => I +>f3 : type Anon = () => I class C { >C : C static g(t: typeof C.g){ } ->g : (t: typeof C.g) => void ->t : (t: typeof C.g) => void ->C.g : (t: typeof C.g) => void +>g : type Anon = (t: Anon) => void +>t : type Anon = (t: Anon) => void +>C.g : type Anon = (t: Anon) => void >C : typeof C ->g : (t: typeof C.g) => void +>g : type Anon = (t: Anon) => void } C.g(3); // error >C.g(3) : void ->C.g : (t: typeof C.g) => void +>C.g : type Anon = (t: Anon) => void >C : typeof C ->g : (t: typeof C.g) => void +>g : type Anon = (t: Anon) => void >3 : 3 var f4: () => typeof f4; ->f4 : () => any ->f4 : () => any +>f4 : type Anon = () => Anon +>f4 : type Anon = () => Anon f4 = 3; // error >f4 = 3 : 3 ->f4 : () => any +>f4 : type Anon = () => Anon >3 : 3 function f5() { return f5; } ->f5 : () => typeof f5 ->f5 : () => typeof f5 +>f5 : type Anon = () => Anon +>f5 : type Anon = () => Anon function f6(): typeof f6; ->f6 : { (): typeof f6; (a: typeof f6): () => number; } ->f6 : { (): typeof f6; (a: typeof f6): () => number; } +>f6 : type Anon = { (): Anon; (a: Anon): () => number; } +>f6 : type Anon = { (): Anon; (a: Anon): () => number; } function f6(a: typeof f6): () => number; ->f6 : { (): typeof f6; (a: typeof f6): () => number; } ->a : { (): typeof f6; (a: typeof f6): () => number; } ->f6 : { (): typeof f6; (a: typeof f6): () => number; } +>f6 : type Anon = { (): Anon; (a: Anon): () => number; } +>a : type Anon = { (): Anon; (a: Anon): () => number; } +>f6 : type Anon = { (): Anon; (a: Anon): () => number; } function f6(a?: any) { return f6; } ->f6 : { (): typeof f6; (a: typeof f6): () => number; } +>f6 : type Anon = { (): Anon; (a: Anon): () => number; } >a : any ->f6 : { (): typeof f6; (a: typeof f6): () => number; } +>f6 : type Anon = { (): Anon; (a: Anon): () => number; } f6("", 3); // error (arity mismatch) >f6("", 3) : any ->f6 : { (): typeof f6; (a: typeof f6): () => number; } +>f6 : type Anon = { (): Anon; (a: Anon): () => number; } >"" : "" >3 : 3 f6(""); // ok (function takes an any param) >f6("") : any ->f6 : { (): typeof f6; (a: typeof f6): () => number; } +>f6 : type Anon = { (): Anon; (a: Anon): () => number; } >"" : "" f6(); // ok ->f6() : { (): typeof f6; (a: typeof f6): () => number; } ->f6 : { (): typeof f6; (a: typeof f6): () => number; } +>f6() : type Anon = { (): Anon; (a: Anon): () => number; } +>f6 : type Anon = { (): Anon; (a: Anon): () => number; } declare function f7(): typeof f7; ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } declare function f7(a: typeof f7): () => number; ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } ->a : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } +>a : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } declare function f7(a: number): number; ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } >a : number declare function f7(a?: typeof f7): typeof f7; ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } ->a : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } +>a : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } f7("", 3); // error (arity mismatch) >f7("", 3) : any ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } >"" : "" >3 : 3 f7(""); // ok (function takes an any param) >f7("") : any ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } >"" : "" f7(); // ok ->f7() : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } ->f7 : { (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; } +>f7() : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } +>f7 : type Anon = { (): Anon; (a: Anon): () => number; (a: number): number; (a?: Anon): Anon; } diff --git a/tests/baselines/reference/recursiveFunctionTypes1.types b/tests/baselines/reference/recursiveFunctionTypes1.types index 52cf90f1059d4..ea5d5e6cc4b17 100644 --- a/tests/baselines/reference/recursiveFunctionTypes1.types +++ b/tests/baselines/reference/recursiveFunctionTypes1.types @@ -3,9 +3,9 @@ class C { >C : C static g(t: typeof C.g){ } ->g : (t: typeof C.g) => void ->t : (t: typeof C.g) => void ->C.g : (t: typeof C.g) => void +>g : type Anon = (t: Anon) => void +>t : type Anon = (t: Anon) => void +>C.g : type Anon = (t: Anon) => void >C : typeof C ->g : (t: typeof C.g) => void +>g : type Anon = (t: Anon) => void } diff --git a/tests/baselines/reference/recursiveIdenticalOverloadResolution.types b/tests/baselines/reference/recursiveIdenticalOverloadResolution.types index 83d785a61a541..b9c01c249392b 100644 --- a/tests/baselines/reference/recursiveIdenticalOverloadResolution.types +++ b/tests/baselines/reference/recursiveIdenticalOverloadResolution.types @@ -6,33 +6,33 @@ module M { >i : I function f(p: I) { return f }; ->f : (p: I) => typeof f +>f : type Anon = (p: I) => Anon >p : I ->f : (p: I) => typeof f +>f : type Anon = (p: I) => Anon var i: I; >i : I f(i); ->f(i) : (p: I) => typeof f ->f : (p: I) => typeof f +>f(i) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon >i : I f(f(i)); ->f(f(i)) : (p: I) => typeof f ->f : (p: I) => typeof f ->f(i) : (p: I) => typeof f ->f : (p: I) => typeof f +>f(f(i)) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon +>f(i) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon >i : I f((f(f(i)))); ->f((f(f(i)))) : (p: I) => typeof f ->f : (p: I) => typeof f ->(f(f(i))) : (p: I) => typeof f ->f(f(i)) : (p: I) => typeof f ->f : (p: I) => typeof f ->f(i) : (p: I) => typeof f ->f : (p: I) => typeof f +>f((f(f(i)))) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon +>(f(f(i))) : type Anon = (p: I) => Anon +>f(f(i)) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon +>f(i) : type Anon = (p: I) => Anon +>f : type Anon = (p: I) => Anon >i : I } diff --git a/tests/baselines/reference/recursiveLetConst.types b/tests/baselines/reference/recursiveLetConst.types index 90b0d7baab1f7..9be70d91884f8 100644 --- a/tests/baselines/reference/recursiveLetConst.types +++ b/tests/baselines/reference/recursiveLetConst.types @@ -52,18 +52,18 @@ let [x2 = x2] = [] >[] : [any?] let z0 = () => z0; ->z0 : () => any ->() => z0 : () => any ->z0 : () => any +>z0 : type Anon = () => Anon +>() => z0 : type Anon = () => Anon +>z0 : type Anon = () => Anon let z1 = function () { return z1; } ->z1 : () => any ->function () { return z1; } : () => any ->z1 : () => any +>z1 : type Anon = () => Anon +>function () { return z1; } : type Anon = () => Anon +>z1 : type Anon = () => Anon let z2 = { f() { return z2;}} ->z2 : { f(): any; } ->{ f() { return z2;}} : { f(): { f(): any; }; } ->f : () => { f(): any; } ->z2 : { f(): any; } +>z2 : type Anon = { f(): Anon; } +>{ f() { return z2;}} : { f(): type Anon = { f(): Anon; }; } +>f : () => type Anon = { f(): Anon; } +>z2 : type Anon = { f(): Anon; } diff --git a/tests/baselines/reference/recursiveTypesWithTypeof.types b/tests/baselines/reference/recursiveTypesWithTypeof.types index 5625e7919cd2a..4a58217d7ecd2 100644 --- a/tests/baselines/reference/recursiveTypesWithTypeof.types +++ b/tests/baselines/reference/recursiveTypesWithTypeof.types @@ -46,127 +46,127 @@ var f3: any; // None of these declarations should have any errors! // Truly recursive types var g: { x: typeof g; }; ->g : { x: any; } ->x : { x: any; } ->g : { x: any; } +>g : type Anon = { x: Anon; } +>x : type Anon = { x: Anon; } +>g : type Anon = { x: Anon; } var g: typeof g.x; ->g : { x: any; } ->g.x : { x: any; } ->g : { x: any; } ->x : { x: any; } +>g : type Anon = { x: Anon; } +>g.x : type Anon = { x: Anon; } +>g : type Anon = { x: Anon; } +>x : type Anon = { x: Anon; } var h: () => typeof h; ->h : () => any ->h : () => any +>h : type Anon = () => Anon +>h : type Anon = () => Anon var h = h(); ->h : () => any ->h() : () => any ->h : () => any +>h : type Anon = () => Anon +>h() : type Anon = () => Anon +>h : type Anon = () => Anon var i: (x: typeof i) => typeof x; ->i : (x: any) => any ->x : (x: any) => any ->i : (x: any) => any ->x : (x: any) => any +>i : type Anon = (x: Anon) => Anon +>x : type Anon = (x: Anon) => Anon +>i : type Anon = (x: Anon) => Anon +>x : type Anon = (x: Anon) => Anon var i = i(i); ->i : (x: any) => any ->i(i) : (x: any) => any ->i : (x: any) => any ->i : (x: any) => any +>i : type Anon = (x: Anon) => Anon +>i(i) : type Anon = (x: Anon) => Anon +>i : type Anon = (x: Anon) => Anon +>i : type Anon = (x: Anon) => Anon var j: (x: T) => T; ->j : (x: T) => T ->j : (x: T) => T +>j : type Anon = (x: T) => T +>j : type Anon = (x: T) => T >x : T var j = j(j); ->j : (x: T) => T ->j(j) : (x: T) => T ->j : (x: T) => T ->j : (x: T) => T +>j : type Anon = (x: T) => T +>j(j) : type Anon = (x: T) => T +>j : type Anon = (x: T) => T +>j : type Anon = (x: T) => T // Same as h, i, j with construct signatures var h2: new () => typeof h2; ->h2 : new () => any ->h2 : new () => any +>h2 : type Anon = new () => Anon +>h2 : type Anon = new () => Anon var h2 = new h2(); ->h2 : new () => any ->new h2() : new () => any ->h2 : new () => any +>h2 : type Anon = new () => Anon +>new h2() : type Anon = new () => Anon +>h2 : type Anon = new () => Anon var i2: new (x: typeof i2) => typeof x; ->i2 : new (x: any) => any ->x : new (x: any) => any ->i2 : new (x: any) => any ->x : new (x: any) => any +>i2 : type Anon = new (x: Anon) => Anon +>x : type Anon = new (x: Anon) => Anon +>i2 : type Anon = new (x: Anon) => Anon +>x : type Anon = new (x: Anon) => Anon var i2 = new i2(i2); ->i2 : new (x: any) => any ->new i2(i2) : new (x: any) => any ->i2 : new (x: any) => any ->i2 : new (x: any) => any +>i2 : type Anon = new (x: Anon) => Anon +>new i2(i2) : type Anon = new (x: Anon) => Anon +>i2 : type Anon = new (x: Anon) => Anon +>i2 : type Anon = new (x: Anon) => Anon var j2: new (x: T) => T; ->j2 : new (x: T) => T ->j2 : new (x: T) => T +>j2 : type Anon = new (x: T) => T +>j2 : type Anon = new (x: T) => T >x : T var j2 = new j2(j2); ->j2 : new (x: T) => T ->new j2(j2) : new (x: T) => T ->j2 : new (x: T) => T ->j2 : new (x: T) => T +>j2 : type Anon = new (x: T) => T +>new j2(j2) : type Anon = new (x: T) => T +>j2 : type Anon = new (x: T) => T +>j2 : type Anon = new (x: T) => T // Indexers var k: { [n: number]: typeof k;[s: string]: typeof k }; ->k : { [s: string]: any; [n: number]: any; } +>k : type Anon = { [s: string]: Anon; [n: number]: Anon; } >n : number ->k : { [s: string]: any; [n: number]: any; } +>k : type Anon = { [s: string]: Anon; [n: number]: Anon; } >s : string ->k : { [s: string]: any; [n: number]: any; } +>k : type Anon = { [s: string]: Anon; [n: number]: Anon; } var k = k[0]; ->k : { [s: string]: any; [n: number]: any; } ->k[0] : { [s: string]: any; [n: number]: any; } ->k : { [s: string]: any; [n: number]: any; } +>k : type Anon = { [s: string]: Anon; [n: number]: Anon; } +>k[0] : type Anon = { [s: string]: Anon; [n: number]: Anon; } +>k : type Anon = { [s: string]: Anon; [n: number]: Anon; } >0 : 0 var k = k['']; ->k : { [s: string]: any; [n: number]: any; } ->k[''] : { [s: string]: any; [n: number]: any; } ->k : { [s: string]: any; [n: number]: any; } +>k : type Anon = { [s: string]: Anon; [n: number]: Anon; } +>k[''] : type Anon = { [s: string]: Anon; [n: number]: Anon; } +>k : type Anon = { [s: string]: Anon; [n: number]: Anon; } >'' : "" // Hybrid - contains type literals as well as type arguments // These two are recursive var hy1: { x: typeof hy1 }[]; ->hy1 : { x: any[]; }[] ->x : { x: any[]; }[] ->hy1 : { x: any[]; }[] +>hy1 : type Anon = { x: Anon[]; }[] +>x : type Anon = { x: Anon[]; }[] +>hy1 : type Anon = { x: Anon[]; }[] var hy1 = hy1[0].x; ->hy1 : { x: any[]; }[] ->hy1[0].x : { x: any[]; }[] ->hy1[0] : { x: any[]; } ->hy1 : { x: any[]; }[] +>hy1 : type Anon = { x: Anon[]; }[] +>hy1[0].x : type Anon = { x: Anon[]; }[] +>hy1[0] : type Anon = { x: Anon[]; } +>hy1 : type Anon = { x: Anon[]; }[] >0 : 0 ->x : { x: any[]; }[] +>x : type Anon = { x: Anon[]; }[] var hy2: { x: Array }; ->hy2 : { x: any[]; } ->x : { x: any[]; }[] ->hy2 : { x: any[]; } +>hy2 : type Anon = { x: Anon[]; } +>x : type Anon = { x: Anon[]; }[] +>hy2 : type Anon = { x: Anon[]; } var hy2 = hy2.x[0]; ->hy2 : { x: any[]; } ->hy2.x[0] : { x: any[]; } ->hy2.x : { x: any[]; }[] ->hy2 : { x: any[]; } ->x : { x: any[]; }[] +>hy2 : type Anon = { x: Anon[]; } +>hy2.x[0] : type Anon = { x: Anon[]; } +>hy2.x : type Anon = { x: Anon[]; }[] +>hy2 : type Anon = { x: Anon[]; } +>x : type Anon = { x: Anon[]; }[] >0 : 0 interface Foo2 { } diff --git a/tests/baselines/reference/returnInfiniteIntersection.types b/tests/baselines/reference/returnInfiniteIntersection.types index 545b94759a0bd..d872c229a4c2e 100644 --- a/tests/baselines/reference/returnInfiniteIntersection.types +++ b/tests/baselines/reference/returnInfiniteIntersection.types @@ -1,25 +1,25 @@ === tests/cases/compiler/returnInfiniteIntersection.ts === function recursive() { ->recursive : () => ((subkey: T) => any & { p: any; }) & { p: any; } +>recursive : () => type Anon = (subkey: T) => Anon & { p: any; } & { p: any; } let x = (subkey: T) => recursive(); ->x : (subkey: T) => any & { p: any; } ->(subkey: T) => recursive() : (subkey: T) => any & { p: any; } +>x : type Anon = (subkey: T) => Anon & { p: any; } +>(subkey: T) => recursive() : type Anon = (subkey: T) => Anon & { p: any; } >subkey : T ->recursive() : ((subkey: T) => any & { p: any; }) & { p: any; } ->recursive : () => ((subkey: T) => any & { p: any; }) & { p: any; } +>recursive() : type Anon = (subkey: T) => Anon & { p: any; } & { p: any; } +>recursive : () => type Anon = (subkey: T) => Anon & { p: any; } & { p: any; } return x as typeof x & { p }; ->x as typeof x & { p } : ((subkey: T) => any & { p: any; }) & { p: any; } ->x : (subkey: T) => any & { p: any; } ->x : (subkey: T) => any & { p: any; } +>x as typeof x & { p } : type Anon = (subkey: T) => Anon & { p: any; } & { p: any; } +>x : type Anon = (subkey: T) => Anon & { p: any; } +>x : type Anon = (subkey: T) => Anon & { p: any; } >p : any } let result = recursive()(1) ->result : ((subkey: T) => any & { p: any; }) & { p: any; } ->recursive()(1) : ((subkey: T) => any & { p: any; }) & { p: any; } ->recursive() : ((subkey: T) => any & { p: any; }) & { p: any; } ->recursive : () => ((subkey: T) => any & { p: any; }) & { p: any; } +>result : type Anon = (subkey: T) => Anon & { p: any; } & { p: any; } +>recursive()(1) : type Anon = (subkey: T) => Anon & { p: any; } & { p: any; } +>recursive() : type Anon = (subkey: T) => Anon & { p: any; } & { p: any; } +>recursive : () => type Anon = (subkey: T) => Anon & { p: any; } & { p: any; } >1 : 1 diff --git a/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.types b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.types index 19a37ae86f414..3a87a2532aa69 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.types +++ b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.types @@ -2,7 +2,7 @@ var x = `abc${ function y() { return y; } }def`; >x : string >`abc${ function y() { return y; } }def` : string ->function y() { return y; } : () => any ->y : () => any ->y : () => any +>function y() { return y; } : type Anon = () => Anon +>y : type Anon = () => Anon +>y : type Anon = () => Anon diff --git a/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.types b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.types index c7a4f2e2bc403..8696cecffa6f5 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.types @@ -2,7 +2,7 @@ var x = `abc${ function y() { return y; } }def`; >x : string >`abc${ function y() { return y; } }def` : string ->function y() { return y; } : () => any ->y : () => any ->y : () => any +>function y() { return y; } : type Anon = () => Anon +>y : type Anon = () => Anon +>y : type Anon = () => Anon diff --git a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction3.errors.txt b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction3.errors.txt index 279119e679acf..bdc604369eed4 100644 --- a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction3.errors.txt +++ b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction3.ts(5,5): error TS2322: Type '{ prop: number; } | { prop: { prop: number; } | any; }' is not assignable to type 'string'. +tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction3.ts(5,5): error TS2322: Type '{ prop: number; } | type Anon = { prop: { prop: number; } | Anon; }' is not assignable to type 'string'. Type '{ prop: number; }' is not assignable to type 'string'. @@ -9,6 +9,6 @@ tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction3.ts(5,5): error TS23 var b: T27; var s: string = b; ~ -!!! error TS2322: Type '{ prop: number; } | { prop: { prop: number; } | any; }' is not assignable to type 'string'. +!!! error TS2322: Type '{ prop: number; } | type Anon = { prop: { prop: number; } | Anon; }' is not assignable to type 'string'. !!! error TS2322: Type '{ prop: number; }' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction3.types b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction3.types index 4faece1919468..adbcf5933efb6 100644 --- a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction3.types +++ b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction3.types @@ -1,17 +1,17 @@ === tests/cases/compiler/unionTypeWithRecursiveSubtypeReduction3.ts === var a27: { prop: number } | { prop: T27 }; ->a27 : { prop: number; } | { prop: { prop: number; } | any; } +>a27 : { prop: number; } | type Anon = { prop: { prop: number; } | Anon; } >prop : number ->prop : { prop: number; } | { prop: { prop: number; } | any; } +>prop : { prop: number; } | type Anon = { prop: { prop: number; } | Anon; } type T27 = typeof a27; ->T27 : { prop: number; } | { prop: { prop: number; } | any; } ->a27 : { prop: number; } | { prop: { prop: number; } | any; } +>T27 : { prop: number; } | type Anon = { prop: { prop: number; } | Anon; } +>a27 : { prop: number; } | type Anon = { prop: { prop: number; } | Anon; } var b: T27; ->b : { prop: number; } | { prop: { prop: number; } | any; } +>b : { prop: number; } | type Anon = { prop: { prop: number; } | Anon; } var s: string = b; >s : string ->b : { prop: number; } | { prop: { prop: number; } | any; } +>b : { prop: number; } | type Anon = { prop: { prop: number; } | Anon; } diff --git a/tests/baselines/reference/witness.types b/tests/baselines/reference/witness.types index 69f318e875816..25e4dc433adcf 100644 --- a/tests/baselines/reference/witness.types +++ b/tests/baselines/reference/witness.types @@ -55,15 +55,15 @@ var a = fnReturn1(); >fnReturn1 : () => any function fnReturn2() { ->fnReturn2 : () => typeof fnReturn2 +>fnReturn2 : type Anon = () => Anon return fnReturn2; ->fnReturn2 : () => typeof fnReturn2 +>fnReturn2 : type Anon = () => Anon } var fnr2: () => any = fnReturn2(); >fnr2 : () => any ->fnReturn2() : () => typeof fnReturn2 ->fnReturn2 : () => typeof fnReturn2 +>fnReturn2() : type Anon = () => Anon +>fnReturn2 : type Anon = () => Anon // Comma var co1 = (co1, 3); @@ -223,21 +223,21 @@ var fnCallResult: any; // Call argument function fnArg1(x: typeof fnArg1, y: number) { ->fnArg1 : (x: typeof fnArg1, y: number) => void ->x : (x: typeof fnArg1, y: number) => void ->fnArg1 : (x: typeof fnArg1, y: number) => void +>fnArg1 : type Anon = (x: Anon, y: number) => void +>x : type Anon = (x: Anon, y: number) => void +>fnArg1 : type Anon = (x: Anon, y: number) => void >y : number var x: (n: typeof fnArg1, m: number) => void; ->x : (x: typeof fnArg1, y: number) => void ->n : (x: typeof fnArg1, y: number) => void ->fnArg1 : (x: typeof fnArg1, y: number) => void +>x : type Anon = (x: Anon, y: number) => void +>n : type Anon = (x: Anon, y: number) => void +>fnArg1 : type Anon = (x: Anon, y: number) => void >m : number fnArg1(fnArg1, 0); >fnArg1(fnArg1, 0) : void ->fnArg1 : (x: typeof fnArg1, y: number) => void ->fnArg1 : (x: typeof fnArg1, y: number) => void +>fnArg1 : type Anon = (x: Anon, y: number) => void +>fnArg1 : type Anon = (x: Anon, y: number) => void >0 : 0 } diff --git a/tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliasNoSpuriousCircularityError.ts b/tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliasNoSpuriousCircularityError.ts new file mode 100644 index 0000000000000..73a48e4c589c0 --- /dev/null +++ b/tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliasNoSpuriousCircularityError.ts @@ -0,0 +1,3 @@ +type Something = type Q = T extends number ? {x: Q} : never; + +type Foo = Something; diff --git a/tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliases.ts b/tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliases.ts new file mode 100644 index 0000000000000..c650504e77ef8 --- /dev/null +++ b/tests/cases/conformance/types/inlineTypeAliases/inlineTypeAliases.ts @@ -0,0 +1,16 @@ +// @declaration: true +export declare const x: type T = { x: T }; + +export const y = (null as type T = { x: T }); + +export function f() { + return (null as any as (type T = {x: T})).x; +} + +export declare const xx: type T = ({ x: {y: T} } & {y: string})["x"]; + +export const yy = (null as any as type T = ({ x: {y: T} } & {y: string})["x"]); + +export function ff() { + return (null as any as type T = ({ x: {y: T} } & {y: string})["x"]).y.y.y.y.y.y; +} diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts index c664b47093836..c780815071a75 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts @@ -15,7 +15,7 @@ const ranges = test.ranges(); const [r0, r1, r2, r3, r4] = ranges; const fnRanges = [r0, r1, r2, r3]; -verify.singleReferenceGroup("function DefaultExportedFunction(): () => typeof DefaultExportedFunction", fnRanges); +verify.singleReferenceGroup("function DefaultExportedFunction(): type Anon = () => Anon", fnRanges); // The namespace and function do not merge, // so the namespace should be all alone. diff --git a/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts index ddb98711629ea..6630adf56bd79 100644 --- a/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts +++ b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts @@ -9,4 +9,4 @@ /////// ////foo(); -verify.singleReferenceGroup("(local function) foo(a?: void, b?: () => (a?: void, b?: ...) => void): void"); +verify.singleReferenceGroup("(local function) foo(a?: void, b?: type Anon = () => (a?: void, b?: Anon) => void): void");