Closed kukjevov closed 3 years ago
Is there any update on this issue? This is pretty much one of the few bad things about using angular : typesafe template binding.
This is a big issue in my opinion. Tight Typescript integration is heavily marketed as an asset of Angular2+, but in reality ~50% of the code is not actually type checked. If you think of passing inputs to components as functions, this basically means that all those function calls are completely untyped. The typing only comes into play within a component, whereas it's completely useless for component to component communication where it would actually be more useful.
This is an even bigger issue because the typing is missing from the part of the app that changes most often.
At this point React has much better typescript integration than Angular contra what is usually stated.
I've also mentioned that there is no autocompletion for custom component inputs. Which may be related to this issue.
relevant, probably blocking: https://github.com/Microsoft/TypeScript/issues/9879
This is needed as it's very bug prone:
<button (click)="foo('bar')">Click me</button>
with a bounded method:
// take note of the parameter type, where the template passes through a string.
public foo(bar: boolean): void {
// ...
}
This should give some sort of warning at least.
Setting the fullTemplateTypeCheck
to true in the tsConfig
file will cause the ng build
to report errors, if it is false it will just fall through.
Agreed that this is a big issue and needed in the language service. This feature will be available when the language service uses the Ivy compiler as a backend (work on this is underway).
This has been fixed by the new Ivy-native language service, released in v11.1.0.
It's an opt-in feature for now, please give it a try and let us know if you have any feedback.
For the best editor experience, please make sure your project has strictTemplates
enabled in angularCompilerOptions
.
In case you run into similar bug, please file a new issue. I'll close this for now.
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.
Now when you use input binding for Directive or Component existance of used variable is checked which is perfect. But this check does not check if input and variable assigned to it are of same type.
It would be absolutely perfect if it would also check matching type or if it assignable. This is probably request for @angular/language-service.
Thank you