-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
@nativescript/[email protected], NativeClass Transformer does not recognize classes defined inside functions #11092
Description
Issue Description
I've identified a regression in the NativeClass transformer starting from version 5.0.25. In previous versions (v5.0.24 and earlier), the transformer appeared to use a broader search (likely fullText.indexOf('@NativeClass')), which successfully captured classes defined within function scopes.
In the latest versions, the transformer seems to only scan top-level class declarations. Classes nested inside functions (local classes/closure classes) are ignored by the transformer, causing TypeScript to emit standard __decorate helpers. Since the NativeScript runtime does not define __decorate and requires specific class rewriting for native injection, this leads to a runtime error.
Reproduction
unzip ts-test.zip
npm i
npx webpack
Expected Behavior:
The nested class should be transformed/rewritten into the compatible ES5-like structure regardless of its nesting level.
Actual Behavior:
The transformer skips the class, and __decorate is emitted in dist/bundle.js
Relevant log output (if applicable)
Environment
No response
Please accept these terms
- I have searched the existing issues as well as StackOverflow and this has not been posted before
- This is a bug report
- I agree to follow this project's Code of Conduct