打字稿编译器API-生成静态嵌套类
可以像以下内容一样声明tysparcript中的嵌套静态类,如以下
export class Foo {
public static readonly Bar = class {
public static readonly FooBar: string = 'FooBar';
}
}
使用函数createClassDeclaration
从Typescript Compiler api生成一个静态类I时,
export class Foo {
public static readonly class Bar {
public static readonly FooBar: string = 'FooBar';
}
}
声明 。节点。
在这里,我的编译
"compilerOptions": {
"module": "commonjs",
"target": "ESNext",
"resolveJsonModule": true,
"esModuleInterop": true
}
是我的问题是,如何创建一个静态类,如上一个代码示例中所示?
Nested static classes in TypeScript can be declared like the following
export class Foo {
public static readonly Bar = class {
public static readonly FooBar: string = 'FooBar';
}
}
When using the function createClassDeclaration
from the TypeScript compiler api to generate a static class I receive the following that doesn't compile
export class Foo {
public static readonly class Bar {
public static readonly FooBar: string = 'FooBar';
}
}
I run my generation script with ts-node.
Here my compilerOptions
"compilerOptions": {
"module": "commonjs",
"target": "ESNext",
"resolveJsonModule": true,
"esModuleInterop": true
}
So my question is, how can I create a static class like shown in the first code example above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论