New error: This spread always overwrites this property
See original GitHub issueI believe the error is both correct and valuable, but filing it for completeness, since it wasn’t produced by 3.8.
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:
npm ci
tsc -b -f tsconfig.build.json
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:13 (5 by maintainers)
Top 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 >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’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.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 bothfeatureA
andfeatureB
will be present onwindow.MockFlags
and will override your explicit values.