diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fd6a033653ac0..d07681c2992a4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14021,7 +14021,7 @@ namespace ts { } // Return contextual type of parameter or undefined if no contextual type is available - function getContextuallyTypedParameterType(parameter: ParameterDeclaration): Type | undefined { + function getContextuallyTypedParameterType(parameter: ParameterDeclaration, omitBindingPatterns?: boolean): Type | undefined { const func = parameter.parent; if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { const iife = getImmediatelyInvokedFunctionExpression(func); @@ -14043,7 +14043,7 @@ namespace ts { links.resolvedSignature = cached; return type; } - const contextualSignature = getContextualSignature(func); + const contextualSignature = getContextualSignature(func, omitBindingPatterns); if (contextualSignature) { const funcHasRestParameters = hasRestParameter(func); const len = func.parameters.length - (funcHasRestParameters ? 1 : 0); @@ -14076,7 +14076,7 @@ namespace ts { // the contextual type of an initializer expression is the type implied by the binding pattern. // Otherwise, in a binding pattern inside a variable or parameter declaration, // the contextual type of an initializer expression is the type annotation of the containing declaration, if present. - function getContextualTypeForInitializerExpression(node: Expression): Type { + function getContextualTypeForInitializerExpression(node: Expression, omitBindingPatterns?: boolean): Type { const declaration = node.parent; if (hasInitializer(declaration) && node === declaration.initializer) { const typeNode = getEffectiveTypeAnnotationNode(declaration); @@ -14084,12 +14084,12 @@ namespace ts { return getTypeFromTypeNode(typeNode); } if (declaration.kind === SyntaxKind.Parameter) { - const type = getContextuallyTypedParameterType(declaration); + const type = getContextuallyTypedParameterType(declaration, omitBindingPatterns); if (type) { return type; } } - if (isBindingPattern(declaration.name)) { + if (isBindingPattern(declaration.name) && !omitBindingPatterns) { return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } if (isBindingPattern(declaration.parent)) { @@ -14109,7 +14109,7 @@ namespace ts { return undefined; } - function getContextualTypeForReturnExpression(node: Expression): Type { + function getContextualTypeForReturnExpression(node: Expression, omitBindingPatterns?: boolean): Type { const func = getContainingFunction(node); if (func) { const functionFlags = getFunctionFlags(func); @@ -14117,7 +14117,7 @@ namespace ts { return undefined; } - const contextualReturnType = getContextualReturnType(func); + const contextualReturnType = getContextualReturnType(func, omitBindingPatterns); return functionFlags & FunctionFlags.Async ? contextualReturnType && getAwaitedTypeOfPromise(contextualReturnType) // Async function : contextualReturnType; // Regular function @@ -14125,11 +14125,11 @@ namespace ts { return undefined; } - function getContextualTypeForYieldOperand(node: YieldExpression): Type { + function getContextualTypeForYieldOperand(node: YieldExpression, omitBindingPatterns?: boolean): Type { const func = getContainingFunction(node); if (func) { const functionFlags = getFunctionFlags(func); - const contextualReturnType = getContextualReturnType(func); + const contextualReturnType = getContextualReturnType(func, omitBindingPatterns); if (contextualReturnType) { return node.asteriskToken ? contextualReturnType @@ -14156,7 +14156,7 @@ namespace ts { return false; } - function getContextualReturnType(functionDecl: FunctionLike): Type { + function getContextualReturnType(functionDecl: FunctionLike, omitBindingPatterns?: boolean): Type { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.kind === SyntaxKind.Constructor || @@ -14167,7 +14167,7 @@ namespace ts { // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature // and that call signature is non-generic, return statements are contextually typed by the return type of the signature - const signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); + const signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl, omitBindingPatterns); if (signature && !isResolvingReturnTypeOfSignature(signature)) { return getReturnTypeOfSignature(signature); } @@ -14196,7 +14196,7 @@ namespace ts { return undefined; } - function getContextualTypeForBinaryOperand(node: Expression): Type | undefined { + function getContextualTypeForBinaryOperand(node: Expression, omitBindingPatterns?: boolean): Type | undefined { const binaryExpression = node.parent; const { left, operatorToken, right } = binaryExpression; switch (operatorToken.kind) { @@ -14205,11 +14205,11 @@ namespace ts { case SyntaxKind.BarBarToken: // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. - const type = getContextualType(binaryExpression); + const type = getContextualType(binaryExpression, omitBindingPatterns); return !type && node === right ? getTypeOfExpression(left, /*cache*/ true) : type; case SyntaxKind.AmpersandAmpersandToken: case SyntaxKind.CommaToken: - return node === right ? getContextualType(binaryExpression) : undefined; + return node === right ? getContextualType(binaryExpression, omitBindingPatterns) : undefined; default: return undefined; } @@ -14254,19 +14254,19 @@ namespace ts { // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one // exists. Otherwise, it is the type of the string index signature in T, if one exists. - function getContextualTypeForObjectLiteralMethod(node: MethodDeclaration): Type { + function getContextualTypeForObjectLiteralMethod(node: MethodDeclaration, omitBindingPatterns?: boolean): Type { Debug.assert(isObjectLiteralMethod(node)); if (node.flags & NodeFlags.InWithStatement) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } - return getContextualTypeForObjectLiteralElement(node); + return getContextualTypeForObjectLiteralElement(node, omitBindingPatterns); } - function getContextualTypeForObjectLiteralElement(element: ObjectLiteralElementLike) { + function getContextualTypeForObjectLiteralElement(element: ObjectLiteralElementLike, omitBindingPatterns?: boolean) { const objectLiteral = element.parent; - const type = getApparentTypeOfContextualType(objectLiteral); + const type = getApparentTypeOfContextualType(objectLiteral, omitBindingPatterns); if (type) { if (!hasNonBindableDynamicName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name @@ -14298,12 +14298,12 @@ namespace ts { } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. - function getContextualTypeForConditionalOperand(node: Expression): Type { + function getContextualTypeForConditionalOperand(node: Expression, omitBindingPatterns?: boolean): Type { const conditional = node.parent; - return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; + return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, omitBindingPatterns) : undefined; } - function getContextualTypeForJsxExpression(node: JsxExpression): Type { + function getContextualTypeForJsxExpression(node: JsxExpression, omitBindingPatterns?: boolean): Type { // JSX expression can appear in two position : JSX Element's children or JSX attribute const jsxAttributes = isJsxAttributeLike(node.parent) ? node.parent.parent : @@ -14318,7 +14318,7 @@ namespace ts { // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type // which is a type of the parameter of the signature we are trying out. // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName - const attributesType = getContextualType(jsxAttributes); + const attributesType = getContextualType(jsxAttributes, omitBindingPatterns); if (!attributesType || isTypeAny(attributesType)) { return undefined; @@ -14339,11 +14339,11 @@ namespace ts { } } - function getContextualTypeForJsxAttribute(attribute: JsxAttribute | JsxSpreadAttribute) { + function getContextualTypeForJsxAttribute(attribute: JsxAttribute | JsxSpreadAttribute, omitBindingPatterns?: boolean) { // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type // which is a type of the parameter of the signature we are trying out. // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName - const attributesType = getContextualType(attribute.parent); + const attributesType = getContextualType(attribute.parent, omitBindingPatterns); if (isJsxAttribute(attribute)) { if (!attributesType || isTypeAny(attributesType)) { @@ -14358,8 +14358,8 @@ namespace ts { // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. - function getApparentTypeOfContextualType(node: Expression): Type { - let contextualType = getContextualType(node); + function getApparentTypeOfContextualType(node: Expression, omitBindingPatterns?: boolean): Type { + let contextualType = getContextualType(node, omitBindingPatterns); contextualType = contextualType && mapType(contextualType, getApparentType); if (!(contextualType && contextualType.flags & TypeFlags.Union && isObjectLiteralExpression(node))) { return contextualType; @@ -14404,7 +14404,7 @@ namespace ts { * @param node the expression whose contextual type will be returned. * @returns the contextual type of an expression. */ - function getContextualType(node: Expression): Type | undefined { + function getContextualType(node: Expression, omitBindingPatterns?: boolean): Type | undefined { if (node.flags & NodeFlags.InWithStatement) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -14419,12 +14419,12 @@ namespace ts { case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: case SyntaxKind.BindingElement: - return getContextualTypeForInitializerExpression(node); + return getContextualTypeForInitializerExpression(node, omitBindingPatterns); case SyntaxKind.ArrowFunction: case SyntaxKind.ReturnStatement: - return getContextualTypeForReturnExpression(node); + return getContextualTypeForReturnExpression(node, omitBindingPatterns); case SyntaxKind.YieldExpression: - return getContextualTypeForYieldOperand(parent); + return getContextualTypeForYieldOperand(parent, omitBindingPatterns); case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: return getContextualTypeForArgument(parent, node); @@ -14432,32 +14432,32 @@ namespace ts { case SyntaxKind.AsExpression: return getTypeFromTypeNode((parent).type); case SyntaxKind.BinaryExpression: - return getContextualTypeForBinaryOperand(node); + return getContextualTypeForBinaryOperand(node, omitBindingPatterns); case SyntaxKind.PropertyAssignment: case SyntaxKind.ShorthandPropertyAssignment: - return getContextualTypeForObjectLiteralElement(parent); + return getContextualTypeForObjectLiteralElement(parent, omitBindingPatterns); case SyntaxKind.SpreadAssignment: - return getApparentTypeOfContextualType(parent.parent as ObjectLiteralExpression); + return getApparentTypeOfContextualType(parent.parent as ObjectLiteralExpression, omitBindingPatterns); case SyntaxKind.ArrayLiteralExpression: { const arrayLiteral = parent; - const type = getApparentTypeOfContextualType(arrayLiteral); + const type = getApparentTypeOfContextualType(arrayLiteral, omitBindingPatterns); return getContextualTypeForElementExpression(type, indexOfNode(arrayLiteral.elements, node)); } case SyntaxKind.ConditionalExpression: - return getContextualTypeForConditionalOperand(node); + return getContextualTypeForConditionalOperand(node, omitBindingPatterns); case SyntaxKind.TemplateSpan: Debug.assert(parent.parent.kind === SyntaxKind.TemplateExpression); return getContextualTypeForSubstitutionExpression(parent.parent, node); case SyntaxKind.ParenthesizedExpression: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. const tag = isInJavaScriptFile(parent) ? getJSDocTypeTag(parent) : undefined; - return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); + return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, omitBindingPatterns); } case SyntaxKind.JsxExpression: - return getContextualTypeForJsxExpression(parent); + return getContextualTypeForJsxExpression(parent, omitBindingPatterns); case SyntaxKind.JsxAttribute: case SyntaxKind.JsxSpreadAttribute: - return getContextualTypeForJsxAttribute(parent); + return getContextualTypeForJsxAttribute(parent, omitBindingPatterns); case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxSelfClosingElement: return getAttributesTypeFromJsxOpeningLikeElement(parent); @@ -14502,17 +14502,17 @@ namespace ts { return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction; } - function getContextualSignatureForFunctionLikeDeclaration(node: FunctionLikeDeclaration): Signature { + function getContextualSignatureForFunctionLikeDeclaration(node: FunctionLikeDeclaration, omitBindingPatterns?: boolean): Signature { // Only function expressions, arrow functions, and object literal methods are contextually typed. return isFunctionExpressionOrArrowFunction(node) || isObjectLiteralMethod(node) - ? getContextualSignature(node) + ? getContextualSignature(node, omitBindingPatterns) : undefined; } - function getContextualTypeForFunctionLikeDeclaration(node: FunctionExpression | ArrowFunction | MethodDeclaration) { + function getContextualTypeForFunctionLikeDeclaration(node: FunctionExpression | ArrowFunction | MethodDeclaration, omitBindingPatterns?: boolean) { return isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node) : - getApparentTypeOfContextualType(node); + getContextualTypeForObjectLiteralMethod(node, omitBindingPatterns) : + getApparentTypeOfContextualType(node, omitBindingPatterns); } // Return the contextual signature for a given expression node. A contextual type provides a @@ -14520,9 +14520,9 @@ namespace ts { // If the contextual type is a union type, get the signature from each type possible and if they are // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures - function getContextualSignature(node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature { + function getContextualSignature(node: FunctionExpression | ArrowFunction | MethodDeclaration, omitBindingPatterns?: boolean): Signature { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); - const type = getContextualTypeForFunctionLikeDeclaration(node); + const type = getContextualTypeForFunctionLikeDeclaration(node, omitBindingPatterns); if (!type) { return undefined; } @@ -18226,7 +18226,7 @@ namespace ts { type = getUnionType(types, UnionReduction.Subtype); } - const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func, /*omitBindingPatterns*/ true); if (!contextualSignature) { reportErrorsFromWidening(func, type); } @@ -18251,7 +18251,7 @@ namespace ts { type = getWidenedLiteralLikeTypeForContextualType(type, contextualType); } - const widenedType = getWidenedType(type); + const widenedType = ((isFunctionExpression(func) && !func.name) || isArrowFunction(func)) && contextualSignature ? type : getWidenedType(type); switch (functionFlags & FunctionFlags.AsyncGenerator) { case FunctionFlags.AsyncGenerator: return createAsyncIterableIteratorType(widenedType); diff --git a/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.errors.txt b/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.errors.txt new file mode 100644 index 0000000000000..19d03bdc90684 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/arrowFunctionMakesStrictLiteralCheck.ts(6,17): error TS2322: Type '() => { x: number; y: number; }' is not assignable to type 'XGetter'. + Type '{ x: number; y: number; }' is not assignable to type 'X'. + Object literal may only specify known properties, and 'y' does not exist in type 'X'. + + +==== tests/cases/compiler/arrowFunctionMakesStrictLiteralCheck.ts (1 errors) ==== + interface X { x: number; } + + type XGetter = () => X; + + const getX2: XGetter = () => { + return { x: 1, y: 2 }; // Expect excess property error on `y` + ~~~~ +!!! error TS2322: Type '() => { x: number; y: number; }' is not assignable to type 'XGetter'. +!!! error TS2322: Type '{ x: number; y: number; }' is not assignable to type 'X'. +!!! error TS2322: Object literal may only specify known properties, and 'y' does not exist in type 'X'. + } \ No newline at end of file diff --git a/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.js b/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.js new file mode 100644 index 0000000000000..401ef3ca70d1f --- /dev/null +++ b/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.js @@ -0,0 +1,13 @@ +//// [arrowFunctionMakesStrictLiteralCheck.ts] +interface X { x: number; } + +type XGetter = () => X; + +const getX2: XGetter = () => { + return { x: 1, y: 2 }; // Expect excess property error on `y` +} + +//// [arrowFunctionMakesStrictLiteralCheck.js] +var getX2 = function () { + return { x: 1, y: 2 }; // Expect excess property error on `y` +}; diff --git a/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.symbols b/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.symbols new file mode 100644 index 0000000000000..02e34665a56d1 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/arrowFunctionMakesStrictLiteralCheck.ts === +interface X { x: number; } +>X : Symbol(X, Decl(arrowFunctionMakesStrictLiteralCheck.ts, 0, 0)) +>x : Symbol(X.x, Decl(arrowFunctionMakesStrictLiteralCheck.ts, 0, 13)) + +type XGetter = () => X; +>XGetter : Symbol(XGetter, Decl(arrowFunctionMakesStrictLiteralCheck.ts, 0, 26)) +>X : Symbol(X, Decl(arrowFunctionMakesStrictLiteralCheck.ts, 0, 0)) + +const getX2: XGetter = () => { +>getX2 : Symbol(getX2, Decl(arrowFunctionMakesStrictLiteralCheck.ts, 4, 5)) +>XGetter : Symbol(XGetter, Decl(arrowFunctionMakesStrictLiteralCheck.ts, 0, 26)) + + return { x: 1, y: 2 }; // Expect excess property error on `y` +>x : Symbol(x, Decl(arrowFunctionMakesStrictLiteralCheck.ts, 5, 9)) +>y : Symbol(y, Decl(arrowFunctionMakesStrictLiteralCheck.ts, 5, 15)) +} diff --git a/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.types b/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.types new file mode 100644 index 0000000000000..74c4fc82451fb --- /dev/null +++ b/tests/baselines/reference/arrowFunctionMakesStrictLiteralCheck.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/arrowFunctionMakesStrictLiteralCheck.ts === +interface X { x: number; } +>X : X +>x : number + +type XGetter = () => X; +>XGetter : XGetter +>X : X + +const getX2: XGetter = () => { +>getX2 : XGetter +>XGetter : XGetter +>() => { return { x: 1, y: 2 }; // Expect excess property error on `y`} : () => { x: number; y: number; } + + return { x: 1, y: 2 }; // Expect excess property error on `y` +>{ x: 1, y: 2 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>2 : 2 +} diff --git a/tests/baselines/reference/assignmentCompatBug2.errors.txt b/tests/baselines/reference/assignmentCompatBug2.errors.txt index 29ba96e6586d4..f77c7655585c0 100644 --- a/tests/baselines/reference/assignmentCompatBug2.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug2.errors.txt @@ -8,8 +8,8 @@ tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'. tests/cases/compiler/assignmentCompatBug2.ts(20,1): error TS2322: Type '{ f: (n: number) => number; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. Property 'g' is missing in type '{ f: (n: number) => number; m: number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. - Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }'. +tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => null; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. + Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => null; }'. ==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ==== @@ -62,8 +62,8 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: b3 = { ~~ -!!! error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. -!!! error TS2322: Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }'. +!!! error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => null; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. +!!! error TS2322: Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => null; }'. f: (n) => { return 0; }, g: (s) => { return 0; }, n: 0, diff --git a/tests/baselines/reference/assignmentCompatBug2.types b/tests/baselines/reference/assignmentCompatBug2.types index 414f91b5bdcfd..cce5a09461d64 100644 --- a/tests/baselines/reference/assignmentCompatBug2.types +++ b/tests/baselines/reference/assignmentCompatBug2.types @@ -93,9 +93,9 @@ b3 = { }; // error b3 = { ->b3 = { f: (n) => { return 0; }, g: (s) => { return 0; }, m: 0, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; m: number; n: number; k: (a: any) => any; } +>b3 = { f: (n) => { return 0; }, g: (s) => { return 0; }, m: 0, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; m: number; n: number; k: (a: any) => null; } >b3 : { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; } ->{ f: (n) => { return 0; }, g: (s) => { return 0; }, m: 0, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; m: number; n: number; k: (a: any) => any; } +>{ f: (n) => { return 0; }, g: (s) => { return 0; }, m: 0, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; m: number; n: number; k: (a: any) => null; } f: (n) => { return 0; }, >f : (n: number) => number @@ -118,17 +118,17 @@ b3 = { >0 : 0 k: (a) =>{ return null; }, ->k : (a: any) => any ->(a) =>{ return null; } : (a: any) => any +>k : (a: any) => null +>(a) =>{ return null; } : (a: any) => null >a : any >null : null }; // ok b3 = { ->b3 = { f: (n) => { return 0; }, g: (s) => { return 0; }, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; } +>b3 = { f: (n) => { return 0; }, g: (s) => { return 0; }, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => null; } >b3 : { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; } ->{ f: (n) => { return 0; }, g: (s) => { return 0; }, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; } +>{ f: (n) => { return 0; }, g: (s) => { return 0; }, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => null; } f: (n) => { return 0; }, >f : (n: number) => number @@ -147,8 +147,8 @@ b3 = { >0 : 0 k: (a) =>{ return null; }, ->k : (a: any) => any ->(a) =>{ return null; } : (a: any) => any +>k : (a: any) => null +>(a) =>{ return null; } : (a: any) => null >a : any >null : null diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.types b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.types index 28bcc4e190a11..9add680f7882d 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.types +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.types @@ -45,19 +45,19 @@ module ClassTypeParam { >() => { this.a = () => null; // ok, same T of required params this.a = (x?: T) => null; // ok, same T of required params this.a = (x: T) => null; // error, too many required params this.a2 = () => null; // ok, same T of required params this.a2 = (x?: T) => null; // ok, same T of required params this.a2 = (x: T) => null; // ok, same number of params this.a3 = () => null; // ok, fewer required params this.a3 = (x?: T) => null; // ok, fewer required params this.a3 = (x: T) => null; // ok, same T of required params this.a3 = (x: T, y: T) => null; // error, too many required params this.a4 = () => null; // ok, fewer required params this.a4 = (x?: T, y?: T) => null; // ok, fewer required params this.a4 = (x: T) => null; // ok, same T of required params this.a4 = (x: T, y: T) => null; // ok, same number of params this.a5 = () => null; // ok, fewer required params this.a5 = (x?: T, y?: T) => null; // ok, fewer required params this.a5 = (x: T) => null; // ok, all present params match this.a5 = (x: T, y: T) => null; // ok, same number of params } : () => void this.a = () => null; // ok, same T of required params ->this.a = () => null : () => any +>this.a = () => null : () => null >this.a : () => T >this : this >a : () => T ->() => null : () => any +>() => null : () => null >null : null this.a = (x?: T) => null; // ok, same T of required params ->this.a = (x?: T) => null : (x?: T) => any +>this.a = (x?: T) => null : (x?: T) => null >this.a : () => T >this : this >a : () => T ->(x?: T) => null : (x?: T) => any +>(x?: T) => null : (x?: T) => null >x : T >T : T >null : null @@ -73,57 +73,57 @@ module ClassTypeParam { >null : null this.a2 = () => null; // ok, same T of required params ->this.a2 = () => null : () => any +>this.a2 = () => null : () => null >this.a2 : (x?: T) => T >this : this >a2 : (x?: T) => T ->() => null : () => any +>() => null : () => null >null : null this.a2 = (x?: T) => null; // ok, same T of required params ->this.a2 = (x?: T) => null : (x?: T) => any +>this.a2 = (x?: T) => null : (x?: T) => null >this.a2 : (x?: T) => T >this : this >a2 : (x?: T) => T ->(x?: T) => null : (x?: T) => any +>(x?: T) => null : (x?: T) => null >x : T >T : T >null : null this.a2 = (x: T) => null; // ok, same number of params ->this.a2 = (x: T) => null : (x: T) => any +>this.a2 = (x: T) => null : (x: T) => null >this.a2 : (x?: T) => T >this : this >a2 : (x?: T) => T ->(x: T) => null : (x: T) => any +>(x: T) => null : (x: T) => null >x : T >T : T >null : null this.a3 = () => null; // ok, fewer required params ->this.a3 = () => null : () => any +>this.a3 = () => null : () => null >this.a3 : (x: T) => T >this : this >a3 : (x: T) => T ->() => null : () => any +>() => null : () => null >null : null this.a3 = (x?: T) => null; // ok, fewer required params ->this.a3 = (x?: T) => null : (x?: T) => any +>this.a3 = (x?: T) => null : (x?: T) => null >this.a3 : (x: T) => T >this : this >a3 : (x: T) => T ->(x?: T) => null : (x?: T) => any +>(x?: T) => null : (x?: T) => null >x : T >T : T >null : null this.a3 = (x: T) => null; // ok, same T of required params ->this.a3 = (x: T) => null : (x: T) => any +>this.a3 = (x: T) => null : (x: T) => null >this.a3 : (x: T) => T >this : this >a3 : (x: T) => T ->(x: T) => null : (x: T) => any +>(x: T) => null : (x: T) => null >x : T >T : T >null : null @@ -141,19 +141,19 @@ module ClassTypeParam { >null : null this.a4 = () => null; // ok, fewer required params ->this.a4 = () => null : () => any +>this.a4 = () => null : () => null >this.a4 : (x: T, y?: T) => T >this : this >a4 : (x: T, y?: T) => T ->() => null : () => any +>() => null : () => null >null : null this.a4 = (x?: T, y?: T) => null; // ok, fewer required params ->this.a4 = (x?: T, y?: T) => null : (x?: T, y?: T) => any +>this.a4 = (x?: T, y?: T) => null : (x?: T, y?: T) => null >this.a4 : (x: T, y?: T) => T >this : this >a4 : (x: T, y?: T) => T ->(x?: T, y?: T) => null : (x?: T, y?: T) => any +>(x?: T, y?: T) => null : (x?: T, y?: T) => null >x : T >T : T >y : T @@ -161,21 +161,21 @@ module ClassTypeParam { >null : null this.a4 = (x: T) => null; // ok, same T of required params ->this.a4 = (x: T) => null : (x: T) => any +>this.a4 = (x: T) => null : (x: T) => null >this.a4 : (x: T, y?: T) => T >this : this >a4 : (x: T, y?: T) => T ->(x: T) => null : (x: T) => any +>(x: T) => null : (x: T) => null >x : T >T : T >null : null this.a4 = (x: T, y: T) => null; // ok, same number of params ->this.a4 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a4 = (x: T, y: T) => null : (x: T, y: T) => null >this.a4 : (x: T, y?: T) => T >this : this >a4 : (x: T, y?: T) => T ->(x: T, y: T) => null : (x: T, y: T) => any +>(x: T, y: T) => null : (x: T, y: T) => null >x : T >T : T >y : T @@ -184,19 +184,19 @@ module ClassTypeParam { this.a5 = () => null; // ok, fewer required params ->this.a5 = () => null : () => any +>this.a5 = () => null : () => null >this.a5 : (x?: T, y?: T) => T >this : this >a5 : (x?: T, y?: T) => T ->() => null : () => any +>() => null : () => null >null : null this.a5 = (x?: T, y?: T) => null; // ok, fewer required params ->this.a5 = (x?: T, y?: T) => null : (x?: T, y?: T) => any +>this.a5 = (x?: T, y?: T) => null : (x?: T, y?: T) => null >this.a5 : (x?: T, y?: T) => T >this : this >a5 : (x?: T, y?: T) => T ->(x?: T, y?: T) => null : (x?: T, y?: T) => any +>(x?: T, y?: T) => null : (x?: T, y?: T) => null >x : T >T : T >y : T @@ -204,21 +204,21 @@ module ClassTypeParam { >null : null this.a5 = (x: T) => null; // ok, all present params match ->this.a5 = (x: T) => null : (x: T) => any +>this.a5 = (x: T) => null : (x: T) => null >this.a5 : (x?: T, y?: T) => T >this : this >a5 : (x?: T, y?: T) => T ->(x: T) => null : (x: T) => any +>(x: T) => null : (x: T) => null >x : T >T : T >null : null this.a5 = (x: T, y: T) => null; // ok, same number of params ->this.a5 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a5 = (x: T, y: T) => null : (x: T, y: T) => null >this.a5 : (x?: T, y?: T) => T >this : this >a5 : (x?: T, y?: T) => T ->(x: T, y: T) => null : (x: T, y: T) => any +>(x: T, y: T) => null : (x: T, y: T) => null >x : T >T : T >y : T @@ -599,20 +599,20 @@ module GenericSignaturesValid { >() => { this.a = () => null; // ok, same T of required params this.a = (x?: T) => null; // ok, same T of required params this.a = (x: T) => null; // error, too many required params this.a2 = () => null; // ok, same T of required params this.a2 = (x?: T) => null; // ok, same T of required params this.a2 = (x: T) => null; // ok, same number of params this.a3 = () => null; // ok, fewer required params this.a3 = (x?: T) => null; // ok, fewer required params this.a3 = (x: T) => null; // ok, same T of required params this.a3 = (x: T, y: T) => null; // error, too many required params this.a4 = () => null; // ok, fewer required params this.a4 = (x?: T, y?: T) => null; // ok, fewer required params this.a4 = (x: T) => null; // ok, same T of required params this.a4 = (x: T, y: T) => null; // ok, same number of params this.a5 = () => null; // ok, fewer required params this.a5 = (x?: T, y?: T) => null; // ok, fewer required params this.a5 = (x: T) => null; // ok, all present params match this.a5 = (x: T, y: T) => null; // ok, same number of params } : () => void this.a = () => null; // ok, same T of required params ->this.a = () => null : () => any +>this.a = () => null : () => null >this.a : () => T >this : this >a : () => T ->() => null : () => any +>() => null : () => null >T : T >null : null this.a = (x?: T) => null; // ok, same T of required params ->this.a = (x?: T) => null : (x?: T) => any +>this.a = (x?: T) => null : (x?: T) => null >this.a : () => T >this : this >a : () => T ->(x?: T) => null : (x?: T) => any +>(x?: T) => null : (x?: T) => null >T : T >x : T >T : T @@ -630,62 +630,62 @@ module GenericSignaturesValid { >null : null this.a2 = () => null; // ok, same T of required params ->this.a2 = () => null : () => any +>this.a2 = () => null : () => null >this.a2 : (x?: T) => T >this : this >a2 : (x?: T) => T ->() => null : () => any +>() => null : () => null >T : T >null : null this.a2 = (x?: T) => null; // ok, same T of required params ->this.a2 = (x?: T) => null : (x?: T) => any +>this.a2 = (x?: T) => null : (x?: T) => null >this.a2 : (x?: T) => T >this : this >a2 : (x?: T) => T ->(x?: T) => null : (x?: T) => any +>(x?: T) => null : (x?: T) => null >T : T >x : T >T : T >null : null this.a2 = (x: T) => null; // ok, same number of params ->this.a2 = (x: T) => null : (x: T) => any +>this.a2 = (x: T) => null : (x: T) => null >this.a2 : (x?: T) => T >this : this >a2 : (x?: T) => T ->(x: T) => null : (x: T) => any +>(x: T) => null : (x: T) => null >T : T >x : T >T : T >null : null this.a3 = () => null; // ok, fewer required params ->this.a3 = () => null : () => any +>this.a3 = () => null : () => null >this.a3 : (x: T) => T >this : this >a3 : (x: T) => T ->() => null : () => any +>() => null : () => null >T : T >null : null this.a3 = (x?: T) => null; // ok, fewer required params ->this.a3 = (x?: T) => null : (x?: T) => any +>this.a3 = (x?: T) => null : (x?: T) => null >this.a3 : (x: T) => T >this : this >a3 : (x: T) => T ->(x?: T) => null : (x?: T) => any +>(x?: T) => null : (x?: T) => null >T : T >x : T >T : T >null : null this.a3 = (x: T) => null; // ok, same T of required params ->this.a3 = (x: T) => null : (x: T) => any +>this.a3 = (x: T) => null : (x: T) => null >this.a3 : (x: T) => T >this : this >a3 : (x: T) => T ->(x: T) => null : (x: T) => any +>(x: T) => null : (x: T) => null >T : T >x : T >T : T @@ -705,20 +705,20 @@ module GenericSignaturesValid { >null : null this.a4 = () => null; // ok, fewer required params ->this.a4 = () => null : () => any +>this.a4 = () => null : () => null >this.a4 : (x: T, y?: T) => T >this : this >a4 : (x: T, y?: T) => T ->() => null : () => any +>() => null : () => null >T : T >null : null this.a4 = (x?: T, y?: T) => null; // ok, fewer required params ->this.a4 = (x?: T, y?: T) => null : (x?: T, y?: T) => any +>this.a4 = (x?: T, y?: T) => null : (x?: T, y?: T) => null >this.a4 : (x: T, y?: T) => T >this : this >a4 : (x: T, y?: T) => T ->(x?: T, y?: T) => null : (x?: T, y?: T) => any +>(x?: T, y?: T) => null : (x?: T, y?: T) => null >T : T >x : T >T : T @@ -727,22 +727,22 @@ module GenericSignaturesValid { >null : null this.a4 = (x: T) => null; // ok, same T of required params ->this.a4 = (x: T) => null : (x: T) => any +>this.a4 = (x: T) => null : (x: T) => null >this.a4 : (x: T, y?: T) => T >this : this >a4 : (x: T, y?: T) => T ->(x: T) => null : (x: T) => any +>(x: T) => null : (x: T) => null >T : T >x : T >T : T >null : null this.a4 = (x: T, y: T) => null; // ok, same number of params ->this.a4 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a4 = (x: T, y: T) => null : (x: T, y: T) => null >this.a4 : (x: T, y?: T) => T >this : this >a4 : (x: T, y?: T) => T ->(x: T, y: T) => null : (x: T, y: T) => any +>(x: T, y: T) => null : (x: T, y: T) => null >T : T >x : T >T : T @@ -752,20 +752,20 @@ module GenericSignaturesValid { this.a5 = () => null; // ok, fewer required params ->this.a5 = () => null : () => any +>this.a5 = () => null : () => null >this.a5 : (x?: T, y?: T) => T >this : this >a5 : (x?: T, y?: T) => T ->() => null : () => any +>() => null : () => null >T : T >null : null this.a5 = (x?: T, y?: T) => null; // ok, fewer required params ->this.a5 = (x?: T, y?: T) => null : (x?: T, y?: T) => any +>this.a5 = (x?: T, y?: T) => null : (x?: T, y?: T) => null >this.a5 : (x?: T, y?: T) => T >this : this >a5 : (x?: T, y?: T) => T ->(x?: T, y?: T) => null : (x?: T, y?: T) => any +>(x?: T, y?: T) => null : (x?: T, y?: T) => null >T : T >x : T >T : T @@ -774,22 +774,22 @@ module GenericSignaturesValid { >null : null this.a5 = (x: T) => null; // ok, all present params match ->this.a5 = (x: T) => null : (x: T) => any +>this.a5 = (x: T) => null : (x: T) => null >this.a5 : (x?: T, y?: T) => T >this : this >a5 : (x?: T, y?: T) => T ->(x: T) => null : (x: T) => any +>(x: T) => null : (x: T) => null >T : T >x : T >T : T >null : null this.a5 = (x: T, y: T) => null; // ok, same number of params ->this.a5 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a5 = (x: T, y: T) => null : (x: T, y: T) => null >this.a5 : (x?: T, y?: T) => T >this : this >a5 : (x?: T, y?: T) => T ->(x: T, y: T) => null : (x: T, y: T) => any +>(x: T, y: T) => null : (x: T, y: T) => null >T : T >x : T >T : T diff --git a/tests/baselines/reference/contextualTypeArrayReturnType.types b/tests/baselines/reference/contextualTypeArrayReturnType.types index 6c91fd7b8b964..7d6becfecfd8d 100644 --- a/tests/baselines/reference/contextualTypeArrayReturnType.types +++ b/tests/baselines/reference/contextualTypeArrayReturnType.types @@ -26,11 +26,11 @@ interface Transform3D { var style: IBookStyle = { >style : IBookStyle >IBookStyle : IBookStyle ->{ initialLeftPageTransforms: (width: number) => { return [ {'ry': null } ]; }} : { initialLeftPageTransforms: (width: number) => { 'ry': any; }[]; } +>{ initialLeftPageTransforms: (width: number) => { return [ {'ry': null } ]; }} : { initialLeftPageTransforms: (width: number) => { 'ry': null; }[]; } initialLeftPageTransforms: (width: number) => { ->initialLeftPageTransforms : (width: number) => { 'ry': any; }[] ->(width: number) => { return [ {'ry': null } ]; } : (width: number) => { 'ry': any; }[] +>initialLeftPageTransforms : (width: number) => { 'ry': null; }[] +>(width: number) => { return [ {'ry': null } ]; } : (width: number) => { 'ry': null; }[] >width : number return [ diff --git a/tests/baselines/reference/destructuringNoFreshLiteralLeak.js b/tests/baselines/reference/destructuringNoFreshLiteralLeak.js new file mode 100644 index 0000000000000..e0b7664bbeb09 --- /dev/null +++ b/tests/baselines/reference/destructuringNoFreshLiteralLeak.js @@ -0,0 +1,9 @@ +//// [destructuringNoFreshLiteralLeak.ts] +const { x = () => ({a: 12}) } = { x: () => ({a: 24, b: 12}) }; +declare function f(x: {a: number}): void; +f(x()); + + +//// [destructuringNoFreshLiteralLeak.js] +var _a = { x: function () { return ({ a: 24, b: 12 }); } }.x, x = _a === void 0 ? function () { return ({ a: 12 }); } : _a; +f(x()); diff --git a/tests/baselines/reference/destructuringNoFreshLiteralLeak.symbols b/tests/baselines/reference/destructuringNoFreshLiteralLeak.symbols new file mode 100644 index 0000000000000..5f05d0c2023e5 --- /dev/null +++ b/tests/baselines/reference/destructuringNoFreshLiteralLeak.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/destructuringNoFreshLiteralLeak.ts === +const { x = () => ({a: 12}) } = { x: () => ({a: 24, b: 12}) }; +>x : Symbol(x, Decl(destructuringNoFreshLiteralLeak.ts, 0, 7)) +>a : Symbol(a, Decl(destructuringNoFreshLiteralLeak.ts, 0, 20)) +>x : Symbol(x, Decl(destructuringNoFreshLiteralLeak.ts, 0, 33)) +>a : Symbol(a, Decl(destructuringNoFreshLiteralLeak.ts, 0, 45)) +>b : Symbol(b, Decl(destructuringNoFreshLiteralLeak.ts, 0, 51)) + +declare function f(x: {a: number}): void; +>f : Symbol(f, Decl(destructuringNoFreshLiteralLeak.ts, 0, 62)) +>x : Symbol(x, Decl(destructuringNoFreshLiteralLeak.ts, 1, 19)) +>a : Symbol(a, Decl(destructuringNoFreshLiteralLeak.ts, 1, 23)) + +f(x()); +>f : Symbol(f, Decl(destructuringNoFreshLiteralLeak.ts, 0, 62)) +>x : Symbol(x, Decl(destructuringNoFreshLiteralLeak.ts, 0, 7)) + diff --git a/tests/baselines/reference/destructuringNoFreshLiteralLeak.types b/tests/baselines/reference/destructuringNoFreshLiteralLeak.types new file mode 100644 index 0000000000000..8dc124e01e069 --- /dev/null +++ b/tests/baselines/reference/destructuringNoFreshLiteralLeak.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/destructuringNoFreshLiteralLeak.ts === +const { x = () => ({a: 12}) } = { x: () => ({a: 24, b: 12}) }; +>x : () => { a: number; } +>() => ({a: 12}) : () => { a: number; } +>({a: 12}) : { a: number; } +>{a: 12} : { a: number; } +>a : number +>12 : 12 +>{ x: () => ({a: 24, b: 12}) } : { x?: () => { a: number; b: number; }; } +>x : () => { a: number; b: number; } +>() => ({a: 24, b: 12}) : () => { a: number; b: number; } +>({a: 24, b: 12}) : { a: number; b: number; } +>{a: 24, b: 12} : { a: number; b: number; } +>a : number +>24 : 24 +>b : number +>12 : 12 + +declare function f(x: {a: number}): void; +>f : (x: { a: number; }) => void +>x : { a: number; } +>a : number + +f(x()); +>f(x()) : void +>f : (x: { a: number; }) => void +>x() : { a: number; } +>x : () => { a: number; } + diff --git a/tests/baselines/reference/fixingTypeParametersRepeatedly1.symbols b/tests/baselines/reference/fixingTypeParametersRepeatedly1.symbols index 3d0c33ebfc04c..86f91c826633c 100644 --- a/tests/baselines/reference/fixingTypeParametersRepeatedly1.symbols +++ b/tests/baselines/reference/fixingTypeParametersRepeatedly1.symbols @@ -45,5 +45,7 @@ g("", x => null, x => x.toLowerCase()); >g : Symbol(g, Decl(fixingTypeParametersRepeatedly1.ts, 1, 39), Decl(fixingTypeParametersRepeatedly1.ts, 4, 63)) >x : Symbol(x, Decl(fixingTypeParametersRepeatedly1.ts, 6, 5)) >x : Symbol(x, Decl(fixingTypeParametersRepeatedly1.ts, 6, 16)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(fixingTypeParametersRepeatedly1.ts, 6, 16)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/fixingTypeParametersRepeatedly1.types b/tests/baselines/reference/fixingTypeParametersRepeatedly1.types index d7326a515f515..986fead41ee8f 100644 --- a/tests/baselines/reference/fixingTypeParametersRepeatedly1.types +++ b/tests/baselines/reference/fixingTypeParametersRepeatedly1.types @@ -18,7 +18,7 @@ f("", x => null, x => x.toLowerCase()); >f("", x => null, x => x.toLowerCase()) : string >f : (x: T, y: (p: T) => T, z: (p: T) => T) => T >"" : "" ->x => null : (x: string) => any +>x => null : (x: string) => null >x : string >null : null >x => x.toLowerCase() : (x: string) => string @@ -48,16 +48,16 @@ declare function g(); >g : { (x: T, y: (p: T) => T, z: (p: T) => T): T; (): any; } g("", x => null, x => x.toLowerCase()); ->g("", x => null, x => x.toLowerCase()) : any +>g("", x => null, x => x.toLowerCase()) : string >g : { (x: T, y: (p: T) => T, z: (p: T) => T): T; (): any; } >"" : "" ->x => null : (x: string) => any +>x => null : (x: string) => null >x : string >null : null ->x => x.toLowerCase() : (x: any) => any ->x : any ->x.toLowerCase() : any ->x.toLowerCase : any ->x : any ->toLowerCase : any +>x => x.toLowerCase() : (x: string) => string +>x : string +>x.toLowerCase() : string +>x.toLowerCase : () => string +>x : string +>toLowerCase : () => string diff --git a/tests/baselines/reference/functionExpressionReturnTypeNotFresh.js b/tests/baselines/reference/functionExpressionReturnTypeNotFresh.js new file mode 100644 index 0000000000000..37b3d1e9adf1e --- /dev/null +++ b/tests/baselines/reference/functionExpressionReturnTypeNotFresh.js @@ -0,0 +1,16 @@ +//// [functionExpressionReturnTypeNotFresh.ts] +const a = () => ({ + a: 12, + b: 11 +}); + +declare function f(arg: {a: number}): void; +f(a()); + +//// [functionExpressionReturnTypeNotFresh.js] +"use strict"; +var a = function () { return ({ + a: 12, + b: 11 +}); }; +f(a()); diff --git a/tests/baselines/reference/functionExpressionReturnTypeNotFresh.symbols b/tests/baselines/reference/functionExpressionReturnTypeNotFresh.symbols new file mode 100644 index 0000000000000..0f3c9a5abd33c --- /dev/null +++ b/tests/baselines/reference/functionExpressionReturnTypeNotFresh.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/functionExpressionReturnTypeNotFresh.ts === +const a = () => ({ +>a : Symbol(a, Decl(functionExpressionReturnTypeNotFresh.ts, 0, 5)) + + a: 12, +>a : Symbol(a, Decl(functionExpressionReturnTypeNotFresh.ts, 0, 18)) + + b: 11 +>b : Symbol(b, Decl(functionExpressionReturnTypeNotFresh.ts, 1, 10)) + +}); + +declare function f(arg: {a: number}): void; +>f : Symbol(f, Decl(functionExpressionReturnTypeNotFresh.ts, 3, 3)) +>arg : Symbol(arg, Decl(functionExpressionReturnTypeNotFresh.ts, 5, 19)) +>a : Symbol(a, Decl(functionExpressionReturnTypeNotFresh.ts, 5, 25)) + +f(a()); +>f : Symbol(f, Decl(functionExpressionReturnTypeNotFresh.ts, 3, 3)) +>a : Symbol(a, Decl(functionExpressionReturnTypeNotFresh.ts, 0, 5)) + diff --git a/tests/baselines/reference/functionExpressionReturnTypeNotFresh.types b/tests/baselines/reference/functionExpressionReturnTypeNotFresh.types new file mode 100644 index 0000000000000..f5fc539bffd66 --- /dev/null +++ b/tests/baselines/reference/functionExpressionReturnTypeNotFresh.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/functionExpressionReturnTypeNotFresh.ts === +const a = () => ({ +>a : () => { a: number; b: number; } +>() => ({ a: 12, b: 11}) : () => { a: number; b: number; } +>({ a: 12, b: 11}) : { a: number; b: number; } +>{ a: 12, b: 11} : { a: number; b: number; } + + a: 12, +>a : number +>12 : 12 + + b: 11 +>b : number +>11 : 11 + +}); + +declare function f(arg: {a: number}): void; +>f : (arg: { a: number; }) => void +>arg : { a: number; } +>a : number + +f(a()); +>f(a()) : void +>f : (arg: { a: number; }) => void +>a() : { a: number; b: number; } +>a : () => { a: number; b: number; } + diff --git a/tests/baselines/reference/functionTypeArgumentAssignmentCompat.types b/tests/baselines/reference/functionTypeArgumentAssignmentCompat.types index 2d072d6ec2434..b29f912f21027 100644 --- a/tests/baselines/reference/functionTypeArgumentAssignmentCompat.types +++ b/tests/baselines/reference/functionTypeArgumentAssignmentCompat.types @@ -17,7 +17,7 @@ var g : { >S : S } = () => []; ->() => [] : () => any[] +>() => [] : () => undefined[] >[] : undefined[] f = g; diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index d2eed9255913d..7fa9ee4d65b3c 100644 --- a/tests/baselines/reference/generatedContextualTyping.types +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -118,7 +118,7 @@ var x11: (s: Base[]) => any = n => { var n: Base[]; return null; }; >x11 : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -234,7 +234,7 @@ class x23 { member: (s: Base[]) => any = n => { var n: Base[]; return null; } } >member : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -351,7 +351,7 @@ class x35 { private member: (s: Base[]) => any = n => { var n: Base[]; return nu >member : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -468,7 +468,7 @@ class x47 { public member: (s: Base[]) => any = n => { var n: Base[]; return nul >member : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -585,7 +585,7 @@ class x59 { static member: (s: Base[]) => any = n => { var n: Base[]; return nul >member : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -702,7 +702,7 @@ class x71 { private static member: (s: Base[]) => any = n => { var n: Base[]; re >member : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -819,7 +819,7 @@ class x83 { public static member: (s: Base[]) => any = n => { var n: Base[]; ret >member : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -936,7 +936,7 @@ class x95 { constructor(parm: (s: Base[]) => any = n => { var n: Base[]; return >parm : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -1053,7 +1053,7 @@ class x107 { constructor(public parm: (s: Base[]) => any = n => { var n: Base[]; >parm : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -1170,7 +1170,7 @@ class x119 { constructor(private parm: (s: Base[]) => any = n => { var n: Base[] >parm : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -1287,7 +1287,7 @@ function x131(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { >parm : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -1393,7 +1393,7 @@ function x143(): (s: Base[]) => any { return n => { var n: Base[]; return null; >x143 : () => (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -1538,12 +1538,12 @@ function x155(): (s: Base[]) => any { return n => { var n: Base[]; return null; >x155 : () => (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base >null : null ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -1665,8 +1665,8 @@ var x167: () => (s: Base[]) => any = () => { return n => { var n: Base[]; return >x167 : () => (s: Base[]) => any >s : Base[] >Base : Base ->() => { return n => { var n: Base[]; return null; }; } : () => (n: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>() => { return n => { var n: Base[]; return null; }; } : () => (n: Base[]) => null +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -1782,8 +1782,8 @@ var x179: () => (s: Base[]) => any = function() { return n => { var n: Base[]; r >x179 : () => (s: Base[]) => any >s : Base[] >Base : Base ->function() { return n => { var n: Base[]; return null; }; } : () => (n: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>function() { return n => { var n: Base[]; return null; }; } : () => (n: Base[]) => null +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -1900,7 +1900,7 @@ module x191 { var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; >t : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -2017,7 +2017,7 @@ module x203 { export var t: (s: Base[]) => any = n => { var n: Base[]; return nu >t : (s: Base[]) => any >s : Base[] >Base : Base ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -2330,9 +2330,9 @@ var x235: (s: Base[]) => any; x235 = n => { var n: Base[]; return null; }; >x235 : (s: Base[]) => any >s : Base[] >Base : Base ->x235 = n => { var n: Base[]; return null; } : (n: Base[]) => any +>x235 = n => { var n: Base[]; return null; } : (n: Base[]) => null >x235 : (s: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -2470,9 +2470,9 @@ var x247: { n: (s: Base[]) => any; } = { n: n => { var n: Base[]; return null; } >n : (s: Base[]) => any >s : Base[] >Base : Base ->{ n: n => { var n: Base[]; return null; } } : { n: (n: Base[]) => any; } ->n : (n: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>{ n: n => { var n: Base[]; return null; } } : { n: (n: Base[]) => null; } +>n : (n: Base[]) => null +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -2991,14 +2991,14 @@ var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n = >x295 : (s: Base[]) => any >s : Base[] >Base : Base ->true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; } : (n: Base[]) => any +>true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; } : (n: Base[]) => null >true : true ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base >null : null ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -3142,10 +3142,10 @@ var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return n >x307 : (s: Base[]) => any >s : Base[] >Base : Base ->true ? undefined : n => { var n: Base[]; return null; } : (n: Base[]) => any +>true ? undefined : n => { var n: Base[]; return null; } : (n: Base[]) => null >true : true >undefined : undefined ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -3283,9 +3283,9 @@ var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : und >x319 : (s: Base[]) => any >s : Base[] >Base : Base ->true ? n => { var n: Base[]; return null; } : undefined : (n: Base[]) => any +>true ? n => { var n: Base[]; return null; } : undefined : (n: Base[]) => null >true : true ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -3427,7 +3427,7 @@ function x331(n: (s: Base[]) => any) { }; x331(n => { var n: Base[]; return null >Base : Base >x331(n => { var n: Base[]; return null; }) : void >x331 : (n: (s: Base[]) => any) => void ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -3590,7 +3590,7 @@ var x343 = (n: (s: Base[]) => any) => n; x343(n => { var n: Base[]; return null; >n : (s: Base[]) => any >x343(n => { var n: Base[]; return null; }) : (s: Base[]) => any >x343 : (n: (s: Base[]) => any) => (s: Base[]) => any ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base @@ -3744,7 +3744,7 @@ var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; retur >Base : Base >x355(n => { var n: Base[]; return null; }) : void >x355 : (n: (s: Base[]) => any) => void ->n => { var n: Base[]; return null; } : (n: Base[]) => any +>n => { var n: Base[]; return null; } : (n: Base[]) => null >n : Base[] >n : Base[] >Base : Base diff --git a/tests/baselines/reference/generatorTypeCheck45.types b/tests/baselines/reference/generatorTypeCheck45.types index 96895acde0fad..b1e06de7ba90c 100644 --- a/tests/baselines/reference/generatorTypeCheck45.types +++ b/tests/baselines/reference/generatorTypeCheck45.types @@ -27,7 +27,7 @@ foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, sh >x.length : number >x : string >length : number ->p => undefined : (p: number) => any +>p => undefined : (p: number) => undefined >p : number >undefined : undefined diff --git a/tests/baselines/reference/generatorTypeCheck46.types b/tests/baselines/reference/generatorTypeCheck46.types index c69ae0881dae6..5d09ef30030fe 100644 --- a/tests/baselines/reference/generatorTypeCheck46.types +++ b/tests/baselines/reference/generatorTypeCheck46.types @@ -41,7 +41,7 @@ foo("", function* () { } } }, p => undefined); // T is fixed, should be string ->p => undefined : (p: number) => any +>p => undefined : (p: number) => undefined >p : number >undefined : undefined diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments.types b/tests/baselines/reference/genericCallWithGenericSignatureArguments.types index a9301c526c043..56a8f577984f2 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments.types +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments.types @@ -37,10 +37,10 @@ var r1b = foo((x) => 1, (x) => ''); // {} => {} >'' : "" var r2 = foo((x: Object) => null, (x: string) => ''); // Object => Object ->r2 : (x: any) => any ->foo((x: Object) => null, (x: string) => '') : (x: any) => any +>r2 : (x: Object) => Object +>foo((x: Object) => null, (x: string) => '') : (x: Object) => Object >foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T ->(x: Object) => null : (x: Object) => any +>(x: Object) => null : (x: Object) => null >x : Object >Object : Object >null : null @@ -49,13 +49,13 @@ var r2 = foo((x: Object) => null, (x: string) => ''); // Object => Object >'' : "" var r3 = foo((x: number) => 1, (x: Object) => null); // number => number ->r3 : (x: any) => any ->foo((x: number) => 1, (x: Object) => null) : (x: any) => any +>r3 : (x: Object) => Object +>foo((x: number) => 1, (x: Object) => null) : (x: Object) => Object >foo : (a: (x: T) => T, b: (x: T) => T) => (x: T) => T >(x: number) => 1 : (x: number) => number >x : number >1 : 1 ->(x: Object) => null : (x: Object) => any +>(x: Object) => null : (x: Object) => null >x : Object >Object : Object >null : null diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types index dea27781ac84f..352a1d0c2d59e 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types @@ -27,14 +27,14 @@ function foo(x: T, a: (x: T) => T, b: (x: T) => T) { } var r1 = foo('', (x: string) => '', (x: Object) => null); // any => any ->r1 : (x: any) => any ->foo('', (x: string) => '', (x: Object) => null) : (x: any) => any +>r1 : (x: Object) => Object +>foo('', (x: string) => '', (x: Object) => null) : (x: Object) => Object >foo : (x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T >'' : "" >(x: string) => '' : (x: string) => string >x : string >'' : "" ->(x: Object) => null : (x: Object) => any +>(x: Object) => null : (x: Object) => null >x : Object >Object : Object >null : null @@ -47,7 +47,7 @@ var r1ii = foo('', (x) => '', (x) => null); // string => string >(x) => '' : (x: string) => string >x : string >'' : "" ->(x) => null : (x: string) => any +>(x) => null : (x: string) => null >x : string >null : null @@ -156,14 +156,14 @@ function foo2(x: T, a: (x: T) => U, b: (x: T) => U) { } var r8 = foo2('', (x) => '', (x) => null); // string => string ->r8 : (x: string) => any ->foo2('', (x) => '', (x) => null) : (x: string) => any +>r8 : (x: string) => string +>foo2('', (x) => '', (x) => null) : (x: string) => string >foo2 : (x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U >'' : "" >(x) => '' : (x: string) => string >x : string >'' : "" ->(x) => null : (x: string) => any +>(x) => null : (x: string) => null >x : string >null : null diff --git a/tests/baselines/reference/genericTypeAssertions3.types b/tests/baselines/reference/genericTypeAssertions3.types index 2c1eb6b793b30..3ebb46d27afa2 100644 --- a/tests/baselines/reference/genericTypeAssertions3.types +++ b/tests/baselines/reference/genericTypeAssertions3.types @@ -6,8 +6,8 @@ var r = < (x: T) => T > ((x) => { return null; }); // bug was 'could not find >x : T >T : T >T : T ->((x) => { return null; }) : (x: T) => any ->(x) => { return null; } : (x: T) => any +>((x) => { return null; }) : (x: T) => null +>(x) => { return null; } : (x: T) => null >x : T >null : null @@ -18,8 +18,8 @@ var s = < (x: T) => T > ((x: any) => { return null; }); // no error >x : T >T : T >T : T ->((x: any) => { return null; }) : (x: any) => any ->(x: any) => { return null; } : (x: any) => any +>((x: any) => { return null; }) : (x: any) => null +>(x: any) => { return null; } : (x: any) => null >x : any >null : null diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.types b/tests/baselines/reference/moduleAugmentationImportsAndExports1.types index 5ab340b3aed9a..9640949070c2f 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports1.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.types @@ -18,13 +18,13 @@ import {B} from "./f2"; >B : typeof B A.prototype.foo = function () { return undefined; } ->A.prototype.foo = function () { return undefined; } : () => any +>A.prototype.foo = function () { return undefined; } : () => undefined >A.prototype.foo : () => B >A.prototype : A >A : typeof A >prototype : A >foo : () => B ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined declare module "./f1" { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.types b/tests/baselines/reference/moduleAugmentationImportsAndExports3.types index 894b6c603623f..b5c9f5349899f 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.types @@ -15,13 +15,13 @@ import {A} from "./f1"; >A : typeof A A.prototype.foo = function () { return undefined; } ->A.prototype.foo = function () { return undefined; } : () => any +>A.prototype.foo = function () { return undefined; } : () => undefined >A.prototype.foo : () => any >A.prototype : A >A : typeof A >prototype : A >foo : () => any ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined namespace N { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports4.types b/tests/baselines/reference/moduleAugmentationImportsAndExports4.types index 1dc7a9da1e853..d06b067e11a00 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports4.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports4.types @@ -18,13 +18,13 @@ import {B} from "./f2"; >B : typeof B A.prototype.foo = function () { return undefined; } ->A.prototype.foo = function () { return undefined; } : () => any +>A.prototype.foo = function () { return undefined; } : () => undefined >A.prototype.foo : () => B >A.prototype : A >A : typeof A >prototype : A >foo : () => B ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined namespace N { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.types b/tests/baselines/reference/moduleAugmentationImportsAndExports5.types index 1dc7a9da1e853..d06b067e11a00 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.types @@ -18,13 +18,13 @@ import {B} from "./f2"; >B : typeof B A.prototype.foo = function () { return undefined; } ->A.prototype.foo = function () { return undefined; } : () => any +>A.prototype.foo = function () { return undefined; } : () => undefined >A.prototype.foo : () => B >A.prototype : A >A : typeof A >prototype : A >foo : () => B ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined namespace N { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.types b/tests/baselines/reference/moduleAugmentationImportsAndExports6.types index 544514d2855a3..2d89dd31d1fb1 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports6.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.types @@ -18,13 +18,13 @@ import {B} from "./f2"; >B : typeof B A.prototype.foo = function () { return undefined; } ->A.prototype.foo = function () { return undefined; } : () => any +>A.prototype.foo = function () { return undefined; } : () => undefined >A.prototype.foo : () => B >A.prototype : A >A : typeof A >prototype : A >foo : () => B ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined export namespace N { diff --git a/tests/baselines/reference/moduleAugmentationsImports1.types b/tests/baselines/reference/moduleAugmentationsImports1.types index e708b574aaf03..14066abe41a64 100644 --- a/tests/baselines/reference/moduleAugmentationsImports1.types +++ b/tests/baselines/reference/moduleAugmentationsImports1.types @@ -27,23 +27,23 @@ import {Cls} from "C"; >Cls : typeof Cls A.prototype.getB = function () { return undefined; } ->A.prototype.getB = function () { return undefined; } : () => any +>A.prototype.getB = function () { return undefined; } : () => undefined >A.prototype.getB : () => B >A.prototype : A >A : typeof A >prototype : A >getB : () => B ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined A.prototype.getCls = function () { return undefined; } ->A.prototype.getCls = function () { return undefined; } : () => any +>A.prototype.getCls = function () { return undefined; } : () => undefined >A.prototype.getCls : () => Cls >A.prototype : A >A : typeof A >prototype : A >getCls : () => Cls ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined declare module "./a" { diff --git a/tests/baselines/reference/moduleAugmentationsImports2.types b/tests/baselines/reference/moduleAugmentationsImports2.types index 70d7e8a76001c..e2f3b225e83f3 100644 --- a/tests/baselines/reference/moduleAugmentationsImports2.types +++ b/tests/baselines/reference/moduleAugmentationsImports2.types @@ -24,13 +24,13 @@ import {B} from "./b"; >B : typeof B A.prototype.getB = function () { return undefined; } ->A.prototype.getB = function () { return undefined; } : () => any +>A.prototype.getB = function () { return undefined; } : () => undefined >A.prototype.getB : () => B >A.prototype : A >A : typeof A >prototype : A >getB : () => B ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined declare module "./a" { @@ -51,13 +51,13 @@ import {Cls} from "C"; >Cls : typeof Cls A.prototype.getCls = function () { return undefined; } ->A.prototype.getCls = function () { return undefined; } : () => any +>A.prototype.getCls = function () { return undefined; } : () => undefined >A.prototype.getCls : () => Cls >A.prototype : A >A : typeof A >prototype : A >getCls : () => Cls ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined declare module "./a" { diff --git a/tests/baselines/reference/moduleAugmentationsImports3.types b/tests/baselines/reference/moduleAugmentationsImports3.types index 030d2af80da2c..ddbbae3baff5d 100644 --- a/tests/baselines/reference/moduleAugmentationsImports3.types +++ b/tests/baselines/reference/moduleAugmentationsImports3.types @@ -78,13 +78,13 @@ import {Cls} from "C"; >Cls : typeof Cls A.prototype.getCls = function () { return undefined; } ->A.prototype.getCls = function () { return undefined; } : () => any +>A.prototype.getCls = function () { return undefined; } : () => undefined >A.prototype.getCls : () => Cls >A.prototype : A >A : typeof A >prototype : A >getCls : () => Cls ->function () { return undefined; } : () => any +>function () { return undefined; } : () => undefined >undefined : undefined declare module "./a" { diff --git a/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.types b/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.types index 18b61aaf8e33b..6e8219b345c4e 100644 --- a/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.types +++ b/tests/baselines/reference/noImplicitAnyFunctionExpressionAssignment.types @@ -2,7 +2,7 @@ var x: (a: any) => void = function (x: T) { >x : (a: any) => void >a : any ->function (x: T) { return null;} : (x: T) => any +>function (x: T) { return null;} : (x: T) => null >T : T >x : T >T : T diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.types b/tests/baselines/reference/parenthesizedContexualTyping1.types index d8272718cadca..8309f051f7899 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping1.types +++ b/tests/baselines/reference/parenthesizedContexualTyping1.types @@ -145,11 +145,11 @@ var h = fun((((x => x))), ((x => x)), 10); // Ternaries in parens var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); ->i : any ->fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : any +>i : number +>fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any ->Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any +>(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => number +>Math.random() < 0.5 ? x => x : x => undefined : (x: number) => number >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -159,17 +159,17 @@ var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); >x => x : (x: number) => number >x : number >x : number ->x => undefined : (x: number) => any +>x => undefined : (x: number) => undefined >x : number >undefined : undefined >10 : 10 var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); ->j : any ->fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : any +>j : number +>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any ->Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => number +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => number >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -180,18 +180,18 @@ var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >x => x : (x: number) => number >x : number >x : number ->(x => undefined) : (x: number) => any ->x => undefined : (x: number) => any +>(x => undefined) : (x: number) => undefined +>x => undefined : (x: number) => undefined >x : number >undefined : undefined >10 : 10 var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); ->k : any ->fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : any +>k : number +>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any ->Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => number +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => number >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -202,22 +202,22 @@ var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >x => x : (x: number) => number >x : number >x : number ->(x => undefined) : (x: number) => any ->x => undefined : (x: number) => any +>(x => undefined) : (x: number) => undefined +>x => undefined : (x: number) => undefined >x : number >undefined : undefined ->x => x : (x: any) => any ->x : any ->x : any +>x => x : (x: number) => number +>x : number +>x : number >10 : 10 var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10); ->l : any ->fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : any +>l : number +>fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any ->(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any ->Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any +>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => number +>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => number +>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => number >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -229,16 +229,16 @@ var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x) >x => x : (x: number) => number >x : number >x : number ->((x => undefined)) : (x: number) => any ->(x => undefined) : (x: number) => any ->x => undefined : (x: number) => any +>((x => undefined)) : (x: number) => undefined +>(x => undefined) : (x: number) => undefined +>x => undefined : (x: number) => undefined >x : number >undefined : undefined ->((x => x)) : (x: any) => any ->(x => x) : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>((x => x)) : (x: number) => number +>(x => x) : (x: number) => number +>x => x : (x: number) => number +>x : number +>x : number >10 : 10 var lambda1: (x: number) => number = x => x; @@ -266,16 +266,16 @@ type ObjType = { x: (p: number) => string; y: (p: string) => number }; var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; >obj1 : ObjType >ObjType : ObjType ->{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; } ->x : (x: number) => any ->x => (x, undefined) : (x: number) => any +>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => undefined; y: (y: string) => undefined; } +>x : (x: number) => undefined +>x => (x, undefined) : (x: number) => undefined >x : number >(x, undefined) : undefined >x, undefined : undefined >x : number >undefined : undefined ->y : (y: string) => any ->y => (y, undefined) : (y: string) => any +>y : (y: string) => undefined +>y => (y, undefined) : (y: string) => undefined >y : string >(y, undefined) : undefined >y, undefined : undefined @@ -285,17 +285,17 @@ var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); >obj2 : ObjType >ObjType : ObjType ->({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => any; y: (y: string) => any; } ->{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; } ->x : (x: number) => any ->x => (x, undefined) : (x: number) => any +>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => undefined; y: (y: string) => undefined; } +>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => undefined; y: (y: string) => undefined; } +>x : (x: number) => undefined +>x => (x, undefined) : (x: number) => undefined >x : number >(x, undefined) : undefined >x, undefined : undefined >x : number >undefined : undefined ->y : (y: string) => any ->y => (y, undefined) : (y: string) => any +>y : (y: string) => undefined +>y => (y, undefined) : (y: string) => undefined >y : string >(y, undefined) : undefined >y, undefined : undefined diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.types b/tests/baselines/reference/parenthesizedContexualTyping2.types index cdab8172b9e59..f7a64a46de515 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.types +++ b/tests/baselines/reference/parenthesizedContexualTyping2.types @@ -186,8 +186,8 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x >i : number >fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } ->(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : (x: (p: T) => T) => any ->Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : (x: (p: T) => T) => (p: T) => T +>Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : (x: (p: T) => T) => (p: T) => T >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -200,7 +200,7 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->x => undefined : (x: (p: T) => T) => any +>x => undefined : (x: (p: T) => T) => undefined >x : (p: T) => T >undefined : undefined >10 : 10 @@ -209,8 +209,8 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >j : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => (p: T) => T +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => (p: T) => T >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -224,8 +224,8 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->(x => undefined) : (x: (p: T) => T) => any ->x => undefined : (x: (p: T) => T) => any +>(x => undefined) : (x: (p: T) => T) => undefined +>x => undefined : (x: (p: T) => T) => undefined >x : (p: T) => T >undefined : undefined >10 : 10 @@ -234,8 +234,8 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >k : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => (p: T) => T +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => (p: T) => T >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -249,8 +249,8 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->(x => undefined) : (x: (p: T) => T) => any ->x => undefined : (x: (p: T) => T) => any +>(x => undefined) : (x: (p: T) => T) => undefined +>x => undefined : (x: (p: T) => T) => undefined >x : (p: T) => T >undefined : undefined >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T @@ -265,9 +265,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) >l : number >fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } ->((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : (x: (p: T) => T) => any ->(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : (x: (p: T) => T) => any ->Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : (x: (p: T) => T) => any +>((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : (x: (p: T) => T) => (p: T) => T +>(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : (x: (p: T) => T) => (p: T) => T +>Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : (x: (p: T) => T) => (p: T) => T >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -282,9 +282,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->((x => undefined)) : (x: (p: T) => T) => any ->(x => undefined) : (x: (p: T) => T) => any ->x => undefined : (x: (p: T) => T) => any +>((x => undefined)) : (x: (p: T) => T) => undefined +>(x => undefined) : (x: (p: T) => T) => undefined +>x => undefined : (x: (p: T) => T) => undefined >x : (p: T) => T >undefined : undefined >((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T @@ -328,16 +328,16 @@ type ObjType = { x: (p: number) => string; y: (p: string) => number }; var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; >obj1 : ObjType >ObjType : ObjType ->{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; } ->x : (x: number) => any ->x => (x, undefined) : (x: number) => any +>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => undefined; y: (y: string) => undefined; } +>x : (x: number) => undefined +>x => (x, undefined) : (x: number) => undefined >x : number >(x, undefined) : undefined >x, undefined : undefined >x : number >undefined : undefined ->y : (y: string) => any ->y => (y, undefined) : (y: string) => any +>y : (y: string) => undefined +>y => (y, undefined) : (y: string) => undefined >y : string >(y, undefined) : undefined >y, undefined : undefined @@ -347,17 +347,17 @@ var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) }; var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) }); >obj2 : ObjType >ObjType : ObjType ->({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => any; y: (y: string) => any; } ->{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; } ->x : (x: number) => any ->x => (x, undefined) : (x: number) => any +>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => undefined; y: (y: string) => undefined; } +>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => undefined; y: (y: string) => undefined; } +>x : (x: number) => undefined +>x => (x, undefined) : (x: number) => undefined >x : number >(x, undefined) : undefined >x, undefined : undefined >x : number >undefined : undefined ->y : (y: string) => any ->y => (y, undefined) : (y: string) => any +>y : (y: string) => undefined +>y => (y, undefined) : (y: string) => undefined >y : string >(y, undefined) : undefined >y, undefined : undefined diff --git a/tests/baselines/reference/promiseType.types b/tests/baselines/reference/promiseType.types index 3228d266319f5..25da104e3ffdd 100644 --- a/tests/baselines/reference/promiseType.types +++ b/tests/baselines/reference/promiseType.types @@ -234,7 +234,7 @@ const p14 = p.catch(() => undefined); >p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >p : Promise >catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const p15 = p.catch(() => null); @@ -243,7 +243,7 @@ const p15 = p.catch(() => null); >p.catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise >p : Promise >catch : (onrejected?: (reason: any) => TResult | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null const p16 = p.catch(() => {}); @@ -329,7 +329,7 @@ const p24 = p.then(() => undefined); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const p25 = p.then(() => null); @@ -338,7 +338,7 @@ const p25 = p.then(() => null); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null const p26 = p.then(() => {}); @@ -429,7 +429,7 @@ const p34 = p.then(undefined, () => undefined); >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >undefined : undefined ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const p35 = p.then(undefined, () => null); @@ -439,7 +439,7 @@ const p35 = p.then(undefined, () => null); >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >undefined : undefined ->() => null : () => any +>() => null : () => null >null : null const p36 = p.then(undefined, () => {}); @@ -534,7 +534,7 @@ const p44 = p.then(null, () => undefined); >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >null : null ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const p45 = p.then(null, () => null); @@ -544,7 +544,7 @@ const p45 = p.then(null, () => null); >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >null : null ->() => null : () => any +>() => null : () => null >null : null const p46 = p.then(null, () => {}); @@ -644,7 +644,7 @@ const p54 = p.then(() => "1", () => undefined); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => "1" : () => string >"1" : "1" ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const p55 = p.then(() => "1", () => null); @@ -655,7 +655,7 @@ const p55 = p.then(() => "1", () => null); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => "1" : () => string >"1" : "1" ->() => null : () => any +>() => null : () => null >null : null const p56 = p.then(() => "1", () => {}); @@ -759,7 +759,7 @@ const p64 = p.then(() => x, () => undefined); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => x : () => any >x : any ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const p65 = p.then(() => x, () => null); @@ -770,7 +770,7 @@ const p65 = p.then(() => x, () => null); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => x : () => any >x : any ->() => null : () => any +>() => null : () => null >null : null const p66 = p.then(() => x, () => {}); @@ -830,7 +830,7 @@ const p70 = p.then(() => undefined, undefined); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined >undefined : undefined @@ -840,7 +840,7 @@ const p71 = p.then(() => undefined, null); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined >null : null @@ -850,7 +850,7 @@ const p72 = p.then(() => undefined, () => 1); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined >() => 1 : () => number >1 : 1 @@ -861,7 +861,7 @@ const p73 = p.then(() => undefined, () => x); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined >() => x : () => any >x : any @@ -872,9 +872,9 @@ const p74 = p.then(() => undefined, () => undefined); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const p75 = p.then(() => undefined, () => null); @@ -883,9 +883,9 @@ const p75 = p.then(() => undefined, () => null); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined ->() => null : () => any +>() => null : () => null >null : null const p76 = p.then(() => undefined, () => {}); @@ -894,7 +894,7 @@ const p76 = p.then(() => undefined, () => {}); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined >() => {} : () => void @@ -904,7 +904,7 @@ const p77 = p.then(() => undefined, () => {throw 1}); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined >() => {throw 1} : () => never >1 : 1 @@ -915,7 +915,7 @@ const p78 = p.then(() => undefined, () => Promise.resolve(1)); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise @@ -930,7 +930,7 @@ const p79 = p.then(() => undefined, () => Promise.reject(1)); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -945,7 +945,7 @@ const p80 = p.then(() => null, undefined); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null >undefined : undefined @@ -955,7 +955,7 @@ const p81 = p.then(() => null, null); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null >null : null @@ -965,7 +965,7 @@ const p82 = p.then(() => null, () => 1); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null >() => 1 : () => number >1 : 1 @@ -976,7 +976,7 @@ const p83 = p.then(() => null, () => x); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null >() => x : () => any >x : any @@ -987,9 +987,9 @@ const p84 = p.then(() => null, () => undefined); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const p85 = p.then(() => null, () => null); @@ -998,9 +998,9 @@ const p85 = p.then(() => null, () => null); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null ->() => null : () => any +>() => null : () => null >null : null const p86 = p.then(() => null, () => {}); @@ -1009,7 +1009,7 @@ const p86 = p.then(() => null, () => {}); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null >() => {} : () => void @@ -1019,7 +1019,7 @@ const p87 = p.then(() => null, () => {throw 1}); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null >() => {throw 1} : () => never >1 : 1 @@ -1030,7 +1030,7 @@ const p88 = p.then(() => null, () => Promise.resolve(1)); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null >() => Promise.resolve(1) : () => Promise >Promise.resolve(1) : Promise @@ -1045,7 +1045,7 @@ const p89 = p.then(() => null, () => Promise.reject(1)); >p.then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->() => null : () => any +>() => null : () => null >null : null >() => Promise.reject(1) : () => Promise >Promise.reject(1) : Promise @@ -1099,7 +1099,7 @@ const p94 = p.then(() => {}, () => undefined); >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {} : () => void ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const p95 = p.then(() => {}, () => null); @@ -1109,7 +1109,7 @@ const p95 = p.then(() => {}, () => null); >p : Promise >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {} : () => void ->() => null : () => any +>() => null : () => null >null : null const p96 = p.then(() => {}, () => {}); @@ -1209,7 +1209,7 @@ const pa4 = p.then(() => {throw 1}, () => undefined); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const pa5 = p.then(() => {throw 1}, () => null); @@ -1220,7 +1220,7 @@ const pa5 = p.then(() => {throw 1}, () => null); >then : (onfulfilled?: (value: boolean) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise >() => {throw 1} : () => never >1 : 1 ->() => null : () => any +>() => null : () => null >null : null const pa6 = p.then(() => {throw 1}, () => {}); @@ -1344,7 +1344,7 @@ const pb4 = p.then(() => Promise.resolve("1"), () => undefined); >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >"1" : "1" ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const pb5 = p.then(() => Promise.resolve("1"), () => null); @@ -1359,7 +1359,7 @@ const pb5 = p.then(() => Promise.resolve("1"), () => null); >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >"1" : "1" ->() => null : () => any +>() => null : () => null >null : null const pb6 = p.then(() => Promise.resolve("1"), () => {}); @@ -1499,7 +1499,7 @@ const pc4 = p.then(() => Promise.reject("1"), () => undefined); >Promise : PromiseConstructor >reject : { (reason: any): Promise; (reason: any): Promise; } >"1" : "1" ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined const pc5 = p.then(() => Promise.reject("1"), () => null); @@ -1514,7 +1514,7 @@ const pc5 = p.then(() => Promise.reject("1"), () => null); >Promise : PromiseConstructor >reject : { (reason: any): Promise; (reason: any): Promise; } >"1" : "1" ->() => null : () => any +>() => null : () => null >null : null const pc6 = p.then(() => Promise.reject("1"), () => {}); diff --git a/tests/baselines/reference/restArgAssignmentCompat.types b/tests/baselines/reference/restArgAssignmentCompat.types index ccccb83134939..7c8fafaa258d1 100644 --- a/tests/baselines/reference/restArgAssignmentCompat.types +++ b/tests/baselines/reference/restArgAssignmentCompat.types @@ -8,7 +8,7 @@ function f(...x: number[]) { >x.forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void >x : number[] >forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void ->(n, i) => void ('item ' + i + ' = ' + n) : (n: number, i: number) => any +>(n, i) => void ('item ' + i + ' = ' + n) : (n: number, i: number) => undefined >n : number >i : number >void ('item ' + i + ' = ' + n) : undefined diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.types b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.types index d1be9c77cb984..826f77af93802 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.types +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.types @@ -112,7 +112,7 @@ someGenerics3 `${() => undefined}`; >someGenerics3 `${() => undefined}` : void >someGenerics3 : (strs: TemplateStringsArray, producer: () => T) => void >`${() => undefined}` : string ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined someGenerics3 `${() => 3}`; @@ -140,7 +140,7 @@ someGenerics4 `${4}${ () => null }`; >someGenerics4 : (strs: TemplateStringsArray, n: T, f: (x: U) => void) => void >`${4}${ () => null }` : string >4 : 4 ->() => null : () => any +>() => null : () => null >null : null someGenerics4 `${''}${ () => 3 }`; @@ -176,7 +176,7 @@ someGenerics5 `${ 4 } ${ () => null }`; >someGenerics5 : (strs: TemplateStringsArray, n: T, f: (x: U) => void) => void >`${ 4 } ${ () => null }` : string >4 : 4 ->() => null : () => any +>() => null : () => null >null : null someGenerics5 `${ '' }${ () => 3 }`; diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.types b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.types index e0a1d33937655..800a4ff36c916 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.types +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.types @@ -112,7 +112,7 @@ someGenerics3 `${() => undefined}`; >someGenerics3 `${() => undefined}` : void >someGenerics3 : (strs: TemplateStringsArray, producer: () => T) => void >`${() => undefined}` : string ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined someGenerics3 `${() => 3}`; @@ -140,7 +140,7 @@ someGenerics4 `${4}${ () => null }`; >someGenerics4 : (strs: TemplateStringsArray, n: T, f: (x: U) => void) => void >`${4}${ () => null }` : string >4 : 4 ->() => null : () => any +>() => null : () => null >null : null someGenerics4 `${''}${ () => 3 }`; @@ -176,7 +176,7 @@ someGenerics5 `${ 4 } ${ () => null }`; >someGenerics5 : (strs: TemplateStringsArray, n: T, f: (x: U) => void) => void >`${ 4 } ${ () => null }` : string >4 : 4 ->() => null : () => any +>() => null : () => null >null : null someGenerics5 `${ '' }${ () => 3 }`; diff --git a/tests/baselines/reference/typeArgumentInference.types b/tests/baselines/reference/typeArgumentInference.types index 1f39235ae36ff..17c87101ea837 100644 --- a/tests/baselines/reference/typeArgumentInference.types +++ b/tests/baselines/reference/typeArgumentInference.types @@ -148,7 +148,7 @@ someGenerics3(() => undefined); >someGenerics3(() => undefined) : void >someGenerics3 : (producer: () => T) => void >Date : Date ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined someGenerics3(() => 3); @@ -172,7 +172,7 @@ someGenerics4(4, () => null); >someGenerics4(4, () => null) : void >someGenerics4 : (n: T, f: (x: U) => void) => void >4 : 4 ->() => null : () => any +>() => null : () => null >null : null someGenerics4('', () => 3); @@ -203,7 +203,7 @@ someGenerics5(4, () => null); >someGenerics5(4, () => null) : void >someGenerics5 : (n: T, f: (x: U) => void) => void >4 : 4 ->() => null : () => any +>() => null : () => null >null : null someGenerics5('', () => 3); diff --git a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.types b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.types index 04dae1dafa758..fd9eca595fe53 100644 --- a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.types +++ b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.types @@ -190,7 +190,7 @@ new someGenerics3(() => undefined); >new someGenerics3(() => undefined) : any >someGenerics3 : someGenerics3 >Window : No type information available! ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined new someGenerics3(() => 3); @@ -220,7 +220,7 @@ new someGenerics4(4, () => null); >new someGenerics4(4, () => null) : any >someGenerics4 : someGenerics4 >4 : 4 ->() => null : () => any +>() => null : () => null >null : null new someGenerics4('', () => 3); @@ -265,7 +265,7 @@ new someGenerics5(4, () => null); >new someGenerics5(4, () => null) : any >someGenerics5 : someGenerics5 >4 : 4 ->() => null : () => any +>() => null : () => null >null : null new someGenerics5('', () => 3); diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.types b/tests/baselines/reference/typeArgumentInferenceWithConstraints.types index 4ca65f02b02b8..dfa428a15aae1 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.types +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.types @@ -162,7 +162,7 @@ someGenerics3(() => undefined); >someGenerics3(() => undefined) : void >someGenerics3 : (producer: () => T) => void >Window : No type information available! ->() => undefined : () => any +>() => undefined : () => undefined >undefined : undefined someGenerics3(() => 3); // Error @@ -186,7 +186,7 @@ someGenerics4(4, () => null); // Valid >someGenerics4(4, () => null) : void >someGenerics4 : (n: T, f: (x: U) => void) => void >4 : 4 ->() => null : () => any +>() => null : () => null >null : null someGenerics4('', () => 3); @@ -225,7 +225,7 @@ someGenerics5(4, () => null); // Valid >someGenerics5(4, () => null) : void >someGenerics5 : (n: T, f: (x: U) => void) => void >4 : 4 ->() => null : () => any +>() => null : () => null >null : null someGenerics5('', () => 3); diff --git a/tests/baselines/reference/typeParameterFixingWithConstraints.types b/tests/baselines/reference/typeParameterFixingWithConstraints.types index 1e71f439e5e2b..2fe91c279a899 100644 --- a/tests/baselines/reference/typeParameterFixingWithConstraints.types +++ b/tests/baselines/reference/typeParameterFixingWithConstraints.types @@ -38,10 +38,10 @@ foo.foo({ bar: null }, bar => null, bar => null); >{ bar: null } : { bar: null; } >bar : null >null : null ->bar => null : (bar: { bar: any; }) => any +>bar => null : (bar: { bar: any; }) => null >bar : { bar: any; } >null : null ->bar => null : (bar: { bar: any; }) => any +>bar => null : (bar: { bar: any; }) => null >bar : { bar: any; } >null : null diff --git a/tests/baselines/reference/typeReferenceDirectives12.types b/tests/baselines/reference/typeReferenceDirectives12.types index cb6f3239bea80..4bc2f6ae1e388 100644 --- a/tests/baselines/reference/typeReferenceDirectives12.types +++ b/tests/baselines/reference/typeReferenceDirectives12.types @@ -43,13 +43,13 @@ import {Cls} from "./main"; >Cls : typeof Cls Cls.prototype.foo = function() { return undefined; } ->Cls.prototype.foo = function() { return undefined; } : () => any +>Cls.prototype.foo = function() { return undefined; } : () => undefined >Cls.prototype.foo : () => Lib >Cls.prototype : Cls >Cls : typeof Cls >prototype : Cls >foo : () => Lib ->function() { return undefined; } : () => any +>function() { return undefined; } : () => undefined >undefined : undefined declare module "./main" { diff --git a/tests/baselines/reference/typeReferenceDirectives9.types b/tests/baselines/reference/typeReferenceDirectives9.types index cb6f3239bea80..4bc2f6ae1e388 100644 --- a/tests/baselines/reference/typeReferenceDirectives9.types +++ b/tests/baselines/reference/typeReferenceDirectives9.types @@ -43,13 +43,13 @@ import {Cls} from "./main"; >Cls : typeof Cls Cls.prototype.foo = function() { return undefined; } ->Cls.prototype.foo = function() { return undefined; } : () => any +>Cls.prototype.foo = function() { return undefined; } : () => undefined >Cls.prototype.foo : () => Lib >Cls.prototype : Cls >Cls : typeof Cls >prototype : Cls >foo : () => Lib ->function() { return undefined; } : () => any +>function() { return undefined; } : () => undefined >undefined : undefined declare module "./main" { diff --git a/tests/cases/compiler/arrowFunctionMakesStrictLiteralCheck.ts b/tests/cases/compiler/arrowFunctionMakesStrictLiteralCheck.ts new file mode 100644 index 0000000000000..ddb65ac35a5ff --- /dev/null +++ b/tests/cases/compiler/arrowFunctionMakesStrictLiteralCheck.ts @@ -0,0 +1,7 @@ +interface X { x: number; } + +type XGetter = () => X; + +const getX2: XGetter = () => { + return { x: 1, y: 2 }; // Expect excess property error on `y` +} \ No newline at end of file diff --git a/tests/cases/compiler/destructuringNoFreshLiteralLeak.ts b/tests/cases/compiler/destructuringNoFreshLiteralLeak.ts new file mode 100644 index 0000000000000..591764aacc3a6 --- /dev/null +++ b/tests/cases/compiler/destructuringNoFreshLiteralLeak.ts @@ -0,0 +1,4 @@ +// @strictNullChecks: true +const { x = () => ({a: 12}) } = { x: () => ({a: 24, b: 12}) }; +declare function f(x: {a: number}): void; +f(x()); diff --git a/tests/cases/compiler/functionExpressionReturnTypeNotFresh.ts b/tests/cases/compiler/functionExpressionReturnTypeNotFresh.ts new file mode 100644 index 0000000000000..51325c61caa6b --- /dev/null +++ b/tests/cases/compiler/functionExpressionReturnTypeNotFresh.ts @@ -0,0 +1,8 @@ +// @strict: true +const a = () => ({ + a: 12, + b: 11 +}); + +declare function f(arg: {a: number}): void; +f(a()); \ No newline at end of file