Skip to content

Repo: add testing around TypeVariables/IndexedAccessTypes and getConstraintInfo #10606

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

Open
kirkwaiblinger opened this issue Jan 3, 2025 · 2 comments
Labels
accepting prs Go ahead, send a pull request that resolves this issue repo maintenance things to do with maintenance of the repo, and not with code/docs

Comments

@kirkwaiblinger
Copy link
Member

Suggestion

See #10602

Also document behavior of IndexedAccessTypes in the JSDoc and update the getConstraintInfo API/type definitions if necessary.

Additional Info

No response

@kirkwaiblinger kirkwaiblinger added triage Waiting for team members to take a look repo maintenance things to do with maintenance of the repo, and not with code/docs labels Jan 3, 2025
@ronami
Copy link
Member

ronami commented Jan 4, 2025

+1, I wasn't sure if I should mention you on the PR. Optimally, I think getConstraintInfo should ensure calling code handles these. Some cases where this seems relevant:

I think this is the IndexedAccessType (other variations):

function test<T>(arg: T, key: keyof T) {
    arg[key];
}

Unconstrained type parameter in union:

function test<T>(arg: T | []) {
  arg;
}

I've looked into some of the existing rules that specifically deal with unconstrained type parameters and got some false positives for these cases (playground link):

// [await-thenable](https://typescript-eslint.io/rules/await-thenable)
async function test<T>(arg: T, key: keyof T, combined: [] | T) {
  // correctly not reported
  await arg;
  // reported even though it shouldn't?
  await arg[key];
  // reported even though it shouldn't?
  await combined;
}

@kirkwaiblinger
Copy link
Member Author

I've reached out for advice in the TS discord here: https://discord.com/channels/508357248330760243/1324909031092916225

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting prs Go ahead, send a pull request that resolves this issue repo maintenance things to do with maintenance of the repo, and not with code/docs
Projects
None yet
Development

No branches or pull requests

3 participants