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

Use JSDoc with tsc for strong static typing #65

Open
brodycj opened this issue Oct 2, 2019 · 1 comment
Open

Use JSDoc with tsc for strong static typing #65

brodycj opened this issue Oct 2, 2019 · 1 comment

Comments

@brodycj
Copy link

brodycj commented Oct 2, 2019

It is possible to use JSDoc comments with the TypeScript compiler to enforce some strong typing, as documented in the following resources:

Here is the best example I have found: prettier/prettier#6313

I would personally favor this alternative over porting to TypeScript as proposed in #64.

@brodycj brodycj changed the title Use JSDoc with tsc for strong typing Use JSDoc with tsc for strong static typing Oct 2, 2019
@fbartho
Copy link
Contributor

fbartho commented Oct 10, 2019

I'm also looking to do a technique like this for another node library I contribute to.

I think this is set up to work best with the next major version of TypeScript coming out at the beginning of next month, as they're making changes to support parsing JS+JSDoc via TypeScript-compiler.

Specifically, I think this PR was a blocker: microsoft/TypeScript#32372

If JSDoc is super detailed and robust, then theoretically, the .d.ts declaration file could be directly output from there. -- From my initial work writing the JSDoc types for another library, however, it was way clunkier and harder to do than directly writing TypeScript, and nothing helped guide correctness in the JSDoc types. :(

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

2 participants