Skip to content

Conversation

@Buckwich
Copy link
Member

@Buckwich Buckwich commented Nov 7, 2025

Closes #39

Proposed Changes

Try out

install and try the new script check-types

npm run check-types

currently no errors should be found

try to adjust jsdoc params in a ts capable editor, you should get in editor errors

image

if you prefer cli only just run the script again to see the errors

Checklist

To ensure you provided everything we need to look at your PR:

  • Brief textual description of the changes present
  • Visual demo attached
  • Steps to try out present, i.e. using the @bpmn-io/sr tool
  • Related issue linked via Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}

@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Nov 7, 2025
@Buckwich Buckwich changed the title 39_check-types Add type checking and fix issues Nov 7, 2025
@Buckwich Buckwich requested review from a team, nikku and philippfromme and removed request for a team November 7, 2025 16:09
@Buckwich
Copy link
Member Author

@bpmn-io/modeling-dev Do you like 2 tsconfigs (one for test, one for source, +helpers) or one unified as in camunda/camunda-modeler#5186 more?

@Buckwich Buckwich requested a review from a team November 13, 2025 10:10
* @property {string} [detail] longer description of the variable content
* @property {boolean} [isList] whether the variable is a list
* @property {Array<Variable>} [schema] array of child variables if the variable is a context or list
* @property {boolean|'optional'} [isList] whether the variable is a list
Copy link
Member

Choose a reason for hiding this comment

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

Any idea of what it means that isList is "optional"?

Copy link
Member Author

@Buckwich Buckwich Nov 13, 2025

Choose a reason for hiding this comment

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

not quite. the tests are using both boolean values and 'optional'. I didn't want to adjust the implementation (for now) and just fix the docs to reflect the implementation (unless its obviously broken).

optional is checked here: https://github.com/bpmn-io/feel-editor/blob/39_check-types/src/autocompletion/pathExpression.js#L43

image

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps the answer is in the variable resolver. I will look for an answer in our codebase.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed it's coming from variable resolver, and is supposed to handle cases where a variable is created once as a list, and once as a non-list: https://github.com/bpmn-io/variable-resolver/blob/e69f839538a8368024dfcbfcef7e56e64b53713a/lib/base/VariableResolver.js#L346
So essentially variable: T[] | U

Copy link
Member

Choose a reason for hiding this comment

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

Meaning: The variable can be a list, but does not have to.

@barmac
Copy link
Member

barmac commented Nov 13, 2025

@bpmn-io/modeling-dev Do you like 2 tsconfigs (one for test, one for source, +helpers) or one unified as in camunda/camunda-modeler#5186 more?

Do we even want to typecheck the tests? What is the benefit?

@Buckwich
Copy link
Member Author

Buckwich commented Nov 13, 2025

Do we even want to typecheck the tests? What is the benefit?

we don't have to typecheck them, but having a tsconfig for tests helps with autocompletion and intellisense. By having two separate configs we could adjust the CI to only enforce one, or check tests less strict. even though I would like to check everywhere with the same config.

Checking tests as well helps validating additional constraints, ie. if I would have just checked src one might think the correct type for isList is string. But by also checking test sources I realized both boolean and 'optional' are required. having the type check saved me from going really deep into the code, or at least pointed me to the right place

@barmac
Copy link
Member

barmac commented Nov 13, 2025

Thanks for the clarification. Can we then have 2 tsconfig files: one for source code, one for tests? Currently, I see 4 files listed.

@Buckwich
Copy link
Member Author

Buckwich commented Nov 13, 2025

can we then have 2 tsconfig files: one for source code, one for tests? Currently, I see 4 files

the base helper is needed to share configs between the src and test. the main tsconfig is an easier entry point for ides and commands, but could be adjusted to just have two tsc commands. Cf b74e767 with some duplicated configs

Note: this only works if test and src are separate, eg in camunda-modeler this wouldn't work as we have __test__ inside src (app/client)

@barmac
Copy link
Member

barmac commented Nov 13, 2025

I've just pushed 1c40800 which I think is the simplest config we can maintain. Two separate config files but the source one includes most of the configuration. WDYT?

Copy link
Member

@barmac barmac left a comment

Choose a reason for hiding this comment

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

✅ from me. Great work

@Buckwich
Copy link
Member Author

the problem with 1c40800 is that vscode then doesn't work in test (eg no intellisense, no type checking), only the cli works

@Buckwich
Copy link
Member Author

i applied your idea of extending source in fa846d8

@barmac
Copy link
Member

barmac commented Nov 13, 2025

OK but it works with ed69c6d

@Buckwich
Copy link
Member Author

yeah, its the same. then i'm fine with it

@barmac
Copy link
Member

barmac commented Nov 13, 2025

i applied your idea of extending source in fa846d8

I missed that, but generally I think tsconfig should be placed in the root unless it's a test-specific config.

@Buckwich
Copy link
Member Author

i'll go ahead and squash the commits and force push

Buckwich and others added 2 commits November 13, 2025 15:02
Co-authored-by: Maciej Barelkowski <maciej.barelkowski@camunda.com>
@Buckwich
Copy link
Member Author

@barmac are you happy with the config now, I'm planning to apply the same also to other projects (where we have separate src/test folders)

@Buckwich Buckwich merged commit 300fa7b into main Nov 13, 2025
7 checks passed
@Buckwich Buckwich deleted the 39_check-types branch November 13, 2025 14:11
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Nov 13, 2025
@barmac
Copy link
Member

barmac commented Nov 13, 2025

Absolutely! Great work

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.

Variable type does not match structure used in editor

3 participants