From 9e59eeddda9fed8b4ea40b8fc1daa3007b6bfa32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 13 Apr 2024 09:59:54 +0200 Subject: [PATCH 1/5] Fixed propagating object flags when dealing with spreads --- src/compiler/checker.ts | 6 +- .../noImplicitAnySpreads1.errors.txt | 22 ++++++++ .../reference/noImplicitAnySpreads1.symbols | 35 ++++++++++++ .../reference/noImplicitAnySpreads1.types | 56 +++++++++++++++++++ tests/cases/compiler/noImplicitAnySpreads1.ts | 19 +++++++ 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/noImplicitAnySpreads1.errors.txt create mode 100644 tests/baselines/reference/noImplicitAnySpreads1.symbols create mode 100644 tests/baselines/reference/noImplicitAnySpreads1.types create mode 100644 tests/cases/compiler/noImplicitAnySpreads1.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 67046e27d2d0b..e93df6ae5fefb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18985,7 +18985,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const skippedPrivateMembers = new Set<__String>(); const indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); + // propagating flags of the right properties should be preserved if they override the left properties + let finalObjectFlags = objectFlags & ~ObjectFlags.PropagatingFlags; for (const rightProp of getPropertiesOfType(right)) { + finalObjectFlags |= getObjectFlags(getTypeOfSymbol(rightProp)) & ObjectFlags.PropagatingFlags; if (getDeclarationModifierFlagsFromSymbol(rightProp) & (ModifierFlags.Private | ModifierFlags.Protected)) { skippedPrivateMembers.add(rightProp.escapedName); } @@ -19021,12 +19024,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } else { + finalObjectFlags |= getObjectFlags(getTypeOfSymbol(leftProp)) & ObjectFlags.PropagatingFlags; members.set(leftProp.escapedName, getSpreadSymbol(leftProp, readonly)); } } const spread = createAnonymousType(symbol, members, emptyArray, emptyArray, sameMap(indexInfos, info => getIndexInfoWithReadonly(info, readonly))); - spread.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectOrArrayLiteral | ObjectFlags.ContainsSpread | objectFlags; + spread.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectOrArrayLiteral | ObjectFlags.ContainsSpread | finalObjectFlags; return spread; } diff --git a/tests/baselines/reference/noImplicitAnySpreads1.errors.txt b/tests/baselines/reference/noImplicitAnySpreads1.errors.txt new file mode 100644 index 0000000000000..0024ea66b813b --- /dev/null +++ b/tests/baselines/reference/noImplicitAnySpreads1.errors.txt @@ -0,0 +1,22 @@ +noImplicitAnySpreads1.ts(13,3): error TS7018: Object literal's property 'other' implicitly has an 'any' type. + + +==== noImplicitAnySpreads1.ts (1 errors) ==== + // https://github.com/microsoft/TypeScript/issues/58150#issuecomment-2052517378 + + function getMore() { + return { + c: "foo", + p: "bar", + s: "baz", + }; + } + + const bar = { + p: null, // no error, this gets overriden + other: null, // error, this does not get overriden + ~~~~~~~~~~~ +!!! error TS7018: Object literal's property 'other' implicitly has an 'any' type. + ...getMore(), + }; + \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnySpreads1.symbols b/tests/baselines/reference/noImplicitAnySpreads1.symbols new file mode 100644 index 0000000000000..bc0c460defcd9 --- /dev/null +++ b/tests/baselines/reference/noImplicitAnySpreads1.symbols @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/noImplicitAnySpreads1.ts] //// + +=== noImplicitAnySpreads1.ts === +// https://github.com/microsoft/TypeScript/issues/58150#issuecomment-2052517378 + +function getMore() { +>getMore : Symbol(getMore, Decl(noImplicitAnySpreads1.ts, 0, 0)) + + return { + c: "foo", +>c : Symbol(c, Decl(noImplicitAnySpreads1.ts, 3, 10)) + + p: "bar", +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 4, 13)) + + s: "baz", +>s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 5, 13)) + + }; +} + +const bar = { +>bar : Symbol(bar, Decl(noImplicitAnySpreads1.ts, 10, 5)) + + p: null, // no error, this gets overriden +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 10, 13)) + + other: null, // error, this does not get overriden +>other : Symbol(other, Decl(noImplicitAnySpreads1.ts, 11, 10)) + + ...getMore(), +>getMore : Symbol(getMore, Decl(noImplicitAnySpreads1.ts, 0, 0)) + +}; + diff --git a/tests/baselines/reference/noImplicitAnySpreads1.types b/tests/baselines/reference/noImplicitAnySpreads1.types new file mode 100644 index 0000000000000..5eeab37f7b74d --- /dev/null +++ b/tests/baselines/reference/noImplicitAnySpreads1.types @@ -0,0 +1,56 @@ +//// [tests/cases/compiler/noImplicitAnySpreads1.ts] //// + +=== noImplicitAnySpreads1.ts === +// https://github.com/microsoft/TypeScript/issues/58150#issuecomment-2052517378 + +function getMore() { +>getMore : () => { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + return { +>{ c: "foo", p: "bar", s: "baz", } : { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + c: "foo", +>c : string +> : ^^^^^^ +>"foo" : "foo" +> : ^^^^^ + + p: "bar", +>p : string +> : ^^^^^^ +>"bar" : "bar" +> : ^^^^^ + + s: "baz", +>s : string +> : ^^^^^^ +>"baz" : "baz" +> : ^^^^^ + + }; +} + +const bar = { +>bar : { c: string; p: string; s: string; other: any; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ p: null, // no error, this gets overriden other: null, // error, this does not get overriden ...getMore(),} : { c: string; p: string; s: string; other: null; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + p: null, // no error, this gets overriden +>p : null +> : ^^^^ + + other: null, // error, this does not get overriden +>other : null +> : ^^^^ + + ...getMore(), +>getMore() : { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>getMore : () => { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +}; + diff --git a/tests/cases/compiler/noImplicitAnySpreads1.ts b/tests/cases/compiler/noImplicitAnySpreads1.ts new file mode 100644 index 0000000000000..308d7bb11ab13 --- /dev/null +++ b/tests/cases/compiler/noImplicitAnySpreads1.ts @@ -0,0 +1,19 @@ +// @strictNullChecks: false +// @noImplicitAny: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/58150#issuecomment-2052517378 + +function getMore() { + return { + c: "foo", + p: "bar", + s: "baz", + }; +} + +const bar = { + p: null, // no error, this gets overriden + other: null, // error, this does not get overriden + ...getMore(), +}; From 0014440b364b7f6abacddc6925cc73aeb305ebdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 15 Jun 2024 10:40:12 +0200 Subject: [PATCH 2/5] update baseline --- ...nyUnionNormalizedObjectLiteral1.errors.txt | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 tests/baselines/reference/noImplicitAnyUnionNormalizedObjectLiteral1.errors.txt diff --git a/tests/baselines/reference/noImplicitAnyUnionNormalizedObjectLiteral1.errors.txt b/tests/baselines/reference/noImplicitAnyUnionNormalizedObjectLiteral1.errors.txt deleted file mode 100644 index 5aec21fd62134..0000000000000 --- a/tests/baselines/reference/noImplicitAnyUnionNormalizedObjectLiteral1.errors.txt +++ /dev/null @@ -1,32 +0,0 @@ -noImplicitAnyUnionNormalizedObjectLiteral1.ts(16,3): error TS7018: Object literal's property 'p' implicitly has an 'any' type. -noImplicitAnyUnionNormalizedObjectLiteral1.ts(17,3): error TS7018: Object literal's property 's' implicitly has an 'any' type. - - -==== noImplicitAnyUnionNormalizedObjectLiteral1.ts (2 errors) ==== - // https://github.com/microsoft/TypeScript/issues/58150 - - function doSthWithParams(params: unknown) { - if (typeof params !== "object") { - return {}; - } - - return { - c: "foo", - p: "bar", - s: "baz", - }; - } - - const bar = { - p: null, - ~~~~~~~ -!!! error TS7018: Object literal's property 'p' implicitly has an 'any' type. - s: null, - ~~~~~~~ -!!! error TS7018: Object literal's property 's' implicitly has an 'any' type. - ...doSthWithParams({ - p: "hello", - s: "world", - }), - }; - \ No newline at end of file From 41271459f6ec536b115eb164cb51757c61c8be03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 15 Jun 2024 11:03:18 +0200 Subject: [PATCH 3/5] add extra test case --- .../noImplicitAnySpreads1.errors.txt | 17 +++++ .../reference/noImplicitAnySpreads1.symbols | 38 +++++++++++ .../reference/noImplicitAnySpreads1.types | 68 +++++++++++++++++++ tests/cases/compiler/noImplicitAnySpreads1.ts | 17 +++++ 4 files changed, 140 insertions(+) diff --git a/tests/baselines/reference/noImplicitAnySpreads1.errors.txt b/tests/baselines/reference/noImplicitAnySpreads1.errors.txt index 0024ea66b813b..d7f6965cc25f2 100644 --- a/tests/baselines/reference/noImplicitAnySpreads1.errors.txt +++ b/tests/baselines/reference/noImplicitAnySpreads1.errors.txt @@ -19,4 +19,21 @@ noImplicitAnySpreads1.ts(13,3): error TS7018: Object literal's property 'other' !!! error TS7018: Object literal's property 'other' implicitly has an 'any' type. ...getMore(), }; + + function doSthWithParams(params: unknown) { + return { + c: 'foo', + p: 'bar', + s: 'baz', + }; + } + + const baz = { + p: null, + s: null, + ...doSthWithParams({ + p: 'hello', + s: 'world', + }), + }; \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnySpreads1.symbols b/tests/baselines/reference/noImplicitAnySpreads1.symbols index bc0c460defcd9..1e8dcd12d7b3a 100644 --- a/tests/baselines/reference/noImplicitAnySpreads1.symbols +++ b/tests/baselines/reference/noImplicitAnySpreads1.symbols @@ -33,3 +33,41 @@ const bar = { }; +function doSthWithParams(params: unknown) { +>doSthWithParams : Symbol(doSthWithParams, Decl(noImplicitAnySpreads1.ts, 14, 2)) +>params : Symbol(params, Decl(noImplicitAnySpreads1.ts, 16, 25)) + + return { + c: 'foo', +>c : Symbol(c, Decl(noImplicitAnySpreads1.ts, 17, 10)) + + p: 'bar', +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 18, 13)) + + s: 'baz', +>s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 19, 13)) + + }; +} + +const baz = { +>baz : Symbol(baz, Decl(noImplicitAnySpreads1.ts, 24, 5)) + + p: null, +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 24, 13)) + + s: null, +>s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 25, 10)) + + ...doSthWithParams({ +>doSthWithParams : Symbol(doSthWithParams, Decl(noImplicitAnySpreads1.ts, 14, 2)) + + p: 'hello', +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 27, 22)) + + s: 'world', +>s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 28, 15)) + + }), +}; + diff --git a/tests/baselines/reference/noImplicitAnySpreads1.types b/tests/baselines/reference/noImplicitAnySpreads1.types index 5eeab37f7b74d..9b4a448b5df04 100644 --- a/tests/baselines/reference/noImplicitAnySpreads1.types +++ b/tests/baselines/reference/noImplicitAnySpreads1.types @@ -54,3 +54,71 @@ const bar = { }; +function doSthWithParams(params: unknown) { +>doSthWithParams : (params: unknown) => { c: string; p: string; s: string; } +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>params : unknown +> : ^^^^^^^ + + return { +>{ c: 'foo', p: 'bar', s: 'baz', } : { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + c: 'foo', +>c : string +> : ^^^^^^ +>'foo' : "foo" +> : ^^^^^ + + p: 'bar', +>p : string +> : ^^^^^^ +>'bar' : "bar" +> : ^^^^^ + + s: 'baz', +>s : string +> : ^^^^^^ +>'baz' : "baz" +> : ^^^^^ + + }; +} + +const baz = { +>baz : { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ p: null, s: null, ...doSthWithParams({ p: 'hello', s: 'world', }),} : { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + p: null, +>p : null +> : ^^^^ + + s: null, +>s : null +> : ^^^^ + + ...doSthWithParams({ +>doSthWithParams({ p: 'hello', s: 'world', }) : { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>doSthWithParams : (params: unknown) => { c: string; p: string; s: string; } +> : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ p: 'hello', s: 'world', } : { p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ + + p: 'hello', +>p : string +> : ^^^^^^ +>'hello' : "hello" +> : ^^^^^^^ + + s: 'world', +>s : string +> : ^^^^^^ +>'world' : "world" +> : ^^^^^^^ + + }), +}; + diff --git a/tests/cases/compiler/noImplicitAnySpreads1.ts b/tests/cases/compiler/noImplicitAnySpreads1.ts index 308d7bb11ab13..10a1b1b558e15 100644 --- a/tests/cases/compiler/noImplicitAnySpreads1.ts +++ b/tests/cases/compiler/noImplicitAnySpreads1.ts @@ -17,3 +17,20 @@ const bar = { other: null, // error, this does not get overriden ...getMore(), }; + +function doSthWithParams(params: unknown) { + return { + c: 'foo', + p: 'bar', + s: 'baz', + }; +} + +const baz = { + p: null, + s: null, + ...doSthWithParams({ + p: 'hello', + s: 'world', + }), +}; From 45a5c7df9bb0ff6c1cabc9b5be5599f75e4b8776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 15 Jun 2024 11:10:59 +0200 Subject: [PATCH 4/5] clarify the comment --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f01837b881c14..70da67499b400 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19495,7 +19495,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const skippedPrivateMembers = new Set<__String>(); const indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); - // propagating flags of the right properties should be preserved if they override the left properties + // propagating flags of the right properties should always be preserved + // propagating flags of the left properties doesn't always happen since right properties can override them let finalObjectFlags = objectFlags & ~ObjectFlags.PropagatingFlags; for (const rightProp of getPropertiesOfType(right)) { finalObjectFlags |= getObjectFlags(getTypeOfSymbol(rightProp)) & ObjectFlags.PropagatingFlags; From 35a60d467fec92e04a9eb6fef711d0408895b78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 15 Jun 2024 18:53:27 +0200 Subject: [PATCH 5/5] add extra test case --- .../noImplicitAnySpreads1.errors.txt | 7 +++- .../reference/noImplicitAnySpreads1.symbols | 39 ++++++++++++------- .../reference/noImplicitAnySpreads1.types | 18 +++++++++ tests/cases/compiler/noImplicitAnySpreads1.ts | 5 +++ 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/tests/baselines/reference/noImplicitAnySpreads1.errors.txt b/tests/baselines/reference/noImplicitAnySpreads1.errors.txt index d7f6965cc25f2..aa0ac10822ffa 100644 --- a/tests/baselines/reference/noImplicitAnySpreads1.errors.txt +++ b/tests/baselines/reference/noImplicitAnySpreads1.errors.txt @@ -1,4 +1,4 @@ -noImplicitAnySpreads1.ts(13,3): error TS7018: Object literal's property 'other' implicitly has an 'any' type. +noImplicitAnySpreads1.ts(18,3): error TS7018: Object literal's property 'other' implicitly has an 'any' type. ==== noImplicitAnySpreads1.ts (1 errors) ==== @@ -12,6 +12,11 @@ noImplicitAnySpreads1.ts(13,3): error TS7018: Object literal's property 'other' }; } + const foo = { + p: null, + ...getMore(), + }; + const bar = { p: null, // no error, this gets overriden other: null, // error, this does not get overriden diff --git a/tests/baselines/reference/noImplicitAnySpreads1.symbols b/tests/baselines/reference/noImplicitAnySpreads1.symbols index 1e8dcd12d7b3a..4bdc3d51cf796 100644 --- a/tests/baselines/reference/noImplicitAnySpreads1.symbols +++ b/tests/baselines/reference/noImplicitAnySpreads1.symbols @@ -19,14 +19,25 @@ function getMore() { }; } +const foo = { +>foo : Symbol(foo, Decl(noImplicitAnySpreads1.ts, 10, 5)) + + p: null, +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 10, 13)) + + ...getMore(), +>getMore : Symbol(getMore, Decl(noImplicitAnySpreads1.ts, 0, 0)) + +}; + const bar = { ->bar : Symbol(bar, Decl(noImplicitAnySpreads1.ts, 10, 5)) +>bar : Symbol(bar, Decl(noImplicitAnySpreads1.ts, 15, 5)) p: null, // no error, this gets overriden ->p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 10, 13)) +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 15, 13)) other: null, // error, this does not get overriden ->other : Symbol(other, Decl(noImplicitAnySpreads1.ts, 11, 10)) +>other : Symbol(other, Decl(noImplicitAnySpreads1.ts, 16, 10)) ...getMore(), >getMore : Symbol(getMore, Decl(noImplicitAnySpreads1.ts, 0, 0)) @@ -34,39 +45,39 @@ const bar = { }; function doSthWithParams(params: unknown) { ->doSthWithParams : Symbol(doSthWithParams, Decl(noImplicitAnySpreads1.ts, 14, 2)) ->params : Symbol(params, Decl(noImplicitAnySpreads1.ts, 16, 25)) +>doSthWithParams : Symbol(doSthWithParams, Decl(noImplicitAnySpreads1.ts, 19, 2)) +>params : Symbol(params, Decl(noImplicitAnySpreads1.ts, 21, 25)) return { c: 'foo', ->c : Symbol(c, Decl(noImplicitAnySpreads1.ts, 17, 10)) +>c : Symbol(c, Decl(noImplicitAnySpreads1.ts, 22, 10)) p: 'bar', ->p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 18, 13)) +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 23, 13)) s: 'baz', ->s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 19, 13)) +>s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 24, 13)) }; } const baz = { ->baz : Symbol(baz, Decl(noImplicitAnySpreads1.ts, 24, 5)) +>baz : Symbol(baz, Decl(noImplicitAnySpreads1.ts, 29, 5)) p: null, ->p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 24, 13)) +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 29, 13)) s: null, ->s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 25, 10)) +>s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 30, 10)) ...doSthWithParams({ ->doSthWithParams : Symbol(doSthWithParams, Decl(noImplicitAnySpreads1.ts, 14, 2)) +>doSthWithParams : Symbol(doSthWithParams, Decl(noImplicitAnySpreads1.ts, 19, 2)) p: 'hello', ->p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 27, 22)) +>p : Symbol(p, Decl(noImplicitAnySpreads1.ts, 32, 22)) s: 'world', ->s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 28, 15)) +>s : Symbol(s, Decl(noImplicitAnySpreads1.ts, 33, 15)) }), }; diff --git a/tests/baselines/reference/noImplicitAnySpreads1.types b/tests/baselines/reference/noImplicitAnySpreads1.types index 9b4a448b5df04..b1f2abd45d209 100644 --- a/tests/baselines/reference/noImplicitAnySpreads1.types +++ b/tests/baselines/reference/noImplicitAnySpreads1.types @@ -32,6 +32,24 @@ function getMore() { }; } +const foo = { +>foo : { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ p: null, ...getMore(),} : { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + p: null, +>p : null +> : ^^^^ + + ...getMore(), +>getMore() : { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>getMore : () => { c: string; p: string; s: string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +}; + const bar = { >bar : { c: string; p: string; s: string; other: any; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/cases/compiler/noImplicitAnySpreads1.ts b/tests/cases/compiler/noImplicitAnySpreads1.ts index 10a1b1b558e15..e1450d1f46f7a 100644 --- a/tests/cases/compiler/noImplicitAnySpreads1.ts +++ b/tests/cases/compiler/noImplicitAnySpreads1.ts @@ -12,6 +12,11 @@ function getMore() { }; } +const foo = { + p: null, + ...getMore(), +}; + const bar = { p: null, // no error, this gets overriden other: null, // error, this does not get overriden