导出的TypeScript问题

时间:2018-12-05 12:55:46

标签: node.js typescript prisma

我面临的是棱柱ts文件中的导出问题: 我正在节点graphql项目中运行它。

以下是问题:

05-12-2018 18:20:16: SyntaxError: /home/user/Publish/PracticeBusiness/src/generated/prisma.ts: Unexpected token, expected { (11:7)
05-12-2018 18:20:16:    9 | import { makePrismaBindingClass, BasePrismaOptions } from 'remote-graphql-binding'
05-12-2018 18:20:16:   10 | 
05-12-2018 18:20:16: > 11 | export interface Query {
05-12-2018 18:20:16:      |        ^
05-12-2018 18:20:16:   12 |     agreement: <T = Agreement | null>(args: { id?: Float, name?: String, description?: String, version?: String, type?: Int, validityduration?: Int, inactive?: Boolean, createdat?: String, createdbyid?: Float, updatedat?: String, updatedbyid?: Float, idEq?: Float, nameEq?: String, descriptionEq?: String, versionEq?: String, typeEq?: Int, validitydurationEq?: Int, inactiveEq?: Boolean, createdatEq?: String, createdbyidEq?: Float, updatedatEq?: String, updatedbyidEq?: Float, idGt?: Float, nameGt?: String, descriptionGt?: String, versionGt?: String, typeGt?: Int, validitydurationGt?: Int, inactiveGt?: Boolean, createdatGt?: String, createdbyidGt?: Float, updatedatGt?: String, updatedbyidGt?: Float, idGte?: Float, nameGte?: String, descriptionGte?: String, versionGte?: String, typeGte?: Int, validitydurationGte?: Int, inactiveGte?: Boolean, createdatGte?: String, createdbyidGte?: Float, updatedatGte?: String, updatedbyidGte?: Float, idLt?: Float, nameLt?: String, descriptionLt?: String, versionLt?: String, typeLt?: Int, validitydurationLt?: Int, inactiveLt?: Boolean, createdatLt?: String, createdbyidLt?: Float, updatedatLt?: String, updatedbyidLt?: Float, idLte?: Float, nameLte?: String, descriptionLte?: String, versionLte?: String, typeLte?: Int, validitydurationLte?: Int, inactiveLte?: Boolean, createdatLte?: String, createdbyidLte?: Float, updatedatLte?: String, updatedbyidLte?: Float, idLike?: Float, nameLike?: String, descriptionLike?: String, versionLike?: String, typeLike?: Int, validitydurationLike?: Int, inactiveLike?: Boolean, createdatLike?: String, createdbyidLike?: Float, updatedatLike?: String, updatedbyidLike?: Float, idIsNull?: Boolean, nameIsNull?: Boolean, descriptionIsNull?: Boolean, versionIsNull?: Boolean, typeIsNull?: Boolean, validitydurationIsNull?: Boolean, inactiveIsNull?: Boolean, createdatIsNull?: Boolean, createdbyidIsNull?: Boolean, updatedatIsNull?: Boolean, updatedbyidIsNull?: Boolean, idIn?: Float[], nameIn?: String[], descriptionIn?: String[], versionIn?: String[], typeIn?: Int[], validitydurationIn?: Int[], inactiveIn?: Boolean[], createdatIn?: String[], createdbyidIn?: Float[], updatedatIn?: String[], updatedbyidIn?: Float[], idNotIn?: Float[], nameNotIn?: String[], descriptionNotIn?: String[], versionNotIn?: String[], typeNotIn?: Int[], validitydurationNotIn?: Int[], inactiveNotIn?: Boolean[], createdatNotIn?: String[], createdbyidNotIn?: Float[], updatedatNotIn?: String[], updatedbyidNotIn?: Float[], idLikeNoCase?: Float, nameLikeNoCase?: String, descriptionLikeNoCase?: String, versionLikeNoCase?: String, typeLikeNoCase?: Int, validitydurationLikeNoCase?: Int, inactiveLikeNoCase?: Boolean, createdatLikeNoCase?: String, createdbyidLikeNoCase?: Float, updatedatLikeNoCase?: String, updatedbyidLikeNoCase?: Float, orderBy?: AgreementPropertiesEnum, orderByDesc?: AgreementPropertiesEnum, range?: Int[], limit?: Int[], offset?: Int[] }, info?: GraphQLResolveInfo | string, options?: Options) => Promise<T> ,
05-12-2018 18:20:16:   13 |     agreements: <T = Agreement[] | null>(args: { id?: Float, name?: String, description?: String, version?: String, type?: Int, validityduration?: Int, inactive?: Boolean, createdat?: String, createdbyid?: Float, updatedat?: String, updatedbyid?: Float, idEq?: Float, nameEq?: String, descriptionEq?: String, versionEq?: String, typeEq?: Int, validitydurationEq?: Int, inactiveEq?: Boolean, createdatEq?: String, createdbyidEq?: Float, updatedatEq?: String, updatedbyidEq?: Float, idGt?: Float, nameGt?: String, descriptionGt?: String, versionGt?: String, typeGt?: Int, validitydurationGt?: Int, inactiveGt?: Boolean, createdatGt?: String, createdbyidGt?: Float, updatedatGt?: String, updatedbyidGt?: Float, idGte?: Float, nameGte?: String, descriptionGte?: String, versionGte?: String, typeGte?: Int, validitydurationGte?: Int, inactiveGte?: Boolean, createdatGte?: String, createdbyidGte?: Float, updatedatGte?: String, updatedbyidGte?: Float, idLt?: Float, nameLt?: String, descriptionLt?: String, versionLt?: String, typeLt?: Int, validitydurationLt?: Int, inactiveLt?: Boolean, createdatLt?: String, createdbyidLt?: Float, updatedatLt?: String, updatedbyidLt?: Float, idLte?: Float, nameLte?: String, descriptionLte?: String, versionLte?: String, typeLte?: Int, validitydurationLte?: Int, inactiveLte?: Boolean, createdatLte?: String, createdbyidLte?: Float, updatedatLte?: String, updatedbyidLte?: Float, idLike?: Float, nameLike?: String, descriptionLike?: String, versionLike?: String, typeLike?: Int, validitydurationLike?: Int, inactiveLike?: Boolean, createdatLike?: String, createdbyidLike?: Float, updatedatLike?: String, updatedbyidLike?: Float, idIsNull?: Boolean, nameIsNull?: Boolean, descriptionIsNull?: Boolean, versionIsNull?: Boolean, typeIsNull?: Boolean, validitydurationIsNull?: Boolean, inactiveIsNull?: Boolean, createdatIsNull?: Boolean, createdbyidIsNull?: Boolean, updatedatIsNull?: Boolean, updatedbyidIsNull?: Boolean, idIn?: Float[], nameIn?: String[], descriptionIn?: String[], versionIn?: String[], typeIn?: Int[], validitydurationIn?: Int[], inactiveIn?: Boolean[], createdatIn?: String[], createdbyidIn?: Float[], updatedatIn?: String[], updatedbyidIn?: Float[], idNotIn?: Float[], nameNotIn?: String[], descriptionNotIn?: String[], versionNotIn?: String[], typeNotIn?: Int[], validitydurationNotIn?: Int[], inactiveNotIn?: Boolean[], createdatNotIn?: String[], createdbyidNotIn?: Float[], updatedatNotIn?: String[], updatedbyidNotIn?: Float[], idLikeNoCase?: Float, nameLikeNoCase?: String, descriptionLikeNoCase?: String, versionLikeNoCase?: String, typeLikeNoCase?: Int, validitydurationLikeNoCase?: Int, inactiveLikeNoCase?: Boolean, createdatLikeNoCase?: String, createdbyidLikeNoCase?: Float, updatedatLikeNoCase?: String, updatedbyidLikeNoCase?: Float, orderBy?: AgreementPropertiesEnum, orderByDesc?: AgreementPropertiesEnum, range?: Int[], limit?: Int[], offset?: Int[] }, info?: GraphQLResolveInfo | string, options?: Options) => Promise<T> ,
05-12-2018 18:20:16:   14 |     location: <T = Location | null>(args: { id?: Float, practiceid?: Float, externalid?: Float, name?: String, address?: String, city?: String, state?: String, postalcode?: String, country?: String, email?: String, contactnumber?: String, inactive?: Boolean, createdat?: String, createdbyid?: Float, updatedat?: String, updatedbyid?: Float, idEq?: Float, practiceidEq?: Float, externalidEq?: Float, nameEq?: String, addressEq?: String, cityEq?: String, stateEq?: String, postalcodeEq?: String, countryEq?: String, emailEq?: String, contactnumberEq?: String, inactiveEq?: Boolean, createdatEq?: String, createdbyidEq?: Float, updatedatEq?: String, updatedbyidEq?: Float, idGt?: Float, practiceidGt?: Float, externalidGt?: Float, nameGt?: String, addressGt?: String, cityGt?: String, stateGt?: String, postalcodeGt?: String, countryGt?: String, emailGt?: String, contactnumberGt?: String, inactiveGt?: Boolean, createdatGt?: String, createdbyidGt?: Float, updatedatGt?: String, updatedbyidGt?: Float, idGte?: Float, practiceidGte?: Float, externalidGte?: Float, nameGte?: String, addressGte?: String, cityGte?: String, stateGte?: String, postalcodeGte?: String, countryGte?: String, emailGte?: String, contactnumberGte?: String, inactiveGte?: Boolean, createdatGte?: String, createdbyidGte?: Float, updatedatGte?: String, updatedbyidGte?: Float, idLt?: Float, practiceidLt?: Float, externalidLt?: Float, nameLt?: String, addressLt?: String, cityLt?: String, stateLt?: String, postalcodeLt?: String, countryLt?: String, emailLt?: String, contactnumberLt?: String, inactiveLt?: Boolean, createdatLt?: String, createdbyidLt?: Float, updatedatLt?: String, updatedbyidLt?: Float, idLte?: Float, practiceidLte?: Float, externalidLte?: Float, nameLte?: String, addressLte?: String, cityLte?: String, stateLte?: String, postalcodeLte?: String, countryLte?: String, emailLte?: String, contactnumberLte?: String, inactiveLte?: Boolean, createdatLte?: String, createdbyidLte?: Float, updatedatLte?: String, updatedbyidLte?: Float, idLike?: Float, practiceidLike?: Float, externalidLike?: Float, nameLike?: String, addressLike?: String, cityLike?: String, stateLike?: String, postalcodeLike?: String, countryLike?: String, emailLike?: String, contactnumberLike?: String, inactiveLike?: Boolean, createdatLike?: String, createdbyidLike?: Float, updatedatLike?: String, updatedbyidLike?: Float, idIsNull?: Boolean, practiceidIsNull?: Boolean, externalidIsNull?: Boolean, nameIsNull?: Boolean, addressIsNull?: Boolean, cityIsNull?: Boolean, stateIsNull?: Boolean, postalcodeIsNull?: Boolean, countryIsNull?: Boolean, emailIsNull?: Boolean, contactnumberIsNull?: Boolean, inactiveIsNull?: Boolean, createdatIsNull?: Boolean, createdbyidIsNull?: Boolean, updatedatIsNull?: Boolean, updatedbyidIsNull?: Boolean, idIn?: Float[], practiceidIn?: Float[], externalidIn?: Float[], nameIn?: String[], addressIn?: String[], cityIn?: String[], stateIn?: String[], postalcodeIn?: String[], countryIn?: String[], emailIn?: String[], contactnumberIn?: String[], inactiveIn?: Boolean[], createdatIn?: String[], createdbyidIn?: Float[], updatedatIn?: String[], updatedbyidIn?: Float[], idNotIn?: Float[], practiceidNotIn?: Float[], externalidNotIn?: Float[], nameNotIn?: String[], addressNotIn?: String[], cityNotIn?: String[], stateNotIn?: String[], postalcodeNotIn?: String[], countryNotIn?: String[], emailNotIn?: String[], contactnumberNotIn?: String[], inactiveNotIn?: Boolean[], createdatNotIn?: String[], createdbyidNotIn?: Float[], updatedatNotIn?: String[], updatedbyidNotIn?: Float[], idLikeNoCase?: Float, practiceidLikeNoCase?: Float, externalidLikeNoCase?: Float, nameLikeNoCase?: String, addressLikeNoCase?: String, cityLikeNoCase?: String, stateLikeNoCase?: String, postalcodeLikeNoCase?: String, countryLikeNoCase?: String, emailLikeNoCase?: String, contactnumberLikeNoCase?: String, inactiveLikeNoCase?: Boolean, createdatLikeNoCase?: String, createdbyidLikeNoCase?: Float, updatedatLikeNoCase?: String, updatedbyidLikeNoCase?: Float, orderBy?: LocationPropertiesEnum, orderByDesc?: LocationPropertiesEnum, range?: Int[], limit?: Int[], offset?: Int[] }, info?: GraphQLResolveInfo | string, options?: Options) => Promise<T> ,
05-12-2018 18:20:16:     at Parser.pp$5.raise (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:4454:13)
05-12-2018 18:20:16:     at Parser.pp.unexpected (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:1761:8)
05-12-2018 18:20:16:     at Parser.pp.expect (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:1749:33)
05-12-2018 18:20:16:     at Parser.pp$1.parseExportSpecifiers (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:2830:8)
05-12-2018 18:20:16:     at Parser.pp$1.parseExport (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:2658:28)
05-12-2018 18:20:16:     at Parser.pp$1.parseStatement (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:1884:74)
05-12-2018 18:20:16:     at Parser.pp$1.parseBlockBody (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:2268:21)
05-12-2018 18:20:16:     at Parser.pp$1.parseTopLevel (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:1778:8)
05-12-2018 18:20:16:     at Parser.parse (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:1673:17)
05-12-2018 18:20:16:     at parse (/usr/lib/node_modules/babel-cli/node_modules/babylon/lib/index.js:7305:37)
05-12-2018 18:20:18: SyntaxError: /home/user/Publish/PracticeBusiness/src/generated/prisma.ts: Unexpected token, expected { (11:7)

谢谢。

2 个答案:

答案 0 :(得分:1)

您似乎正在尝试在运行时使用未编译的TypeScript文件。

您可能应该加载prisma.js,而不是prisma.ts

答案 1 :(得分:1)

我已经解决了,您需要将prisma.ts文件编译为prisma.js

为此,我们需要在Visual Studio中使用“ tsc”(查找波纹管链接进行安装) 将.ts文件转换为.js即可解决问题。

参考链接 Can't find Typescript compiler: Command "tsc" is not valid

https://code.visualstudio.com/docs/languages/typescript