Open Sytten opened 4 years ago
It's also incorrect.
See the following code:
type Key = 'foo' | 'bar';
const keys: Key[] = ['foo'];
const b = Object.fromEntries<Key, number>(
keys.map((key) => {
return [key, 1];
}),
);
console.log(b.bar);
The type of b.bar
is number
but it evaluates to undefined
.
The same code behaves as expected with official typing.
Both examples use noUncheckedIndexedAccess
compiler flag.
Hi!
Currently,
Object.fromentries
in theapollo-env
polyfill is declared as:While the Typescript official method is:
Since
apollo-env
is declared globally, it will overwrite the official method. And the official typing is nicer to work with. Would it be possible to align the typing with the official one and/or remove it since it is now part of >ES2019.Thanks!