【问题标题】:TypeScript Error: (TS1128) Declaration or statement expectedTypeScript 错误:(TS1128)声明或声明预期
【发布时间】:2020-12-09 08:48:30
【问题描述】:

我有一个 TypeScript 错误 TS1128:需要声明或声明。我花了几个小时,我找不到错误...它在 master/node_modules/@theme-ui/core/dist/index.d.ts (4, 1) 中:

import * as React from 'react';
import './react-jsx';
export type { CSSObject, CSSOthersObject, CSSProperties, CSSPseudoSelectorProps, ColorMode, ColorModesScale, Label, ResponsiveStyleValue, Scale, StylePropertyValue, TLengthStyledSystem, Theme, ThemeDerivedStyles, ThemeStyles, ThemeUICSSObject, ThemeUICSSProperties, ThemeUIExtendedCSSProperties, ThemeUIStyleObject, VariantProperty, } from '@theme-ui/css';
export * from './types';
export declare const jsx: typeof React.createElement;
export interface ContextValue {
    __EMOTION_VERSION__: string;
    theme: Theme;
}
export declare const Context: React.Context<ContextValue>;
export declare const useThemeUI: () => ContextValue;
/**
 * Deeply merge themes
 */
export declare const merge: {
    (a: Theme, b: Theme): Theme;
    all: typeof mergeAll;
}
declare function mergeAll<A, B>(a: A, B: B): A & B;
declare function mergeAll<A, B, C>(a: A, B: B, c: C): A & B & C;
declare function mergeAll<A, B, C, D>(a: A, B: B, c: C, d: D): A & B & C & D;
interface BaseProviderProps {
    context: ContextValue;
}
export interface ThemeProviderProps {
    theme: Theme | ((outerTheme: Theme) => Theme);
    children?: React.ReactNode;
}
export declare function ThemeProvider({ theme, children }: ThemeProviderProps): React.FunctionComponentElement<BaseProviderProps>;

【问题讨论】:

  • 您可能应该告诉 typescript 完全忽略您的 node_modules 文件夹。没有理由检查您无法解决的问题。如果它发生在特定的外部依赖项中,您可以在托管项目的 git 存储库中提交问题(或拉取请求以修复它)。检查node_modules/theme-ui/package.json 文件以找到它。

标签: reactjs typescript build-error


【解决方案1】:

试试下面的:

 npm uninstall -g typescript
 npm install typescript --save-dev

【讨论】:

    猜你喜欢
    • 2021-02-09
    • 1970-01-01
    • 2022-01-23
    • 2020-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-12
    • 1970-01-01
    相关资源
    最近更新 更多