goo.gle/devtools-tsstyle (go/devtools-tsstyle)
By default we assume the Google TypeScript Style Guide as the base set of style rules for our TypeScript. Some of the TypeScript style guide limits certain features based on the Google internal toolchain, we are able to take advantage of certain features that the Google internal TypeScript developers cannot. This document, therefore, primarily specifies modifications to the official Google TypeScript style guide.
private
visibility annotation. This ensures that the output JavaScript more closely matches the authored TypeScript._
to prefix private fields.#
prior to the field’s name denotes it as private._
to prefix private functions.We compile to ESNext in TypeScript. This means that the JavaScript we output is as close to the authored TypeScript as possible. There is therefore no need to consider transpiling optimizations.
const enum
without restriction.We do not currently support these or plan to add them at this time.
import * as entrypoint from 'path/to/entrypoint/entrypoint.js'
wherever possibleany
This is already in the TypeScript style guide, but to reiterate, DevTools code should not use any
wherever possible. All current instances of any are to manage legacy code, and ideally these will be rewritten or refactored out over time.
const enum
whenever possible. const enum
s are only available at compile time, and at runtime their values are inlined into the code, which helps decrease our bundle size.const enum Foo { A = 'a' }
. This keeps the values much easier to debug than trying to figure which value TypeScript assigned to any member.