diff --git a/tests/cases/compiler/excessPropertyErrorForFunctionExpressionReturns.ts b/tests/cases/compiler/excessPropertyErrorForFunctionExpressionReturns.ts new file mode 100644 index 00000000000..e3428b5653c --- /dev/null +++ b/tests/cases/compiler/excessPropertyErrorForFunctionExpressionReturns.ts @@ -0,0 +1,97 @@ +// @strict: true + +export type SomeObj1 = { a: number, b: number }; + +declare function valueOrGetter(x: T, f: () => T): T; + +namespace arrows { + declare function consumeObj1(f: () => SomeObj1): void; + consumeObj1(() => ({ + a: 100, + b: 200, + c: 300, + })); + + function obj1FactoryFactory(): () => SomeObj1 { + return () => ({ + a: 100, + b: 200, + c: 300, + }); + } + + valueOrGetter({ a: 100, b: 200 }, () => ({ + a: 100, + b: 200, + c: 300, + })); + + valueOrGetter({ a: 100, b: 200, c: 300 }, () => ({ + a: 100, + b: 200, + })); + + valueOrGetter({ a: 100, b: 200 }, () => ({ + a: 100, + b: 200, + c: 300, + })); + + valueOrGetter({ a: 100, b: 200, c: 300 }, () => ({ + a: 100, + b: 200, + })); +} + +namespace funcExprs { + declare function consumeObj1(f: () => SomeObj1): void; + consumeObj1(function() { + return { + a: 100, + b: 200, + c: 300, + }; + }); + + function obj1FactoryFactory(): () => SomeObj1 { + return function() { + return { + a: 100, + b: 200, + c: 300, + } + }; + } + + valueOrGetter({ a: 100, b: 200 }, function() { + return { + a: 100, + b: 200, + c: 300, + }; + }); + + valueOrGetter({ a: 100, b: 200, c: 300 }, function() { + return { + a: 100, + b: 200, + c: 300, + }; + }); + + valueOrGetter({ a: 100, b: 200 }, function() { + return { + a: 100, + b: 200, + c: 300, + }; + }); + + valueOrGetter({ a: 100, b: 200, c: 300 }, function() { + return { + a: 100, + b: 200, + c: 300, + }; + }); +} \ No newline at end of file