n8n
n8n copied to clipboard
refactor: Use `NodeConnectionType` consistently across the code base (no-changelog)
Summary
I was moving the NodeSettings.vue file https://github.com/n8n-io/n8n/pull/10545 to use the composition API and trying to fix one small type issue snowball into a lot of type issues because we have two types in the FE that represent the same. One is an enum, and the other is a type union that we use in the editor-ui, workflow, and nodes-base, and they do not match (a known problem with enums). So, to avoid this, I deleted the ConnectionType type and used the NodeConnectionType enum everywhere.
- Uses NodeConnectionType consistently across the code base.
- Deletes ConnectionType type.
ALL unit, integration and e2e tests pass.
Review / Merge checklist
- [x] PR title and summary are descriptive. (conventions)
- [ ] Docs updated or follow-up ticket created.
- [ ] Tests included.
- [ ] PR Labeled with
release/backport(if the PR is an urgent fix that needs to be backported)
n8n
Run #6665
Run Properties:
Passed #6665 •
93a6afacd5: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 RicardoE105 🗃️ e2e/*
| Project |
n8n
|
| Branch Review |
refactor-types-NodeConnectionType
|
| Run status |
|
| Run duration | 04m 48s |
| Commit |
|
| Committer | Ricardo Espinoza |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
421
|
| View all changes introduced in this branch ↗︎ | |
:white_check_mark: All Cypress E2E specs passed
Got released with [email protected]
eslint-plugin-n8n-nodes-base is not happy with NodeConnectionType.Main
30:3 error Replace with "['main']" [autofixable] n8n-nodes-base/node-class-description-outputs-wrong
if I put ['main'] then INodeTypeDescription yells at me.
I am not sure how the community node developers are keeping up with you guys. :(
@Juneezee apologies for the harm this caused. Us not realizing this is a breaking change for the n8n-workflow package was an oversight from our end. To fix the errors you can use the NodeConnectionType enum from the n8n-workflow package and replace 'main' with NodeConnectionType.Main
To fix the errors you can use the
NodeConnectionTypeenum from then8n-workflowpackage and replace'main'withNodeConnectionType.Main
@tomi Thanks for your reply. This fixes the TypeScript error, but the ESLint error still remain. The ESLint rule from this plugin https://github.com/ivov/eslint-plugin-n8n-nodes-base needs to be updated. See
- https://github.com/ivov/eslint-plugin-n8n-nodes-base/issues/194
- https://github.com/ivov/eslint-plugin-n8n-nodes-base/issues/195
i am still not able to figure out if i put input: [NodeConnectionType.Main] then linter yells at me and if i put input: ['main'], compiler yells at me. finally when i use input: '={{"main"}}' both are happy. i am not sure if this will work or break.
To fix the errors you can use the NodeConnectionType enum from the n8n-workflow package and replace 'main' with NodeConnectionType.Main
@tomi that is indeed the fix, however, as @anantanandgupta pointed out (and I've suffered as well), the linter rules have not been updated to reflect these changes, and therefore the only option to build a custom node currently is to completely disable the linter.