We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It can create lots of new types easily and structurally.
function build<N, T>() { return <{ (a: N & T): void; (a: T): N & T; }>((a: T) => a); } namespace Types { export namespace Nominal1 { class Nominal<T> { private NOMINAL: T; } export type A = Nominal<'A'> & number; export const A = build<Nominal<'A'>, number>(); export type B = Nominal<'B'> & number; export const B = build<Nominal<'B'>, number>(); } } namespace Types { export namespace Nominal2 { class Nominal<T> { private NOMINAL: T; } export type A = Nominal<'A'> & number; export const A = build<Nominal<'A'>, number>(); export type B = Nominal<'B'> & number; export const B = build<Nominal<'B'>, number>(); } } var a1: Types.Nominal1.A; var b1: Types.Nominal1.B; var a2: Types.Nominal2.A; a1 = b1; // error a1 = a2; // error a1 = Types.Nominal1.A(0); // ok a1 = Types.Nominal1.A(a1); // error a1 = Types.Nominal1.B(0); // error a1 = Types.Nominal2.A(0); // error
The text was updated successfully, but these errors were encountered:
looks like the same topic as in #4895. i suggest moving the discussion there.
Sorry, something went wrong.
This issue posted only for documentation. This is a different technique, and has a different purpose from #4895.
I understand; #4895 is a discussion item that is meant for brainstorming and sharing ideas.
No branches or pull requests
It can create lots of new types easily and structurally.
The text was updated successfully, but these errors were encountered: