object literal types

Michael Haufe TNO at TheNewObjective.com
Sun Feb 15 09:51:44 PST 2009


I was reading through the wiki on the type discussions:

http://wiki.ecmascript.org/doku.php?id=strawman:types
http://wiki.ecmascript.org/doku.php?id=discussion:object_literals_type_of

I realize that some of the content is dated and does not apply to 
Harmony in particular, but  I'm curious to what the proposal is for 
inline types declarations on object literals

This example (from the second url) is straightforward enough:

type Goose = {name: string, email: string, noisy: boolean};
// create a Goose and pass it to f()
f({name: 'Ben', email: 'ben at quack.net', noisy: true} : Goose);

But this example seems a bit lacking:

var white = {r: 0xff, g: 0xff, b: 0xff};  // the type is {*}, not {r:*, g:*, b:*, *} or anything like that.


Is there a problem with the following syntax or did I overlook some implication/discussion?

var Point:object = {
    color:string
    x:double = 20,
    y:double = 50,
    z:double = 3
}






More information about the Es-discuss mailing list