Property undefined error in type definitions.
See original GitHub issueSteps to Reproduce
Just import apollo-client
.
Buggy Behavior
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,18): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'networkInterface' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,36): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'reduxRootKey' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,50): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'reduxRootSelector' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,69): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'initialState' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,83): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'dataIdFromObject' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,101): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'queryTransformer' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,119): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'resultTransformer' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,138): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'resultComparator' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,156): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'shouldBatch' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,169): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'ssrMode' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,178): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'ssrForceFetchDelay' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,198): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'mutationBehaviorReducers' and no string index signature.
[0] /home/zhenghu/coding/qsc/qsc-main-react-typescript/node_modules/apollo-client/index.d.ts
[0] (47,224): error TS2459: Type '{ networkInterface?: NetworkInterface | undefined; reduxRootKey?: string | undefined; reduxRootSe...' has no property 'batchInterval' and no string index signature.
Expected Behavior
No error.
Version
- apollo-client@0.4.21
- react-apollo@0.5.11
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >Uncaught TypeError: Cannot read property of undefined In
In basic terms, undefined means that a variable has been declared but has not yet been assigned a value. This particular error is...
Read more >Why does TypeScript not check for undefined when looking up ...
When looking up properties from such an object, they are returned as number s, as is expected. let key = 'pi'; let pi...
Read more >How to Deal with Optional Things and "Undefined" in TypeScript
Working with JavaScript means working with undefined . It's a standard way to say, “This thing you asked for doesn't exist.”.
Read more >How to Avoid the Infamous "Cannot read properties of ... - Bitovi
That error message is telling you the function is returning undefined implicitly, but its return type does not include undefined in it. Awesome!...
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
This is also biting me, also using
strictNullChecks
. I’m just casting to get this to work without copying any definitions around, but would be great to get it resolved in the shipped definitions.I fixed this by manually editing the
.d.ts
file to remove the first?
from the constructor declaration (at the end of the second line below) to eliminates the errors, and adding a second constructor declaration for the case when nothing is passed in:I was going to submit a PR for this, but the
.d.ts
file does not appear to be in the repo? I guess it is generated by some magic that I have not yet learned.