question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New error: This spread always overwrites this property

See original GitHub issue

I believe the error is both correct and valuable, but filing it for completeness, since it wasn’t produced by 3.8.

https://github.com/apollographql/apollo-server/blob/c177acd7959aaf516f8ac814f1a6bb2e6d3ed2e6/packages/apollo-server-core/src/ApolloServer.ts#L775

packages/apollo-server-core/src/ApolloServer.ts:775:7 - error TS2783: 'context' is specified more than once, so this usage will be overwritten.

775       context,
          ~~~~~~~

  packages/apollo-server-core/src/ApolloServer.ts:787:7
    787       ...this.requestOptions,
              ~~~~~~~~~~~~~~~~~~~~~~
    This spread always overwrites this property.

To repro:

  1. npm ci
  2. tsc -b -f tsconfig.build.json

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

14reactions
sethlowiecommented, May 18, 2020

I’m not sure this error is correct. I have the use case of wanting to overwrite the properties. I have to use Object.assign which compiles fine, even though it’s the same behavior. This change is forcing users to choose a specific syntax for the same behavior.

2reactions
amcaseycommented, May 18, 2020

So maybe the issue here is that using Object.assign instead of spreading doesn’t throw an error.

It does seem like they should be consistent.

In your example, it looks like MockFlags should be optional? Otherwise, the || {} will never do anything, will it? As written, it seems to guarantee that both featureA and featureB will be present on window.MockFlags and will override your explicit values.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you use spread operator to overwrite properties in ...
I was now getting the error Error TS2783: 'stateOrProvince' is specified more than once, so this usage will be overwritten. which makes sense....
Read more >
How to avoid overwriting nested object with spread operator?
I want to set the ssmlGender in shared options, but not the languageCode . I'm thinking I might have to set properties one...
Read more >
TypeScript/JavaScript Spread operator (three dots)
The spread operator (three dots) is used to copy an array and expand an array to pass the values to another object or...
Read more >
Object spread Lesson - Everyday TypeScript - Execute Program
We mixed up the property order, causing a type error. Fix the order so that the property is actually overwritten.
Read more >
TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found