“Decorators-legacy”当前未启用

Posted

技术标签:

【中文标题】“Decorators-legacy”当前未启用【英文标题】:"Decorators-legacy" isn't currently enabled 【发布时间】:2020-01-07 13:01:54 【问题描述】:

我在后端和前端之间共享一个对象类型。我将它用作验证器,当 Graphql 在客户端和服务器之间交换数据时,它只发送这些对象类型的数据。

这是一个 AuthenticationInput 对象:

    import  Field, InputType  from "type-graphql";
    @InputType()
export class AuthenticationInput 

    @Field(nullable: false)
    email: string;

    @Field(nullable: false)
    password: string

这存在于后端和前端。在 graphQL 上运行的 apollo 服务器的后端没有问题。但是,在客户端我收到此错误:

Support for the experimental syntax 'decorators-legacy' isn't currently enabled

我的 tsconfig.json 中确实有 "experimentalDecorators": true。我不知道该怎么办。我收到 Field 和 InputType 的错误。

使用 webpack、next.js、react、typescript 运行。

谢谢。

【问题讨论】:

【参考方案1】:

问题是这些配置不能在客户端运行并且与 React 不兼容。

【讨论】:

有什么解决办法吗?

以上是关于“Decorators-legacy”当前未启用的主要内容,如果未能解决你的问题,请参考以下文章