-
Notifications
You must be signed in to change notification settings - Fork 62
feat(): Add support for void generic argument, which translates to dynamic #334
Conversation
@@ -76,7 +78,13 @@ export class TranspilerBase { | |||
maybeVisitTypeArguments(n: {typeArguments?: ts.NodeArray<ts.TypeNode>}) { | |||
if (n.typeArguments) { | |||
this.emit('<'); | |||
this.visitList(n.typeArguments); | |||
this.visitList(n.typeArguments, ',', (node) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, I think it'd be better to make this code less generic, and only specifically handle the case of a single type argument that's void
by just leaving out the type argument.
This code is arguable better by being more generic, but in this case we should be restrictive - we shouldn't support patterns that are going to cause odd APIs for Dart users, when we really only need to support Promise<void>
and EventEmitter<void>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -75,6 +75,10 @@ export class TranspilerBase { | |||
|
|||
maybeVisitTypeArguments(n: {typeArguments?: ts.NodeArray<ts.TypeNode>}) { | |||
if (n.typeArguments) { | |||
// If it's a single type argument `<void>`, ignore it and emit nothing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could you mention that this is for e.g. Promise<void>
, and link to dart-lang/sdk#2231 (comment) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Will submit.
One nit, LGTM otherwise. |
This allows us to use stuff like:
Which before was harder because we couldn't use
void
as a generic type.