找不到具有模块样式声明文件的模块的声明文件

Could not find a declaration file for module with module style declaration file

我有一个根 @typessrc 文件夹

// @types/index.d.ts
import type { Profile } from "passport-discord"

declare module "fastify" {
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
  interface PassportUser extends Profile {}
}

declare module "@elastic/ecs-pino-format"

// @TODO: remove when https://github.com/pinojs/pino-elasticsearch/issues/54 has been fixed
declare module "pino-elasticsearch"

在我的 tsconfig.json 中,我尝试添加 "include": ["@types", "src"], 但 运行 我的构建命令

"build": "rimraf dist && NODE_ENV=development npm run nexus:reflect && tsc",
"nexus:reflect": "SHOULD_EXIT_AFTER_GENERATE_ARTIFACTS=true ts-node --transpile-only src/schema.ts",

结果

daniell@DESKTOP-EKQSHNG:~/GitHub/akira$ npm run build

> akira@1.0.0 build
> rimraf dist && NODE_ENV=development npm run nexus:reflect && tsc


> akira@1.0.0 nexus:reflect
> SHOULD_EXIT_AFTER_GENERATE_ARTIFACTS=true ts-node --transpile-only src/schema.ts

Generated Artifacts:
          TypeScript Types  ==> /home/daniell/GitHub/akira/node_modules/@types/nexus-typegen/index.d.ts
          GraphQL Schema    ==> (not enabled)
src/utilities/logger.ts:1:23 - error TS7016: Could not find a declaration file for module '@elastic/ecs-pino-format'. '/home/daniell/GitHub/akira/node_modules/@elastic/ecs-pino-format/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/elastic__ecs-pino-format` if it exists or add a new declaration (.d.ts) file containing `declare module '@elastic/ecs-pino-format';`

1 import ecsFormat from "@elastic/ecs-pino-format"
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~

src/utilities/logger.ts:3:25 - error TS7016: Could not find a declaration file for module 'pino-elasticsearch'. '/home/daniell/GitHub/akira/node_modules/pino-elasticsearch/lib.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/pino-elasticsearch` if it exists or add a new declaration (.d.ts) file containing `declare module 'pino-elasticsearch';`

3 import pinoElastic from "pino-elasticsearch"
                          ~~~~~~~~~~~~~~~~~~~~


Found 2 errors.

使用带有 files 选项的 ts-node 怎么样?

 - "nexus:reflect": "SHOULD_EXIT_AFTER_GENERATE_ARTIFACTS=true ts-node --transpile-only src/schema.ts",
 + "nexus:reflect": "SHOULD_EXIT_AFTER_GENERATE_ARTIFACTS=true ts-node --transpile-only --files src/schema.ts",

文档说 ts-node 默认情况下不会在启动时从 tsconfig.json 加载 filesincludeexcludehttps://github.com/TypeStrong/ts-node#help-my-types-are-missing