且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Visual Studio Code Intellisense Typescript不起作用

更新时间:2022-12-16 12:21:42

这是因为你告诉编译器你正在使用外部模块:

It's because you have told the compiler you are using external modules:

"module": "commonjs",

但您实际上是在尝试使用内部模块:

But you are actually trying to use internal modules:

module test

***选择其中一种方式。

It is best to choose one way or the other.

如果你正在使用外部模块 - 使用:

If you are using external modules - use:

test2.ts

export class test2 {

}

tester.ts

import ModuleAlias = require('test2');

export class tester {
    public testy: ModuleAlias.test2;
}



内部模块



如果您不使用外部模块,则可以使用原始代码,但删除module:commonjs flag。

{
    "compilerOptions": {
        "out": "test.js"
    },
    "files": [
        "test2.ts",
        "tester.ts"
    ]
}