Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TypeScript readonly modifier for external/array types #303

Merged
merged 1 commit into from Nov 28, 2022

Conversation

bmish
Copy link
Owner

@bmish bmish commented Nov 28, 2022

Use TypeScript readonly keyword in many places. This prevents us from modifying certain properties/data, kind of like the ESLint no-param-reassign rule. It's best practice to avoid modifying input data like user-provided options.

  • Use readonly keyword on all internal array types
  • Use readonly keyword on all our public GenerateOptions option types
  • Perform a few minor refactorings to avoid mutating affected data

If using readonly ends up causing any issues, we can relax some of this later.

https://www.typescriptlang.org/docs/handbook/2/classes.html#readonly
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#a-new-syntax-for-readonlyarray

@bmish bmish added the bug Something isn't working label Nov 28, 2022
@bmish bmish merged commit 05687c0 into main Nov 28, 2022
@bmish bmish deleted the readonly-types branch November 28, 2022 16:49
@bmish bmish changed the title Use readonly for external/array types Use TypeScript readonly modifier for external/array types Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant