Linter和Compiler Option,无需转换即可进行显式类型转换

时间:2018-11-15 13:25:49

标签: typescript visual-studio-code tslint

在以下情况下,我想在vscode和编译时出错:

场景1:

let myAny: any;
let myString: string;

myString = myAny;           // error
myString = <string> myAny;  // ok
myAny    = myString;        // error
myAny    = <any> myString;  // ok

场景2:

let myAny: any;
let myString: string;
foo(myParam: string): void{}

foo(myAny);                  // error
foo(myString);               // ok
foo(<string> myString);      // ok

0 个答案:

没有答案