1

I've installed the VsCode Angular Language Service Extension and I enabled strictTemplates in my .tsconfig.

It works almost like a charm. But I have a strange case. If you take a look at the images below, you will see that when the directive ngFor is used, everything works fine. IntelliSense detects the type of let test. But when using cdkVirtualFor it just gives me the type any back.

Image1 Image2

I tried searching for solutions online, but I didn't really find anything.

  • According to [this](https://github.com/angular/vscode-ng-language-service/issues/737) it was fixed and you just need to use `strictTemplate` rule. It may be a stupid question, but is that what you mean with _I enabled strict mode_ ? – Jacopo Sciampi Jul 10 '23 at 14:54
  • @JacopoSciampi Thanks for the try, but I saw this post and it didn't help much. Thanks for the help tho :). Sorry about the confusion with the term "strict mode", I meant strictTemplates. (For future readers, I have edited my question) – bjoern.stark Jul 11 '23 at 07:24
  • you can try https://stackoverflow.com/questions/45964576/type-casting-within-a-template-in-angular-2/66154034#66154034 – smnbbrv Jul 11 '23 at 07:25
  • Thanks for the help @smnbbrv. This actually works great. But it still feels just like a hack and not like a good solution. – bjoern.stark Jul 11 '23 at 12:00
  • Welcome to stackoverflow. Note, this community discourages the use of images when text would do ([see here](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors)). Please put the errors you want to share inline. – postylem Jul 11 '23 at 13:58
  • Thanks for the input @postylem, but I can't show what VsCode's IntelliSense suggests me when hovering over the variable if i would put the code inline. I could, but I think that images are more clear for any readers. – bjoern.stark Jul 11 '23 at 14:15

0 Answers0