-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
I2I: Restoring AMP’s Type Checking #34096
Comments
Can we switch the check-types task to using |
That would/will require re-writing almost all of the current typecheck annotations in |
Why? |
There's enough incongruities to make it non-trivial (I timeboxed a few hours to attempt at one point and progress was slow). Transitioning means updating everything at once, or disabling type-checking again in the interim (since making things work with TS == breaking them in CC). Not all JSDoc/CC annotations are handled by TS. CC supports type-narrowing after something like I would love if we used |
Also, I don't know if you've ever seen what the syntax looks like to try to add global externs or add properties to global symbols like |
Now that all of |
Do the honors! |
👏 🎉 |
Overview
For the past year, type checking has been accidentally disabled for the
amphtml
repository. Unfortunately, flipping the switch back on is not so simple because during this time period a very large number (1000s) of type errors have organically been created. Restoring type-checking would help avoid bugs and potentially allow for more advanced compilation optimizationsThis document proposes a multi-pronged approach for gradually restoring type checking to AMP binaries.
Goals
Non-goals
build-system
ortest
files.Current state
src
andextensions
files, except for the newly introducedsrc/core
have type checking disabled.build-system/externs
, and there are 100s of them. This has similar issues with having just a few giant CSS files. It is hard to track which source files depend on which externs and therefore hard to know when it is ok to delete one.*.extern.js
files in build-system to be co-located with the files that need them. Currently onlysrc/core/\*\*/\*.extern.js
(core externs)Approaches
At a high level, there are two kinds of approaches we’d like to pursue: vertical and horizontal.
Horizontal: Gradually increase the minimum type quality via crowdsourcing
Goal: Establish a floor of type quality that each and every AMP Developer is required to maintain.
Source files: --local_changes in each branch.
Encourage (force) developers to ensure the types within the files they are modifying have a baseline of quality. We do this by failing CI when specific JSC errors are found in the modified files. We can also gradually increase the failable error types as time goes on. The first set of errors we should include are
JSC_TYPE_PARSE_ERROR
- Types should at least parse properly.JSC_INVALID_PARAM
- Parameter types should parse.Top-down: expand passing targets
Goal: Lock down passing file(s), preventing new type errors from being introduced to them
**Source files: **any
Externs: migrated externs and build-system externs
pride
type-check target enabling CI type-checkingBottom-up: target top-level src directories
Goal: Establish and lock-down type-safe directories
Source files: subdirectories of
src
(ex. context, polyfills, purifier, etc)**Externs: **its own migrated externs along with core externs
shame.extern.js
src/utils
andsrc/\*.js
flatfiles)/cc @samouri
The text was updated successfully, but these errors were encountered: