Skip to content

TS syntax for string types for OneOf #93

@a8775

Description

@a8775

TypeScript 1.8 is introducing a new syntax for string types:

https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#string-literal-types

eg.:

interface AnimationOptions {
    deltaX: number;
    deltaY: number;
    easing: "ease-in" | "ease-out" | "ease-in-out";
}

This could provide or extend the OneOf annotation.
Possibly some tools could infer more from this syntax as well.

Current syntax is as follow (https://github.com/angular/material2/blob/master/src/components/sidenav/sidenav.ts):

@Input() @OneOf(['over', 'push', 'side']) mode: string = 'over';

I think of something like:

@Input() @OneOf() mode: 'over'|'push'|'side' = 'over';

or even NG M2 could infer from the type the OneOf annotation is expected:

@Input() mode: 'over'|'push'|'side' = 'over';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions