我已经尝试了很长时间,但无论我做什么,似乎都不能让Visual Studio Code intellisense在typescript的单个文件之外工作。这在windows和Ubuntu上都有。
我已经包含了一个tsconfig.json文件,但它仍然没有任何项目规模的智能感知。
我当前的测试项目包含以下内容:
tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"out": "test.js"
},
"files": [
"test2.ts",
"tester.ts"
]
}tasks.json:
{
"version": "0.1.0",
"command": "tsc",
"showOutput": "always",
"windows": {
"command": "tsc.exe"
},
"args": ["-p", "."],
"problemMatcher": "$tsc"
}test2.ts:
module test
{
export class test2
{
}
}tester.ts:
module test
{
export class tester
{
public testy: test2;
}
}在类测试器中,即使我将其更改为test.test2,test2也不会被智能感知拾取。向test2添加变量也无济于事。
有谁知道为什么它根本不工作的任何可能的原因吗?
发布于 2019-07-12 18:55:31
在我的例子中,我不得不选择工作空间版本而不是VSCode版本的typescript。
单击底部蓝色功能区中的版本号

并在顶部栏中显示的选项中选择工作空间版本

希望这能有所帮助。
发布于 2015-05-22 19:57:04
这是因为您已经告诉编译器您正在使用外部模块:
"module": "commonjs",但您实际上是在尝试使用内部模块:
module test最好选择一种或另一种方式。
外部模块
如果您使用的是外部模块-请使用:
test2.ts
export class test2 {
}tester.ts
import ModuleAlias = require('test2');
export class tester {
public testy: ModuleAlias.test2;
}内部模块
如果你没有使用外部模块,你可以使用你的原始代码,但是去掉"module": "commonjs"标志。
{
"compilerOptions": {
"out": "test.js"
},
"files": [
"test2.ts",
"tester.ts"
]
}发布于 2020-07-12 00:55:32
对于遇到此问题的任何人,请尝试替换以下代码:
const { ConnectionPool } = require("mssql");有了这个:
import { ConnectionPool } from "mssql"..。用于您的等价库。这解决了我的问题。
当然,不要忘记您同时需要实现和@type模块:
npm i mssql
npm i -D @types/mssqlhttps://stackoverflow.com/questions/30394831
复制相似问题