Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio TypeScript-Visual Studio 2015 Intellisense找不到模块_Visual Studio_Typescript_Visual Studio 2015 - Fatal编程技术网

Visual studio TypeScript-Visual Studio 2015 Intellisense找不到模块

Visual studio TypeScript-Visual Studio 2015 Intellisense找不到模块,visual-studio,typescript,visual-studio-2015,Visual Studio,Typescript,Visual Studio 2015,我在Visual Studio 2015中使用TypeScript intellisense时遇到问题。当我试图从Nuget上的打字切换到使用npm安装它们时,问题就开始了。我在node_modules/@types中拥有所需的一切,但intellisense没有找到输入,说它无法解析模块。该项目使用VisualStudio的build和命令行中的tsc生成,没有错误 我目前的猜测是,问题在于我使用的TypeScript版本与打字的版本不同,因为当我打开打字文件时,打字文件中存在intellis

我在Visual Studio 2015中使用TypeScript intellisense时遇到问题。当我试图从Nuget上的打字切换到使用npm安装它们时,问题就开始了。我在
node_modules/@types
中拥有所需的一切,但intellisense没有找到输入,说它无法解析模块。该项目使用VisualStudio的build和命令行中的tsc生成,没有错误

我目前的猜测是,问题在于我使用的TypeScript版本与打字的版本不同,因为当我打开打字文件时,打字文件中存在intellisense错误。例如,我使用npm为React(v.^15.4.2)安装了打字(v.^15.0.21)。打开已安装的index.d.ts文件时,我收到许多错误:

// Type definitions for React v15.0
// Project: http://facebook.github.io/react/
// Definitions by: ...
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2

export = React;
export as namespace React;
例如,在前两行中,我得到:

  • 除非提供“--module”标志,否则无法编译模块。。。(整个第一行)

  • 需要声明或声明。(第二行,出口项下)

  • 找不到名称“as”。(根据as)
  • “;”预期。(在命名空间下)
你明白了,这些都会在文件中继续。我尝试了以下方法来解决此问题:

  • 切换到使用tsconfig文件而不是VS-typescript工具
  • 让3名同事在他们的电脑上试用(两名intellisense工作,第三名遇到同样的问题)
  • 通过删除.suo文件清除intellisense缓存
  • 正在更新TypeScript工具和Visual Studio。当我开始的时候,我正在VS2015更新1上运行一个非常旧的TypeScript版本。我现在正在VS2015更新3上使用TypeScript 2.2.2。我已经从开发者命令提示符和PackageManager控制台验证了TypeScript的版本
  • 手动添加指向打字文件的
    //
    标记。这样做可以成功地将tsx html元素(如
    标记)解析为
    JSX.intrinsiceelements
    类型,但React模块仍然无法解析,可能是因为上面列出的错误
  • 在tsconfig中使用
    typeroot
    元素直接指向@types文件夹。在一位同事的推荐下,我删除了这个,这是intellisense工作的两位同事之一
  • 编辑.csproj文件类型脚本部分。我将TypeScript工具版本更改为2.2,将模块解析选项更改为Node、Node和NodeJs,如下所示:
这是我的tsconfig.json文件:

{
    "compileOnSave": true,
    "compilerOptions": {
        "sourceMap": true,
        "noImplicitAny": false,
         "module": "commonjs",
         "target": "es5",
         "jsx": "react"
    },
    "exclude": [ "./__Redesign/node_modules", "./__Redesign/jspm_packages" ],
    "include": [
        "./__Redesign/node_modules/@types",
        "__Redesign/app/**/*.ts",
        "__Redesign/app/**/*.tsx"
    ]
}
我的tsconfig位于站点根目录中,
package.json
文件与
节点模块
文件夹一起位于一个名为
\uu Redesign
的文件夹中。这就是为什么我认为可能需要将编译器显式地指向tsconfig中的类型


在这一点上,我已经没有线索可以追查了,任何新的想法都是值得赞赏的。谢谢。

经过一点试验后,我尝试在我之前下载的TypeScript 2.2.2安装程序上运行修复程序,这解决了问题。我不确定它做了什么来解决这个问题,但至少它起作用了