We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in my code i often use, let's call them, type invariants assertions:
function mustBe<T>(_: () => T): void {} interface A { isThat: true; text: string; } interface B { isThat: false; value: number; } type C = A | B; declare const C: C; mustBe<true>(() => C.isThat); // <-- type error as expected
now i wish i could do type invariant assertions without emitting any useless code, making it a zero cost abstraction:
makesure C.isThat sameas true;
where makesure is a new TS syntax/construct that participates in type checking, but doesn't get emitted
makesure
few more examples
makesure typeof c.isThat subtypeof boolean makesure MyClass subtypeof BaseClass // ...
The text was updated successfully, but these errors were encountered:
I use type aliases for pseudo static asserts.
type HasType<T, Q extends T> = Q; type StaticAssert1 = HasType<true, A['isThat']> // OK type StaticAssert2 = HasType<true, C['isThat']> // Error as expected
Sorry, something went wrong.
duplicate of #16605?
No branches or pull requests
closed in favor of #16605
in my code i often use, let's call them, type invariants assertions:
now i wish i could do type invariant assertions without emitting any useless code, making it a zero cost abstraction:
where
makesure
is a new TS syntax/construct that participates in type checking, but doesn't get emittedfew more examples
The text was updated successfully, but these errors were encountered: