eslint-plugin-tree-shaking
eslint-plugin-tree-shaking copied to clipboard
Private identifiers not recognized
Hi,
If I have some TypeScript like:
export class Secret {
#secret: string
constructor() {
this.#secret = 'secret'
}
getSecret(): string {
return this.#secret
}
}
I get an error:
Unknown node type PrivateIdentifier.
If you are using the latest version of this plugin, please consider filing an issue noting this message, the offending statement, your ESLint version, and any active ESLint presets and plugins eslint(tree-shaking/no-side-effects-in-initialization)
at the line #secret: string.
eslint: 8.22.0 eslint-plugin-tree-shaking: 1.10.0 eslint-config-prettier: 8.5.0 eslint-plugin-import: 2.26.0 eslint-plugin-prettier: 4.2.1, typescript: 4.7.4 @typescript-eslint/eslint-plugin: 5.34.0 @typescript-eslint/parser: 5.34.0
Is this likely an issue with the plugin or my tsconfig or ....?
Thanks,
Tim
Fix might just be to duplicate the processing for "Identifier" as "PrivateIdentifier" - I have a local build where this resolves the issue for me but I'm not confident that the solution is correct - nor am I certain how best to write unit tests for it or I'd submit a PR.