-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.92
Search Terms: did you mean spelling suggestion same
Code
type NonVoid = Object | object;
type Something<T> = { test: string } & (T extends NonVoid ? {
requiredWhenNonVoid: T
} : {
requiredWhenNonVoid?: undefined
});
function testFunc2<A extends NonVoid>(a: A): Something<A> {
return {
test: 'test',
requiredWhenNonVoid: a
// ~~~~~~~~~~~~~~~~~~~
};
}
Expected behavior: Probably no error, or at least not this error suggestion
Actual behavior:
clipboard.ts:12 requiredWhenNonVoid: a
~~~~~~~~~~~~~~~~~~~~~~
TS2322: Type '{ test: string; requiredWhenNonVoid: A; }' is not assignable to type 'Something<A>'.
Object literal may only specify known properties, but 'requiredWhenNonVoid' does not exist in type 'Something<A>'. Did you mean to write 'requiredWhenNonVoid'?
There's no spelling error here -- the requiredWhenNonVoid
being cited is the same requiredWhenNonVoid
being suggested 🤡
Playground Link: Link
Related Issues: Nope
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue