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(Table Schematic Code): Build warning error in the 'table' schematic code #27329

Closed
1 task
bradws opened this issue Jun 19, 2023 · 4 comments · Fixed by #27407
Closed
1 task

bug(Table Schematic Code): Build warning error in the 'table' schematic code #27329

bradws opened this issue Jun 19, 2023 · 4 comments · Fixed by #27407
Assignees
Labels
area: material/table P4 A relatively minor issue that is not relevant to core functions

Comments

@bradws
Copy link

bradws commented Jun 19, 2023

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

When creating a fresh Angular v16.1.0 project, then adding Angular Material to the project, and finally adding the 'table' schematic to produce an example component, the component produces an Angular build warning error in line 20 of the html template stating that the '?.' operator can be replaced with the '.' operator.

Reproduction

StackBlitz link: Build Warning Error
Steps to reproduce:

  1. Create a fresh Angular v16.1.0 project:

ng new angular-material-ex2 --standalone

  1. Change directory:

cd angular-material-ex2/src/app

  1. Add Angular Material:

ng add @angular/material

  1. Generate the 'table' schematic:

ng g @angular/material:table MyTable

  1. Modify code to accept the newly-created MyTable
    5.1 In app.component.ts file, change code line from:
    imports: [CommonModule],
    ..to..
    imports: [CommonModule, MyTableComponent],
    5.2 In app.component.ts file, after the code line:
    import { CommonModule } from '@angular/common';
    ..put an additional code line..
    import { MyTableComponent } from './my-table/my-table.component';
  2. Build the project:

ng run build

  1. You will be presented with the Angular build warning error:
    "Warning: src/app/my-table/my-table.component.html:20:29 - warning NG8107: The left side of this optional chain operation does not include 'null' or 'undefined' in its type, therefore the '?.' operator can be replaced with the '.' operator."
    Note: The Stackblitz code sample should show the error
  2. To fix, just remove the two Optional Chaining operators; i.e. the two question marks

Expected Behavior

No Build warning error will appear.

Actual Behavior

Code will compile with out any errors.

Environment

  • Angular: 16.1.0
  • CDK/Material: 16.1.1 / 16.1.1
  • Browser(s): Any (Firefox & Chrome)
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 11
@bradws bradws added the needs triage This issue needs to be triaged by the team label Jun 19, 2023
@bradws bradws changed the title bug(COMPONENT): Build warning error in the 'table' schematic code bug(Table Schematic Code): Build warning error in the 'table' schematic code Jun 19, 2023
@bradws
Copy link
Author

bradws commented Jun 19, 2023

I would be happy to contribute to this change after triage.

@andrewseguin
Copy link
Contributor

@crisbeto Is this due to any recent changing in Schematics code?

@andrewseguin andrewseguin added area: material/table P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent P4 A relatively minor issue that is not relevant to core functions and removed needs triage This issue needs to be triaged by the team P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Jun 21, 2023
@crisbeto
Copy link
Member

It's due to the new extended template diagnostics coming from the framework. I'll sort it out.

@crisbeto crisbeto self-assigned this Jun 21, 2023
crisbeto added a commit to crisbeto/material2 that referenced this issue Jul 5, 2023
Fixes that the table schematic was producing a template diagnostic for null checking a value that doesn't need to be null checked. Also removes an unnecessary constructor.

Fixes angular#27329.
crisbeto added a commit that referenced this issue Jul 5, 2023
…27407)

Fixes that the table schematic was producing a template diagnostic for null checking a value that doesn't need to be null checked. Also removes an unnecessary constructor.

Fixes #27329.

(cherry picked from commit 017a541)
crisbeto added a commit that referenced this issue Jul 5, 2023
…27407)

Fixes that the table schematic was producing a template diagnostic for null checking a value that doesn't need to be null checked. Also removes an unnecessary constructor.

Fixes #27329.
stephenrca pushed a commit to stephenrca/components that referenced this issue Aug 2, 2023
…ngular#27407)

Fixes that the table schematic was producing a template diagnostic for null checking a value that doesn't need to be null checked. Also removes an unnecessary constructor.

Fixes angular#27329.
@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 Aug 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/table P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants