feat(ivy): use the schema registry to check DOM bindings#32171
feat(ivy): use the schema registry to check DOM bindings#32171alxhub wants to merge 1 commit intoangular:masterfrom
Conversation
There was a problem hiding this comment.
How about renaming this option to checkTypeOfInputBindings?
There was a problem hiding this comment.
How about
| const id = this.sourceManager.allocateId(sourceMapping, file); | |
| const id = this.sourceManager.captureSource(sourceMapping, file); |
or similar as it's not only allocating an id, but actually storing the source mapping data for later use.
There was a problem hiding this comment.
Could you please move TemplateSource to below TcbSourceManager, as it's the sole owner of that type. Perhaps even better would be to break out this logic into a separate file.
There was a problem hiding this comment.
Extracted to source.ts :) thanks, this is cleaner.
There was a problem hiding this comment.
I like this refactor, now that it has substantially more usage sites :)
There was a problem hiding this comment.
Yeah, it feels like this was a missing piece in the design.
There was a problem hiding this comment.
Could use a comment, especially how it relates to TcbUnclaimedInputsOp as these ops are queued in pairs.
There was a problem hiding this comment.
| this.opQueue.push(new TcbSchemaCheckerOp(this.tcb, node, true, claimedInputs)); | |
| this.opQueue.push(new TcbSchemaCheckerOp(this.tcb, node, /* checkElement */ true, claimedInputs)); |
There was a problem hiding this comment.
Even better, I extracted a variable with a long comment attached to it.
There was a problem hiding this comment.
Loosing this test is quite unfortunate, as it's an easy feature to regress in. We could pass a full TypeCheckingConfig to tcb to keep verifying this behavior.
In general, there seems to be no remaining tests for checkTypeOfDomBindings IIUC, as it's disabled in all configurations I stumbled upon.
There was a problem hiding this comment.
👍 reinstated the test in an experimental section.
There was a problem hiding this comment.
The invocation of the DOM schema checker is currently not controlled by this flag, but only depending on the NgModule.schemas config. I believe this is the desired behavior as I mentioned in an earlier review, however can we include a note here to mention it explicitly, as any schemas configured will still check DOM bindings according to the schema.
|
As a side note, disabling the DOM bindings in the template type checker for now will "fix" several reported issues around |
b352f48 to
db8a227
Compare
JoostK
left a comment
There was a problem hiding this comment.
Except for the failing Material tests and a minor comment, LGTM!
There was a problem hiding this comment.
Oops, looks like a bad rebase. Could you restore this test and the one below?
There was a problem hiding this comment.
Actually this change was intentional - these tests as written tested the behavior when binding to properties of plain DOM elements. But you're right, their functionality is relevant for binding to directive inputs as well, so I've ported them to test that instead.
db8a227 to
83de52f
Compare
Previously, ngtsc attempted to use the .d.ts schema for HTML elements to check bindings to DOM properties. However, the TypeScript lib.dom.d.ts schema does not perfectly align with the Angular DomElementSchemaRegistry, and these inconsistencies would cause issues in apps. There is also the concern of supporting both CUSTOM_ELEMENTS_SCHEMA and NO_ERRORS_SCHEMA which would have been very difficult to do in the existing system. With this commit, the DomElementSchemaRegistry is employed in ngtsc to check bindings to the DOM. Previous work on producing template diagnostics is used to support generation of this different kind of error with the same high quality of error message.
83de52f to
d8f5014
Compare
|
@AndrewKushnir this could probably use an Ivy global presubmit prior to landing, just to make sure it doesn't break any apps in g3. |
Previously, ngtsc attempted to use the .d.ts schema for HTML elements to check bindings to DOM properties. However, the TypeScript lib.dom.d.ts schema does not perfectly align with the Angular DomElementSchemaRegistry, and these inconsistencies would cause issues in apps. There is also the concern of supporting both CUSTOM_ELEMENTS_SCHEMA and NO_ERRORS_SCHEMA which would have been very difficult to do in the existing system. With this commit, the DomElementSchemaRegistry is employed in ngtsc to check bindings to the DOM. Previous work on producing template diagnostics is used to support generation of this different kind of error with the same high quality of error message. PR Close angular#32171
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Previously, ngtsc attempted to use the .d.ts schema for HTML elements to
check bindings to DOM properties. However, the TypeScript lib.dom.d.ts
schema does not perfectly align with the Angular DomElementSchemaRegistry,
and these inconsistencies would cause issues in apps. There is also the
concern of supporting both CUSTOM_ELEMENTS_SCHEMA and NO_ERRORS_SCHEMA which
would have been very difficult to do in the existing system.
With this commit, the DomElementSchemaRegistry is employed in ngtsc to check
bindings to the DOM. Previous work on producing template diagnostics is used
to support generation of this different kind of error with the same high
quality of error message.
Reviewers: only the last commit is important.