Repository: babel/babel
File: packages/babel-parser/src/tokenizer/state.ts (TypeScript)

Code before:
  // When a topic binding has been currently established,
  // then this is 1. Otherwise, it is 0. This is forwards compatible
  // with a future plugin for multiple lexical topics.
  maxNumOfResolvableTopics: number;
  // When a topic binding has been currently established, and if that binding
  // has been used as a topic reference `#`, then this is 0. Otherwise, it is
  // `null`. This is forwards compatible with a future plugin for multiple
  // lexical topics.
  maxTopicIndex: null | 0;
};

export const enum LoopLabelKind {
  Loop = 1,
  Switch = 2,
}

declare const bit: import("../../../../scripts/babel-plugin-bit-decorator/types.d.ts").BitDecorator<State>;

export default class State {
  @bit.storage flags: number = 0;

  @bit accessor strict = false;

  declare startIndex: number;
  declare curLine: number;
  declare lineStart: number;

  // And, if locations are used, the {line, column} object
  // corresponding to those offsets
  declare startLoc: Position;
  declare endLoc: Position;

  init({
    strictMode,
    sourceType,
    startIndex,
    startLine,
    startColumn,
  }: OptionsWithDefaults): void {
    this.strict =
      strictMode === false
        ? false
        : strictMode === true
          ? true
          : sourceType === "module";

    this.startIndex = startIndex;
    this.curLine = startLine;
    this.lineStart = -startColumn;
    this.startLoc = this.endLoc = new Position(
      startLine,

Review comment (suggestion):
This is a runtime change, now when initializing these properties the engine will first have to check if they are on the prototype. Would this work instead?
```js
  startIndex!: number;
  curLine!: number;
  lineStart!: number;
```

Code after:
  // When a topic binding has been currently established,
  // then this is 1. Otherwise, it is 0. This is forwards compatible
  // with a future plugin for multiple lexical topics.
  maxNumOfResolvableTopics: number;
  // When a topic binding has been currently established, and if that binding
  // has been used as a topic reference `#`, then this is 0. Otherwise, it is
  // `null`. This is forwards compatible with a future plugin for multiple
  // lexical topics.
  maxTopicIndex: null | 0;
};

export const enum LoopLabelKind {
  Loop = 1,
  Switch = 2,
}

declare const bit: import("../../../../scripts/babel-plugin-bit-decorator/types.d.ts").BitDecorator<State>;

export default class State {
  @bit.storage flags: number = 0;

  @bit accessor strict = false;

  startIndex!: number;
  curLine!: number;
  lineStart!: number;

  // And, if locations are used, the {line, column} object
  // corresponding to those offsets
  startLoc!: Position;
  endLoc!: Position;

  init({
    strictMode,
    sourceType,
    startIndex,
    startLine,
    startColumn,
  }: OptionsWithDefaults): void {
    this.strict =
      strictMode === false
        ? false
        : strictMode === true
          ? true
          : sourceType === "module";

    this.startIndex = startIndex;
    this.curLine = startLine;
    this.lineStart = -startColumn;
    this.startLoc = this.endLoc = new Position(
      startLine,