-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
WIP: feat(eslint-plugin): migrate no-unnecessary-generics from dtslint #3756
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
Conversation
Thanks for the PR, @Zzzen! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
Nx Cloud ReportCI ran the following commands for commit e320d46. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch Sent with 💌 from NxCloud. |
} | ||
} | ||
|
||
function forEachType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
● no-unnecessary-generics › valid ›
function f1<T extends { new (...args: any[]): any }>(a: T) { return class Foo extends a { f = 1; }; }RangeError: Maximum call stack size exceeded Occurred while linting typescript-eslint/packages/eslint-plugin/tests/fixtures/file.ts:2 250 | }); 251 | > 252 | forEachType(signature.getReturnType(), cb, checker); | ^ 253 | 254 | // const predicate = checker.getTypePredicateOfSignature(); 255 | const decl = signature?.getDeclaration();
It seems checking if a type is used in another type is extremely difficult. Even an innocent constructor signature may kill the linter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there another way to get this info?
There must be otherwise TS would always die for that sort of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have found why it is crashing.
To check if type T
is used in any[]
, we need to check every member/method of any[]
.
interface Array<T> {
length: number;
concat(...items: Array<ConcatArray<T>>);
}
Apparently, the definition of Array
is recursive, which spans Array<ConcatArray<...<ConcatArray<ConcatArray<T>>>...>>
👋 @Zzzen, just checking in! Do you still have interest + time for this PR? No worries if not! |
🥲 It's much more complicated than I have expected. It would be great if someone else can implement it. |
I'll close this for housekeeping purposes. |
#3729