【发布时间】:2021-01-18 10:01:51
【问题描述】:
我有一个根目录 @types 和 src 文件夹
// @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.
【问题讨论】:
标签: typescript tsconfig tsc