Skip to content

Instantly share code, notes, and snippets.

@Dremora
Created December 15, 2021 20:32
Show Gist options
  • Save Dremora/945af2ab3a3daa8e6298301290d494e6 to your computer and use it in GitHub Desktop.
Save Dremora/945af2ab3a3daa8e6298301290d494e6 to your computer and use it in GitHub Desktop.
TypeScript runtime error due to the lack of exact types
const foo = { a: 1, b : {}}
const bar: { a: number} = foo;
const baz: { [a: string]: number} = bar;
const b = baz['b'];
if (typeof b !== 'undefined') {
console.log(b.toFixed(2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment