Within the context of TypeScript, there is no practical difference but there is a semantic difference. All the members of the Object
are implicitly present on all objects.
{}
means something that has no members of its own. {} would still have all the members of Object
. So they are interchangeable in TypeScript.
// Extend ALL objects
interface Object{
baz:number;
}
var foo:{} = {};
var bar:Object = {};
foo.baz = 123;
bar.baz = 123;
Personally I haven't ever declared a variable to be one of these. Perhaps you should use any
which is something that is compatible with everything.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…