glideapps / glideapps/quicktype
TypeScript -> Python creates a new synthetic type for unions of interfaces
- Dominant language
- TypeScript
- Stars
- 13.9k
- Forks
- 1.2k
- Avg merge
- 8h 53m
- Merged PRs (30d)
- 369
Description
See https://app.quicktype.io/?share=av9JMpZCKBG1DtHb7phv
```
interface Foo {
foo: string;
}
interface Bar {
bar: string;
}
interface Container {
op: Foo | Bar;
}
```
results in
```
from dataclasses import dataclass
from typing import Optional
@dataclass
class Foo:
foo: str
@dataclass
class Bar:
bar: str
@dataclass
class Op:
foo: Optional[str] = None
bar: Optional[str] = None
@dataclass
class Container:
op: Op
```
when ideally, it should result in
```
from dataclasses import dataclass
from typing import Optional, Union
@dataclass
class Foo:
foo: str
@dataclass
class Bar:
bar: str
@dataclass
class Container:
op: Union[Foo, Bar]
```
Contributor guide
Assessment
This issue has not been assessed yet.