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

Add improved TypeScript support. #355

Merged
merged 26 commits into from
Apr 6, 2024
Merged

Add improved TypeScript support. #355

merged 26 commits into from
Apr 6, 2024

Conversation

jheer
Copy link
Member

@jheer jheer commented Apr 1, 2024

This PR starts to provide better TypeScript support, but stops well short of complete typings. Sufficient changes were made to prevent the widget test from failing on the latest TS version. Future todos include more coverage of jsdoc-based types in the core Mosaic packages.

Changelog:

  • Add and publish TypeScript types for declarative JSON specs.
  • Update some jsdoc typings throughout Mosaic packages.
  • Add test TypeScript files for all specs, run tsc on them as part of @uwdata/mosaic-spec tests.
  • Refactor handleParam mark utility for better clarity and type-friendliness.
  • Bump to latest version of TypeScript.

@jheer jheer requested a review from domoritz April 1, 2024 19:39
@jheer
Copy link
Member Author

jheer commented Apr 1, 2024

@domoritz It would be great if you can take a look and chime in on whether this is on the right track and if you'd suggest any changes in approach.

jheer and others added 2 commits April 2, 2024 08:58
* chore(deps): bump actions/configure-pages from 4 to 5 (#352)

* docs: add types for setPlot and plot attributes

---------

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@jheer
Copy link
Member Author

jheer commented Apr 2, 2024

@domoritz FYI it looks like your type updates now cause type check failures, probably due to interactions with my changes?

@domoritz
Copy link
Member

domoritz commented Apr 2, 2024

I fixed the issues in my changes so they pass now. I also just enabled type checks for the specs in js. Feel free disable that again but it looks like we have some discrepancies that this finds. E.g. SpecNode is a thing in js but not in d.ts.

@jheer
Copy link
Member Author

jheer commented Apr 2, 2024

I fixed the issues in my changes so they pass now. I also just enabled type checks for the specs in js. Feel free disable that again but it looks like we have some discrepancies that this finds. E.g. SpecNode is a thing in js but not in d.ts.

Yes, thank you! I've been focusing first on types for the declarative spec itself, and then will look more at the AST node classes. My ideal would likely be to use jsdoc for the classes and d.ts for the JSON, but I'm not sure such a hybrid typing approach is supported out of the box (and I haven't had time to dig into that yet).

@domoritz
Copy link
Member

domoritz commented Apr 2, 2024

Disabled for now. Might actually be worth switching to Typescript at this point so we type check the implementation against the spec as well. But that can happen later.

Copy link
Member

@domoritz domoritz left a comment

Choose a reason for hiding this comment

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

having both .d.ts and JSDocs with types is confusing and seems to break VSCode at least (and tsk if we type check the js files). The problem is that it doesn't know whether to go to the js file or the d.ts file to get the types for a method etc. It would maybe be easier to either go all in on ts or to move all types into the d.ts files.

Having said that, this is still a good step forwards so I am supportive of merging it.

@domoritz
Copy link
Member

domoritz commented Apr 5, 2024

What's your main concern with going all ts? Is it that it would mean that we have to explicitly opt out of typing rather than opt in for all code or that we would need to compile any dependency before we can use it in a dependent package?

@jheer
Copy link
Member Author

jheer commented Apr 5, 2024

I'm not dead set against going all TS at some point. It's just that it's a big porting lift and not a top priority at the moment.

@jheer jheer merged commit 81099a6 into main Apr 6, 2024
2 checks passed
@jheer jheer deleted the jh/spec-types branch April 6, 2024 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants