无法解决&#34; tslib&#34;来自<path>

时间:2018-06-09 10:44:27

标签: typescript react-native expo

我有一个基于JS的React Native应用程序的TS。在将一些旧的JS内容移动到TS时,我收到错误:

  

无法解决&#34; tslib&#34;来自

这意味着什么,我该如何解决?该文件如下所示:

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)
            });
    }
}

1 个答案:

答案 0 :(得分:0)

修复了安装tslib

的问题

npm install --save tslib