【发布时间】:2018-04-11 15:40:28
【问题描述】:
我正在开发一个 react-native 项目,该项目使用包 react-native-firebase 作为提供远程和本地通知的解决方案。
一切都很好,如果我执行以下操作:
import firebase from 'react-native-firebase'
...
const messagingPermission = await firebase.messaging().hasPermission()
上面的代码运行良好,没有任何抱怨。然而,
import firebase from 'react-native-firebase'
...
const customNotification = new firebase.notifications.Notification()
抱怨
[ts] Property 'Notification' does not exist on type '{ (): Notifications;
nativeModuleExists: boolean }'
但是,如果我按照输入(ctrl+click)进行操作,那么我可以在那里看到类 Notifications 并输入。
我在这里错过了重要的 Typescript 课程还是我忽略了问题?我确定包的输入正确,所以这里发生了什么?
如果您认为有帮助,我可以提供我的 tsconfig.json。
{
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"noImplicitAny": false,
"preserveConstEnums": true,
"allowJs": false,
"sourceMap": true,
"noImplicitReturns": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"watch": false,
"skipLibCheck": true,
"jsx": "react",
"outDir": "artifacts",
"rootDir": "src",
"baseUrl": "src",
},
"filesGlob": [
"typings/index.d.ts",
"app/**/*.ts",
"app/**/*.tsx"
],
"types": [
"react",
"react-native",
"jest"
],
"exclude": [
"android",
"ios",
"build",
"node_modules"
],
"compileOnSave": true
}
编辑:添加 tsconfig
【问题讨论】:
-
tsconfig.json在这种情况下可能有用。如果你能提供,那就太好了...... -
已添加
tsconfig.json:) -
@Aleski 如果任一答案有帮助,您能否将其中一个标记为已接受? (或评论,如果你想澄清)
-
我的错,是的,它是由下面的 Chris 排序的(不是在 4.0.2 中,但经过一些故障排除后最终在 4.0.4 中)
标签: typescript react-native react-native-firebase