question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide extension option to enable strictTemplates (override compiler options from tsconfig)

See original GitHub issue

With the release of v12, the Ivy-based Language Service became the default. With that, the information provided by the extension follows what the application has configured the compiler to interpret (see Alex’s blog post for more information on why this was done). As a result, developers upgrading from previous versions that have apps which do not have strict templates enabled often experience a loss of information from the extension. It also may not be feasible for large projects to enable strictTemplates immediately due to an abundance of new errors that would need to be fixed.

This feature request is to provide an extension option to override the project’s angularCompilerOptions. This would allow the language service to enable strictTemplates.

Importantly, this would likely result in the language service producing diagnostics that are not produced when running/compiling the application. However, this may still be a more ideal state than the current experience (which would be simply not getting any useful information for lots of locations in the template which require stricter type checking options).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:14

github_iconTop GitHub Comments

3reactions
atscottcommented, May 3, 2022

We’ve decided to add the option to the extension. It’ll be available in the v14 release.

2reactions
t-bowersoxcommented, May 3, 2022

I’m working on a codebase that was built prior to Angular 13, but has since been upgraded. As a result, we didn’t have strictTemplates set in our tsconfig. Enabling it would result in errors that would block our builds.

Obviously, the ideal is to get those errors addressed; but in the meantime, that would mean not getting the full benefit of the Angular VS Code extension.

I discovered a workaround, however, that seems to convince the extension to perform strict template checks, while not blocking the builds:

  • In your main tsconfig.json, set strictTemplates: true.
  • In your tsconfig.app.json and tsconfig.spec.json, set strictTemplates: false.
  • Restart VS Code (or you could try just restarting the Angular language server)

Thus far, this has given me the best of both worlds and I’ve not noticed any issues (knock on wood). But, your mileage may vary of course.

Not sure if this should be possible with the extension, but I wanted to share it in case it helps out anyone else. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Suppress Angular Language Service VSCode extension's ...
To access all features, enable strictTemplates in angularCompilerOptions . Source: Angular Language Service (Extension). With a link to "Open ...
Read more >
Angular compiler options
The configuration options from the base file are loaded first, then overridden by those in the inheriting configuration file. For example: tsconfig.app.json
Read more >
TSConfig Reference - Docs on every TSConfig option
Provides a way to override the default list of file name suffixes to search when resolving a module. {. " compilerOptions ": {....
Read more >
Angular 9's Best Hidden Feature: Strict Template Checking
We'll also adjust some compilation settings. ... Let's change the setting in tsconfig.json to enable strict template checks.
Read more >
coc-angular - npm
This extension provides a rich editing experience for Angular ... set the strictTemplates option in tsconfig.json , as shown in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found