Hack feature request: ShapeKey<T>
Open
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
Assessment
This issue has not been assessed yet.