I was wondering whether anyone else would be interested in maintaining typings for ProseMirror (in the definitely typed repo I suppose).
I started using ProseMirror in a typescript project this month and am slowly typing the parts of the API I touch (though typings should be helpful for folks with ES6 as well, providing intellisense and all).
p.s.: I am sure these will breaks a lot during the next months as Marijn is changing the API, but we’ll have to adapt existing code anyways
I am just starting out, so basic editor, menubar, some ui related ones - tooltip, update, etc. Mostly its going to grow gradually as I use features and may be some weekends try to complete rest of apis. I like idea of having a shared repo from 0.6 onward. Do you know the projected release timeline for 0.6?
But with TypeScript 2 (with non-nullables, shorthand ambient modules, etc.) coming out soonish and the discussion over here RFC: Splitting the library into packages I have chosen to wait a bit before I start any greater efforts.
I am also still considering to programatically extract definitions from Marijns source files though I currently do not have the time to start efforts on this either. Maybe someone else wants to pick this up?
I will eventually get to this myself (but there’s a looong list of stuff like that), but if someone else wants to tackle this, note that the getdocs library which I’m using to generate the docs can be used to easily extract the type information from the source files. In many cases (though not 100% of them), creating .d.ts files could just be a matter of running getdocs JSON output through a template.
This could probably be generated during npm publish (in case it is ever shipped with the code). Otherwise it should probably go into the typed typings repo on github so everyone can find them.
Have a look at this link. If we can change the package.json then this should be enough. In case Marijn decides to publish the d.ts files alongside the npm package then even having the .d.ts file next to the original JS file should be enough.
I have done some digging on the topic of .d.ts generation - there seems to be a library written in F# that generates definition files from XML (not really what we need).
Your template approach seems to be the most straight forward and quickest to a solution.
Thanks for looking into that! We also tried to generate definitions for prosemirror. We attempted doing the following approach:
runing lebab to convert src/**/*.js to es6 on a separate folder
renaming all ‘.js’ to '.ts’
running tsc(typescript compiler) with some sane default settings to generate definitions
running dts-bundle(type definition bundler) to merge all the .d.ts files into a single one with the declared modules.
We got an almost perfect representation. We however had to clean by hand, the problems we found were:
Not able to generate definitions for this.foo=bar type of assignments inside the constructor
Not able to generate definitions for modules that used the copyObj() to mingle the exports
Our approach was to have a CI build that will attempt to check compatibility with latest prosemirror and this type definitions file and fix by hand from there on.
Would be great if prosemirror itself could export its definitions files. Otherwise we could add the current definitions file that we have to either definitelyTyped or a typings repository so that we could leverage from the community contribution.
Would anyone be so kind to share their typings? Preferably via a public github repo, so that it can be easily installed via typings
I don’t even need to have a .d.ts that is feature-complete or on a par with the latest releases, just enough to start playing with ProseMirror in TypeScript and not having the IDE complain about the imports and missing modules…
Yeah @Mobiletainment, forgot to mention, we published the type definitions to NPM, we have not moved the repo yet to a public repository to allow contributions but we should be doing that soon. Feel free to use our npm package https://www.npmjs.com/package/atlassian-prosemirror-type-definitions however there are still chances that some definitions are broken, we are fixing as we go during our development. Will talk to the team this week to see if we can open the repository to the public to allow external contributions
I’ve also been working on a prosemirror.d.ts file for the latest version, and have something that is mostly working (though not complete, it covers all the parts of pm we’re interacting with and then some). Happy to share it, but also trying to make it a bit more finished first.