expo: SDK 32 TypeScript errors

Just a heads up: I’m using typescript in my project and right after updating to SDK 32, a few errors were picked up by the compiler.

In my codebase:

  • takeSnapshotAsync gives Property 'snapshotContentContainer' is required in type 'SnapshotOptions'

I don’t see snapshotContentContainer anywhere in the docs, what does it do ?

  • DocumentPicker.getDocumentAsync gives 'copyToCacheDirectory' does not exist in type 'GetDocumentOptions' and yet it is (still ?) in the docs

  • ImagePicker.launchImageLibraryAsync gives 'base64' and 'exif' does not exist in type 'ImageLibraryOptions'

  • startAsync is marked as required in AppLoading.d.ts but from the docs:

The following props are recommended, but optional for the sake of backwards compatibility

Can I still use AppLoading the same way ?

In expo’s codebase: These errors appear repeatedly in a bunch of files

  • Namespace 'React' has no exported member 'ComponentProps'
  • Namespace 'React' has no exported member 'RefObject'
  • Namespace 'React' has no exported member 'Context'
  • Generic type 'Component<P, S>' requires between 0 and 2 type arguments
  • Generic type 'ComponentClass<P>' requires between 0 and 1 type arguments

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 29 (20 by maintainers)

Most upvoted comments

It’s merged 🎉

The latest version of expo package doesn’t have type declaration files and I have sent a PR to DT to update the types: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/32002

In the long run we will include .d.ts definitions with the expo package. Until then, we have no types (other than in the source .ts files) from the Expo team.

can confirm @dai-shi config works for me with minor changes because src is my root dir:

{
  "compilerOptions": {
    "rootDir": "src",
    "baseUrl": "src",
    "paths": {
      "expo": ["../node_modules/@types/expo", "../node_modules/expo"],
    }
  },
}

Hi, I’m back! 😁

This is my project: https://github.com/dai-shi/typescript-expo-apollo-boilerplate and especially the config is here.

OK, understood. I’ll look for a config to use @types/expo instead of expo. Thanks for your prompt response.

We publish the packages:

  • from master if we’re during the release process (no other changes land on master in that time)
  • when the release is ready, sdk-XX branch is created, from which we publish the packages

In such case, the proper place to look for published expo-asset@32.0.0 would be https://github.com/expo/expo/tree/sdk-32/packages/expo-asset. 🙂

Hey all, thanks for the comments!

  • My bad, I haven’t updated takeSnapshotAsync doc after upgrading the underlying react-native-view-shot, on it!
  • copyToCacheDirectory is missing in TS declaration, docs are correct
  • same goes for base64 and exif
  • startAsync should be optional

When it comes to React problems, on what @types/react version are you? 🤔 We compile expo against @types/react@^16.7.7, maybe on this version it would work? 🙂