-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Types: Enable incremental JSDoc type checking #13104
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
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for the pull request, @donmccurdy! ✅ We can confirm we have a CLA on file for you. |
jjspace
left a comment
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 this @donmccurdy! Overall I'm hugely in favor of this change. It should let us get more out of our intellisense and start catching some type errors even before switching fully to TS.
Can you please add a section to our documentation pages about this? Probably part of the Contribution guides, maybe the CodingGuide? I also had a few more comments to help guide what gets documented.
f2cef71 to
fbe8a40
Compare
84dfb32 to
c8a10b5
Compare
|
@jjspace I think all feedback on the PR has been addressed! Draft documentation in the coding guide: I've moved the I also attempted a bulk conversion to ES6 classes for That's too large to review and merge in bulk, for sure, but still it's encouraging to see tests passing after excluding a handful of files from the conversion. |
Description
Summary
Enables IDEs with TypeScript language server support (such as VSCode) to infer types from JSDoc and detect type errors automatically. The PR is 'minimal' in the sense that it does not require migrating code into subpackages, and does not require replacing tsd-jsdoc. Either of those larger changes might still be preferable for other reasons, certainly. Adoption of TypeScript checks could be entirely incremental with this approach; we can turn type-checking on one file at a time.
Changes
packages/engine/tsdoc.json, with type-checking disabled for all JS files by default. Individual JS files may opt-in to type checking with a// @ts-checkcomment at top of file./** @import Cartesian3 from './Cartesian3.js'; */. TypeScript understands these, but JSDoc errors on them, so we update the JSDoc configuration to ignore@importtags. Huge thanks to @jjspace for this solution!tscand check types, for files that we have opted in.Background
Minimal subset of work from 12/16/2025 hackathon day, including work from @jjhembd, @jdehorty, @jjspace, and myself. Other tracks explored in the hackathon — including JSDoc-TS compatibility conversion with Gemini, smaller package reorganization, build system updates, documentation generation with typedoc, , etc. — are on the
core-mathbranch. We'll likely want to use some of those results too, but this PR might be the minimum-viable starting point.Issue number and link
Testing plan
Run
npm run tsc, and observe no errors reported. Addthis.x = 'hello world'to the Cartesian2 constructor, runnpm run tscagain, and see expected error output:The same error should appear in your editor/IDE, without explicitly running
tsc, if the editor supports the TypeScript Language Server.Author checklist
CONTRIBUTORS.mdCHANGES.mdwith a short summary of my changePR Dependency Tree
This tree was auto-generated by Charcoal