-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Quick Infoe.g. hover text, tool-tips, and tooltips.e.g. hover text, tool-tips, and tooltips.Help WantedYou can do thisYou can do this
Milestone
Description
Bug Report
π Search Terms
- unique symbol
- type inference
- opaque
π Version & Regression Information
- This changed between versions v4.9.5 and v5.0.2
- The nightly build also has the bug
β― Playground Link
π» Code
declare const tag: unique symbol;
type Tagged<Token> = {
readonly [tag]?: Token;
};
export type Opaque<Type, Token = unknown> = Type & Tagged<Token>;
export type Query<_V, _R> = Opaque<string>;
const q: Query<{}, {}> = 'query {}'The opaque type that I borrowed from:
- https://younho9.dev/how-to-iterate-object-more-safely (Korean)
- https://evertpot.com/opaque-ts-types/
π Actual behavior
The type of q is annotated correctly, Query<{}, {}> while the declaration of Query is on the same file. However, when I moved it to another file, the q is inferred as Query<_V, _R>. It is not reproduced on v4.9.5.
π Expected behavior
The type of q should be inferred as Query<{}, {}> wherever the declaration of Query is located.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Quick Infoe.g. hover text, tool-tips, and tooltips.e.g. hover text, tool-tips, and tooltips.Help WantedYou can do thisYou can do this