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

feat: add type declarations for core components #732

Merged
merged 7 commits into from
Mar 1, 2023

Conversation

philippfromme
Copy link
Contributor

@philippfromme philippfromme commented Jan 17, 2023

Includes TypeScript declarations for

  • lib/command/*
  • lib/core/*
  • lib/model/*
  • lib/draw/BaseRenderer
  • lib/features/modeling/Modeling
  • lib/features/modeling/Overlays

Related to #78
Related to https://github.com/bpmn-io/internal-docs/issues/688

@bpmn-io-tasks bpmn-io-tasks bot added the in progress Currently worked on label Jan 17, 2023
@philippfromme philippfromme force-pushed the type-declarations branch 10 times, most recently from 899ed38 to 427577a Compare January 23, 2023 08:28
@philippfromme
Copy link
Contributor Author

philippfromme commented Jan 23, 2023

Next steps:

  • decide whether to add more type declarations (e.g. for context pad, palette, ...)
  • decide whether or not the strategy for testing the type declarations is sufficient
  • fix JSDoc comments
  • add type declarations to bpmn-js

@philippfromme philippfromme marked this pull request as ready for review January 23, 2023 08:46
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Jan 23, 2023
canExecute?(context: any): boolean;
preExecute?(context: any): void;
postExecute?(context: any): void;
$inject?: string[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$inject is necessary? Why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if we require it it shall be static.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was asking myself that question. I'd like to communicate somehow that a command handler is going to be instantiated by the command stack and, therefore, can use the $inject syntax. Unfortunately, interfaces do not support static members (cf. microsoft/TypeScript#13462).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not transport that through types, but through proper documentation.

You could consider to expand the CommandHandler documentation or write new one (docs.bpmn.io).

@nikku
Copy link
Member

nikku commented Jan 24, 2023

Really nice stuff.

I dove into this and added #744 as a potential to improve this PR. Please have a 👀.

What I really like is how you created dedicated type specs (that also cover real world use-cases).

This way we can build out types on a real world use-case / demand basis.

@nikku
Copy link
Member

nikku commented Jan 24, 2023

Consider splitting up existing type tests so the file does not get HUGE at some point.

@barmac
Copy link
Member

barmac commented Jan 27, 2023

I'm looking into this today. Sorry for delay.

@nikku
Copy link
Member

nikku commented Jan 27, 2023

@barmac This is not urgent I believe. Please add your feedback, and also account for #744 in the process.

@barmac
Copy link
Member

barmac commented Jan 27, 2023

In the end, I deprioritized this for this week ^^

@philippfromme
Copy link
Contributor Author

philippfromme commented Jan 30, 2023

As discussed with @nikku we will:

  • merge Type declarations 2 #744 (review) into the feature branch of this pull request
  • not add more type declarations
  • add integration tests for each type declaration file (e.g. Canvas.spec.ts tests Canvas.d.ts)
  • fix and copy/add JSDoc comments to the type declarations

@nikku nikku added the in progress Currently worked on label Feb 1, 2023 — with bpmn-io-tasks
@nikku
Copy link
Member

nikku commented Feb 23, 2023

@philippfromme Looks like you're still making progress on this item.

Let's chat tomorrow what is left open / the status of this PR. Happy to review (if it makes sense) tomorrow.

@philippfromme
Copy link
Contributor Author

@nikku I walked @marstamm through the pull request today and he'll review it, too. Yes, I'm making a couple of adjustments that are easy fixes. Let's chat tomorrow.

@philippfromme philippfromme force-pushed the type-declarations branch 4 times, most recently from a9ea7f6 to 6825273 Compare February 23, 2023 19:36
Fixes some type declarations.
@philippfromme philippfromme force-pushed the type-declarations branch 2 times, most recently from 897bc70 to e7d1a18 Compare February 24, 2023 07:59
@philippfromme
Copy link
Contributor Author

@marstamm @nikku Let me know if there's anything keeping you from approving the pull request.

@marstamm
Copy link
Contributor

I will look into it today

Comment on lines 3 to 7
import CoreModule from '.';
import ElementFactory from '../../core/ElementFactory';

import ModelingModule from '.';
import Modeling from './Modeling';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoreModule and ModelingModule import the same thing here. Because the test suceeds, I assume we don't actually need the Core Module here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dropped it with 81d861e and it works fine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the same thing indeed 👍

Copy link
Contributor Author

@philippfromme philippfromme Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooopsie. Good catch! The tests don't fail because errors due to missing modules can only happen during runtime.

Copy link
Contributor

@marstamm marstamm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified some import paths and fixed some typos. Can you confirm that #732 was just a copy/paste issue and not something fundamental?

Other than that, I am happy to merge it 🎉

@nikku
Copy link
Member

nikku commented Mar 1, 2023

Great stuff @philippfromme and great review @marstamm 🎉. Let's get this merged @philippfromme?

* options are optional
* core module is added by default
@philippfromme
Copy link
Contributor Author

I just added a last simplification. Let's merge!

@philippfromme
Copy link
Contributor Author

🎉

@philippfromme philippfromme merged commit 2ba1a7f into develop Mar 1, 2023
@philippfromme philippfromme deleted the type-declarations branch March 1, 2023 08:39
@bpmn-io-tasks bpmn-io-tasks bot removed the in progress Currently worked on label Mar 1, 2023
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

Successfully merging this pull request may close these issues.

4 participants