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

IntelliJ TS parameter warnings #1279

Open
kostasb opened this issue Dec 12, 2023 · 3 comments
Open

IntelliJ TS parameter warnings #1279

kostasb opened this issue Dec 12, 2023 · 3 comments
Assignees
Labels
bug Something isn't working needs-triage

Comments

@kostasb
Copy link
Contributor

kostasb commented Dec 12, 2023

Describe the bug
IntelliJ (2023.3) Typescript language service raises argument warnings with Xata SDK (0.28) calls such as select and filter.

With "email" being a string column:

    const page = await xata.db.repro
        .filter("email", "email")
        .select(["id", "email"])
        .getMany();

Filter:

Argument type "email" is not assignable to parameter type FilterColumns | JSONFilterColumns

Select:

Argument type string[] is not assignable to parameter type SelectableColumnWithObjectNotation[]

image

@kostasb kostasb added the bug Something isn't working label Dec 12, 2023
@eemmiillyy
Copy link
Contributor

Assigning Alexis because he had some ideas about a fix for this

@kostasb
Copy link
Contributor Author

kostasb commented Dec 12, 2023

Note: this issue surfaced since IntelliJ version 2023.3, it doesn't occur with 2023.2.

@mkurczewski
Copy link

I'm having same issue with select function. When I write it this way

const userRoles = await xataClient.db.usersRoles
    .filter({ userId })
    .select([{ name: "roles" }])
    .getFirst()

WebStorm stops complaining about it, but then I'm losing typing for userRoles so I can't do

  console.log(userRole?.roles)

I mean it works but I'm getting TS2339: Property roles does not exist on type XataRecord<UsersRolesRecord>. To get rid of this error I need to switch back to .select(["roles"]). The other option is to call read function on userRoles:

console.log((await userRole?.read())?.roles)

but this looks like an overkill.

So, to me it's better to just write

const userRole = await xataClient.db.usersRoles
    .filter({ userId })
    .select(["roles"])
    .getFirst()

  console.log(userRole?.roles)

and ignore the IntelliJ issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

4 participants