HaxeFoundation / HaxeFoundation/haxe

Infer optional fields on open structures when accessed with null coalescing operator.

Open
#10,605 9 comments 3 reactions 1 assignee Claimed by @Simn View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Example:

```haxe
import sys.net.*;
function connect(options) {
var ret = new Socket();
ret.connect(options.host ?? Host.localhost(), options.port);
return ret;
}
```

In this case I would like `options` to be inferred to `{ ?host:sys.net.Host, port:Int }`, unless there are reasons not to.

It's perhaps worth mentioning that there's a bit of a special case in combination with safe navigation:

```haxe
import sys.net.*;
function connect(?options) {
var ret = new Socket();
ret.connect(options?.host ?? Host.localhost(), options?.port ?? 3306);
return ret;
}
```

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.