menu
up-caret
down-caret

Expo

Build and share truly native apps that work across both iOS and Android. Open source, free and uses React Native.

# General

General Chatter

Trending conversations
expo video battery drain : 1% per minute
@codeplaygoa · 2d
Help: expo publish error write ECONNRESET
@devautor · 4d
expo-payments-stripe
@tafelito · 6d
generated .expo folder
@s-m · 11d
Unable to find a specification for `EXCore` depended upon by `EXWebBrowser`
@petekp · 12d

Extend (Update) third-party old type declaration interface with new one

Ilker Güller (@the-bluescreen1) · September 25, 2018 at 4:34pm

Extend (Update) third-party old type declaration interface with new one

September 25, 2018 at 4:34pm

My problem is that I'm using an old type declaration package (@types/expo). So that's why I need to update some part of it. I created a new typing file like this. (./typings/expo/index.d.ts)

import * as expo from 'expo';
declare module 'expo' {
var Icon: any;
var SplashScreen: any;
export interface AppLoadingProps {
startAsync?: () => Promise<void[]>;
}
}

Some parts were started to work but also I started to get this error:

[ts] Subsequent property declarations must have the same type.
Property 'startAsync' must be of type '(() => Promise<void>) | undefined',
but here has type '(() => Promise<void[]>) | undefined'

I searched it on google and typescript forums but It doesn't have any meaningful answer for this. Is it possible to update the interface that has same props? Or do I need to wait until the company updates its package on definitelyTyped?

my tsconfig.json file;

{
"compilerOptions": {
"target": "ES2017",
"module": "es2015",
"lib": [ /* Specify library files to be included in the compilation. */
"es2017",
"dom"
],
"jsx": "react-native",
"importHelpers": true,
"strict": true,
"noImplicitAny": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"moduleResolution": "node",
"typeRoots": [ /* List of folders to include type definitions from. */
"./typings",
"./node_modules/@types"
],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"noEmitHelpers": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"forceConsistentCasingInFileNames": true,
"outDir": "build/dist"
},
"exclude": [
"build",
"node_modules"
],
"types": [
"typePatches"
]
}

October 15, 2018 at 1:35pm

I think you mistyped your function. The types are different.

Notice that startAsync can be two things:

1 - undefined

2 - a function that returns an empty promise (`Promise<void>`)

But your value can be two of the following:

1- undefined

2 - a function that returns a promise with an array of empty values (`Promise<void[]>`, which can be written as Promise<Array<void>>)

  • reply
  • like