-
Notifications
You must be signed in to change notification settings - Fork 714
Closed
Labels
Domain: Type CheckingRelated to type checking, grammar checkingRelated to type checking, grammar checkingbugSomething isn't workingSomething isn't working
Description
Steps to reproduce
export type Data = {
rows: Array<{ foo: string }>
} | {
columns: number[];
}
declare function callback(response: Data | undefined) : void
callback({
rows: [
{}
]
});
Behavior with typescript@5.8
We get an error on {}
telling us the property foo
is missing:
generic/some-code.ts:10:9 - error TS2741: Property 'foo' is missing in type '{}' but required in type '{ foo: string; }'.
10 {}
~~
....
Behavior with tsgo
We get an error on the whole object literal making it more difficult to find the cause:
generic/some-code.ts:8:10 - error TS2345: Argument of type '{ rows: {}[]; }' is not assignable to parameter of type 'Data | undefined'.
Types of property 'rows' are incompatible.
Type '{}[]' is not assignable to type '{ foo: string; }[]'.
Property 'foo' is missing in type '{}' but required in type '{ foo: string; }'.
8 callback({
~
9 rows: [
~~~~~~~~~~~
...
11 ]
~~~~~
12 });
...
Removing | undefined
from the parameter type makes the error be the same as in 5.8
Metadata
Metadata
Assignees
Labels
Domain: Type CheckingRelated to type checking, grammar checkingRelated to type checking, grammar checkingbugSomething isn't workingSomething isn't working