question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

This plugin is ignoring the type when using the "keyvalue" pipe.

See original GitHub issue

Describe the bug

Using the keyvalue pipe throws errors in template.

Identifier 'myProperty' is not defined. 'V' does not contain such a member. (ng)

Because this error is only in the VS Code html file, I guess that this is related to this extension. The build works.

To Reproduce

Steps to reproduce the behavior:

  1. Use the keyvalue pipe on a property with a custom type. See my source code blocks / graphics or download the demo (see below).
  2. See that all properties of value are marked as error. The pipe does not pass the type correctly.
  3. Build it. It works. But the error in editor persists. It seems to be related to the ng extension.
  4. Try restart of VS Code. Nothing helped.

Source Code

app.component.html

<ul>
  <li *ngFor="let entry of menuService.menu | keyvalue">
    <span>{{ entry.value.text }}</span>
  </li>
</ul>

menu-items.model.ts

export interface MenuItem {
  text: string;
}

export interface Menu {
  [key: string]: MenuItem;
}

Other (Snippets):

// app.component.ts
import { MenuService } from './menu-items/menu-items.service';
export class AppComponent {
  constructor(public menuService: MenuService) {}
}

// menu-items.service.ts
import { Menu, MenuItem } from './menu-items.model';
public menu: Menu = {};
// See model (above).

Expected behavior

No error when using the keyvalue pipe. I think it’s a correct use of it. It works everywhere.

Logs

Identifier 'text' is not defined. 'V' does not contain such a member. (ng)

Screenshots

demo (Gif Animation. Wait for the first frame in app.component.html)

Additional context

Download Demo Project

Versions

VS Code:

Version: 1.50.1 (user setup)
Commit: d2e414d9e4239a252d1ab117bd7067f125afd80a
Date: 2020-10-13T15:06:15.712Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19041

Angular Language Service (VS Code Extension): 0.1001.0

Angular CLI (ng --version):

Angular CLI: 11.0.0-rc.0
Node: 10.22.1
OS: win32 x64

Angular: 11.0.0-rc.0    
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.0-rc.0
@angular-devkit/build-angular   0.1100.0-rc.0
@angular-devkit/core            11.0.0-rc.0
@angular-devkit/schematics      11.0.0-rc.0
@schematics/angular             11.0.0-rc.0
@schematics/update              0.1100.0-rc.0
rxjs                            6.6.3
typescript                      4.0.3

Info

Created a new Angular app for this demo using the Angular CLI 11 with default settings. No special configs. Just a simple single app repository.

See current Angular repo pipe source code.

Workaround

No solution yet. It’s really annoying. We need a solution. Any guesses?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ayazhafizcommented, Nov 3, 2020

As @infacto mentioned, this is a known issue (angular/angular#21224) and is fixed by the Ivy language service, which will be beta released in Angular 11 (#335 (comment)). As such, I am closing this report.

0reactions
angular-automatic-lock-bot[bot]commented, Dec 4, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngFor with keyvalue pipe: Type 'unknown' is not assignable to ...
For me, it turned out to be that the variable used in the keyvalue pipe, was invalid which causes an error to be...
Read more >
Command Line Interface - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Lookup plugins - Ansible Documentation
You can use lookup plugins to access data from outside sources (files, databases, key/value stores, APIs, and other services) within your playbooks.
Read more >
4.2.5 Connecting to the Server Using URI-Like Strings or Key ...
For the full syntax, see Connecting Using Key-Value Pairs. ... This option is ignored for accounts that do not authenticate with that plugin....
Read more >
Elasticsearch output plugin | Logstash Reference [8.5] | Elastic
... modern versions of this plugin don't use the document-type when ... events to Elasticsearch in the shape produced by your pipeline, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found