Skip to content

Using path aliases breaks eslint validation #88

@Thinkscape

Description

@Thinkscape

We're referencing quite a lot of the generated GQL types within our project and end up with quite annoying, and easy to break imports like

const QUERY = gql`
  query Something{} 
` as import('../../../../__generated__/ts-gql/Something').type;

As a solution we attempted using TS path aliases, such that in tsconfig.json we put

{
  "compilerOptions": {
    "paths": {
      "@gql/*": ["../../../../__generated__/ts-gql/*"]
    }
  }
}

and our import becomes:

const QUERY = gql`
  query Something{} 
` as import('@gql/Something').type;

However that is not accepted by the eslint plugin, which will complain with:

 error    You must cast gql tags with the generated type  @ts-gql/ts-gql

I haven't found a workaround yet. tsc is happy with the imports, if I disable the ts-sql eslint plugin then I can build it in Next.js context.

Is there an easy fix or does it require refactoring the plugin?

Cheers,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions