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
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
export type ElChildren = | ElChildren.Void | ElChildren.Text; export namespace ElChildren { export type Void = undefined; export type Text = string; } type Relax<C extends ElChildren> = C extends ElChildren.Text ? ElChildren.Text : C; export class Elem< C extends ElChildren, > { constructor( private children_: Relax<C>, ) { } } new Elem(undefined as ElChildren.Void); new Elem('' as ElChildren.Text); new Elem('' as ElChildren.Void | ElChildren.Text); // error new Elem('' as ElChildren); // error
Expected behavior:
pass
Actual behavior:
Argument of type 'ElChildren' is not assignable to parameter of type 'undefined'. Type 'string' is not assignable to type 'undefined'.
Playground Link: http://www.typescriptlang.org/play/index.html#src=export%20type%20ElChildren%20%3D%0D%0A%20%20%7C%20ElChildren.Void%0D%0A%20%20%7C%20ElChildren.Text%3B%0D%0Aexport%20namespace%20ElChildren%20%7B%0D%0A%20%20export%20type%20Void%20%3D%20undefined%3B%0D%0A%20%20export%20type%20Text%20%3D%20string%3B%0D%0A%7D%0D%0A%0D%0Atype%20Relax%3CC%20extends%20ElChildren%3E%20%3D%20C%20extends%20ElChildren.Text%20%3F%20ElChildren.Text%20%3A%20C%3B%0D%0A%0D%0Aexport%20class%20Elem%3C%0D%0A%20%20C%20extends%20ElChildren%2C%0D%0A%20%20%3E%20%7B%0D%0A%20%20constructor(%0D%0A%20%20%20%20private%20children_%3A%20Relax%3CC%3E%2C%0D%0A%20%20)%20%7B%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0Anew%20Elem(undefined%20as%20ElChildren.Void)%3B%0D%0Anew%20Elem(''%20as%20ElChildren.Text)%3B%0D%0Anew%20Elem(''%20as%20ElChildren.Void%20%7C%20ElChildren.Text)%3B%0D%0Anew%20Elem(''%20as%20ElChildren)%3B
Related Issues:
The text was updated successfully, but these errors were encountered:
weswigham
Successfully merging a pull request may close this issue.
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
Expected behavior:
pass
Actual behavior:
Playground Link: http://www.typescriptlang.org/play/index.html#src=export%20type%20ElChildren%20%3D%0D%0A%20%20%7C%20ElChildren.Void%0D%0A%20%20%7C%20ElChildren.Text%3B%0D%0Aexport%20namespace%20ElChildren%20%7B%0D%0A%20%20export%20type%20Void%20%3D%20undefined%3B%0D%0A%20%20export%20type%20Text%20%3D%20string%3B%0D%0A%7D%0D%0A%0D%0Atype%20Relax%3CC%20extends%20ElChildren%3E%20%3D%20C%20extends%20ElChildren.Text%20%3F%20ElChildren.Text%20%3A%20C%3B%0D%0A%0D%0Aexport%20class%20Elem%3C%0D%0A%20%20C%20extends%20ElChildren%2C%0D%0A%20%20%3E%20%7B%0D%0A%20%20constructor(%0D%0A%20%20%20%20private%20children_%3A%20Relax%3CC%3E%2C%0D%0A%20%20)%20%7B%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0Anew%20Elem(undefined%20as%20ElChildren.Void)%3B%0D%0Anew%20Elem(''%20as%20ElChildren.Text)%3B%0D%0Anew%20Elem(''%20as%20ElChildren.Void%20%7C%20ElChildren.Text)%3B%0D%0Anew%20Elem(''%20as%20ElChildren)%3B
Related Issues:
The text was updated successfully, but these errors were encountered: