我有一个基于JS的React本地应用程序的TS。在将一些旧的JS东西移到TS时,我收到了一个错误:
无法从
它能意味着什么,我如何修复它?该文件如下所示:
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)
});
}
}发布于 2018-06-09 10:51:55
修正了安装tslib
npm install --save tslib
https://stackoverflow.com/questions/50773412
复制相似问题