【发布时间】:2019-03-01 08:14:00
【问题描述】:
我的问题是我使用的是旧的类型声明包 (@types/expo)。所以这就是为什么我需要更新它的某些部分。我像这样创建了一个新的打字文件。 (./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[]>;
}
}
一些部件开始工作,但我也开始收到此错误:
[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'
我在谷歌和打字稿论坛上搜索过它,但它没有任何有意义的答案。是否可以更新具有相同道具的界面?还是我需要等到公司在definitelyTyped 上更新它的包?
我的 tsconfig.json 文件;
{
"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"
]
}
【问题讨论】:
标签: typescript typescript-typings expo