Skip to content

Feature Request: Allow Non-Blocking Mode for strictTemplates #55868

Closed as not planned

Description

@tomer953

Which @angular/* package(s) are relevant/related to the feature request?

language-service

Description

We are working on a large-scale Angular project and are interested in adopting the strictTemplates option to improve our type safety and overall code quality. However, enabling strictTemplates currently flags a significant number of errors due to our existing codebase size, making an immediate adoption impractical as it would halt our build processes.

Proposed solution

Implement an option within angularCompilerOptions where strictTemplates can be enabled in a non-blocking mode. This mode would allow developers to see warnings instead of errors for strict template checks, preventing them from blocking the build process. This feature would be incredibly beneficial for large projects wanting to gradually adopt strict type checking in their templates without disrupting their development workflow.

Alternatives considered

Incremental Adoption \ Directive/Component Specific Flagging

Activity

  1. tomer953 commented on May 18, 2024

    @tomer953
    ContributorAuthor

    related to: angular/vscode-ng-language-service#1646

    Seems like VSCode extension allow to force strictTemplates without effecting the build process, However:

    • its only works with VSCode, other IDEs don't have this flag
    • Its an optional choice by the developer, and can't be enforced by a project setting.
  2. JoostK commented on May 20, 2024

    @JoostK
    Member

    I'd recommend to adopt different tsconfig.json files for this pattern. I suspect that IDEs typically use the closest tsconfig.json, so having a tsconfig.app.json which extends the base tsconfig would allow you to have different compiler options for builds vs IDE.

  3. spock123 commented on May 20, 2024

    @spock123

    @JoostK We're in the same boat as @tomer953 and feel quite stupid not having thought of this solution... thanks!

  4. tomer953 commented on May 20, 2024

    @tomer953
    ContributorAuthor

    Edited:

    Oh got it.. so its actually pretty simple just use different tsconfig file for the tsConfig option in the angular.json and let the IDE use the default tsconfig file for template checks

    🚀

  5. modified the milestone: needsTriage on May 22, 2024
  6. tomer953 commented on May 23, 2024

    @tomer953
    ContributorAuthor

    The workaround is not the easiest on large projects, We had to change every tsConfig build path in the angular.json and create new tsconfig files for each project

    I hope we will have some option to force strict template option on the language service, so I'll keep this issue open.

  7. alxhub commented on May 29, 2024

    @alxhub
    Member

    We've discussed this question and decided that we shouldn't try to support any kind of warning mode for strictTemplates, for a few significant reasons:

    1. tsconfig.json is already a standard way of applying different configurations to different parts of your codebase.

    This is how TypeScript rolls out new strictness flags - at the granularity of the tsconfig options. It's also possible to configure two tsconfig.jsons: one for the actual build, and one which enables new flags for experimentation.

    1. Angular already has incremental ratcheting flags for type-checking strictness.

    2. The way template type-checking works really isn't conducive to lifting specific types of checks into warnings.

    Template type-checking works by generating TypeScript code representing the template, and feeding it to TypeScript's checker. The diagnostics we get back are (for the most part) real TypeScript diagnostics produced by tsc. Therefore we can't really know per-diagnostic why it was produced, only that TypeScript found something wrong in the template block. Sometimes we can correlate specific lines with specific types of checks, but mostly this is not the case.

  8. angular-automatic-lock-bot commented on Jun 29, 2024

    @angular-automatic-lock-bot

    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.

  9. locked and limited conversation to collaborators on Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions