dart-archive/angular_analyzer_plugin

Angular operator === not recognized

Closed this issue ยท 17 comments

The plugin doesn't seem to recognize the === operator. If I replace === by == in the following template then the plugin doesn't report any errors:

  <li *ngFor="let hero of heroes"
      [class.selected]="hero === selected"
      (click)="onSelect(hero)">
    <span class="badge">{{hero.id}}</span> {{hero.name}}
  </li>

Otherwise, I get the following errors:

screen shot 2018-03-28 at 14 04 53

The HTML excerpt is taken from the Angular Tutorial, part 2, which you can download from https://github.com/angular-examples/toh-2/archive/5-dev.zip

Environment:

  • Dart VM version: 2.0.0-dev.43.0 (Wed Mar 28 01:04:15 2018 +0200) on "macos_x64"
  • WebStorm 2017.3
  • MacOS X 10.13.3

cc @kwalrath @matanlurey

That's Dart code, I wouldn't expect === to work there.
What is === supposed to do?

From the side note in the tutorial section Style the selected hero:

The === operator tests whether the given objects are identical.

@chalin thanks. Now it even seems somewhat familiar.
That means | (pipe) and === are the only things that deviate from standard Dart, right?

... are the only things that deviate from standard Dart, right?

That sounds about right but I'm not sure.

Thanks for filing!

We've been moving a few things from typescripty origins over to dart syntax (for instance, {x: y} is now an error and must be {"x": y}) and we're starting a lot of that migration in our plugin. I just checked with some other angular teammembers about whether we want to encourage identical() instead of ===.

Due to ecosystem reasons, it can be hard for us to maintain support for these additions on top of regular dart syntax. Are you relying heavily on this?

We've been moving a few things from typescripty origins over to dart syntax

๐Ÿ‘

Are you relying heavily on this?

No. I'd be glad to switch to regular Dart syntax. The current error message is cryptic. Maybe the plugin should at least say that "===" is deprecated and that it should be replaced with "identical()"?

@matanlurey: are there plans to deprecate === in Angular 5?

No, we don't want to touch the AST format at all at this time.

The current error message is cryptic. Maybe the plugin should at least say that "===" is deprecated and that it should be replaced with "identical()"?

+1. I can definitely do this.

No, we don't want to touch the AST format at all at this time.

Then maybe the plugin should match Angular 5 syntax?

Fixed. This is now accepted, pending future decisions about whether we'll keep this.

Thanks for filing!

@MichaelRFairhurst - which release did the fix make it into? (Although I'm wondering how I can know which version of the plugin WebStorm is using.) I deleted ~/.dartServer, restarted WS and I'm still seeing the error.

Sorry it hasn't been released yet.

I opened this to try and release today or tomorrow: #548

Note the comment about the next dev release auto-updating plugins. You can still update exactly how you said, but in the future you won't have to!

I'll respond here again when that publish lands!

Thanks!

You can still update exactly how you said, but in the future you won't have to!

\o/

@MichaelRFairhurst: was this fix also applied to !==?

(Also, how can I tell which version of the plugin I'm using?)

I just published and on the latest SDK it seems to auto-update successfully.

!== should work too.

Unfortunately, the version isn't forwarded clearly anywhere. You can open the analyzer diagnostics to get the plugin packages path (something like /home/mfairhurst/.dartServer/.plugin_manager/9b15e7a4a98b6a87b090d13dc0757aa9/analyzer_plugin/.packages), and then in that you can look for angular_analyzer_plugin: .....pub-cache/....0.0.15+1/....

You can open the analyzer diagnostics to get the plugin packages path

Got it.

!== should work too.

Yes it does, thanks.