作者:手机用户2502886335 | 来源:互联网 | 2023-05-18 21:03
IhaveanissuewiththewebstormIDE.Itseemslikethatwebstormalwaysshowstheerrorofinvalid
I have an issue with the webstorm IDE. It seems like that webstorm always shows the error of invalid argument in the IDE, but the typescript compiler do not show such error; I'm starting to believe that this issue is with the IDE.
我有一个关于webstorm IDE的问题。似乎webstorm总是在IDE中显示无效参数的错误,但是typescript编译器并没有显示出这样的错误;我开始相信这个问题与IDE有关。
I have the following repository: https://github.com/danielmahadi/modular-typescript
我有以下存储库:https://github.com/danielmahadi/modulescript。
There are 4 typescript files:
有4个打字文件:
customerModel.ts => customer model file
customerModel。客户模型文件。
export class User{
constructor(public id: string, public name: string){}
}
converter.ts => convert json data to customer model
转换器。ts =>将json数据转换为客户模型。
import model = require('./customerModel')
export function convertToUser(data: any) : model.User {
return new model.User(data.id, data.name);
}
printer.ts => print the customer model to console
打印机。ts =>打印客户模型到控制台。
import model = require('./customerModel')
export function print(data : model.User) : void {
console.log('PRINTING...');
console.log(data);
}
app.js => the entry point for the app.
app.js =>应用程序的入口点。
import cOnverter= require('./converter');
import printer = require('./printer');
var d = {
id: '123', name: 'Test'
}
var user = converter.convertToUser(d);
printer.print(user);
Environment:
环境:
- webstorm 7.0.3, build number: WS-133.434
- webstorm 7.0.3,构建数字:WS-133.434。
- Mac OSX with Maverick
- Mac OSX和特立独行的
- Typescript version: 0.9.5.0
- 打印稿版本:0.9.5.0
Typescript file watcher setting for typescript:
Typescript文件watcher设置为Typescript:
- Typescript compiler => tsc --module commonjs --sourcemap $FileName$
- Typescript编译器=> tsc—模块commonjs—sourcemap $FileName$。
If you open this with webstorm IDE, you will see that in the app.ts line 15, the "user" is always underlined with red line with the error "Argument type './customerModel'.User is not assignable to parameter type model.User".
如果你用webstorm IDE打开它,你会看到在app.ts第15行,“用户”总是用红线加上错误的“参数类型”。/customerModel。用户不能被分配给参数类型模型。用户。
This is what the error looks like:
这就是错误的样子:
Has anyone else encountered this before? Am I doing something wrong, or this is just another webstorm bug?
有人以前遇到过这种情况吗?我是不是做错了什么,或者这只是另一个webstorm bug?
2 个解决方案