Closed
Description
🔎 Search Terms
T | (() => T)
"T | (() => T)" inference
inference of lazy generic type
lazy generic inferred too wide
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about callbacks and functions and laziness and sum types.
⏯ Playground Link
💻 Code
type OptionallyLazy<T> = T | (() => T)
type MyType = { a: boolean }
const fn = (t: OptionallyLazy<MyType>) => {}
fn({ a: true, shouldFail: 'it does, good'})
fn(() => ({ a: true, shouldFail: 'this does not fail, which is bad' }))
🙁 Actual behavior
No type error for shouldFail
on last line above.
🙂 Expected behavior
Type error for shouldFail
on last line above, same as line above it.
Metadata
Metadata
Assignees
Labels
No labels