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

Suggestion: generate typescript declarations using angular/clutz (Closure to TypeScript .d.ts generator) #1826

Closed
Bnaya opened this issue Jan 17, 2018 · 9 comments

Comments

@Bnaya
Copy link

Bnaya commented Jan 17, 2018

As Allow --declaration with --allowJs TypeScript/issues/7546 has no clear due date (future milestone)

I think it would be very helpful to find alternative way to generate high-quality and correct typescript declarations.

Angular has https://github.com/angular/clutz, which is: Closure to TypeScript .d.ts generator
And because puppeteer already have Closure compiler annotations that passes typescript linting, I assume it should be trivial for someone who knows Closure well to use it to generate declarations.

(I tired myself, had issues with nodejs externes. i will continue trying when i will find time)

Related #1170

@aslushnikov
Copy link
Contributor

@Bnaya I've unsuccessfully spent quite a bit of time convincing closure to work with node.js codebase.
We ended up adopting tsc for linting.

What's the goal of this? As I've heard from VSCode users, suggestions work really nice with puppeteer.

+cc @JoelEinbinder

@Bnaya
Copy link
Author

Bnaya commented Jan 18, 2018

@aslushnikov, vscode ain't typescript, for typescript project you still need to install the @types/puppeteer, (which is manually managed, and not aligned with the actual puppeteer api)
There's no way (?) to tell tsc to treat the JSDOC of an external package as the types information.
If its not part of the project goals,I totally understand, and i will close issue

I will try to do it myself,
I'm also struggling with the commonjs and closure, but i still have some motivation left

@JoelEinbinder
Copy link
Contributor

types@puppeteer is an external project which appears maintained: https://www.npmjs.com/package/@types/puppeteer
I use it in my personal projects.

Without built in support from typescript itself, I don’t think it’s a big enough win for us to create our own d.ts files.

@stereobooster
Copy link

One thing most developers do not pay attention is that there are a lot of flavours of JSDoc and not all of them compatible. For example:

I learned this idea from "state of documentation.js" post. Here is a full list of JSDoc flavours that I'm aware of.

@Bnaya
Copy link
Author

Bnaya commented Jan 18, 2018

@JoelEinbinder, its not up to date with 1.0, and also using dom, symbols, (not clear to me why). it's forcing the user to also add the dom lib to the tsconfig even its a node project.

@JoelEinbinder
Copy link
Contributor

@Bnaya, Because of the way we handle evaluation in Chromium, Elements can appear as the arguments to page functions.

As stereobooster mentions, JSDoc is not very consistent. Moving from closure style JSDoc to typescript style JSDoc was a large project, and I'm not very excited to add a third JSDoc parser into the mix in parallel.

@Bnaya
Copy link
Author

Bnaya commented Jan 21, 2018

Looks like there's activity at microsoft/TypeScript#20735, with emitting types from typescript-jsdocs
So i'm closing this one

@Bnaya Bnaya closed this as completed Jan 21, 2018
@nojvek
Copy link
Contributor

nojvek commented Jan 29, 2018

This is the PR you probably want: microsoft/TypeScript#21455

The goal is to enable tons of pure js projects just like puppeteer to automatically generate .d.ts files as part of build.

I will be using puppeteer as a real world example to test this out. I'll create a PR with auto-generated declarations for your feedback.

Do you know of other projects with well documented jsdoc types that I should be aware of?

@stereobooster
Copy link

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

No branches or pull requests

5 participants