Incorrect template errors with union types
See original GitHub issueI’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
Issue Analytics
- State:
- Created 6 years ago
- Reactions:37
- Comments:16 (1 by maintainers)
Top Results From Across the Web
Angular Template Check Error while using Union Type of ...
When I display a review sometimes I just want userId as a string or sometimes I populate the userId with some user's schema...
Read more >*ngSwitch Type Errors with Discriminated Unions in Angular ...
Here's a workaround for resolving *ngSwitch type errors in Angular templates and switching on a discriminated union type.
Read more >Handbook - Unions and Intersection Types - TypeScript
Union Types. Occasionally, you'll run into a library that expects a parameter to be either a number or a string . For instance,...
Read more >Invalid template errors - Azure Resource Manager
Solution 2: Incorrect segment lengths ... Another invalid template error occurs when the resource name isn't in the correct format. To resolve ...
Read more >Using TypeScript Union Types Like a Pro | by Bytefer
Union Type in TypeScript, TypeScript Union Types, ... want the logError function to support multiple error messages in the form of an array?...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.