相关疑难解决方法(0)

当tsc成功编译项目时,ts-node忽略d.ts文件

成功编译了我的TypeScript项目之后,我打算在VS Code的调试模式下运行它ts-node.问题是,ts-node找不到d.ts我创建的文件(虽然tsc它没有问题).

项目结构是:

/
    conf/
    dist/
    src/
        types/
package.json
tsconfig.json
Run Code Online (Sandbox Code Playgroud)

tsconfig.json 相关条目是:

{
    "compilerOptions": {
        "target": "es2017",
        "module": "commonjs",
        // "lib": [],
        "sourceMap": true,
        "outDir": "dist",
        "rootDir": "src",
        "moduleResolution": "node",
        "baseUrl": ".",
        "paths": {
            "*": [
                "node_modules/*",
                "src/types/*"
            ]
        },
        // "rootDirs": [],
        // "typeRoots": [],
        // "types": [],
    },
    "include": [
        "src/**/*"
    ]
}
Run Code Online (Sandbox Code Playgroud)

定义文件ts-node找不到的是src/types/global.d.ts:

import { App } from '../App';

declare global {
    namespace NodeJS { …
Run Code Online (Sandbox Code Playgroud)

typescript typescript-typings ts-node

16
推荐指数
5
解决办法
4553
查看次数

标签 统计

ts-node ×1

typescript ×1

typescript-typings ×1