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

Create TypeScript type definitions for phet-lib #3

Closed
jonathanolson opened this issue Feb 7, 2024 · 3 comments
Closed

Create TypeScript type definitions for phet-lib #3

jonathanolson opened this issue Feb 7, 2024 · 3 comments

Comments

@jonathanolson
Copy link
Collaborator

This would be helpful/necessary to really work with phet-lib in TypeScript. Ideally we'd build the type definitions along-side the JS code.

@samreid
Copy link
Member

samreid commented Oct 28, 2024

We added d.ts output in phetsims/chipper#1424, next we need a way to bundle/include it with phet-lib.

jonathanolson added a commit to phetsims/scenery-stack-test that referenced this issue Oct 30, 2024
@jonathanolson
Copy link
Collaborator Author

I've got the holy grail of an NPM package set up in testing (scenery-stack-test). Using phetsims/phet-vite-demo@03eb961 (the scenery-stack-test branch of phet-vite-demo), I have a much more standard setup running:

image

It's type-safe (using TSC output for JS, d.ts, d.ts.map, and js.map), supports all of our common code, and seems to be working very swimmingly!

Example imports in a library: https://github.com/phetsims/phet-vite-demo/blob/scenery-stack-test/src/main.ts#L8-L16. It is type safe, and uses declaration/source maps so the development experience is up to par.

It also shows promise for how we might be able to link our dependencies easily in package.json (instead of awkwardly in sherpa, with type definition hackery): https://github.com/phetsims/scenery-stack-test/blob/main/package.json#L100-L115. I'm able to easily wrap those to provide globals (https://github.com/phetsims/scenery-stack-test/blob/main/src/minimal-preload.ts#L4-L33).

Current build approach is brittle. Figuring out "what translated strings do we include, and do we include translations" will be an interesting problem/question. It is NOT tree-shakeable right now.

jonathanolson added a commit to phetsims/axon that referenced this issue Oct 31, 2024
jonathanolson added a commit to phetsims/density-buoyancy-common that referenced this issue Oct 31, 2024
jonathanolson added a commit to scenerystack/scenerystack that referenced this issue Oct 31, 2024
@jonathanolson
Copy link
Collaborator Author

This has been completed for the scope of this issue, closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants