Skip to content

feat(@schematics/angular): enable stricter type checking and optimization effective coding rules #17372

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

Merged
merged 2 commits into from
May 5, 2020
Merged

Conversation

alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Apr 2, 2020

With this change we enable stricter type checking and optimization effective coding rules when using the --strict option.

Changes in schematics

  • ng-new: A prompt for the strict option was added. This option is a proxy and will be passed to the application and workspace schematics.
  • application: A package.json was added in the app folder, to tell the bundlers whether the application is free from side-effect code. When strict is true. the sideEffects will be set false.
  • workspace When strict is true, we add stricter TypeScript and Angular type-checking options.

Note: AIO is already using these strict TypeScript compiler settings. PR to enable strictTemplates angular/angular#36391

Reference: TOOL-1366

@alan-agius4 alan-agius4 added the target: major This PR is targeted for the next major release label Apr 2, 2020
@alan-agius4 alan-agius4 added this to the V10-candidates milestone Apr 2, 2020
@alan-agius4 alan-agius4 closed this Apr 2, 2020
@alan-agius4 alan-agius4 reopened this Apr 2, 2020
@alan-agius4 alan-agius4 marked this pull request as ready for review April 2, 2020 16:35
@alan-agius4 alan-agius4 requested review from clydin and IgorMinar April 2, 2020 16:35
@alan-agius4 alan-agius4 requested a review from clydin April 3, 2020 08:09
@alan-agius4 alan-agius4 marked this pull request as draft April 21, 2020 13:14
@alan-agius4 alan-agius4 changed the title feat(@schematics/angular): enable strict workspaces by default feat(@schematics/angular): enable stricter type checking and optimization effective coding rules Apr 22, 2020
@alan-agius4 alan-agius4 requested review from IgorMinar and clydin April 22, 2020 11:52
@alan-agius4 alan-agius4 marked this pull request as ready for review April 22, 2020 11:52
@alan-agius4 alan-agius4 added target: major This PR is targeted for the next major release and removed target: major This PR is targeted for the next major release labels Apr 30, 2020
Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than the nits I posted, this looks good overall.

Please resolve the comments.

@kyliau can you please add these changes to the list of changes we'll want the Docs and DevRel team to carefully review - I'd like them to review all changes to "strings" that are displayed to the user either as prompts, config file / schema comments/docs, or comments in generated files that end up in user workspace. thanks!

"noFallthroughCasesInSwitch": true,
"strictNullChecks": true,<% } %>
"strictPropertyInitialization": false,<% } %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? Is this because of @components with @inputs?

I do think that developer's should provide a default value. That's what I do and it works quite well.

I recommend removing this line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that’s the reason.

I’ll also do a PR In AIO to remove that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for AIO, we better do a followup task, as there a quite a lot of errors when I removed "strictPropertyInitialization": false

@IgorMinar IgorMinar added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label May 4, 2020
Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh.. @alan-agius4 one more thing.. weren't we supposed to decrease the budget limits in the --strict mode as well? was that skipped intentionally? Is that in a separate PR? thanks

@alan-agius4
Copy link
Collaborator Author

@IgorMinar, yes I skipped that intentionally as I wanted to follow up with a couple of other PRs to address the bundle budgets and module target.

@IgorMinar
Copy link
Contributor

@alan-agius4 ok. Sgtm

@alan-agius4
Copy link
Collaborator Author

@IgorMinar, FYI I actually pushed the budget change in the PR.

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels May 5, 2020
Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there!

Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great now! let's get this puppy in! thank you!

@dgp1130
Copy link
Collaborator

dgp1130 commented May 5, 2020

@alan-agius4, looks like this was the unlucky one again that hit a merge conflict today.

…tion effective coding rules

With this change we enable stricter type checking and optimization effective coding rules when using the `--strict` option.

Changes in schematics
- `ng-new`: A prompt for the `--strict` option was added. This option is a proxy and will be passed to the application and workspace schematics.
- `application`: A `package.json` was added in the `app` folder, to tell the bundlers whether the application is free from side-effect code. When `strict` is `true`. the `sideEffects` will be set `false`.
- `workspace` When `strict` is true, we add stricter TypeScript and Angular type-checking options.

Note: AIO is already using these strict TypeScript compiler settings. PR to enable `strictTemplates`  angular/angular#36391

Reference: TOOL-1366
… `--strict` option

When using the strict option `anyComponentStyle` and `initial` budgets are more strict.
@alan-agius4
Copy link
Collaborator Author

@dgp1130, conflict solved.

@dgp1130 dgp1130 merged commit a7cf22c into angular:master May 5, 2020
@alan-agius4 alan-agius4 deleted the strict-workspaces branch May 5, 2020 18:51
@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 Jun 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants