4 ms·
Why is satisfies needed at all, when can't. Typescript realize that `a` satisfies `Rect` automatically?
by nixpulvis 11mo ago
Why is satisfies needed at all, when can't. Typescript realize that `a` satisfies `Rect` automatically?
- ameliaquining 11mo agoIt does; the code will still type-check without the satisfies operator. satisfies lets you say "if this value doesn't conform to this type then I want that to be an immediate compile error, even if it would otherwise be okay". Which isn't needed all that often since usually getting the type wrong would produce a compile error elsewhere, but occasionally it proves useful. When designing the feature they collected some use cases: https://github.com/microsoft/TypeScript/issues/47920 https://github.com/microsoft/TypeScript/issues/47920
- deleted 11mo ago[deleted]