JsonMa / swagger-egg

Eggjs Swagger-UI API文档自动生成插件(如果喜欢请点赞支持)。Egg swagger documentation generator(welcome to star this project).
MIT License
44 stars 16 forks source link

TS应用中默认的 `yarn start` 命令启动报错 #25

Open kerryChen95 opened 2 years ago

kerryChen95 commented 2 years ago

问题复现步骤

eggjs新建 TS 项目。 egg@2.33.1, swagger-egg@1.7.0

正常写 app/schema/definitions.ts

yarn run tsc ,再 yarn start

问题表现

[egg-scripts] File '<egg-app>/app/schema/definitions.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
[egg-scripts]   The file is in the program because:
[egg-scripts]     Root file specified for compilation

奇怪为什么 app/schema/definitions.js 会成为 root file。

在 egg-scripts 中断点拿到的此异常的信息 error TS6504: File '*.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?

尝试解决未果

eggjs为TS应用生成的 tsconfig.json 中为 compilerOptions.allowJs: false ,不确定eggjs是否对此强依赖。如果改成 true,那么在 yarn run tsc 时会报错,或许是强依赖,没继续深入研究。

error TS2347: Untyped function calls may not accept type arguments.
error TS2339: Property 'mongoose' does not exist on type 'MockApplication'.
const invalidAccountAppId = (new app.mongoose.Types.ObjectId()).toString();