1 typescript typegraphql ts-node-dev
import { ObjectType, ID, Int, Field } from 'type-graphql';
@ObjectType()
export default class Address {
@Field(type => ID)
id: String;
@Field()
type: string;
@Field()
title: string;
@Field()
location: string;
}
Run Code Online (Sandbox Code Playgroud)
信息:ts-node-dev 版本。1.0.0(使用 ts-node 版本 9.1.1,typescript 版本 4.0.5)
使用此命令启动应用程序时ts-node-dev --respawn server.shop.ts
出现以下错误。(无法从 TypeScript 反射系统推断 GraphQL 类型。您需要为“Address”类的“id”提供显式类型。)
添加
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
Run Code Online (Sandbox Code Playgroud)
在你的 tsconfig.json 中