我有这个可以编译:
export namespace Foo {
export namespace GET {
export namespace Basic {
export class Req {}
}
}
}
type Req = Foo.GET.Basic.Req;
e.setRequestBodyType(Foo.GET.Basic.Req);
我想做的是将其减少到一行,就像这样:
type Req = typeof e.setRequestBodyType(Foo.GET.Basic.Req);
但是,我遇到此错误:
tsc --watch只是这样说:
express-test.ts:34:37-错误TS1005:“;”预期的。
34 type Req = typeof e.setRequestType(Foo.GET.Basic.Req);
有人知道我该怎么做吗?
现在辅助方法如下:
setRequestType(v:any){
return v;
}
我尝试过:
setRequestType<T>(v:T): T{
return v;
}
但是我得到:
很奇怪。
答案 0 :(得分:1)
org.apache.kafka.common.errors.RecordTooLargeException: The request included a message larger than the max message size the server will accept
类型的运算符仅接受标识符,而不接受方法调用。
请参见spec。