-
Notifications
You must be signed in to change notification settings - Fork 32
Add types to ecmascript.ts #74
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
Conversation
5aaf364
to
73fb640
Compare
eef0d7e
to
98893f3
Compare
40a9ed1
to
f8a4a57
Compare
Not sure why Test262 shows as failed given that the output doesn't report any failures. Trying to re-run. |
Hmmm, looks like Test262 tests aren't actually emitting output into the GH actions log. There was a local failure but I don't see its details in CI. I'll fix the failure but seems like something isn't quite right with our CI setup. |
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.
Mostly just questions for my own understanding.
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.
Thanks for reviewing so many changes! I think I've either resolved all the issues you found, or want to defer them until later.
I'll commit the final changes over the weekend and if I don't hear complaints from @ptomato then I'll go ahead and merge because I have a follow-up PR ready to add parameter and return types to all other methods. This includes cleaning up the Parameters
stuff you commented about. If there are remaining issues from this PR to deal with, we can resolve them in the next one since there's a lot of overlap.
BTW, adding types to other files found a few bugs in the public types. Was a useful exercise.
fallback: Allowed | 'auto', | ||
disallowedStrings: ReadonlyArray<Disallowed> = [], | ||
autoValue?: IfAuto | ||
): IfAuto extends undefined ? Allowed | 'auto' : Allowed { |
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.
Yep, I didn't figure out a way in the compiler to validate that Allowed doesn't overlap with Disallowed. Also, agreed on the overloads, because once I typed all the usage of this function then I learned that IfAuto didn't actually work. I'll push a commit with some edits. PTAL.
This commit continues where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, it turns on --noImplicitAny. Getting this working in calendar.ts will probably require more work than I want to take on in this PR, so I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will defnitely need a follow up to improve calendar.ts. Other than that one file, this should be pretty solid. One thing I need to figure out is why tests won't work. I think it's caused by importing Intl fom `..` (to pick up the public types) instead of importing it from intl.ts directly. The fix is probably in resolve.source.mjs but I could use help to figure this out.
This commit continues where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, it turns on --noImplicitAny. The worst `any` offender is calendar.ts, and fully declaring all its types is more work than I want to take on in this PR, so I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will defnitely need a follow up to improve calendar.ts. Other than that one file, this commit essentially removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. There's still lots of TS work remaining (e.g. strictNullChecks, strictPropertyInitialization, and cleaning up calendar.ts), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this commit fixes those too.
f0ace7c
to
3e8a755
Compare
This commit continues where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, it turns on --noImplicitAny. The worst `any` offender is calendar.ts, and fully declaring all its types is more work than I want to take on in this PR, so I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will defnitely need a follow up to improve calendar.ts. Other than that one file, this commit essentially removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. There's still lots of TS work remaining (e.g. strictNullChecks, strictPropertyInitialization, and cleaning up calendar.ts), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this commit fixes those too.
3e8a755
to
b58d996
Compare
This commit continues where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, it turns on --noImplicitAny. The worst `any` offender is calendar.ts, and fully declaring all its types is more work than I want to take on in this PR, so I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will defnitely need a follow up to improve calendar.ts. Other than that one file, this commit essentially removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. There's still lots of TS work remaining (e.g. strictNullChecks, strictPropertyInitialization, and cleaning up calendar.ts), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this commit fixes those too.
This commit continues where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, it turns on --noImplicitAny. The worst `any` offender is calendar.ts, and fully declaring all its types is more work than I want to take on in this PR, so I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will defnitely need a follow up to improve calendar.ts. Other than that one file, this commit essentially removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. There's still lots of TS work remaining (e.g. strictNullChecks, strictPropertyInitialization, and cleaning up calendar.ts), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this commit fixes those too.
This commit continues where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, it turns on --noImplicitAny. The worst `any` offender is calendar.ts, and fully declaring all its types is more work than I want to take on in this PR, so I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will defnitely need a followup PR to improve calendar.ts. Other than that one file, this commit essentially removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. There's still lots of TS work remaining (e.g. `strictNullChecks`, `strictPropertyInitialization`, and cleaning up calendar.ts), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this commit fixes those too.
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.
No objection from me
Seems like the GH UI is doing something weird - I can't seem to respond to any of the open conversations unless I click "into" them, and even then the comments don't seem to propagate back. I have no objections to merging this as-is and following up on my comments later, especially given some of them might be fixed by compiler flag changes (e.g. |
b58d996
to
31f1b41
Compare
This commit continues where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, it turns on --noImplicitAny. The worst `any` offender is calendar.ts, and fully declaring all its types is more work than I want to take on in this PR, so I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will defnitely need a followup PR to improve calendar.ts. Other than that one file, this commit essentially removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. There's still lots of TS work remaining (e.g. `strictNullChecks`, `strictPropertyInitialization`, and cleaning up calendar.ts), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this commit fixes those too.
* Improves types for slots and intrinsics * ecmascript.ts now has types throughout and compiles with `noImplicitAny` (although a later PR will actually enable this option) * Fixes BigInt errors in a few places to fix compiler errors and test failures. Will be replaced by James's work on JSBI. * Fixes a few index.d.ts bugs in the public types. * Overhauls how plural units are handled in TS types. * Partially adds types to calendar.ts. (More coming later.) * A new internal types file for non-public shared types.
31f1b41
to
04b214f
Compare
This commit continues where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, it turns on --noImplicitAny. The worst `any` offender is calendar.ts, and fully declaring all its types is more work than I want to take on in this PR, so I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will defnitely need a followup PR to improve calendar.ts. Other than that one file, this commit essentially removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. There's still lots of TS work remaining (e.g. `strictNullChecks`, `strictPropertyInitialization`, and cleaning up calendar.ts), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this commit fixes those too.
This commit continues where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, it turns on --noImplicitAny. The worst `any` offender is calendar.ts, and fully declaring all its types is more work than I want to take on in this PR, so I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will defnitely need a followup PR to improve calendar.ts. Other than that one file, this commit essentially removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. There's still lots of TS work remaining (e.g. `strictNullChecks`, `strictPropertyInitialization`, and cleaning up calendar.ts), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this commit fixes those too.
Continue where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, turn on `noImplicitAny`. Except for calendar.ts, this PR removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. For calendar.ts, `any` is removed from the top level `Calendar` implementation and some of the `impl[]` code, but fully declaring all types in that file was more work than I wanted to take on in this PR. So I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will definitely need a followup PR to improve calendar.ts. @12wrigja has discussed the possibility of replacing the old-school inheritance using Object.apply with a modern `class`-based implementation. If we're going to do that, then it may make sense to fix the types then instead of on top of the current solution. Aside from calendar.ts, there's still lots of TS work remaining (e.g. `strictNullChecks`, `strictPropertyInitialization`), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this PR fixes those too. Once the dust settles and the changes are reviewed, I can port a change back to proposal-temporal to keep all public types in sync.
Continue where js-temporal#74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, turn on `noImplicitAny`. Except for calendar.ts, this PR removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. For calendar.ts, `any` is removed from the top level `Calendar` implementation and some of the `impl[]` code, but fully declaring all types in that file was more work than I wanted to take on in this PR. So I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will definitely need a followup PR to improve calendar.ts. @12wrigja has discussed the possibility of replacing the old-school inheritance using Object.apply with a modern `class`-based implementation. If we're going to do that, then it may make sense to fix the types then instead of on top of the current solution. Aside from calendar.ts, there's still lots of TS work remaining (e.g. `strictNullChecks`, `strictPropertyInitialization`), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this PR fixes those too. Once the dust settles and the changes are reviewed, I can port a change back to proposal-temporal to keep all public types in sync.
Continue where #74 left off by adding parameter and return types to the rest of (non-ecmascript.ts) Temporal source files. Also, turn on `noImplicitAny`. Except for calendar.ts, this PR removes `any` (implicit or otherwise) from the polyfill, with only a few exceptions for truly generic code or testing propeties on `globalThis`. For calendar.ts, `any` is removed from the top level `Calendar` implementation and some of the `impl[]` code, but fully declaring all types in that file was more work than I wanted to take on in this PR. So I did an initial pass on obvious types and assigned a lot of `any` for the rest. Will definitely need a followup PR to improve calendar.ts. @12wrigja has discussed the possibility of replacing the old-school inheritance using Object.apply with a modern `class`-based implementation. If we're going to do that, then it may make sense to fix the types then instead of on top of the current solution. Aside from calendar.ts, there's still lots of TS work remaining (e.g. `strictNullChecks`, `strictPropertyInitialization`), but at least we'll now have valid types on all functions. I didn't find any runtime errors as a result of this work (good!) but I did find quite a few problems with the public types in index.d.ts, and this PR fixes those too. Once the dust settles and the changes are reviewed, I can port a change back to proposal-temporal to keep all public types in sync.
Make ecmascript.ts type-safe:
noImplicitAny
BTW, this is part of a larger roadmap. Here's the tentative plan: