typescript.api icon indicating copy to clipboard operation
typescript.api copied to clipboard

Inheritance issue, doesn't works with AMD compilation

Open Vadorequest opened this issue 11 years ago • 2 comments

I guess I understand now why inheritance dosn't works sometimes.

I made a test:

__message = require('./../../../shared/lib/public/Message.ts').Message;
    __validatorMessage = require('./../../../shared/lib/public/ValidatorMessage.ts').ValidatorMessage;

First works, second fails because he inherit the Message class. I got a

__validatorMessage = require('./../../../shared/lib/public/ValidatorMessage.ts').Validator
                                                                                ^
TypeError: Cannot read property 'ValidatorMessage' of null

If I remove inheritance (and comment inherited code compilation errors) it works.

Both files are compiled in AMD mode. Now, if I compile both in CommonJS, that works perfectly (loading + execution)

Vadorequest avatar Jan 01 '14 04:01 Vadorequest

Hiya

Apologies for the late reply,

Yeah, I did not spend a lot of time trying to support AMD modules, as the library was mostly geared towards nodejs development (all commonjs). So im actually amazed you got AMD working at all :P

Also, inheritance is somewhat quirky, some of the issues i was hitting came down to the source file resolver i had written, and oddities with the typescript emitter. I believe the updated TypeScript compiler comes bundled with a built in resolver and better emitter than what was in 0.9.1.1, So i would recommend checking out https://www.npmjs.org/package/typescript-api, which grants easy access to the most recent compiler classes.

All the best :)

sinclairzx81 avatar Mar 14 '14 12:03 sinclairzx81

Node.js use CommonJs by default, yes. But some files that I wrote were shared between both client/server and compiled in AMD to do so, in these special cases use typescript-api didn't work, especially with inheritance (A in AMD inherited by B in commonJs)

And sometimes, I don't know why, the module doesn't works anymore and we need to npm remove and install again.

Finally, I don't use it anymore, but use TypeScript with node was actually a LOT more difficult than what I thought in first place. Even now I'm using AMD from requirejs and I got other bullshit issues related to the paths.

So... TS and Node.js is not really a good way to work, not server side. Too much complicated issues not solvable. (the requirejs path is horrible, it use absolute path from root while the TS need relative path from file when you want to inherit, and both are incompatible, no solution found)

2014-03-14 13:38 GMT+01:00 sinclairzx81 [email protected]:

Hiya

Apologies for the late reply,

Yeah, I did not spend a lot of time trying to support AMD modules, as the library was mostly geared towards nodejs development (all commonjs). So im actually amazed you got AMD working at all :P

Also, inheritance is somewhat quirky, some of the issues i was hitting came down to the source file resolver i had written, and oddities with the typescript emitter. I believe the updated TypeScript compiler comes bundled with a built in resolver and better emitter than what was in 0.9.1.1, So i would recommend checking out https://www.npmjs.org/package/typescript-api, which grants easy access to the most recent compiler classes.

All the best :)

— Reply to this email directly or view it on GitHubhttps://github.com/sinclairzx81/typescript.api/issues/14#issuecomment-37642595 .

Cordialement,

M. Ambroise Dhenain.

Vadorequest avatar Mar 14 '14 12:03 Vadorequest