-
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
♻️ Migrate most of #core to pass TS typechecking #37141
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read through the first half. Will finish reviewing tomorrow morning. Looks great ⭐
This pull request introduces 15 alerts when merging 80a13bb into 3e8072d - view on LGTM.com new alerts:
|
This pull request introduces 7 alerts when merging 06e7268 into 6268ef3 - view on LGTM.com new alerts:
|
Hey @jridgewell! These files were changed:
|
Pass tsc for #core/dom
@samouri bumping this |
Do you know what all of the bundle size changes are from? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work like usual
// obfuscated. | ||
// TODO(rcebulko): Closure Compiler used this and the @dict annotation to check | ||
// that properties are only accessed using bracket notation. We need to | ||
// verify this works with TypeScript/esbuild. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot enforce this guarantee unless we write a custom script via the new TS API.
That said, I don't think fields get dangerously obfuscated like they did with CC... so this is not really an issue.
cc @jridgewell
Migrates most of the files under
src/core
from Closure type-checking to Typescript. Closure will no longer pass type-checking on many (most?) of these files. As a result, all Closure-based type-checking will stop passing (and so has been silenced incheck-types.js
). Later PRs will handle cleaning out legacy type-checking code.Two
#core
directories are excluded:context
andassert
.context
is intricate and isolated, so it can be migrated independently while this PR unblocks progress elsewhere in the repo.assert
will be more involved because of differences in how CC and TS handle assertion annotations, so its type signatures are stubbed in this PR to be addressed in a later PR.Some "globals" we access through the
window
object, which we rely on for some polyfills and testing scenarios. Because TS doesn't expect them to be on the window, there are corresponding TS definition files.d.ts
which add these properties to theWindow
interface. Anything in a.d.ts
file is TS-only logic that need to live outside of existing JS annotations. Mostly, they replace existing.extern.js
files.Files ending in
.shame.d.ts
contain "band-aids", such as type stubs, that allow type-checking to pass. One example isassert.shame.d.ts
, which tellstsc
to skip type-checking#core/assert
for now and instead provides the type signatures it should expect.