I get: [ts] 'Promise' only refers to a type, but is being used as a value here

前端 未结 2 370
情歌与酒
情歌与酒 2021-01-14 04:39

I\'m taking an Angular2 course and following along. Everything I have been doing thus far for all the other exercise has worked fine until I got to creating this custom vali

2条回答
  •  走了就别回头了
    2021-01-14 05:14

    Possible duplicate of #43546088 (only if you're already using DefinitelyTyped): in case you aren't, I would suggest you to try and use them so you can normalize your compiler references and possibly fix the issue.

    If you're using it, I suggest you to read this Github thread for an extensive analysis of the problem and also some workaround. To quickly recap the (IMHO) best one of them, assuming that you have this in your package.json file:

      "scripts": {
        "postinstall": "typings install dt~core-js --global"
      }
    

    Change it in the following way:

      "scripts": {
        "postinstall": "typings install dt~core-js@0.9.7+20161130133742 --global"
      }
    

    So you'll force VS to get a unaffected version/build of the core-js definitions file(s). However, is highly recommended to remove the explicit version+build reference as soon as the issue will be released.

    For further info regarding this issue, you can also read this post on my blog.

提交回复
热议问题