RapydScript icon indicating copy to clipboard operation
RapydScript copied to clipboard

Typescript has problem compile RS --es6 output at class attributes

Open mozbugbox opened this issue 6 years ago • 2 comments

Test:

class Test:
    def __init__(self):
        self.value1 = null
    def method(self):
        self.value1 = 0
$ npx rapydscript -p -6 typescriptKlass.pyj > typescriptKlass.ts
$ tsc --lib es7 typescriptKlass.ts 
typescriptKlass.ts:26:18 - error TS2339: Property 'value1' does not exist on type 'Test'.

26             self.value1 = null;
                    ~~~~~~

typescriptKlass.ts:30:18 - error TS2339: Property 'value1' does not exist on type 'Test'.

30             self.value1 = 0;
                    ~~~~~~


Found 2 errors.

It seems that the attributes need to be decleared at the scope of class first for typescript.

BTW: It would be great to transcompile to type annotated typescript code.

mozbugbox avatar Dec 12 '19 03:12 mozbugbox

RS has its own type-annotation, why do you need TS?

valq7711 avatar Dec 12 '19 18:12 valq7711

Some 3rd party projects use typescript. I want to include RS libs I wrote to the projects.

mozbugbox avatar Dec 13 '19 01:12 mozbugbox