Typescript template immutable types, missing readonly attribute on __typename
See original GitHub issueWhen I use CODEGEN_IMMUTABLE_TYPES=true I get this output:
export type Query = {
__typename?: "Query";
readonly tenants: ReadonlyArray<Tenants>;
readonly plugins: ReadonlyArray<Plugins>;
};
I guess the __typename
property should also have a readonly
attribute in this case?
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Real Immutable Types With TypeScript - Temple Coding
When writing TypeScript there's a pretty easy, simple solution to create immutable objects and it doesn't involve adding third-party libraries.
Read more >Immutable TypeScript - Paul-Sebastian Codes
TypeScript has this syntax where you can tell the compiler that an object is of a specific type after declaring it. It's called...
Read more >Google TypeScript Style Guide
Use readonly Mark properties that are never reassigned outside of the constructor with the readonly modifier (these need not be deeply immutable).
Read more >Argument of type 'readonly ...' is not assignable to parameter ...
By setting the parameter as readonly, typescript won't complain anymore ... This way, you're not passing the original, immutable array, ...
Read more >Documentation - TypeScript 3.4
TypeScript 3.4 can now produce generic function types when inference from other generic functions produces free type variables for inferences. This means many ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had not upgraded the
graphql-codegen-typescript-template
package to 0.9.1. After I did that it works! 👍What do you mean by “more static”? it’s static in the generated type, and static in the resolvers signature (if you are using
typescript-resolvers
), so if you change the GraphQL type - it will change the generated file, and then the build will fail because of an invalid return value from the resolvers. Am I missing something? What is the benefit of generating the typename in a different variable?