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

Need support for type alias checking... #6461

Closed
qdwang opened this issue Jan 13, 2016 · 2 comments
Closed

Need support for type alias checking... #6461

qdwang opened this issue Jan 13, 2016 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@qdwang
Copy link

qdwang commented Jan 13, 2016

type price = number;
type size = number;

var a: price = 1;
var b: price = 1;

var c: size = 1;
var d: size = 1;

console.log(a + b); // this should work;
console.log(a + c); // this should fail;

Or is there an alternative way to achieve this?

@sandersn
Copy link
Member

You can use an interface with a private brand, but type aliases are pure aliases -- they have no [nominal] identity of their own. #364 covers units of measure, which is related, and actually has a concrete proposal open.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 13, 2016
@RyanCavanaugh
Copy link
Member

See also #202

@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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants