facebook / facebook/hhvm

Hack feature request: ShapeKey<T>

Open
#7,280 0 comments 3 reactions 0 assignees View on GitHub
feature request hack
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

Basically an `enum: arraykey`:

``` Hack
$key): string;
// ... or ...
abstract public function getSettingsDescriptions(): ImmMap, string>;
}

final class Foo extends FooBase {
const type TSettings = shape('herp' => string, 'derp' => string);

public function getSettingDescription(ShapeKey $key): string {
switch($key) {
case 'herp':
return 'some description';
}
// existing type error: inexhaustive switch statement
}

public function getSettingsDescriptions(): ImmMap, string>> {
return ImmMap {
'herp' => 'some description',
'dero' => 'I typoed, but the typechecker tells me',
};
}
}
```

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.