Type inference is broken for `array().of(...)`: union type turns into unknown
See original GitHub issueDescribe the bug
import yup from 'yup'
const alphabet = ['a', 'b', 'c'] as const
const letter = yup.mixed().oneOf(alphabet).required() // MixedSchema<"a" | "b" | "c">
const word = yup.array().of(letter) // NotRequiredArraySchema<unknown>, should be <"a" | "b" | "c"> instead of unknown
To Reproduce https://codesandbox.io/s/adoring-wing-xss7k?file=/src/index.ts
Version
@types/yup: 0.29.6
yup: 0.29.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Documentation - Type Inference - TypeScript
The type of the x variable is inferred to be number . This kind of inference takes place when initializing variables and members,...
Read more >Why is type inference not working on union types when one of ...
The real use case I am facing is that I get a response from some HTTP call. Right off the wire, it has...
Read more >Announcing TypeScript 4.8 - Microsoft Developer Blogs
Today we're excited to announce the release of TypeScript 4.8! ... For example, unknown is close in spirit to the union type {}...
Read more >TypeScript Fundamentals - Joy of Code
Since pokemon is an array the editor intellisense is smart enough to only show us array methods. ... TypeScript can infer types to...
Read more >Python Type Checking (Guide) - Real Python
Type annotations and type hints; Adding static types to code, both your code and the code of others; Running a static type checker;...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@amankkg Hey. I am new here. Just trying to check the issue out. It seems the codesandbox is incomplete. Can you please take a look?
types aren’t maintained here currently open an Issue on DT for any type issues please