BugDomain: Conditional TypesHelp Wanted
Métriques du dépôt
- Stars
- (48 455 stars)
- Métriques de merge PR
- (Merge moyen 6j 17h) (9 PRs mergées en 30 j)
Description
🔎 Search Terms
string extends template bug wrong error conditional
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ.
⏯ Playground Link
💻 Code
type No = [false]
type IsAString<S> = S extends `${infer _}` ? true : false;
type StringIsAString<T extends string> = [IsAString<`${T}`>] extends No ? false : true
const shouldAlwaysBeTrue: StringIsAString<'s'> = true;
🙁 Actual behavior
shouldAlwaysBeTrue reports the following error:
Type 'true' is not assignable to type 'false'.(2322)
🙂 Expected behavior
No error
Additional information about the issue
This is the most minimal reproduction of the issue I could come up with after whittling it down from a much more complicated scenario.
Interestingly enough, if I change almost anything about it, the issue goes away. For example, if I replace No with [false], issue goes away. If I take out one of the templates, issue goes away. Etc.