LeDDGroup / typescript-transform-paths

Transforms module resolution paths using TypeScript path mapping and/or custom paths
MIT License
480 stars 27 forks source link

[Bug] 3.4.1 update breaks decorator #163

Closed samchon closed 2 years ago

samchon commented 2 years ago

After updating to 3.4.1 version, such error occurs.

If I rollback to previous version, the error be disappeard.

The one thing special is, such error occurs only when run by dynamic import statement with ts-node, but imported in a JS file. Type of decorator is not a matter.

TypeError: Cannot read properties of undefined (reading 'value')
    at D:\github\samchon\nestia\node_modules\@nestjs\common\decorators\http\request-mapping.decorator.js:15:76
    at D:\github\samchon\nestia\node_modules\@nestjs\common\decorators\core\apply-decorators.js:21:13
    at DecorateProperty (D:\github\samchon\nestia\node_modules\reflect-metadata\Reflect.js:553:33)
    at Reflect.decorate (D:\github\samchon\nestia\node_modules\reflect-metadata\Reflect.js:123:24)
:1180:10)    at Object.require.extensions.<computed> [as .ts] (D:\github\samchon\nestia\node_modules\ts-node\src\index.ts:1600:12)
samchon commented 2 years ago

This is a demonstration repo occuring that bug.

https://github.com/samchon/typescript-transform-paths-163

samchon commented 2 years ago

@nonara Same error on v3.4.2

nonara commented 2 years ago

Thanks for the report!

I've cloned and done some preliminary investigation. From what I can tell the PropertyDescriptor is not being passed from the compiled __decorate() function in controller.ts.

Notably, I would point out that 3.3.x did not properly support TS 4.8, because TS merged Decorators and Modifiers in their AST. It also didn't properly support ts-node when not run in transpileOnly mode.

There is a chance that what you are seeing is a result of these modes being supported, and it may not be a bug within TSTP, itself.

The best way to track this out is to get at the compiled source for controller.ts and then determine exactly why it's not passing a property descriptor with one version vs. the other.

Unfortunately, I don't have the time right now to continue tracking this out. I've spent the last two days during a heavy work week doing the fixes I could. If you're able to tag in and do some debugging to figure out more about what is happening, you can keep me in the loop in this thread and I can help get it done. I just don't have the bandwidth right now to do in depth debugging.

nonara commented 2 years ago

Never mind! I had a thought on this and did a little more digging. Thanks for reporting this.

It is corrected in v3,4,3, Let me know if you have any further issues.