-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed