retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.14k stars 653 forks source link

Seamless TypeScript integration #260

Closed Ni55aN closed 5 years ago

juliandavidmr commented 5 years ago

Hello, I converted all the source code from Rete to Typescript, including several improvements in type recognition ... All the changes are here: https://github.com/juliandavidmr/rete

juliandavidmr commented 5 years ago

Also, I started to test the use of Rete from decorators to create components, events and controls.

Ni55aN commented 5 years ago

I have added @babel/preset-typescript and build a code as before via rete-cli without tons of dependencies in each package. For type checking and generating .d.ts I'm using pure tsc. FYI, JS code also replaced with TS

juliandavidmr commented 5 years ago

What do you think about of incorporating decorators into this project? (Same as Angular or NestJS)

i.e:

@Component()
export class ComponentA { /* ... */ }
@Control()
export class ControlX { /* ... */ }

With functions:

@Event('nodecreated')
OnCreateNode(node: Node) {
    console.log('Node created:', node)
}

It might be good to separate this new feature into a new repository (for maintainability reasons).

Some examples here

Githamza commented 5 years ago

@juliandavidmr Thank you for your efforts . I would like to start a projet using Angular + Rete, I would like to know if it's better to use the official JS version or your version.

You think that you will be able to update your version every official Rete new release ?

I would ask your for a demo ( in stackblitz ) using Rete TS inside an angular projet if it's possible ? 👍

Ni55aN commented 5 years ago

What do you think about of incorporating decorators into this project?

What is the advantage of decorators over inheritance in this case? What are the alternatives for JS?

Ni55aN commented 5 years ago

@juliandavidmr events are well typed at the previous form

Screenshot from 2019-03-23 21-29-35

IMHO decorators in this case are not needed, moreover there is the issue of compatibility with JS

Ni55aN commented 5 years ago

rete-cli@v0.6.0 supports additional babel presets and extensions, which allows to add TS support for plugins on demand

https://rete.js.org/#/cli