angular: Incorrect template errors with union types
I’m submitting a…
[x] Bug report
Current behavior
Imported from https://github.com/angular/vscode-ng-language-service/issues/231
With the following component
@Component({
selector: 'my-app',
template: `
<div>
<h2>Hello {{name}}</h2>
<p *ngIf="name == 'steve'">hi steve</p>
</div>
`,
})
export class App {
name: string | number;
constructor() {
this.name = `Angular!`
}
}
An error is given for the *ngIf
value: [Angular] Expected the operants to be of similar type or any
.
Expected behavior
No template error appears similar to https://github.com/angular/vscode-ng-language-service/issues/16
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 37
- Comments: 16 (1 by maintainers)
Error happens with plain string values as well.
Error: property mystring of MyComponent Expected the operants to be of similar type or any
This was fixed in #36529 and also won’t be an issue anymore with the Ivy language service.
I no longer see the issue with the latest language-service plugin on VSCode and after upgrading to angular 8.1.0