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

bug(material/schematics): table schematic does not generate code that works with strict mode #21981

Closed
Splaktar opened this issue Feb 22, 2021 · 1 comment · Fixed by #22052, cayacdev/cashbox#88, ToWipf/jasmarty#155 or CarlosPavajeau/Kaizen#251
Assignees
Labels
area: ng-generate Schematics that generate code in user projects P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@Splaktar
Copy link
Member

Splaktar commented Feb 22, 2021

Reproduction

Steps to reproduce:

  1. ng new with strict mode on
  2. ng add @angular/material
  3. ng g @angular/material:table table
  4. npm start

Expected Behavior

What behavior were you expecting to see?
The app should build and work.

Actual Behavior

What behavior did you actually see?

Error: src/app/table/table-datasource.ts:44:3 - error TS2564: Property 'paginator' has no initializer and is not definitely assigned in the constructor.

44   paginator: MatPaginator;
     ~~~~~~~~~


Error: src/app/table/table-datasource.ts:45:3 - error TS2564: Property 'sort' has no initializer and is not definitely assigned in the constructor.

45   sort: MatSort;
     ~~~~


Error: src/app/table/table.component.ts:13:28 - error TS2564: Property 'paginator' has no initializer and is not definitely assigned in the constructor.

13   @ViewChild(MatPaginator) paginator: MatPaginator;
                              ~~~~~~~~~


Error: src/app/table/table.component.ts:14:23 - error TS2564: Property 'sort' has no initializer and is not definitely assigned in the constructor.

14   @ViewChild(MatSort) sort: MatSort;
                         ~~~~


Error: src/app/table/table.component.ts:15:24 - error TS2564: Property 'table' has no initializer and is not definitely assigned in the constructor.
[39m[0m
15   @ViewChild(MatTable) table: MatTable<TableItem>;
                          ~~~~~


Error: src/app/table/table.component.ts:16:3 - error TS2564: Property 'dataSource' has no initializer and is not definitely assigned in the constructor.

16   dataSource: TableDataSource;
     ~~~~~~~~~~


Error: src/app/table/table.component.html:20:34 - error TS2532: Object is possibly 'undefined'.

20       [length]="dataSource?.data.length"
                                    ~~~~~~

  src/app/table/table.component.ts:9:16
    9   templateUrl: './table.component.html',
                     ~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component TableComponent.

Environment

  • Angular: 11.2.1
  • CDK/Material: 11.2.1
  • Browser(s): N/A
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS Catalina

Relates to #17135

@Splaktar Splaktar added needs triage This issue needs to be triaged by the team area: ng-generate Schematics that generate code in user projects P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Feb 22, 2021
@Splaktar Splaktar self-assigned this Feb 23, 2021
@Splaktar Splaktar removed the needs triage This issue needs to be triaged by the team label Feb 23, 2021
Splaktar added a commit to DevIntent/components that referenced this issue Feb 28, 2021
…ects

- fix `strictNullChecks` errors
- fix `strictPropertyInitialization` errors
- default to smaller paginator rows so that paging works out of the box
- fix tslint errors from default CLI settings

Fixes angular#21981
Splaktar added a commit to DevIntent/components that referenced this issue Feb 28, 2021
- fix tslint error from default CLI settings

Relates to angular#21981
Splaktar added a commit to DevIntent/components that referenced this issue Feb 28, 2021
…ects

- fix `strictNullChecks` errors
- fix `strictPropertyInitialization` errors
- default to smaller paginator rows so that paging works out of the box
- fix tslint errors from default CLI settings

Fixes angular#21981
Splaktar added a commit to DevIntent/components that referenced this issue Feb 28, 2021
- fix tslint error from default CLI settings

Relates to angular#21981
Splaktar added a commit to DevIntent/components that referenced this issue Mar 1, 2021
…ects

- fix `strictNullChecks` errors
- fix `strictPropertyInitialization` errors
- default to smaller paginator rows so that paging works out of the box
- fix tslint errors from default CLI settings

Fixes angular#21981
Splaktar added a commit to DevIntent/components that referenced this issue Mar 1, 2021
- fix tslint error from default CLI settings

Relates to angular#21981
annieyw pushed a commit that referenced this issue Mar 5, 2021
…ects (#22052)

* fix(material/schematics): generate code that works in strict CLI projects

- fix `strictNullChecks` errors
- fix `strictPropertyInitialization` errors
- default to smaller paginator rows so that paging works out of the box
- fix tslint errors from default CLI settings

Fixes #21981

* fix(cdk/schematics): generate code that works in strict CLI projects

- fix tslint error from default CLI settings

Relates to #21981
annieyw pushed a commit that referenced this issue Mar 5, 2021
…ects (#22052)

* fix(material/schematics): generate code that works in strict CLI projects

- fix `strictNullChecks` errors
- fix `strictPropertyInitialization` errors
- default to smaller paginator rows so that paging works out of the box
- fix tslint errors from default CLI settings

Fixes #21981

* fix(cdk/schematics): generate code that works in strict CLI projects

- fix tslint error from default CLI settings

Relates to #21981

(cherry picked from commit 0441ae9)
@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 Apr 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.