Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloads with singleton string literal types have assignability issues #6276

Closed
DanielRosenwasser opened this issue Dec 28, 2015 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Literal Types Unit types including string literal types, numeric literal types, Boolean literals, null, undefined Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

The following compiles:

function f(x: "foo"): number;
function f(x: string): number {
    return 0;
}

function g(x: "bar"): number;
function g(x: string): number {
    return 0;
}

var a = f;
var b = g;

a = b;
b = a;

This is because specialized overloads are ignored for assignment compatibility purposes.

Related to #6143.

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Dec 28, 2015
@DanielRosenwasser DanielRosenwasser self-assigned this Dec 28, 2015
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 1.8 milestone Dec 28, 2015
@DanielRosenwasser DanielRosenwasser added the Domain: Literal Types Unit types including string literal types, numeric literal types, Boolean literals, null, undefined label Jan 4, 2016
@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Feb 20, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: Literal Types Unit types including string literal types, numeric literal types, Boolean literals, null, undefined Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants