Skip to content
New issue

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

transpiler: Add support for generics to traceur. Type<SubType1, SubType2> #8

Closed
tbosch opened this issue Sep 25, 2014 · 12 comments
Closed
Assignees

Comments

@tbosch
Copy link
Contributor

tbosch commented Sep 25, 2014

var x:Array<SubType> = []

at runtime we would call 

Array.of(SubType)
@tbosch
Copy link
Contributor Author

tbosch commented Sep 25, 2014

Changed parser to just eat up the generics, no change to the AST yet.
See https://github.com/angular/angular/blob/master/tools/js2dart/src/parser.js#L12

@naomiblack naomiblack changed the title js2dart: Add support for generics to traceur. Type<SubType1, SubType2> transpiler: Add support for generics to traceur. Type<SubType1, SubType2> Sep 29, 2014
@mhevery mhevery modified the milestone: October Sep 29, 2014
@naomiblack naomiblack added ready and removed ready labels Oct 14, 2014
@vicb
Copy link
Contributor

vicb commented Oct 29, 2014

Traceur has just added support for generics, see google/traceur-compiler@32aadd5

@Alxandr
Copy link
Contributor

Alxandr commented Nov 7, 2014

This means @InjectPromise(UserList) userList should be changed to userList: Promise<UserList> with regards to di injection, right?

@vojtajina
Copy link
Contributor

Here is my understanding of the state of this feature (@vicb can correct me):
Traceur does parse the generics (type arguments). That is all.

