You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Search Terms: destructuring assignment , Object literal may only specify known properties
Code
declarefunctionfoo<Textends{dataType: 'a'|'b';}>(template: T): [T,any,any];//<-- there no error, when it is [any,any,any]declarefunctionbar<Textends{dataType: 'a'|'b';}>(template: T): [T,any];functiontest_foo(){const[,,]=foo({dataType: 'a',day: 0});const[x,y,z]=foo({dataType: 'a',day: 0});const[,,t]=foo({dataType: 'a',day: 0});//<-- red line under the `day`console.log(x,y,z,t);}functiontest_bar(){const[,]=bar({dataType: 'a',day: 0});const[x,y]=bar({dataType: 'a',day: 0});const[,z]=bar({dataType: 'a',day: 0});//<-- red line under the `day`console.log(x,y,z);}
Expected behavior:
no compile error Actual behavior:
Argument of type '{ dataType: "a"; day: number; }' is not assignable to parameter of type '{ dataType: "a" | "b"; }'. Object literal may only specify known properties, and 'day' does not exist in type '{ dataType: "a" | "b"; }'.
Hello, we are a group of researchers developing machine learning techniques to locate issues suitable for newcomers, and our model consider this issue as likely a "good first issue". May we recommend you to label it as "good first issue" so newcomers know where to choose?
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript.
Object literal may only specify known properties, and 'day' does not exist in type '{ dataType: "a" | "b"; }'.
Object literal may only specify known properties, and 'day' does not exist in type '{ dataType: "a" | "b"; }'.
Historical Information
Version
Reproduction Outputs
4.2.2, 4.3.2, 4.4.2, 4.5.2, 4.6.2
❌ Failed:
-
Argument of type '{ dataType: "a"; day: number; }' is not assignable to parameter of type '{ dataType: "a" | "b"; }'.
Object literal may only specify known properties, and 'day' does not exist in type '{ dataType: "a" | "b"; }'.
Argument of type '{ dataType: "a"; day: number; }' is not assignable to parameter of type '{ dataType: "a" | "b"; }'.
Object literal may only specify known properties, and 'day' does not exist in type '{ dataType: "a" | "b"; }'.
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: v4.0.5
Search Terms: destructuring assignment , Object literal may only specify known properties
Code
Expected behavior:
no compile error
Actual behavior:
**Playground Link:
link
Related Issues:
The text was updated successfully, but these errors were encountered: