Skip to content
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

feat(ivy): strictness flags for template type checking #33273

Closed
wants to merge 4 commits into from

Conversation

JoostK
Copy link
Member

@JoostK JoostK commented Oct 19, 2019

feat(ivy): strictness flags for template type checking

The template type checking abilities of the Ivy compiler are far more
advanced than the level of template type checking that was previously
done for Angular templates. Up until now, a single compiler option
called "fullTemplateTypeCheck" was available to configure the level
of template type checking. However, now that more advanced type checking
is being done, new errors may surface that were previously not reported,
in which case it may not be feasible to fix all new errors at once.

Having only a single option to disable a large number of template type
checking capabilities does not allow for incrementally addressing newly
reported types of errors. As a solution, this commit introduces some new
compiler options to be able to enable/disable certain kinds of template
type checks on a fine-grained basis.


feat(ivy): add flag to disable checking of empty attributes

For elements that have a static attribute without a value, which is
typically the case for attributes like disabled, it may happen that
the element is matched by a directive that consumes the attribute as an
input. In that case, the template type checker will validate the
correctness of the attribute with respect to the directive's declared
type of the input, which would typically be boolean for the disabled
input. Since empty attributes are assigned the empty string at runtime,
the template type checker would report an error for this template.

This commit introduces a strictness flag to help alleviate this
particular situation, effectively ignoring empty attributes that happen
to be consumed by a directive.

@JoostK JoostK added feature Issue that requests a new feature target: major This PR is targeted for the next major release comp: ivy area: compiler Issues related to `ngc`, Angular's template compiler labels Oct 19, 2019
@ngbot ngbot bot added this to the needsTriage milestone Oct 19, 2019
@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@JoostK JoostK force-pushed the ngtsc-ttc-strictness-flags branch 2 times, most recently from ea61718 to 2ed0d51 Compare October 21, 2019 19:14
@kara kara added cla: yes and removed cla: no labels Oct 22, 2019
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@JoostK JoostK marked this pull request as ready for review October 22, 2019 17:31
@JoostK JoostK requested a review from a team as a code owner October 22, 2019 17:31
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

Mostly comments about changing defaults to false even with TTC on.

packages/compiler-cli/src/ngtsc/program.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/ngtsc/typecheck/src/api.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/ngtsc/typecheck/src/api.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/ngtsc/typecheck/src/api.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/transformers/api.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/transformers/api.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/transformers/api.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/transformers/api.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/transformers/api.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/transformers/api.ts Show resolved Hide resolved
alxhub and others added 4 commits October 22, 2019 22:29
In View Engine, with fullTemplateTypeCheck mode disabled, the type of any
inferred based on the entity being referenced. This is a bug, since the
goal with fullTemplateTypeCheck: false is for Ivy and VE to be aligned in
terms of type inference.

This commit adds a 'checkTypeOfReference' flag in the TypeCheckingConfig
to control this inference, and sets it to false when fullTemplateTypeCheck
is disabled.
For elements that have a text attribute, it may happen that the element
is matched by a directive that consumes the attribute as an input. In
that case, the template type checker will validate the correctness of
the attribute with respect to the directive's declared type of the
input, which would typically be `boolean` for the `disabled` input.
Since empty attributes are assigned the empty string at runtime, the
template type checker would report an error for this template.

This commit introduces a strictness flag to help alleviate this
particular situation, effectively ignoring text attributes that happen
to be consumed by a directive.
The template type checking abilities of the Ivy compiler are far more
advanced than the level of template type checking that was previously
done for Angular templates. Up until now, a single compiler option
called "fullTemplateTypeCheck" was available to configure the level
of template type checking. However, now that more advanced type checking
is being done, new errors may surface that were previously not reported,
in which case it may not be feasible to fix all new errors at once.

Having only a single option to disable a large number of template type
checking capabilities does not allow for incrementally addressing newly
reported types of errors. As a solution, this commit introduces some new
compiler options to be able to enable/disable certain kinds of template
type checks on a fine-grained basis.
@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@alxhub alxhub mentioned this pull request Oct 23, 2019
@alxhub
Copy link
Member

alxhub commented Oct 23, 2019

I'm going to close this just to avoid confusion, as I opened my own PR with @JoostK's commits (#33365), so I can do faster round trips and land this ASAP.

@alxhub alxhub closed this Oct 23, 2019
@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 Nov 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler cla: yes feature Issue that requests a new feature target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants