0
在下面的代码片段中,TypeScript可以表达“a是某个对象,但不是布尔,数字,字符串,数组或函数”?可以用Typescript表示“一个是某个对象”吗?
var a:Object;
a = {
just: "some object",
n: 1,
};
// what type does `a` need to disallow the following
a = ["array", 2, {}];
a = "nostring";
a = false;
a = 0;
a =()=> { return "i am a function!"};
var button = document.createElement('button');
button.textContent = "Say Hello";
button.onclick = function() {
alert(a.toString());
};
document.body.appendChild(button);