question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

infer extends number in conditional type handles '\n' incorrectly

See original GitHub issue

Bug Report

🔎 Search Terms

  • infer extends number

🕗 Version & Regression Information

4.8.0-beta (in playground)

⏯ Playground Link

Playground link with relevant code

A simple type-level JSON parser encounters this issue

💻 Code

// number
type Foo = '\n' extends `${infer T extends number}${infer R}` ? T : never;

🙁 Actual behavior

Foo is number

🙂 Expected behavior

Foo should be never

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Josh-Cenacommented, Aug 2, 2022

Not just parseInt()—but Number(). It uses the StringNumericLiteral production, which means 0b111 is a `${number}` as well. (Disclaimer: didn’t read that source code; this is based on experiment).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditional type is inferred differently with generic type
The issue is that the compiler does not consult generic constraints when evaluating conditional types that depend upon as-yet-unspecified ...
Read more >
Common issues and solutions - mypy 0.991 documentation
The reason is that if the type of a is unknown, the type of a.split() is also unknown, so it is inferred as...
Read more >
Chapter 18. Type Inference
Describing how inference is used to handle wildcard-parameterized functional interface target types and most specific method analysis.
Read more >
Semantics
So in type checked Groovy, flow typing is a very important concept, which also implies that if @TypeChecked is applied, methods are selected ......
Read more >
Useful Patterns by Use Case - React TypeScript Cheatsheets
Strategy: extend React. ... no error return <Button type="button"> text </Button>; ... Strategy: extract a component's props by inferring them. Example:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found