Vla*_*tko 4 typescript react-native expo
我有一个基于 JS 的 TS React Native 应用程序。在将一些旧的 JS 内容移动到 TS 期间,我收到一个错误:
无法解析“tslib”
这意味着什么?我该如何解决它?该文件如下所示:
import WordsService from './../data/wordsService/WordsService'
import { Word } from './../types/Word'
import { Dispatch, GetState, Action } from './../types/Redux'
export const dictionaryAction = {
ADD_NEW_WORD: "dictionaryActions.ADD_NEW_WORD",
DELETE_WORD: "dictionaryActions.DELETE_WORD",
SET_WORDS: "dictionaryActions.SET_WORDS"
}
export const setWords = (words: Word[]): Action => {
return { type: dictionaryAction.SET_WORDS, payload: words }
}
export const addNewWord = (word: Word) => {
return (dispatch: Dispatch, getState: GetState) => {
new WordsService().addNewWord(word)
.then((insertedWord) => {
const insertId = insertedWord.insertId
word.id = insertId
dispatch({ type: dictionaryAction.ADD_NEW_WORD, payload: word })
})
.catch(error => {
console.log(error)
});
}
}
export const deleteWord = (word: Word) => {
return (dispatch: Dispatch, getState: GetState) => {
new WordsService().deleteWord(word)
.then(() => {
dispatch({ type: dictionaryAction.DELETE_WORD, payload: word })
})
.catch(error => {
console.log(error)
});
}
}
export const getLocalWords = () => {
return (dispatch: Dispatch, getState: GetState) => {
new WordsService().getLocalWords()
.then(words => {
dispatch(setWords(words))
})
.catch(error => {
console.log(error)
});
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2366 次 |
| 最近记录: |