DiFuks / ts-overrides-plugin

A plugin for TypeScript that allows overriding tsconfig for specific files
https://www.npmjs.com/package/ts-overrides-plugin
MIT License
38 stars 0 forks source link

Some typescript-eslint rules do not work with the plugin #22

Open DiFuks opened 13 hours ago

DiFuks commented 13 hours ago
const alwaysStringVar = 'Some string';

alwaysStringVar?.toLowerCase();

ESLint: This rule requires the `strictNullChecks` compiler option to be turned on to function correctly.(@typescript-eslint/ no-unnecessary-condition)

DiFuks commented 13 hours ago

The issue lies here: typescript-eslint retrieves compiler options from the original program. In theory, this can be addressed by passing a custom program to the parser options (example). However, there’s still a problem—it's impossible to provide different compiler options for different files.

Even then, it only works correctly in the CLI. For proper functionality in an IDE, a languageService is required instead of a program. typescript-eslint has a configuration option that allows using TypeScript plugins in conjunction with languageService. However, I’m currently stuck because TypeScript throws errors about conflicting program instances when trying to modify a file in the IDE (example)