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

Assignability check skipped for unique symbols #21584

Closed
rbuckton opened this issue Feb 2, 2018 · 0 comments
Closed

Assignability check skipped for unique symbols #21584

rbuckton opened this issue Feb 2, 2018 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@rbuckton
Copy link
Member

rbuckton commented Feb 2, 2018

TypeScript Version: 2.8.0-dev.20180202

In #20898 @rozzzly discovered a bug that was tangential to that issue:

On a side note, I think I may have found a bug. So while typing up this issue, I found that I am able to achieve the desired behavior by using an intersection with a "tagged" object literal:

export type FOO = symbol & { FOO: true };
export const FOO: FOO = Symbol('FOO'); // ❓️ no error

We also don't see the error for declarations like:

const FOO: string = Symbol();

Expected behavior:

This should report the error: error TS2322: Type 'unique symbol' is not assignable to type 'symbol & { FOO: true; }'.

Actual behavior:

No error is reported. This is because getESSymbolLikeTypeForNode uses the type property on SymbolLinks which already has a type from the declaration, so it gets symbol & { FOO: true }.

Related Issues:

@rbuckton rbuckton added the Bug A bug in TypeScript label Feb 2, 2018
@rbuckton rbuckton self-assigned this Feb 2, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 5, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants