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.

Returned tuples don't match compatible types when using function union types

See original GitHub issue

The 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:open
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
falsandtrucommented, Jan 8, 2020

@jcalz Your stupid comments are really useless and annoying. Don’t touch my issues. I’m not posting issues to talk to you.

1reaction
jcalzcommented, Jan 7, 2020

Magic? (No, I’m not sure.)

Read more comments on GitHub >

github_iconTop 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 >

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