-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve type hints to support advanced code navigation and assistance in IDEs (Intellij, VSCode) and LSPs #1002
Comments
@philippfromme I've commented with a few more findings. @barmac Would be amazing if you could fill in the TypeScript blanks 😉. |
@nikku I'll work with this project using Typescript, thus I will most likely produce type definitions for it. My opinion is that you should move everything to Typescript incrementally. I've noticed it really gives a boost to code quality and organization. Also, as a user of IDEA/WebStorm, I've yet to find a better tooling, it's amazing, no joke. |
@lppedd Thanks for sharing your feedback. Just to manage expectations: We cannot promise any move to TypeScript any time soon 😉 . |
As mentioned in the issue text, there exists other solution approaches that will likely give you the same amount of type hints without the need for us to move fully to TypeScript. We'd appreciate your help improving the typed support. |
@nikku I almost completed typings for |
@nikku @philippfromme here you can find an initial attempt at typings. I've done a bit of everything, but still I'm losing a lot of time debugging trying to understand objects' structures. If you could give a look and comment with some suggestion, it would be awesome! The nice thing about the declarations is that
|
I like this one in particular that implements your example. |
@nikku yeah, that was a good idea! The same concept is applied also to
I've provided "defaults" for bpmn-js, but a user can extend those typings by simply redefining
and then, in implementation code
And if no match
What I'm not sure about is the |
That's how I implemented
The
Which is basically what you'd do with
Just a lot cleaner for TS. |
This is awesome! Is it planned to release in npm? |
Nothing planned here. |
It would be great to see detailed API documentation and/or TypeScript added to this project. It is quite a lot of effort to find out what properties certain objects have (contexts, elements, events, etc.) what events are available, what parts of the system respond to which events, what the 'best practices' are for using/overriding/creating modules, what modules do, among other things. This would be particularly useful when breaking changes are introduced, as while there is a changelog, type safety really does help the developer experience. I would be happy to help out with at least the TypeScript effort if there is to be one. |
@nikku Hi! I've made some progress with typings. I'd like some help with this declaration, the |
@patoncrispy If you want you can PR here https://github.com/lppedd/bpmnio-typings for now. |
Cool thanks @lppedd I'll take a look soon. |
Hey @lppedd what more work do you think would need to be done to get your typings work into DefinitelyTyped? |
@patoncrispy it has been months I haven't worked on TS/JS projects, but I can assure you what I have done is a small portion of the framework. There is much much more |
For historical purposes, this is what we've found in the past: Option 1: Leverage TypeScript foundations... Option 2: Leverage existing JSDoc annotationsRight now we have a quite comprehensive set of existing type definitions, baked into our JSDoc statements. One example from our code base ( /**
* Parse and render a BPMN 2.0 diagram.
*
* Once finished the viewer reports back the result to the
* provided callback function with (err, warnings).
*
* ## Life-Cycle Events
*
* During import the viewer will fire life-cycle events:
*
* * import.parse.start (about to read model from xml)
* * import.parse.complete (model read; may have worked or not)
* * import.render.start (graphical import start)
* * import.render.complete (graphical import finished)
* * import.done (everything done)
*
* You can use these events to hook into the life-cycle.
*
* @param {String} xml the BPMN 2.0 xml
* @param {ModdleElement<BPMNDiagram>|String} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
* @param {Function} [done] invoked with (err, warnings=[])
*/
Viewer.prototype.importXML = function(xml, bpmnDiagram, done) {
... This allows VSCode to provide decent hints already. It does not know about Idea: Create type definitions for all types we refer toBy providing the corresponding JSDoc type definitions we can improve the existing developer experience. Given the following typings:
|
As indicated via #332 (comment) you can now generate TypeScript definitions from JSDoc types. |
Closed by https://github.com/bpmn-io/internal-docs/issues/688. bpmn-js@13 includes type declarations. |
What should we do
We should fix the JSDoc type definitions across our projects and leverage TypeScript's support for JavaScript projects.
tsc --noEmit --pretty
JSDoc
(Provide Documentation #332 (comment))bpmnJS.get
What we should not do
We should not, as of today, migrate our projects to TypeScript:
The text was updated successfully, but these errors were encountered: