我有一个简单的函数,它以函数为参数并返回新函数。我Object is of type 'unknown'在调用返回的函数时得到
const makeFunction = <T>(callback: (someParam: number, options: T) => any) => {
return (options: T) => {
const param = 4;
return callback(param, options)
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码可以用于打字稿,但是当我调用函数时,我会抱怨
makeFunction((param, options) => {
const a = options.optionsValue //(parameter) options: unknown, Object is of type 'unknown'
})({optionsValue: 'some value'})
Run Code Online (Sandbox Code Playgroud) 我想创建依赖于其他 Pod 的自定义 Pod。我有 podspec 文件
...
s.source_files = "ios/**/*.{h,c,m,swift}"
s.requires_arc = true
s.dependency "UserSDK"
Run Code Online (Sandbox Code Playgroud)
UserSDK 是我想在自定义模块中使用的 pod。它有自己的依赖项 FirebaseCore,例如FirebaseMessaging UserSDK podspec
在我的 CustomModule.swift 文件中有
import Foundation
import UserSDK
Run Code Online (Sandbox Code Playgroud)
要使用自定义库,请通过 pod 文件包含它;
# Uncomment the next line to define a global platform for your project
# platform :ios, '11.0'
target 'MyTarget' do
pod 'FBLazyVector', :path => "../modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../modules/react-native/'
pod 'React-Core', …Run Code Online (Sandbox Code Playgroud)