Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Support generic types in a Component/Directive #68

Closed
frankpepermans opened this issue Sep 7, 2016 · 7 comments
Closed

Support generic types in a Component/Directive #68

frankpepermans opened this issue Sep 7, 2016 · 7 comments

Comments

@frankpepermans
Copy link

frankpepermans commented Sep 7, 2016

This occurs when I compile using dart2js,

Say I have a Component defined as such:

class MyComponent<T extends something>

and I want to inject the following property:

final Container<T> myContainer;

I use @Inject(Container) this.myContainer; (generic type is not allowed here)

This generates the following warning:

[Warning from Dart2JS on ...]:
packages\...:
Cannot resolve type 'T'.
(Container<T> myContainer) => new MyComponent(myContainer),
          ^
@matanlurey
Copy link
Contributor

We currently don't retain type information during the compile.

Blocked by #48.

@matanlurey matanlurey added this to the Type-aware compiler milestone Dec 26, 2016
@matanlurey matanlurey removed this from the Type-aware compiler milestone Jan 20, 2017
@matanlurey
Copy link
Contributor

Investigating feasibility for 4.0.0. One issue there isn't a way to express this:

@Inject(Container<String>)

/cc @kevmoo Is this something planned for the Dart language in the very near future?

@zoechi
Copy link

zoechi commented Apr 5, 2017

What about something like @Inject(const InjectionToken(Container, const[String]))

@matanlurey
Copy link
Contributor

This is not planned for 4.0.0 at this time (other lower-hanging fruit).

@matanlurey matanlurey added this to the Post-V4 milestone May 12, 2017
@matanlurey matanlurey changed the title template compiler: generic types are dropped Support generic types in a Component/Directive Jun 9, 2017
@matanlurey
Copy link
Contributor

Open question: How should we implement this?

@matanlurey
Copy link
Contributor

We should try to gather internal data on how often generic components are used.

@matanlurey matanlurey modified the milestones: V5, V6+ Feb 26, 2018
@matanlurey
Copy link
Contributor

I think based on how Dart2 works, this is not likely to happen for V5.

I've marked this to revisit in V6+.

@matanlurey matanlurey assigned leonsenft and unassigned matanlurey Aug 8, 2018
leonsenft added a commit that referenced this issue Sep 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants