Returned tuples don't match compatible types when using function union types
See original GitHub issueThe first error is especially odd.
TypeScript Version: 3.7.x-dev.20200104
Search Terms:
Code
type C1 = (a: 1) => [0];
type C2 = (a: 2) => [number];
type C3 = (a: 3) => undefined;
declare function f(a: C1 | C3): void;
f(() => [0]);
declare function g(a: C2 | C3): void;
g(() => [0]);
Expected behavior: pass Actual behavior: Type ‘number’ is not assignable to type ‘0’.(2322) Property ‘0’ is missing in type ‘number[]’ but required in type ‘[number]’.(2741) Playground Link: http://www.typescriptlang.org/play/index.html?ts=3.8.0-dev.20200104&ssl=1&ssc=1&pln=8&pc=14#code/C4TwDgpgBAwgjFAvFAFAQwFxTgSiQPigG0AGAXQG4AoUSWAJiVUynr0UKIDsBXAWwBGEAE6Ua4aDADMTdFintCPLgBMIAMwCWXCCupU1AYwA2aYdHXLDwTQHsuUdXNgIAPrAVYAbrc16qTiiKxOQ41Eam5o5WNvZQAObOMIzu0jjevv6JQQQhZGFAA
Related Issues:
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Handbook - Unions and Intersection Types - TypeScript
How to use unions and intersection types in TypeScript. ... Function lacks ending return statement and return type does not include 'undefined'.2366Function ......
Read more >Type manipulations: union to tuple · Issue #13298 - GitHub
The suggestion is for a keyword similar to keyof that, when given a union type, would result in a tuple type that includes...
Read more >typing — Support for type hints — Python 3.11.1 documentation
The Python runtime does not enforce function and variable type ... UnionType and the ability to use the binary-or operator | to signify...
Read more >python - How to specify multiple return types using type-hints
A union object holds the value of the | (bitwise or) operation on multiple type objects. These types are intended primarily for type...
Read more >Type Constraints - Configuration Language | Terraform
Values that match the object type must contain all of the specified keys, and the value for each key must match its specified...
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 Free
Top 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
@jcalz Your stupid comments are really useless and annoying. Don’t touch my issues. I’m not posting issues to talk to you.
Magic? (No, I’m not sure.)