Background
Currently, the language features of ts-plugin are enabled automatically. This means they are enabled in all TypeScript projects. Consequently, Code Actions for CSS Modules appear in projects not using CSS Modules Kit, such as the following:
This can be annoying for some users.
Solution
Enable language features only if cmkOptions.enable is set to true in tsconfig.json. The default value is false. The minimal configuration to enable language features is as follows:
// tsconfig.json
{
"compilerOptions": {/* ... */},
"cmkOptions": {
"enabled": true
}
}
In projects where tsconfig.json lacks cmkOptions, language features will not be enabled.
cmkOptions.enabled can be inherited using extends. Therefore, language features will be enabled in the following packages/pkg-a/tsconfig.json:
We also add the cmkOptions.enabled option to explicitly disable language features. This allows disabling language features in projects inheriting from tsconfig.base.json.
Backwards Compatibility
This is a breaking change. Previously, language features were enabled even in projects without cmkOptions in tsconfig.json. However, this change disables them.
Before implementing this change, I believe we should add a warning feature to codegen that advises adding "cmkOptions": { "enabled": true } to tsconfig.json.
Progress
Background
Currently, the language features of ts-plugin are enabled automatically. This means they are enabled in all TypeScript projects. Consequently, Code Actions for CSS Modules appear in projects not using CSS Modules Kit, such as the following:
This can be annoying for some users.
Solution
Enable language features only if
cmkOptions.enableis set totrueintsconfig.json. The default value isfalse. The minimal configuration to enable language features is as follows:In projects where
tsconfig.jsonlackscmkOptions, language features will not be enabled.cmkOptions.enabledcan be inherited usingextends. Therefore, language features will be enabled in the followingpackages/pkg-a/tsconfig.json:We also add the
cmkOptions.enabledoption to explicitly disable language features. This allows disabling language features in projects inheriting fromtsconfig.base.json.Backwards Compatibility
This is a breaking change. Previously, language features were enabled even in projects without
cmkOptionsintsconfig.json. However, this change disables them.Before implementing this change, I believe we should add a warning feature to codegen that advises adding
"cmkOptions": { "enabled": true }totsconfig.json.Progress
cmkOptions.enabledis not set, and exit with error whencmkOptions.enabledis false #290cmkConfig.enabledisfalse#299cmkOptions.enabledistrue, and remove warning feature in codegen.