【问题标题】:Unable to resolve "tslib" from <path>无法从 <path> 解析“tslib”
【发布时间】:2018-11-19 06:26:49
【问题描述】:

我有一个基于 JS 的 React Native 应用程序的 TS。在将一些旧的 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)
            });
    }
}

【问题讨论】:

    标签: typescript react-native expo


    【解决方案1】:

    修复了安装tslib:

    npm install --save tslib

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-29
      • 1970-01-01
      • 1970-01-01
      • 2022-11-04
      • 2016-08-19
      • 2014-08-24
      • 1970-01-01
      相关资源
      最近更新 更多