Closed
Description
π Search Terms
- asserts
- intersection
π Version & Regression Information
Occurs since v3.7 update, the first update supporting the asserts
statement.
β― Playground Link
π» Code
export function assertString(input: unknown): asserts input is string & string {
if (typeof input !== 'string')
throw new Error('Input is not a string');
return input;
}
π Actual behavior
It is possible to declare an asserts
guard function with intersection return type. There's no error until that.
However, the intersection return type does not work, and just working as a void
return type.
Type 'string' is not assignable to type 'void'.
π Expected behavior
Hope the intersection return type to work.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels