8000 Interop Gen: Support Union Types · Issue #385 · dart-lang/web · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Interop Gen: Support Union Types #385
Open
@nikeokoronkwo

Description

@nikeokoronkwo

This issue is to add support for parsing and transforming union types in typescript for the Dart JS Interop Generator

export type Color = 'red' | 'green' | 'blue';
export declare const stringOrNumber: string | number;

export declare const colorOrOther: Color | string;

Some union types can be reduced to base interop types such as JSString for the typical "enum"-like union syntax ('red' | 'green' | 'blue'), JSObject, or JSAny.

Custom Types

We are considering generating custom types containing an intersection of the properties contained in the union of the types (if any). We can make use of the typescript type checker API to find an intersection for these types, and add helpers for casting to the necessary union type, as well as checking if such type is one or the other.

We would also need to consider handling isA checks if we are going on with custom types, as they do not exist on JS.

This option should be configurable as well, as users may choose to generate such custom type or not (i.e default to base intersection type)

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

      0