We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
请问为啥说「装饰器对类的行为的改变,是代码编译时发生的,而不是在运行时」?
这里的「代码编译时」指的是「ts/esnext 编译为 js」,还是指「js 运行过程中的编译阶段」?
如果是指的「ts/esnext 编译为 js」,那么我测试了一下 babel 和 tsc,编译出来的代码中 testable 装饰器是在运行时才会执行的。
testable
如果是指「js 运行过程中的编译阶段」,那目前还没有浏览器/Node 能够直接运行 decorator,执行的都是 ts/esnext 转为 js 后的代码。
这个是因为历史原因么?以前的 babel 编译会在编译阶段执行?
The text was updated successfully, but these errors were encountered:
JS 引擎以前不支持装饰器,“编译”就是指在 Babel/TS 转换代码时,会处理掉装饰器。
JS 引擎现在支持了,这样说就不对了,应该说装饰器是在引擎“评估”(evalute)代码时执行。我把这行删了。
Sorry, something went wrong.
e8c2d2e
docs(decorator): fixed ruanyf#1165
589fa2c
No branches or pull requests
请问为啥说「装饰器对类的行为的改变,是代码编译时发生的,而不是在运行时」?
这里的「代码编译时」指的是「ts/esnext 编译为 js」,还是指「js 运行过程中的编译阶段」?
如果是指的「ts/esnext 编译为 js」,那么我测试了一下 babel 和 tsc,编译出来的代码中
testable
装饰器是在运行时才会执行的。如果是指「js 运行过程中的编译阶段」,那目前还没有浏览器/Node 能够直接运行 decorator,执行的都是 ts/esnext 转为 js 后的代码。
这个是因为历史原因么?以前的 babel 编译会在编译阶段执行?
The text was updated successfully, but these errors were encountered: