Skip to content

Does not support TS decorators? #4884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
7 tasks done
kcsap opened this issue Sep 9, 2021 · 6 comments
Closed
7 tasks done

Does not support TS decorators? #4884

kcsap opened this issue Sep 9, 2021 · 6 comments

Comments

@kcsap
Copy link

kcsap commented Sep 9, 2021

Describe the bug

Does not support TS decorators? The return of reflect.getmetadata acquisition is null
image

The expected results are as follows:

image

Reproduction

npm run dev

System Info

node v12.5.0
npm V6.9.0
"vite": "^2.5.3",
"vue": "3.2.8",

Used Package Manager

npm

Logs

No response

Validations

@github-actions
Copy link

github-actions bot commented Sep 9, 2021

Hello @kcsap. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@kcsap
Copy link
Author

kcsap commented Sep 9, 2021

This is the source code

`
import {BaseController, Controller, Resource} from "csap-typescript-framework/lib";
import {TestService} from "@/api/service/TestService";
import {TestList, TestRequest, TestSearch} from "@/api/model/TestModel";
import {TestService2} from "@/api/service/TestService2";

@controller("product",)
export class TestController extends BaseController<TestService, TestRequest, TestSearch, TestList, number> {
@resource()
service: TestService;
@resource()
service2: TestService2;

getFormValidate(): Array<Function | TestRequest> {
    return [TestRequest];
}

getService(): TestService {
    return this.service;
}

getService2(): TestService2 {
    return this.service2;
}

test(): void {

}

}`

After operation

var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __decorateClass = (decorators, target, key, kind) => { var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result; if (kind && result) __defProp(target, key, result); return result; }; import __vite__cjsImport0_csapTypescriptFramework_lib from "/node_modules/.vite/csap-typescript-framework_lib.js?v=1ae95b89"; const BaseController = __vite__cjsImport0_csapTypescriptFramework_lib["BaseController"]; const Controller = __vite__cjsImport0_csapTypescriptFramework_lib["Controller"]; const Resource = __vite__cjsImport0_csapTypescriptFramework_lib["Resource"]; import { TestRequest } from "/src/api/model/TestModel.js"; export let TestController = class extends BaseController { service; service2; getFormValidate() { return [TestRequest]; } getService() { return this.service; } getService2() { return this.service2; } test() { } }; __decorateClass([ Resource() ], TestController.prototype, "service", 2); __decorateClass([ Resource() ], TestController.prototype, "service2", 2); TestController = __decorateClass([ Controller("product") ], TestController);

There should be TS reflection type, which can be accessed by the reflect. GetMetadata () method

__metadata("design:type", Function)

@haoqunjiang
Copy link
Member

That's not a valid reproduction.

@kcsap
Copy link
Author

kcsap commented Sep 9, 2021

Esbuild does not support TS decorators, so is there any other solution? I don't want to use webpack too slowly. It's mainly the development environment. Thank you.

@haoqunjiang
Copy link
Member

esbuild does support TypeScript experimentalDecorators.

@haoqunjiang
Copy link
Member

emitDecoratorMetadata can't be supported though. It needs a type system https://esbuild.github.io/content-types/#no-type-system

@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants