Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Support generics on methods #282

Closed
Closed
@tbosch

Description

@tbosch

It would be nice to write something like this:

function add<NUM>(a:NUM):NUM {...}

and have the following in Dart:

/*<NUM>*/ add/*<NUM>*/(/*<NUM>*/ a){...}

This is needed in Angular e.g. for ViewContainerRef.createEmbeddedView:
I would like to write this:

createEmbeddedView<C>(templateRef: TemplateRef<C>, context?: C,
                              index?: number): EmbeddedViewRef<C>

But right now ts2dart outputs this:

EmbeddedViewRef<C> createEmbeddedView/*< C >*/(TemplateRef<C> templateRef,
      [C context, num index]);

The tricky bit here is that this output of ts2dart would be correct if ViewContainerRef had a generic C declared on itself (e.g. class ViewContainerRef<C> { ...}). However, in this case, the generic originates just from the method itself.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions