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

Operand of null-aware operation '?.' has type 'String' which excludes null, when passing a string to a native directive #58

Open
insinfo opened this issue May 17, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@insinfo
Copy link

insinfo commented May 17, 2023

Which ng* package(s) are the source of the bug?

ngcompiler, ngdart

Which operating system(s) does this bug appear on?

Windows

Which browser(s) does this bug appear on?

Chrome 113.0.5672.93

Is this a regression?

No

Description

Operand of null-aware operation '?.' has type 'String' which excludes null, when passing a string to a native directive

Please provide the steps to reproduce the bug

create a new project with AngularDart 7, create a component and place some html using some default directive like class, style passing some value as shown below.

<span class="d-none d-lg-inline-block mx-lg-2">
   <div>
    <div #divName>
             {{ $pipe.titleCase(authService.authPayload.nomCgm) }}
     </div>
     <div class="fs-xs" [style.width]="divName.offsetWidth.toString() + 'px'" style="text-overflow: ellipsis;background: none;border: none;overflow: hidden; white-space: nowrap;">
              {{ $pipe.titleCase(authService.authPayload.nomSetor) }}
          </div>
    </div>
</span>

Please provide the exception or error you saw

Warning: Operand of null-aware operation '?.' has type 'String' which excludes null.


webdev serve web:8005 --auto refresh
[WARNING] Throwing away cached asset graph because the build phases have changed. This most commonly would happen as a result of adding a new dependency or updating your dependencies.
[WARNING] Throwing away cached asset graph because the language version of some package(s) changed. This would most commonly happen when updating dependencies or changing your min sdk constraint.
[INFO] Cleaning up outputs from previous builds. completed, took 1.9s
[INFO] Building new asset graph completed, took 2.8s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Serving `web` on http://127.0.0.1:8005
[INFO] build_web_compilers:ddc on lib/new_sali_frontend.ddc.module:
packages/new_sali_frontend/src/modules/home/components/main_nav/main_nav.template.dart:157:46: Warning: Operand of null-aware operation '?.' has type 'String' which excludes null.
      this._el_20.style.setProperty('width', currVal_1?.toString()) /* REF:package:new_sali_frontend/src/modules/home/components/main_nav/main_nav.html:1561:1614 */;
                                             ^
[INFO] Running build completed, took 1m 7s
[INFO] Caching finalized dependency graph completed, took 592ms
[INFO] Succeeded after 1m 7s with 5265 outputs (13680 actions)
[INFO] ------------------------------------------------------------------------------------------------------------------------------------- 
[INFO] Updating asset graph completed, took 5ms
[INFO] build_web_compilers:ddc on lib/new_sali_frontend.ddc.module:
packages/new_sali_frontend/src/modules/home/components/main_nav/main_nav.template.dart:156:46: Warning: Operand of null-aware operation '?.' has type 'String' which excludes null.
      this._el_20.style.setProperty('width', currVal_1?.toString()) /* REF:package:new_sali_frontend/src/modules/home/components/main_nav/main_nav.html:1545:1598 */;
                                             ^
[INFO] Running build completed, took 9.5s
[INFO] Caching finalized dependency graph completed, took 512ms
[INFO] Succeeded after 10.0s with 52 outputs (49 actions)

Please provide the dependency environment you discovered this bug in (run dart pub deps -s compact)

environment:   
  sdk: '>=2.18.0 <3.0.0'

dependencies:   
  ngdart: ^7.1.1 
  ngforms: ^4.1.1
  ngrouter: ^3.1.1

Anything else?

No response

@insinfo insinfo added the bug Something isn't working label May 17, 2023
@GZGavinZhao
Copy link

Is this a warning only, or does it also break stuff?

@insinfo
Copy link
Author

insinfo commented May 30, 2023

warning only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants