在tsconfig.json

时间:2019-09-23 01:14:40

标签: javascript typescript

我有一些打字稿代码(vscode扩展名),它引用一个.js文件,该文件具有一个相应的.d.ts文件来定义它。但是,即使使用了它,也似乎永远都不会编译到输出中。

我的目录结构:

src/
   tests/
        suite/
             tests.ts
        runTests.ts
   module/
       module.d.ts
       module.js
   extension.ts
   commands.ts

extension.ts,commands.ts和tests目录都已编译,并且test从未引用该扩展名。但是,即使commands.ts引用了module.js,编译时它也不在输出中。我使用tsconfig.json进行构建,但我看不到这会如何影响该结果。

extension.ts

import * as commands from "./commands";

commands.ts

import Module from './module/module.js';

tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "outDir": "out",
        "lib": [
            "es6"
        ],
        "sourceMap": true,
        "rootDir": "src",
        "strict": true   /* enable all strict type-checking options */
        /* Additional Checks */
        // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
        // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
        // "noUnusedParameters": true,  /* Report errors on unused parameters. */
    },
    "exclude": [
        "node_modules",
        ".vscode-test"
    ]
}

我尝试将模块目录和文件添加到rootDir(将其更改为rootDirs之后)并包括目录,但是我做错了,或者没有用。任何帮助将不胜感激。

0 个答案:

没有答案