Improve type inferrence of data type rules
See original GitHub issueThe idea came from the discussion. Currently, ON returns string: 'on';
infers
export type ON = string;
Instead, we could infer it like
export type ON = 'on'
Issue Analytics
- State:
- Created a year ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Documentation - Type Inference - TypeScript
This kind of inference takes place when initializing variables and members, setting parameter default values, and determining function return types. In most ...
Read more >Type Inference, Type Improvement, and Type Simplification in ...
the language, the typing rules, and the type inference algorithm (not to mention proofs of sound- ness and completeness in the system), all...
Read more >Lecture 26: Type Inference and Unification - CS@Cornell
Type inference refers to the process of determining the appropriate types for expressions based on how they are used. For example, in the...
Read more >CS345H: Programming Languages Lecture 12: Type Inference
In this rule, this type variable encodes the return type of the application. Thomas Dillig,. CS345H: Programming Languages Lecture 12: Type Inference.
Read more >9.6. Type Inference — OCaml Programming - GitHub Pages
We introduce a fresh type variable 't for the type of the application expression. We use inference to determine the types of the...
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
Okay, adding enums is not what we want. However, I’d anyway expect that
MyEnum returns string: 'on'
would generate a typeon
forMyEnum
and not just a string. It’s like a enum with the only one element, and if forMyEnum returns string: 'on' | 'off'
we generate a type'on' | 'off'
, why not do the same for the only one type alternative?@dhuebner, yes, I like this idea. For example, this
will generate
So, addition a keyword
enum
restricts to use only data type rules in a union, and we can infer type like a union of these data type rules without tries to evaluate a pattern.