Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: template input binding type check #143

Closed
kukjevov opened this issue Aug 11, 2017 · 8 comments
Closed

FEATURE: template input binding type check #143

kukjevov opened this issue Aug 11, 2017 · 8 comments
Assignees
Labels
feature ivy Feature / enhancement / bug fix in Ivy lib Relates to an issue in the @angular/language-service library

Comments

@kukjevov
Copy link

kukjevov commented Aug 11, 2017

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

@AlexandreOuellet
Copy link

Is there any update on this issue? This is pretty much one of the few bad things about using angular : typesafe template binding.

@UrKr
Copy link

UrKr commented Jul 27, 2018

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.

@kyliau kyliau added the ivy Feature / enhancement / bug fix in Ivy label Nov 25, 2019
@feafarot
Copy link

I've also mentioned that there is no autocompletion for custom component inputs. Which may be related to this issue.

@ayazhafiz ayazhafiz self-assigned this Dec 28, 2019
@ayazhafiz
Copy link
Member

relevant, probably blocking: microsoft/TypeScript#9879

@ayazhafiz ayazhafiz added the lib Relates to an issue in the @angular/language-service library label Feb 21, 2020
@JAspeling
Copy link

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.

@ayazhafiz
Copy link
Member

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).

@kyliau
Copy link
Contributor

kyliau commented Jan 21, 2021

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.

@kyliau kyliau closed this as completed Jan 21, 2021
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature ivy Feature / enhancement / bug fix in Ivy lib Relates to an issue in the @angular/language-service library
Projects
None yet
Development

No branches or pull requests

8 participants