Skip to content

Conversation

@yCodeTech
Copy link
Owner

This pull request refactors how configuration values are accessed in the Configuration class to improve type safety and maintainability. The main change is the introduction of a new Settings interface that defines all supported configuration keys and their types, and the update of the getConfigurationValue method to use this interface for type-safe access throughout the codebase.

Type Safety and Configuration Refactor:

  • Introduced a new Settings interface in src/interfaces/settings.ts that explicitly defines all available configuration keys and their respective types.
  • Updated the getConfigurationValue method in src/configuration.ts to use generic key access (K extends keyof Settings) and return the correct type from Settings, ensuring type-safe retrieval of configuration values.
  • Refactored all usages of getConfigurationValue in src/configuration.ts to remove explicit type arguments and leverage the new type-safe method signature.

- Added new `Settings` interface to define all the configuration settings and their typings.

- Refactored the `Configuration::getConfigurationValue` method to use the new `Settings` interface and automatically get the correct typing of the specified key from the interface. This also enables intellisense support for the settings keys. It also removes the requirement of hardcoding the type via generic typing when using the method. ie. `getConfigurationValue<string[]>()`.

- Removed all generic typings from the `getConfigurationValue` method calls.
- Fixed the typing of `overrideDefaultLanguageMultiLineComments` setting to use the `Record` utility type. The setting is defined in the package.json as an object, but it has always been wrongly typed as an array (`string[]`). The utility type `Record` defines the types for the keys and values, assuming all keys and all values will be of the same typing, ie stringed keys and numeric values, in our case though it's stringed values. It's an easier way of typing it as `{ [ key: string ]: string }`.
- Removed the import for the `SupportUnsupportedLanguages` interface, as this isn't available until 1.2.0. This was wrongly added to this PR while adding it for the 1.2.0 version.
- Removed the generic typing from the `Configuration::getConfigurationValue` method call in extension.ts file.
- Changed the job name in check-ts.yml from `deploy` to `check-ts`, as it's confusing seeing `deploy` on GitHub PR's and actions when it actually isn't the deploy workflow. This workflow only checks ts errors.
@yCodeTech yCodeTech added the enhancement New feature or quality of life enhancement label Jan 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or quality of life enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants