cache.identify : Index signature is missing in type
See original GitHub issuerelated to
Intended outcome:
I want to retrieve the Apollo Client cache ID for a particular object.
interface MyMapInterface {
__typename: "Map";
id: string;
width: number;
height: number;
}
const myMap: MyMapInterface = { __typename: "Map", id: "1", width: 100, height: 100 };
client.cache.identify(myMap);
Actual outcome:
I get the following TS error.
Argument of type 'MyInterface' is not assignable to parameter of type 'StoreObject | Reference'.
Type 'MyInterface' is not assignable to type 'StoreObject'.
Index signature is missing in type 'MyInterface'.
How to reproduce the issue:
Versions
System:
OS: Windows 10 10.0.19041
Binaries:
Node: 15.5.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.10 - ~\Documents\workspace\GOunite\v3\client\node_modules\.bin\yarn.CMD
npm: 6.14.10 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 87.0.4280.88
Edge: Spartan (44.19041.423.0), Chromium (87.0.664.75)
npmPackages:
@apollo/client: 3.3.6 => 3.3.6
@apollo/link-context: 2.0.0-beta.3 => 2.0.0-beta.3
@apollo/link-error: 2.0.0-beta.3 => 2.0.0-beta.3
@apollo/link-persisted-queries: 1.0.0-beta.0 => 1.0.0-beta.0
@apollo/link-ws: 2.0.0-beta.3 => 2.0.0-beta.3
@apollo/react-testing: 3.1.4 => 3.1.4
apollo: 2.32.1 => 2.32.1
apollo-cache-persist: 0.1.1 => 0.1.1
apollo-upload-client: 14.1.0 => 14.1.0
TS 4.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:6 (1 by maintainers)
Top Results From Across the Web
TypeScript: Index signature is missing in type - Stack Overflow
The problem is that when the type is inferred, then the type of o is: { dic: { a: number, b: number }...
Read more >Managing objects with unknown structures in TypeScript using ...
We look into various options on how to handle an object that has a structure we don't know. We use index signatures and...
Read more >Documentation - TypeScript 4.4
TypeScript lets us describe objects where every property has to have a certain type using index signatures. This allows us to use these...
Read more >Index signature for type 'X' is missing in type 'Y' in TS
The error "Index signature for type is missing in type" occurs when TypeScript doesn't consider a type that uses an index signature and...
Read more >Common issues and solutions - mypy 0.991 documentation
The # type: ignore comment will only assign the implicit Any type if mypy cannot find information about that particular module. So, if...
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
The same issue exists if the interface passed is generated by the Apollo CLI (e.g. using an object returned in the data of a mutation). For best compatibility between Apollo created tools, it seems like changing the parameter type might be the best fix.
It’s possible to circumvent the issue by using spread syntax.
Although this could affect performance. Personally I prefer to
@ts-ignore
the warning.There is a related issue in the Typescript repo.