Skip to content

Typescript namespaces to be considered? #5633

Closed
@danielkcz

Description

@danielkcz

After some initial bickering that Typescript support does not include this and that I've decided to give it a try. Unfortunately, I've stumbled upon a big obstacle.

I am using graphql-code-generator package to generate strong types for my GraphQL queries. In the essence, it generates types like this.

export namespace GLogoutWidget {
  export type Variables = {
    id: string
  }

  export type Query = {
    __typename?: 'Query'
    user: User
  }

  export type User = {
    __typename?: 'User'
    id: string
    firstName?: string | null
    lastName?: string | null
  }
}

Usage of namespaces in this is extremely helpful as it clearly separates types for each query/mutation. Compared to apollo-codegen which outputs extremely long and annoying names for types, this is a clear win.

I would like to know if namespace support is such a huge technical problem that it cannot be included. I mean when bundling the app it should be mostly about stripping type information and let the TypeScript worry about type checking. I am kinda lost why such a decision has been made to have a separate TypeScript parser that's limited like this.

/cc @Timer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions