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

Converted no-unnecessary-generics from TSLint to ESLint #539

Merged

Conversation

JoshuaKGoldberg
Copy link
Contributor

Continues the work from #489.

Deduplicates the typescript package dependency versions by switching them all to the stable 4.7.4 (which was already being used). Without deduped versions, there are type errors like:

Argument of type 'Declaration' is not assignable to parameter of type 'Node'.
  Types of property 'kind' are incompatible.
    Type 'import("/Users/josh/repos/DefinitelyTyped-tools/packages/dtslint/node_modules/@typescript-eslint/typescript-estree/node_modules/typescript/lib/typescript").SyntaxKind' is not assignable to type 'import("/Users/josh/repos/DefinitelyTyped-tools/packages/dtslint/node_modules/typescript/lib/typescript").SyntaxKind'.
      Property 'OutKeyword' is missing in type 'import("/Users/josh/repos/DefinitelyTyped-tools/packages/dtslint/node_modules/typescript/lib/typescript").SyntaxKind'.ts(2345)

Also adds a tsconfig.json to the dtslint tests directory so that ESLint rules using type information can be tested. https://typescript-eslint.io/docs/development/custom-rules#testing-typed-rules

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review September 26, 2022 18:41
@JoshuaKGoldberg
Copy link
Contributor Author

Bump @sandersn - is there any chance this & the other open TSLint->ESLint PRs be looked at soon, please?

"strict": true,
"target": "esnext"
},
"files": ["file.ts"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this require a real 'file.ts' to exist? A quick read of the documentation suggests 'yes'.

Edit: But...all tests pass, so maybe not.

`function example<T>(a: T[]): T;`,
`function example<T>(a: Set<T>): T;`,
`function example<T>(a: Set<T>, b: T[]): void;`,
`function example<T>(a: Map<T, T>): void;`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the last example function example<T, U extends T>(t: T, u: U): U


return soleUse ? { type: "sole", soleUse } : { type: "never" };

function recurse(node: ts.Node): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function recurse(node: ts.Node): void {
function recur(node: ts.Node): void {

The original verb form is 'recur'. But you can't have the noun form be *recurion, because, roughly, it violates a constraint on the pronunciation of the -ion suffix. 's' turns out to be the cheapest insertion that satisfies the constraint, giving you 'recursion'.

However, the noun 'recursion' gets used a lot more than the verb 'recur', so people end up treating that form as primary and creating the verb 'recurse' from 'recursion'. Chomskyan linguistics doesn't have a good explanation for this last part since it's not concerned with statistics or language change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, as much as I love discussion Chomskyan linguistics in PRs, this was the established convention in TSLint back in the day.

@sandersn
Copy link
Member

Whew! Finally got a clean local run -- looots of exemptions on this one, in varying syntaxes. I'm going merge this now.

@sandersn sandersn merged commit c941b4a into microsoft:master Dec 29, 2022
@JoshuaKGoldberg JoshuaKGoldberg deleted the tseslint-no-unnecessary-generics branch December 29, 2022 19:26
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

Successfully merging this pull request may close these issues.

None yet

2 participants