据我所知,TypeScript 允许为任何类型创建别名。例如:
但以下代码不正确:
我错在哪里,我该如何创建MyType的实例?
type MyNum = number;
var y: MyNum;
y = 33; // it's ok
但以下代码不正确:
type MyType = Object;
const dt = new MyType(); // here is an error: 'MyType only refers to a type, but is being used as a value here'
我错在哪里,我该如何创建MyType的实例?
const dt : MyType = {}
? - evolutionxbox