我正在开发一个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
那里看到该类并输入。
我是否在这里错过了重要的打字稿课程或我忽略的问题?我很肯定包裹输入正确,所以这里发生了什么?
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