WebStorm中的TypeScript AMD.恼人的"分配表达式类型"错误

Jul*_*anG 5 amd webstorm typescript

我在JetBrains WebStorm中尝试使用TypeScript.

我在"person.ts"中有一个非常简单的课程:

export class Person {
  constructor(public name:string, public age:number) {
  }
    toString() {
    return this.name + ", " + this.age;
  }
}
Run Code Online (Sandbox Code Playgroud)

然后,在我的应用程序上,我尝试像这样导入它:

import nsp = module("person");

export class App {
    start() {
        var my_user:nsp.Person;
        my_user = new nsp.Person("Julian", 111);
        console.log( my_user.toString() );
    }
}
Run Code Online (Sandbox Code Playgroud)

这似乎有效.我可以使用tsc编译为javascript:

tsc --module AMD .\public\script\app.ts
Run Code Online (Sandbox Code Playgroud)

我还在WebStorm中为TypeScript设置了FileWatcher.没关系.

但我收到这个恼人的错误/警告:"分配的表达式类型Person不能分配给exports.Person类型"

问题

有任何想法吗?难道我做错了什么?这是WebStorm中的错误吗?

这是我在GitHub上的项目:https://github.com/JulianG/typescript-modularization-demo/,以防你想尝试一下.

Fen*_*ton 6

此错误在下一个WebStorm版本中得到修复,但在此期间您可以忽略错误或将表达式合并为一行,并查看类型推断是否有帮助:

var my_user = new nsp.Person('Julian', 111);
Run Code Online (Sandbox Code Playgroud)