Skip to content
TypeScriptTypeScript13 min read

Do it at build time

A metatable keeps field names in the running script. TypeScript can check them at build time and emit plain positions instead. For 100 buffer records, that's of the script's memory rather than , with reads about 12 times as fast.

tl;dr

  • A checks field names at build time and leaves plain positions in the script
  • Class bring the metatable lookup back, and reading through them took about 19 times as long as through const enum offsets
  • Guard each diagnostic call with a , since a logger that returns early still builds its message