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.
I have the following repository: https://github.com/danielmahadi/modular-typescript
There are 4 typescript files:
customerModel.ts => customer model file
export class User{
constructor(public id: string, public name: string){}
}
converter.ts => convert json data to customer model
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
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.
import converter = require('./converter');
import printer = require('./printer');
var d = {
id: '123', name: 'Test'
}
var user = converter.convertToUser(d);
printer.print(user);
Environment:
Typescript file watcher setting for typescript:
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".
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?
Definitely an error in webstorm. Would appreciate it if you report it here : http://youtrack.jetbrains.com/issues/WEB and put a link so we can vote on it.
Please try WebStorm 8 EAP - the bug seems to be fixed there
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With