# Possible issue with Apollo package types for ApolloError object

**URL:** <https://community.apollographql.com/t/possible-issue-with-apollo-package-types-for-apolloerror-object/6017>\
**Category:** About the Community\
**Tags:** client, web\
**Created:** [March 27, 2023, 12:34pm UTC](https://community.apollographql.com/t/possible-issue-with-apollo-package-types-for-apolloerror-object/6017 "2023-03-27T12:34:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luccahora](https://avatars.discourse-cdn.com/v4/letter/l/edb3f5/32.png) [@luccahora](https://community.apollographql.com/u/luccahora)\
**Post date:** [March 27, 2023, 12:34pm UTC](https://community.apollographql.com/t/possible-issue-with-apollo-package-types-for-apolloerror-object/6017/1 "2023-03-27T12:34:32Z")

</div>

I am writing to report a possible issue with the Apollo package types. When using the `ApolloError` object, TypeScript allows me to access the `extensions` property directly, even when the `graphQLErrors` array may be empty, which can result in a “Cannot read property ‘extensions’ of undefined” error at runtime.

It is possible that the types defined in the Apollo package are inaccurate or incomplete, leading to this error. I suggest reviewing and updating the types to prevent this issue from occurring.

Example:

```auto
import { ApolloError } from "@apollo/client";

const handleError = (err: ApolloError) => {
  if (err.graphQLErrors[0].extensions?.code !== "CONFLICT") {
    console.log("Error occurred");
  }
};
```

---

<div class="post-metadata">

**Author:** ![lenz](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/lenz/32/4007_2.png) [@lenz](https://community.apollographql.com/u/lenz)\
**Post date:** [March 27, 2023, 12:39pm UTC](https://community.apollographql.com/t/possible-issue-with-apollo-package-types-for-apolloerror-object/6017/2 "2023-03-27T12:39:14Z")

</div>

Hi, thanks for the report!  
That’s just how TypeScript works with arrays - you will see the same with this example:

```ts
const test: Array<{foo:string}> = []

test[0].foo

```

You can change that behavior by setting `noUncheckedIndexedAccess: true` in your `tsconfig.json` - but that’s really something you have to enable on a per-project level, we don’t have any influence on that on a library level.

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:49pm UTC](https://community.apollographql.com/t/possible-issue-with-apollo-package-types-for-apolloerror-object/6017/3 "2025-02-06T20:49:06Z")

</div>

Archived on February 6, 2025, 8:49pm UTC


