如何在服务器和客户端之间使用服务器端装饰器共享类

时间:2019-01-13 07:25:00

标签: node.js angular

我有包含服务器项目,客户端项目和共享文件夹的存储库。

在共享文件夹中,例如,我有用户模型。

一切正常,直到我尝试添加装饰器,然后尝试尝试编译不必要的服务器库。

我的课:

import {ObjectType, ArgsType, Field} from "../../data-server/node_modules/type-graphql";

@ObjectType()
@ArgsType()
export class User {
    @Field()
    _id?: string;
    @Field()
    firstName: string;
    @Field()
    lastName: string;
}

还有角度编译错误

ERROR in ../data-server/node_modules/@types/graphql/subscription/subscribe.d.ts(36,13): error TS2583: Cannot find name 'AsyncIterator'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.

我不会使用接口,因为我不会为它们添加一些逻辑,也不会创建两个相同的类。 那么还有另一种解决方案吗?

0 个答案:

没有答案