-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed as not planned
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
🔎 Search Terms
union type of type assertion
🕗 Version & Regression Information
- This changed in commit or PR Fix creation of composite union type predicates #54169
⏯ Playground Link
💻 Code
function asserts1(x: string | number | undefined): asserts x {}
function asserts2(x: string | undefined): asserts x {}
const maybeString = Math.random() > 0.5 ? 'string'.slice() : undefined;
const someAssert: typeof asserts1 | typeof asserts2 =
Math.random() > 0.5 ? asserts1 : asserts2;
function a() {
someAssert(maybeString);
maybeString.charAt(0);
}🙁 Actual behavior
maybeString is string | undefined
🙂 Expected behavior
maybeString must have only string type
Additional information about the issue
Related: #59707
When i implementing lint rule for about assert functions, cannot be report error coz checker doesn't respect someAssert is assertion function.
oxc-project/tsgolint#222
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/strict-boolean-expressions.test.ts#L3547
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed