8000 Nested casting for objects · Issue #34 · sirisian/ecmascript-types · GitHub
[go: up one dir, main page]

Skip to content
Nested casting for objects #34
@sirisian

Description

@sirisian

This was brought up in #33. Essentially offering a compact way to cast object properties. As an example say you have an object, possibly returned from another library, and want to cast the individual properties to different types:

const foo = { a: [0, 1, 2] };
const bar = foo:{ (a:uint8[]) }; // Returns a new object: { a:uint8[]:[0, 1, 2] }

or:

const foo = { a: 1, b: 1.234 };
const bar = foo:{ (a:uint8), (b:MyType): c }; // Returns new object: { a:uint8: 1, c:MyType: 1.234 }

This is kind of low priority and doesn't need to really be considered for the spec unless for some reason it couldn't be added later if it was necessary. I don't think it's overly useful, and I'm not convinced the syntax is right. More of a random idea.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0