kamilkisiela / apollo-angular

A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
https://apollo-angular.com
MIT License
1.5k stars 309 forks source link

Compile Error in generated code: "TS414 must use override" #1800

Closed tmtron closed 2 years ago

tmtron commented 2 years ago

Describe the bug

The generated code does not compile:

TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Mutation<ConfigUpsertMutation, Exact<{ data: ConfigCreateInput; }>>'.

This happens because the document property in the generated Mutation overrides the document property of the parent Apollo.Mutation class

image

To Reproduce

in tsconfig.json set "noImplicitOverride": true

Expected behavior

should compile

Environment:

+-- @angular/cli@13.1.2 
+-- @angular/core@13.1.1
+-- @apollo/client@3.6.8
+-- apollo-angular@3.0.1
+-- graphql@16.5.0
`-- typescript@4.5.4
synerp commented 2 years ago

Did you end up fixing this?

tmtron commented 2 years ago

@synerp No. As a workaround I've set "noImplicitOverride": false in tsconfig.json until this is fixed

synerp commented 2 years ago

@tmtron have you tried this option?

config: addExplicitOverride: true

tmtron commented 2 years ago

@synerp Thanks, that works. I was not aware of this config option.

After enabling the addExplicitOverride config option of typescript-apollo-angular plugin generated code also works when noImplicitOverride is true.

I've added the config at the plugin-level of my codegen.yml

generates:
  ./libs/`XXX/generated.ts:
    plugins:
      - typescript
      - typescript-operations
      - typescript-apollo-angular:
          addExplicitOverride: true