Typescript namespaces to be considered?
See original GitHub issueAfter 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
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (5 by maintainers)
Top GitHub Comments
@Timer As it was said a linked babel issue, I wasn’t able to find any information about why are namespaces legacy. Later in that discussion, it’s revealed that it’s more of a technical issue than a problem of being deprecated. I can live what that, but let’s not spread the false accusations here 😃
@brunolemos Thanks for the tip, but I’ve already switched back to TS fork and don’t want to spend time on this anymore. It’s kinda a shame. In a sense, I was looking into being able to tap into Babel world while using TypeScript without extra hassle, but this is too much blocker for me.
Seems like that should just about settle this issue. Either convince the Babel folks to support this, or shoot me a PR over at customize-cra adding the ts-loader, and removing the current Babel solution.