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

feat(common): rename underlying NgFor class and add a type parameter #14104

Closed
wants to merge 3 commits into from

Conversation

chuckjaz
Copy link
Contributor

@chuckjaz chuckjaz commented Jan 25, 2017

feat(compiler): generate a type parameters for generic type references
feat(tsc-wrapped): record arity of generic classes

Note, this affects the underlying class and should not affect usage.

DEPRECATION:

  • the NgFor class is now deprecated. Use NgForOf<T> instead.
    IMPORTANT: Only the NgFor class is deprecated, not the ngFor
    directive. The *ngFor and related directives are unaffected by
    this change as references to the NgFor class generated from
    templates will be automatically converted to references to
    NgForOf<T> without requiring any template modifications.
  • TrackByFn is now deprecated. Use TrackByFunction<T> instead.

Migration:

  • Replace direct references to the NgFor class to NgForOf<any>.
  • Replace references to TrackByFn to TrackByFunction<any>.

BREAKING CHANGE:
A definition of Iterable<T> is now required to correctly compile
Angular applications. Support for Iterable<T> is not required at
runtime but a type definition Iterable<T> must be available.

NgFor, and now NgForOf<T>, already supports Iterable<T> at
runtime. With this change the type definition is updated to reflect
this support.

Migration:

  • add "es2015.iterable.ts" to your tsconfig.json "libs" fields.

What kind of change does this PR introduce? (check one with "x")

[x] Feature

What is the current behavior? (You can also link to an open issue here)

NgFor uses NgForRow for its context which has a $implicit type of any. The type of $implicit should be the element type of the iterator assigned to the ngForOf property.

The class name NgFor is incorrect as well as it implies it is associated with the ngFor directive instead of the ngForOf directive. Calling it NgFor seems to imply that if we add syntax to support iterating the fields of an object such as for...in, NgFor would need to host the code instead of creating a new class.

The TypeScript code generation does not supply the correct number of type arguments to classes with generic parameters.

What is the new behavior?

A new class is created, NgForOf<T> and the old class is deprecated and transformed into a derived class class NgFor extends NgForOf<any> {}.

The TypeScript emitter was changed to generate the correct number of type parameters for references to generic types.

The TypeScript code generation will generate NgForOf<any> for references to this class. However, once #12398 lands, the type parameter would be used to validate references to the context$implicit

Does this PR introduce a breaking change? (check one with "x")

[x] Yes
[ ] No

This change requires the project's tsconfig.json to include a definition of Iterable<T> to in the global scope. This can be accomplished by adding "es2015.iterable" into the "libs" field.

@vicb
Copy link
Contributor

vicb commented Jan 25, 2017

feat(compile): generate a type parameters for generic type references
feat(tsc-wrapped): record arity of generic classes

Should this be 2 separate commits ?

@chuckjaz
Copy link
Contributor Author

Sure. Do you want three commits, one for adding arity, one for adding generics and one for renaming NgFor etc?

@chuckjaz chuckjaz force-pushed the ngfor-type-parameter branch 3 times, most recently from e40e6f6 to f4bc94c Compare January 25, 2017 21:50
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 25, 2017
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 25, 2017
…ngular#14104)

DEPRECATION:
- `NgFor` is now deprecated. Use `NgForOf<T>` instead.
- `TrackByFn` is not deprecated. Use `TrackByFunciton<T>` instead.

Migration:
- Most code is unaffected by this change as references to `NgFor`
  are generated by the AOT compiler. No template changes required.
- Replace references to `NgFor` to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

Part of angular#12398
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 25, 2017
…ngular#14104)

DEPRECATION:
- `NgFor` is now deprecated. Use `NgForOf<T>` instead.
- `TrackByFn` is not deprecated. Use `TrackByFunciton<T>` instead.

Migration:
- Most code is unaffected by this change as references to `NgFor`
  are generated by the AOT compiler. No template changes required.
- Replace references to `NgFor` to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

Part of angular#12398
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 25, 2017
…ngular#14104)

DEPRECATION:
- `NgFor` is now deprecated. Use `NgForOf<T>` instead.
- `TrackByFn` is not deprecated. Use `TrackByFunciton<T>` instead.

Migration:
- Most code is unaffected by this change as references to `NgFor`
  are generated by the AOT compiler. No template changes required.
- Replace references to `NgFor` to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

Part of angular#12398
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 25, 2017
…ngular#14104)

DEPRECATION:
- `NgFor` is now deprecated. Use `NgForOf<T>` instead.
- `TrackByFn` is not deprecated. Use `TrackByFunciton<T>` instead.

Migration:
- Most code is unaffected by this change as references to `NgFor`
  are generated by the AOT compiler. No template changes required.
- Replace references to `NgFor` to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

Part of angular#12398
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 27, 2017
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 27, 2017
…ngular#14104)

DEPRECATION:
- `NgFor` is now deprecated. Use `NgForOf<T>` instead.
- `TrackByFn` is not deprecated. Use `TrackByFunciton<T>` instead.

Migration:
- Most code is unaffected by this change as references to `NgFor`
  are generated by the AOT compiler. No template changes required.
- Replace references to `NgFor` to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

Part of angular#12398
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 28, 2017
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 28, 2017
…ngular#14104)

DEPRECATION:
- `NgFor` is now deprecated. Use `NgForOf<T>` instead.
- `TrackByFn` is not deprecated. Use `TrackByFunciton<T>` instead.

Migration:
- Most code is unaffected by this change as references to `NgFor`
  are generated by the AOT compiler. No template changes required.
- Replace references to `NgFor` to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

Part of angular#12398
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 28, 2017
…ngular#14104)

DEPRECATION:
- `NgFor` is now deprecated. Use `NgForOf<T>` instead.
- `TrackByFn` is not deprecated. Use `TrackByFunciton<T>` instead.

Migration:
- Most code is unaffected by this change as references to `NgFor`
  are generated by the AOT compiler. No template changes required.
- Replace references to `NgFor` to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

BREAKING CHANGE:
A definition of `Iterable<T>` is now required to correctly compile
Angular applications. Support for `Iterable<T>` is not required at
runtime but a type definition must be available.

Migration:
- adding "es2015.iterable.ts" to your tsconfig.json "libs" fields.

Part of angular#12398
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 28, 2017
…ter (angular#14104)

DEPRECATION:
- the `NgFor` class is now deprecated. Use `NgForOf<T>` instead.
  IMPORTANT: Only the `NgFor` class is deprecated, not the `ngFor`
  directive. The `*ngFor` and related directives are unaffected by
  this change  as references to the `NgFor` class generated from
  templates will be automatically converted to references to
  `NgForOf<T>` without requiring any template modifications.
- `TrackByFn` is now deprecated. Use `TrackByFunction<T>` instead.

Migration:
- Replace direct references to the `NgFor` class to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

BREAKING CHANGE:
A definition of `Iterable<T>` is now required to correctly compile
Angular applications. Support for `Iterable<T>` is not required at
runtime but a type definition `Iterable<T>` must be available.

`NgFor`, and now `NgForOf<T>`, already supports `Iterable<T>` at
runtime. With this change the type definition is updated to reflect
this support.

Migration:
- add "es2015.iterable.ts" to your tsconfig.json "libs" fields.

Part of angular#12398
@chuckjaz chuckjaz changed the title feat(common): rename NgFor to NgForOf and add a type parameter feat(common): rename NgFor class to NgForOf and add a type parameter Jan 28, 2017
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 30, 2017
angular#14104)

Note, this affects the underlying class and should not affect usage.

DEPRECATION:
- the `NgFor` class is now deprecated. Use `NgForOf<T>` instead.
  IMPORTANT: Only the `NgFor` class is deprecated, not the `ngFor`
  directive. The `*ngFor` and related directives are unaffected by
  this change  as references to the `NgFor` class generated from
  templates will be automatically converted to references to
  `NgForOf<T>` without requiring any template modifications.
- `TrackByFn` is now deprecated. Use `TrackByFunction<T>` instead.

Migration:
- Replace direct references to the `NgFor` class to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

BREAKING CHANGE:
A definition of `Iterable<T>` is now required to correctly compile
Angular applications. Support for `Iterable<T>` is not required at
runtime but a type definition `Iterable<T>` must be available.

`NgFor`, and now `NgForOf<T>`, already supports `Iterable<T>` at
runtime. With this change the type definition is updated to reflect
this support.

Migration:
- add "es2015.iterable.ts" to your tsconfig.json "libs" fields.

Part of angular#12398
@chuckjaz chuckjaz changed the title feat(common): rename NgFor class to NgForOf and add a type parameter feat(common): rename underlying NgFor class and add a type parameter Jan 30, 2017
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 30, 2017
angular#14104)

Note, this affects the underlying class and should not affect usage.

DEPRECATION:
- the `NgFor` class is now deprecated. Use `NgForOf<T>` instead.
  IMPORTANT: Only the `NgFor` class is deprecated, not the `ngFor`
  directive. The `*ngFor` and related directives are unaffected by
  this change  as references to the `NgFor` class generated from
  templates will be automatically converted to references to
  `NgForOf<T>` without requiring any template modifications.
- `TrackByFn` is now deprecated. Use `TrackByFunction<T>` instead.

Migration:
- Replace direct references to the `NgFor` class to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

BREAKING CHANGE:
A definition of `Iterable<T>` is now required to correctly compile
Angular applications. Support for `Iterable<T>` is not required at
runtime but a type definition `Iterable<T>` must be available.

`NgFor`, and now `NgForOf<T>`, already supports `Iterable<T>` at
runtime. With this change the type definition is updated to reflect
this support.

Migration:
- add "es2015.iterable.ts" to your tsconfig.json "libs" fields.

Part of angular#12398
chuckjaz added a commit to chuckjaz/angular that referenced this pull request Jan 30, 2017
angular#14104)

Note, this affects the underlying class and should not affect usage.

DEPRECATION:
- the `NgFor` class is now deprecated. Use `NgForOf<T>` instead.
  IMPORTANT: Only the `NgFor` class is deprecated, not the `ngFor`
  directive. The `*ngFor` and related directives are unaffected by
  this change  as references to the `NgFor` class generated from
  templates will be automatically converted to references to
  `NgForOf<T>` without requiring any template modifications.
- `TrackByFn` is now deprecated. Use `TrackByFunction<T>` instead.

Migration:
- Replace direct references to the `NgFor` class to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

BREAKING CHANGE:
A definition of `Iterable<T>` is now required to correctly compile
Angular applications. Support for `Iterable<T>` is not required at
runtime but a type definition `Iterable<T>` must be available.

`NgFor`, and now `NgForOf<T>`, already supports `Iterable<T>` at
runtime. With this change the type definition is updated to reflect
this support.

Migration:
- add "es2015.iterable.ts" to your tsconfig.json "libs" fields.

Part of angular#12398
angular#14104)

Note, this affects the underlying class and should not affect usage.

DEPRECATION:
- the `NgFor` class is now deprecated. Use `NgForOf<T>` instead.
  IMPORTANT: Only the `NgFor` class is deprecated, not the `ngFor`
  directive. The `*ngFor` and related directives are unaffected by
  this change  as references to the `NgFor` class generated from
  templates will be automatically converted to references to
  `NgForOf<T>` without requiring any template modifications.
- `TrackByFn` is now deprecated. Use `TrackByFunction<T>` instead.

Migration:
- Replace direct references to the `NgFor` class to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

BREAKING CHANGE:
A definition of `Iterable<T>` is now required to correctly compile
Angular applications. Support for `Iterable<T>` is not required at
runtime but a type definition `Iterable<T>` must be available.

`NgFor`, and now `NgForOf<T>`, already supports `Iterable<T>` at
runtime. With this change the type definition is updated to reflect
this support.

Migration:
- add "es2015.iterable.ts" to your tsconfig.json "libs" fields.

Part of angular#12398
@chuckjaz chuckjaz removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jan 31, 2017
@mhevery mhevery added the action: merge The PR is ready for merge by the caretaker label Jan 31, 2017
@mhevery mhevery closed this in 86b2b25 Feb 1, 2017
mhevery pushed a commit that referenced this pull request Feb 1, 2017
#14104)

Note, this affects the underlying class and should not affect usage.

DEPRECATION:
- the `NgFor` class is now deprecated. Use `NgForOf<T>` instead.
  IMPORTANT: Only the `NgFor` class is deprecated, not the `ngFor`
  directive. The `*ngFor` and related directives are unaffected by
  this change  as references to the `NgFor` class generated from
  templates will be automatically converted to references to
  `NgForOf<T>` without requiring any template modifications.
- `TrackByFn` is now deprecated. Use `TrackByFunction<T>` instead.

Migration:
- Replace direct references to the `NgFor` class to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

BREAKING CHANGE:
A definition of `Iterable<T>` is now required to correctly compile
Angular applications. Support for `Iterable<T>` is not required at
runtime but a type definition `Iterable<T>` must be available.

`NgFor`, and now `NgForOf<T>`, already supports `Iterable<T>` at
runtime. With this change the type definition is updated to reflect
this support.

Migration:
- add "es2015.iterable.ts" to your tsconfig.json "libs" fields.

Part of #12398

PR Close #14104
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
angular#14104)

Note, this affects the underlying class and should not affect usage.

DEPRECATION:
- the `NgFor` class is now deprecated. Use `NgForOf<T>` instead.
  IMPORTANT: Only the `NgFor` class is deprecated, not the `ngFor`
  directive. The `*ngFor` and related directives are unaffected by
  this change  as references to the `NgFor` class generated from
  templates will be automatically converted to references to
  `NgForOf<T>` without requiring any template modifications.
- `TrackByFn` is now deprecated. Use `TrackByFunction<T>` instead.

Migration:
- Replace direct references to the `NgFor` class to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

BREAKING CHANGE:
A definition of `Iterable<T>` is now required to correctly compile
Angular applications. Support for `Iterable<T>` is not required at
runtime but a type definition `Iterable<T>` must be available.

`NgFor`, and now `NgForOf<T>`, already supports `Iterable<T>` at
runtime. With this change the type definition is updated to reflect
this support.

Migration:
- add "es2015.iterable.ts" to your tsconfig.json "libs" fields.

Part of angular#12398

PR Close angular#14104
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
angular#14104)

Note, this affects the underlying class and should not affect usage.

DEPRECATION:
- the `NgFor` class is now deprecated. Use `NgForOf<T>` instead.
  IMPORTANT: Only the `NgFor` class is deprecated, not the `ngFor`
  directive. The `*ngFor` and related directives are unaffected by
  this change  as references to the `NgFor` class generated from
  templates will be automatically converted to references to
  `NgForOf<T>` without requiring any template modifications.
- `TrackByFn` is now deprecated. Use `TrackByFunction<T>` instead.

Migration:
- Replace direct references to the `NgFor` class to `NgForOf<any>`.
- Replace references to `TrackByFn` to `TrackByFunction<any>`.

BREAKING CHANGE:
A definition of `Iterable<T>` is now required to correctly compile
Angular applications. Support for `Iterable<T>` is not required at
runtime but a type definition `Iterable<T>` must be available.

`NgFor`, and now `NgForOf<T>`, already supports `Iterable<T>` at
runtime. With this change the type definition is updated to reflect
this support.

Migration:
- add "es2015.iterable.ts" to your tsconfig.json "libs" fields.

Part of angular#12398

PR Close angular#14104
@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 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants