angular: language-service: Member (function) is not callable in ng-template
I’m submitting a … (check one with “x”)
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
As seen in demo for ngx-datatable project, this usage:
<ng-template let-column="column" let-sort="sortFn" ngx-datatable-header-template>
<span (click)="sort()">{{column.name}}</span>
</ng-template>
Results in an error of:
Error:(32, 2) Angular: Member sort is not callable
Expected behavior
No error. sortFn
is a callable function and the code does in fact work correctly.
Minimal reproduction of the problem with instructions
Run demo for ngx-datatable through the language-service.
What is the motivation / use case for changing the behavior?
I like my error console to be empty. Having to constantly mentally process and dismiss this error in the IDE is unproductive.
Please tell us about your environment:
IntelliJ IDEA 2017.1.1 Build #IU-171.4073.35, built on April 6, 2017 JRE: 1.8.0_112-release-736-b16 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Mac OS X 10.12.4
-
Angular version: 4.0.3
-
Browser: N/A
-
Language: TypeScript 2.2.2
-
Node (for AoT issues):
node --version
= v7.9.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 45
- Comments: 24 (2 by maintainers)
Commits related to this issue
- fix(language-service): Function alias should be callable This commit fixes a long standing bug whereby a template variable that gets initialized to a class method gets resolved to the Any type, thus ... — committed to kyliau/angular by kyliau 5 years ago
- fix(language-service): Function alias should be callable This commit fixes a long standing bug whereby a template variable that gets initialized to a class method gets resolved to the Any type, thus ... — committed to kyliau/angular by kyliau 5 years ago
- fix(language-service): Function alias should be callable This commit fixes a long standing bug whereby a template variable that gets initialized to a class method gets resolved to the Any type, thus ... — committed to kyliau/angular by kyliau 5 years ago
- fix(language-service): Function alias should be callable This commit fixes a long standing bug whereby a template variable that gets initialized to a class method gets resolved to the Any type, thus ... — committed to kyliau/angular by kyliau 5 years ago
- fix(language-service): Function alias should be callable (#33782) This commit fixes a long standing bug whereby a template variable that gets initialized to a class method gets resolved to the Any ty... — committed to angular/angular by kyliau 5 years ago
That’s caused by “Angular Language Service” plugin in VS-Code. Just uninstall it.
Until this gets somehow fixed, you can workaround this by creating a trigger method and use it like this:
In component add the method:
any updates?
I’ve got the same problem and found another workaround: use
fn.call(thisArg, ...args)
I am still experiencing this error with language service 0.900.0 in combination with transloco, See for an example: https://github.com/ngneat/transloco/issues/177
+1
+1
Sorry it took so long, https://github.com/angular/angular/pull/33782 should fix this.
This workaround is working for me:
By invoking the function inside the
let-
assignment instead of inside the (click) handler, you will avoid this bug and still get the same functionality.The workaround that I use is this:
Instead of passing the
highlight
function directly, pass afns
object that has this content{ highlight: highlight }
And use it like this with no errors:
Another workaround is proposed here: https://github.com/angular/vscode-ng-language-service/issues/234#issuecomment-385955606 I haven’t tried it myself, but it makes sense.
Same here, using VSCode.
Same happening here, using Angular 5.2.8.
Any progress on this issue ?
@chuckjaz any updates on this?
Same here, Angular 5.2.9 and ng-bootstrap 1.0.4. ng build --prod works fine and my app also works. Not sure why the intellisence complains. Any progress on this issue?