使用类型记录3.7.3,当我构建我的项目时,它会在我的主index.d.ts中生成无效的三重斜杠指令。
这是我的index.d.ts的一个摘录:
/// <reference path="types/augmentations.d.ts" />
/// <reference types="node" />
/// <reference types="fastify" />
/// <reference types="mongoose" />
/// <reference types="@keplr/backend-types/lib/mongo" />
/// <reference types="node/http" />
/// <reference types="@keplr/backend-types/lib/fastify" />
/// <reference types="fastify-cookie" />
/// <reference types="fastify-multipart" />
import * as email from './helpers/email';
import * as password from './helpers/password';
import * as token from './helpers/token';
export declare const models: {
...
};
export declare const plugins: {
MainPlugin: (instance: import("fastify").FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse>, options: unknown, callback: (err?: import("fastify").FastifyError | undefined) => void) => void;
RouteLessPlugin: (instance: import("fastify").FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse>, options: unknown, callback: (err?: import("fastify").FastifyError | undefined) => void) => void;
};行/// <reference types="node/http" />无效并生成错误。
如何防止TS为node/http生成三重斜杠指令?
我试了一下TS 3.6,还是一样的。
这是我的tsconfig:
{
"compilerOptions": {
"target": "es2020",
"lib": ["es2020", "esnext.asynciterable"],
"module": "commonjs",
"declaration": true,
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"incremental": true,
"tsBuildInfoFile": "./.tsbuildinfo",
"noUnusedLocals": true,
"esModuleInterop": false
},
"include": ["./src/**/*.ts"],
"exclude": ["**/__tests__"]
}发布于 2019-12-21 19:24:38
如果有人有同样的问题。
这是由于内部库中的节点http模块增加而造成的问题。
declare module 'http' {
...
}放弃这种增强解决了问题。
https://stackoverflow.com/questions/59293719
复制相似问题