We are missing:

  • generate runtime annotations
  • generate runtime type assertions (probably the same format as annotations)
  • output the generics in the dart code
  • output the generics in the ES6 code (we don't need this, but would be nice)

How do we generate type annotations and runtime type assertions? I suggest this:

function foo(a: Bar, b: Bar<Baz>) {}

// Currently we generate this:
foo.parameters = [[Bar]];

// I suggest to generate this:
foo.parameters = [[new TypeAnnotation(Bar)], [new TypeAnnotation(Bar, Baz)]];

That means, traceur-runtime need to define the TypeAnnotation class.

How about type assertions? Should we do something like this?

function foo(a, b) {
  assert.argumentTypes(a, new TypeAnnotation(Bar), b, new TypeAnnotation(Bar, Baz));
}

Thoughts? @mhevery @arv

@mhevery
Copy link
Contributor

mhevery commented Nov 12, 2014

I was thinking something along these lines:

function foo(a: Bar, b: Bar<Baz>) {}

foo.parameters = [Bar, Bar.parameterize(Baz)];

This means that only types which define parameterize method can be generecized. The purpose of the parameterize is to crate (or returned a cache) of a new type which is parameterize on such a type an which can than be used for assertions as normal.

Thoughts?

@Alxandr
Copy link
Contributor

Alxandr commented Nov 12, 2014

@mhevery That would indicate that if I write a generic class, it would generate a parameterize static method automagically?

@vojtajina
Copy link
Contributor

@mhevery I like this! It would be good to limit the amount of garbage we create.

@Alxandr yes, we can generate the .parameterize method. That just reminds me we need one more thing - update the parser to allow class Foo<...> so that you can actually define parametrizable types. For these, Traceur would also generate the parametrize method.

@vojtajina
Copy link
Contributor

So here's the updated list of tasks:

@vojtajina
Copy link
Contributor

I'm going to work on this today.

@arv
Copy link

arv commented Nov 12, 2014

For Traceur, I currently transform the TypeReference

A<B, C>

to

$traceurRuntime.genericType(A2, B2, C2);
// where A2 is the transformed A

which in turn creates a new instance of $traceurRuntime.GenericType. The last step is important so that the assertion library can do instanceof to see if it is a generic.

google/traceur-compiler@633acbc#diff-c5472491bfb53e84718d853046894688R39

This is all very adhoc at the moment.

@vojtajina vojtajina assigned vicb and unassigned vojtajina Nov 18, 2014
@vicb vicb added in progress and removed ready labels Dec 5, 2014
vicb added a commit to vicb/angular that referenced this issue Dec 17, 2014
@vicb vicb closed this as completed in f04967a Jan 6, 2015
@vicb vicb removed the in progress label Jan 6, 2015
@tbosch
Copy link
Contributor Author

tbosch commented Feb 6, 2015

We actually never removed our hack from our transpiler, so we never used the new feature from traceur. See #554

kegluneq pushed a commit that referenced this issue Mar 21, 2015
`guinness` is a Dart port of Jasmine. Since the rest of Angular 2 uses
Jasmine, use it for the transformer too.

Closes #8

Closes #1037

Closes #1000
gkalpak added a commit to gkalpak/angular that referenced this issue May 31, 2019
mhevery pushed a commit that referenced this issue May 31, 2019
gkalpak added a commit to gkalpak/angular that referenced this issue Jun 7, 2019
mhevery pushed a commit that referenced this issue Jun 7, 2019
gkalpak added a commit to gkalpak/angular that referenced this issue Jun 11, 2019
Updating [angular#8.0.x](https://github.com/angular/angular/tree/8.0.x) from [cli-builds#8.0.x](https://github.com/angular/cli-builds/tree/8.0.x).

##
Relevant changes in [commit range](angular/cli-builds@d09f130...e567d15):

**Modified**
- help/build.json
- help/generate.json
- help/new.json
- help/serve.json
- help/test.json

##
AndrewKushnir pushed a commit that referenced this issue Jun 11, 2019
)

Updating [#8.0.x](https://github.com/angular/angular/tree/8.0.x) from [cli-builds#8.0.x](https://github.com/angular/cli-builds/tree/8.0.x).

##
Relevant changes in [commit range](angular/cli-builds@d09f130...e567d15):

**Modified**
- help/build.json
- help/generate.json
- help/new.json
- help/serve.json
- help/test.json

##

PR Close #30971
gkalpak added a commit to gkalpak/angular that referenced this issue Jun 12, 2019
AndrewKushnir pushed a commit that referenced this issue Jun 12, 2019
gkalpak added a commit to gkalpak/angular that referenced this issue Jun 27, 2019
Updating [angular#8.1.x](https://github.com/angular/angular/tree/8.1.x) from [cli-builds#8.0.x](https://github.com/angular/cli-builds/tree/8.0.x).

##
Relevant changes in [commit range](angular/cli-builds@01a7186...823731f):

**Modified**
- help/analytics.json
- help/build.json
- help/e2e.json
- help/generate.json
- help/new.json
- help/serve.json
- help/test.json
- help/update.json
- help/xi18n.json

##
alxhub pushed a commit that referenced this issue Jun 27, 2019
)

Updating [#8.1.x](https://github.com/angular/angular/tree/8.1.x) from [cli-builds#8.0.x](https://github.com/angular/cli-builds/tree/8.0.x).

##
Relevant changes in [commit range](angular/cli-builds@01a7186...823731f):

**Modified**
- help/analytics.json
- help/build.json
- help/e2e.json
- help/generate.json
- help/new.json
- help/serve.json
- help/test.json
- help/update.json
- help/xi18n.json

##

PR Close #31308
gkalpak added a commit to gkalpak/angular that referenced this issue Jul 18, 2019
Updating [angular#8.1.x](https://github.com/angular/angular/tree/8.1.x) from [cli-builds#8.1.x](https://github.com/angular/cli-builds/tree/8.1.x).

##
Relevant changes in [commit range](angular/cli-builds@823731f...f99913e):

**Modified**
- help/add.json
- help/analytics.json
- help/build.json
- help/doc.json
- help/e2e.json
- help/generate.json
- help/new.json
- help/serve.json
- help/test.json
- help/update.json
- help/xi18n.json

##
mhevery pushed a commit that referenced this issue Jul 18, 2019
)

Updating [#8.1.x](https://github.com/angular/angular/tree/8.1.x) from [cli-builds#8.1.x](https://github.com/angular/cli-builds/tree/8.1.x).

##
Relevant changes in [commit range](angular/cli-builds@823731f...f99913e):

**Modified**
- help/add.json
- help/analytics.json
- help/build.json
- help/doc.json
- help/e2e.json
- help/generate.json
- help/new.json
- help/serve.json
- help/test.json
- help/update.json
- help/xi18n.json

##

PR Close #31620
gkalpak added a commit to gkalpak/angular that referenced this issue Jul 26, 2019
gkalpak added a commit to gkalpak/angular that referenced this issue Jul 26, 2019
AndrewKushnir pushed a commit that referenced this issue Jul 26, 2019
gkalpak added a commit to gkalpak/angular that referenced this issue Jul 31, 2019
AndrewKushnir pushed a commit that referenced this issue Jul 31, 2019
gkalpak added a commit to gkalpak/angular that referenced this issue Aug 15, 2019
AndrewKushnir pushed a commit that referenced this issue Aug 15, 2019
gkalpak added a commit to gkalpak/angular that referenced this issue Aug 17, 2019
Updating [angular#8.2.x](https://github.com/angular/angular/tree/8.2.x) from [cli-builds#8.3.x](https://github.com/angular/cli-builds/tree/8.3.x).

##
Relevant changes in [commit range](angular/cli-builds@43fc440...e0055d2):

**Added**
- help/deploy.json

**Modified**
- help/generate.json
- help/new.json
- help/serve.json

##
AndrewKushnir pushed a commit that referenced this issue Aug 19, 2019
)

Updating [#8.2.x](https://github.com/angular/angular/tree/8.2.x) from [cli-builds#8.3.x](https://github.com/angular/cli-builds/tree/8.3.x).

##
Relevant changes in [commit range](angular/cli-builds@43fc440...e0055d2):

**Added**
- help/deploy.json

**Modified**
- help/generate.json
- help/new.json
- help/serve.json

##

PR Close #32175
gkalpak added a commit to gkalpak/angular that referenced this issue Aug 22, 2019
gkalpak added a commit to gkalpak/angular that referenced this issue Aug 23, 2019
Updating [angular#8.2.x](https://github.com/angular/angular/tree/8.2.x) from [cli-builds#8.3.x](https://github.com/angular/cli-builds/tree/8.3.x).

##
Relevant changes in [commit range](angular/cli-builds@e0055d2...166cd15):

**Modified**
- help/add.json
- help/deploy.json

##
atscott pushed a commit that referenced this issue Aug 23, 2019
)

Updating [#8.2.x](https://github.com/angular/angular/tree/8.2.x) from [cli-builds#8.3.x](https://github.com/angular/cli-builds/tree/8.3.x).

##
Relevant changes in [commit range](angular/cli-builds@e0055d2...166cd15):

**Modified**
- help/add.json
- help/deploy.json

##

PR Close #32286
gkalpak added a commit to gkalpak/angular that referenced this issue Aug 24, 2019
atscott pushed a commit that referenced this issue Aug 26, 2019
gkalpak added a commit to gkalpak/angular that referenced this issue Aug 30, 2019
matsko pushed a commit that referenced this issue Aug 30, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants