有没有人知道TypeScript中String和string之间的区别?假设它们应该是相同的,我是否正确?
var a: String = "test";
var b: string = "another test";
a = b;
b = a; // this gives a compiler error!
Run Code Online (Sandbox Code Playgroud)
当前版本的编译器说:
Type 'String' is not assignable to type 'string'.
'string' is a primitive, but 'String' is a wrapper object.
Prefer using 'string' when possible.
Run Code Online (Sandbox Code Playgroud)
那是一个错误吗?
typescript ×1