HaxeFoundation / HaxeFoundation/haxe

HTML externs, improve type unions

Open
#7,596 3 comments 0 reactions 1 assignee Claimed by @haxiomic View on GitHub
platform-javascript type-system
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

If a type union has nested `EitherType`s then we can have unification issues, for example (from @SlavaRa's PR #7593)
```haxe
typedef BlobPart = Array<
haxe.extern.EitherType<
haxe.extern.EitherType<
ArrayBufferView,
ArrayBuffer
>,
haxe.extern.EitherType
>
>;

var arrayBuffers = [new ArrayBuffer()];
var x: Array = arrayBuffers;
```

To fix we can create an abstract for each type union that merges all `EitherType`s:
```haxe
abstract BlobPart(Dynamic)
from ArrayBufferView to ArrayBufferView
from ArrayBuffer to ArrayBuffer
from Blob to Blob
from String to String
{}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.