如何使用visual studio 2015设置Typescript 2.0?

时间:2017-01-07 02:30:40

标签: visual-studio typescript

我的问题是

  1. 简介如何使用visual studio 2015设置打字稿?
  2. 如何确保@types与npm包的版本相同?**
  3. 背景问题1

    我已尝试更新到typescript 2.0但无法获得intellisense并在编译时出错。

    我有package.json指向我的类型:

      "dependencies": {
        "@types/react-router": "^2.0.41",
        "@types/react": "^2.0.41",
        "react": "^0.14.0",
        "react-dom": "^0.14.0",
        "react-router": "^3.0.0"
      }
    

    我也尝试将其添加到我的tsconfig中(当然没有注释):

    //"typeRoots": [
    //  "node_modules/@types"
    //]
    

    我不知道是否还需要这个。我猜不会?

    背景问题2:

    关于版本控制的问题更为笼统。从类型绝对中我的类型有很多问题。这就是为什么我转向2.0,因为我认为它会更加一致。但是我仍然遇到这些错误:

       ERROR in C:\Users\alexander\Documents\Visual Studio 2015\Projects\Projects_CleanDir\clean\react-hot\node_modules\@types\react-router\lib\history.d.ts
        (9,23): error TS2694: Namespace '"C:/Users/alexander/Documents/Visual Studio 2015/Projects/Projects_CleanDir/clean/react-hot/node_modules/@types/react-router/lib/history"' has no exported member 'Location'.
    
        ERROR in C:\Users\alexander\Documents\Visual Studio 2015\Projects\Projects_CleanDir\clean\react-hot\node_modules\@types\react-router\lib\history.d.ts
        (9,103): error TS2694: Namespace '"C:/Users/alexander/Documents/Visual Studio 2015/Projects/Projects_CleanDir/clean/react-hot/node_modules/@types/react-router/lib/history"' has no exported member 'Location'.
    
        ERROR in C:\Users\alexander\Documents\Visual Studio 2015\Projects\Projects_CleanDir\clean\react-hot\node_modules\@types\react-router\lib\history.d.ts
        (10,26): error TS2694: Namespace '"C:/Users/alexander/Documents/Visual Studio 2015/Projects/Projects_CleanDir/clean/react-hot/node_modules/@types/react-router/lib/history"' has no exported member 'Pathname'.
    
        ERROR in C:\Users\alexander\Documents\Visual Studio 2015\Projects\Projects_CleanDir\clean\react-hot\node_modules\@types\react-router\lib\history.d.ts
        (10,46): error TS2694: Namespace '"C:/Users/alexander/Documents/Visual Studio 2015/Projects/Projects_CleanDir/clean/react-hot/node_modules/@types/react-router/lib/history"' has no exported member 'Query'.   
    

    这是版本问题吗?也许还有别的东西......它应该不仅仅是有效......

0 个答案:

没有答案