assignable
The rule that decides whether a value of one type may be used where another type is expected.
In more detail
A type is assignable to another if it has at least all the required properties with compatible types. Errors such as TS2345, argument of type string is not assignable to parameter of type number, are assignability failures. Utility types such as Exclude and Extract are defined in terms of assignability.
Related terms
- structural typing — A type rule where two types are compatible if they have the same shape, whatever they are called.
- TypeScript error code — The number TypeScript attaches to each kind of compiler error, such as TS2345 for an argument whose type does not fit.
- Exclude<T, U> — The utility type that removes from union T every member assignable to U, such as Exclude<HttpMethod, "GET">.
Taught in
- never: The Bottom Type And Exhaustive Switch Checking — Production TypeScript
- Optional Properties, Readonly And Index Signatures — Production TypeScript
- Union Utilities: Exclude, Extract, NonNullable And Awaited — Production TypeScript