Skip to content

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

@mozbugbox

Description

@mozbugbox

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions