Skip to content

Emit enums as union types instead of current string - #221

Merged
Mohamed Hegazy (mhegazy) merged 7 commits into
microsoft:masterfrom
saschanaz:enums
Mar 30, 2017
Merged

Mohamed Hegazy (mhegazy) merged 7 commits into
microsoft:masterfrom
saschanaz:enums

Conversation

@saschanaz

Copy link
Copy Markdown
Contributor

Fixes #200

Current:

interface Request extends Object, Body {
    readonly cache: string;
    readonly credentials: string;
    readonly destination: string;
    readonly headers: Headers;
    readonly integrity: string;
    readonly keepalive: boolean;
    readonly method: string;
    readonly mode: string;
    readonly redirect: string;
    readonly referrer: string;
    readonly referrerPolicy: string;
    readonly type: string;
    readonly url: string;
    clone(): Request;
}

Fixed:

interface Request extends Object, Body {
    readonly cache: RequestCache;
    readonly credentials: RequestCredentials;
    readonly destination: RequestDestination;
    readonly headers: Headers;
    readonly integrity: string;
    readonly keepalive: boolean;
    readonly method: string;
    readonly mode: RequestMode;
    readonly redirect: RequestRedirect;
    readonly referrer: string;
    readonly referrerPolicy: ReferrerPolicy;
    readonly type: RequestType;
    readonly url: string;
    clone(): Request;
}

type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url";
type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache";
type RequestCredentials = "omit" | "same-origin" | "include";
type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker";
type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors";
type RequestRedirect = "follow" | "error" | "manual";
type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video";

@saschanaz

Copy link
Copy Markdown
Contributor Author

Will reopen after fixing build.

@mhegazy

Copy link
Copy Markdown
Contributor

Zhengbo Li (@zhengbli) can you please review this change?

@zhengbli

Copy link
Copy Markdown

LGTM

@zhengbli

Copy link
Copy Markdown

Thanks Kagami Sascha Rosylight (@saschanaz) !

@mhegazy

Copy link
Copy Markdown
Contributor

We need to document this as a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants