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

[no-explicit-generics] False positive when the generic isn't *exactly* the infered type #102

Open
Samuel-Therrien-Beslogic opened this issue Aug 17, 2022 · 0 comments

Comments

@Samuel-Therrien-Beslogic
Copy link

Samuel-Therrien-Beslogic commented Aug 17, 2022

See the below example:
private readonly mySubject = new BehaviorSubject<string | undefined>(undefined)
Results in Explicit generic type arguments are forbidden. Despite the generic being necessary to specify the full type here.

A possible workaround is to cast the subject's initial value:
private readonly mySubject = new BehaviorSubject(undefined as string | undefined)
But we find specifying generics to be preferable over casting.

I remember reading some time ago about adding some sort of unnecessary generic check as part of typescript-eslint itslef. There was a mention of current limitations with TypeScript or using complicated (and slower) AST checks. So I understand if such false-positives may not be possible to detect.
Edit: typescript-eslint/typescript-eslint#4978 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant