-
Notifications
You must be signed in to change notification settings - Fork 214
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
clean up types modules #9364
clean up types modules #9364
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.
Before I approve,
- I'd like to hear from @Chris-Hibbert about the Timestamp vs. TimestampRecord change
- I think I should understand the use of CapData in smart-wallet better
* @param {Timestamp} baseTime | ||
* @param {TimestampRecord} baseTime | ||
* @returns {import('./scheduler.js').Schedule} | ||
*/ | ||
export const computeRoundTiming = (params, baseTime) => { |
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.
The test that's changed in eb64643 seems to show that the wider Timestamp
type does work here. While narrowing the type is a longer-term goal, the fact that a test had to be changed shows that it's a breaking change.
@Chris-Hibbert what do you think about narrowing this type at this point?
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.
I think this is movement forward. This particular change won't have wider impacts beyond the test, so it's fine to require compliance with the target state.
defineKind: <P, S, F>( | ||
tag: string, | ||
// @ts-expect-error rest parameter must be of an array type | ||
init: (...args: P) => S, |
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.
must be array or Parameters
type, right? I suppose there's no way to say "<P extends Parameters, ...>"?
I'm a little surprised that this works; i.e. that the types of the init parameters get checked. Do we happen to have a type test?
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.
I didn't invest in fixing these because they're all on @deprecated
types
packages/time/src/types.ts
Outdated
@@ -290,17 +290,19 @@ export type TimeMathType = { | |||
) => RelativeTimeRecord; | |||
/** | |||
* An absolute time + a relative time gives a new absolute time. | |||
* | |||
* @template {Timestamp} T |
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.
this was ignored before because it wasn't a .js
file.
When I made converted the syntax, it narrowed too much all the way to the value literal. That's why made the conditional to return one of two types
gah. this will need more work. Some packages export types at the top level like so: https://github.com/Agoric/agoric-sdk/blob/9553675cd136d389c427e024fc4da78558344779/packages/time/index.js#L3-L5 When those packages get bundled, the bundler can't find the file. This is good for safety of the bundler (it doesn't know anything about I'll see about exporting through the package.json exports patterns. But that will take a while so I'll drop this PR into draft. |
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.
looks fine to me.
* @param {Timestamp} baseTime | ||
* @param {TimestampRecord} baseTime | ||
* @returns {import('./scheduler.js').Schedule} | ||
*/ | ||
export const computeRoundTiming = (params, baseTime) => { |
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.
I think this is movement forward. This particular change won't have wider impacts beyond the test, so it's fine to require compliance with the target state.
Deploying agoric-sdk with Cloudflare Pages
|
Until we release from master (#9252), even types changes can have an impact on the cost of preparing a release. I don't think this PR makes the job much harder than it already is, but I do keep that in mind. |
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.
I think I'll need get more experience with this to grok fully.
but for now, it looks like a step forward
to fix build order sensitivity
Helps avoid exporting private type
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.
These look like great improvements and documentation. My main concern is how this might indeed make cherry-picking more complex for PRs stacked on top of this.
|
||
We have `"skipLibCheck": true"` in the root tsconfig.json because some libraries we depend on have their own type errors. (A massive one is the output of Telescope, used in `@agoric/cosmic-proto`.) | ||
|
||
This means that the types you write in `.d.ts` file won't be checked by `tsc`. To gain some confidence, you can temporarily flip that setting in a package's own `tsconfig.json` and pay attention to only the relevant errors. |
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.
I didn't realize that, yikes!
- package entrypoint(s) exports explicit types | ||
- for packages upon which other packages expect ambient types: | ||
- `exported.js` exports the explicit types and ambient re-exports | ||
|
||
## .d.ts modules | ||
|
||
We cannot use `.ts` files any modules that are transitively imported into an Endo bundle. The reason is that the Endo bundler doesn't understand `.ts` syntax and we don't want it to until we have sufficient auditability of the transformation. Moreover we've tried to avoid a build step in order to import a module. (The one exception so far is `@agoric/cosmic-proto` because we codegen the types. Those modules are written in `.ts` syntax and build to `.js` by a build step that creates `dist`, which is the package export.) |
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.
Is the dist
not checked in? I didn't realize we introduced a required build step. At least those files don't really change much.
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.
Correct.
|
||
One option considered is having the conditional package `"exports"` include `"types"` but that has to be a .d.ts file. That could be generated from a `.ts` but it would require a build step, which we've so far avoided. | ||
|
||
Once we have [JSDoc export type support](https://github.com/microsoft/TypeScript/issues/48104) we'll be able instead to keep the `index.js` entrypoint and have it export the types from `.ts` files without a runtime import of the module containing them. |
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.
That would be great indeed. I would likely still want the .ts
file to only contain declare
statements.
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.
Agreed!
To help I've reduced the number of changes. I hope they'll be obvious to resolve in a merge. Another reason I reduced them is I realized the |
refs: #9364 ## Description Follow-up to #9364, also doing the `skipLibCheck: false` for Zoe package and fixing up most of the issues. (Documenting the deferred). ### Security Considerations <!-- Does this change introduce new assumptions or dependencies that, if violated, could introduce security vulnerabilities? How does this PR change the boundaries between mutually-suspicious components? What new authorities are introduced by this change, perhaps by new API calls? --> ### Scaling Considerations <!-- Does this change require or encourage significant increase in consumption of CPU cycles, RAM, on-chain storage, message exchanges, or other scarce resources? If so, can that be prevented or mitigated? --> ### Documentation Considerations <!-- Give our docs folks some hints about what needs to be described to downstream users. Backwards compatibility: what happens to existing data or deployments when this code is shipped? Do we need to instruct users to do something to upgrade their saved data? If there is no upgrade path possible, how bad will that be for users? --> ### Testing Considerations <!-- Every PR should of course come with tests of its own functionality. What additional tests are still needed beyond those unit tests? How does this affect CI, other test automation, or the testnet? --> ### Upgrade Considerations just types and tests. will not affect production but small impact on release process (cherry picking)
no ticket
Description
Started as documentation for #9356 (comment) , then I carried out the new best practice so it would be consistent. That was a bit of a rabbit hole.
It's in a better place, though I don't see it reflected obviously in the type coverage report.
Security Considerations
n/a, types
Scaling Considerations
n/a, types
Documentation Considerations
This documents the new beset practice
Testing Considerations
CI
Upgrade Considerations
n/a, types