Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unroll correctly setters for union types #311

Closed
Schahen opened this issue Jun 17, 2020 · 2 comments
Closed

Unroll correctly setters for union types #311

Schahen opened this issue Jun 17, 2020 · 2 comments
Labels
better-translation Code is translated and even useable, but can be better domain:unions anything that has to do with union types
Milestone

Comments

@Schahen
Copy link
Contributor

Schahen commented Jun 17, 2020

Following code:

interface Dict<T> {
    [key: string]: T | undefined;
}

interface BasicHeaders extends Dict<string | string[]> { }

it converted to:

external interface Dict<T> {
    @nativeGetter
    operator fun get(key: String): T?
    @nativeSetter
    operator fun set(key: String, value: T?)
}

external interface BasicHeaders : Dict<dynamic /* String | Array<String> */> {
    override operator fun get(key: String): Any?
    override operator fun set(key: String, value: Any?)
}

while actually what we really do expect to have is a set unrolled to:

external interface BasicHeaders : Dict<dynamic /* String | Array<String> */> {
    override operator fun get(key: String): Any?
    override operator fun set(key: String, value: String?)
    override operator fun set(key: String, value: Array<String>?)
}
@Schahen Schahen added better-translation Code is translated and even useable, but can be better domain:unions anything that has to do with union types labels Jun 17, 2020
@Schahen
Copy link
Contributor Author

Schahen commented Jun 17, 2020

In fact we don't even need to inherit Dict, so the minimal example would be:

interface BasicHeaders {
    'retry-after'?: string;
    'set-cookie'?: string[];
}

@Schahen Schahen added this to the 0.5.3 milestone Jun 17, 2020
@Schahen
Copy link
Contributor Author

Schahen commented Jun 17, 2020

this one is closely related to #310

Schahen added a commit that referenced this issue Jun 19, 2020
@Schahen Schahen closed this as completed Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
better-translation Code is translated and even useable, but can be better domain:unions anything that has to do with union types
Projects
None yet
Development

No branches or pull requests

1 participant