Skip to content
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

chore(swingset-liveslots): export TypeScript definitions #10869

Merged

Conversation

sirtimid
Copy link
Contributor

@sirtimid sirtimid commented Jan 21, 2025

refs: #6343

Description

Properly expose TypeScript definitions from @agoric/swingset-liveslots package by adding TypeScript build steps in package.json which generate the definitions.

Security Considerations

No security impact - only affects TypeScript type definitions which are stripped at compile time.

Scaling Considerations

No scaling impact - changes only affect development-time TypeScript support.

Documentation Considerations

No documentation updates needed - this is a developer-facing change for TypeScript users.

Testing Considerations

Existing type coverage tests continue to pass. No additional testing needed as this only affects type definition exposure.

Upgrade Considerations

No upgrade impact - purely development-time TypeScript support changes.

@sirtimid sirtimid requested a review from a team as a code owner January 21, 2025 20:02
@sirtimid sirtimid requested a review from AgoricTriage January 21, 2025 20:02
Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the motivation for introducing a "types" field in package.json (and the manual ts-types.d.ts file. Our types-index approach should work just as well (if it doesn't, I'd like to understand why)

Adding @turadg as he has practice with similar changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to change away from our types-index approach? We tend to avoid adding a types field to the package.json as it's often unnecessary if sibling .d.ts files are generated.

Some of this is described in https://github.com/Agoric/agoric-sdk/blob/master/docs/typescript.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue is that typescript expects a definition of the index file when we import it, else it can't find the types even with the types-index.js approach. This is solved with the pre/postpack commands. Another issue is that we need to export types that aren't part of the runtime hence the types-index approach, which already handled that.

I was trying to avoid making an exception at the postpack which deletes all the definitions (along with the hardcoded one types-index.d.js) hence the type key. My ts-types.ts is not referenced on runtime somewhere. types-index.js was renamed to ts-types.ts but I can revert that of course. It seemed to me it's not the index since index.d.ts is the index now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining. To help keep the codebase manageable we try to be consistent across packages. For this PR please follow the guidelines in https://github.com/Agoric/agoric-sdk/blob/master/docs/typescript.md and if you think they should let's have another PR which updates that guidance and implements the new practice across all the packages.

Copy link
Contributor Author

@sirtimid sirtimid Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhofman @turadg I've reverted the changes with the types field to the package.json and kept the types-index.js approach.

packages/swingset-liveslots/package.json Outdated Show resolved Hide resolved
packages/swingset-liveslots/package.json Outdated Show resolved Hide resolved
packages/swingset-liveslots/tsconfig.json Outdated Show resolved Hide resolved
packages/swingset-liveslots/tsconfig.build.json Outdated Show resolved Hide resolved
@mhofman mhofman requested a review from turadg January 21, 2025 20:24
@sirtimid sirtimid force-pushed the sirtimid/export-swingset-liveslots-types branch 2 times, most recently from 5b4d8c8 to 0211466 Compare January 22, 2025 15:11
@sirtimid sirtimid requested a review from mhofman January 22, 2025 15:11
Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine with a minor nit.

packages/swingset-liveslots/tsconfig.build.json Outdated Show resolved Hide resolved
@mhofman mhofman added the force:integration Force integration tests to run on PR label Jan 22, 2025
@sirtimid sirtimid force-pushed the sirtimid/export-swingset-liveslots-types branch from 0211466 to 8157b30 Compare January 22, 2025 20:23
@mhofman mhofman added the automerge:squash Automatically squash merge label Jan 22, 2025
@turadg
Copy link
Member

turadg commented Jan 22, 2025

This failure is real:

> @agoric/[email protected] prepack
> tsc --build tsconfig.build.json

Error: ../vat-data/src/index.js(53,15): error TS2304: Cannot find name 'MapStore'.
lerna ERR! npm run prepack stderr:

It wasn't detected until integration testing that doesn't run on PR pushes by default (until merge or a force:integration tag)

It appears the d.ts broke the ambients. There might be a lot of changes required to get this passing. (Incidentally this is an issue this PR advances so I've linked it in the description.) I can help but probably not until next week.

@mergify mergify bot merged commit 79df2da into Agoric:master Jan 22, 2025
81 of 82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:squash Automatically squash merge force:integration Force integration tests to run on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants