Is there a better way to assign constructor parameter in Typescript?
This is typical example of service locator anti pattern that should be refactored to builder pattern.

export class Hexagone {
  constructor(
    private ctx: CanvasRenderingContext2D,
    private center: Vector2,
    private size: number,
    private color: string,
    private type: HexagoneType
  ) {}
}

export class HexagoneBuilder {
  public center?: Vector2;
  public size?: number;
  public color?: string;
  public type?: HexagoneType;

  constructor(private ctx: CanvasRenderingContext2D) {}

  create() {
    return new Hexagone(
      this.ctx,
      this.center ?: new Vector2(),
      this.size ?: 100,
      this.color ?: "red",
      this.type ?: HexagonType.POINTY
    )
  }
}


Sorry if i made some syntax errors, I dont work with ts on daily basis, but you should get the idea...