reactjs - React typescript '=' forventet. TS1005


Jeg får feil med

'=' expected.  TS1005
  
   5 |  * LICENSE file in the root directory of this source tree.    
   6 |  */    
>  7 | import type { NewPlugin, Optionsz, OptionsReceived } from './types';
     |             ^
   8 | export type { Colors, Config, Options, OptionsReceived, OldPlugin, NewPlugin, Plugin, Plugins, Printer, Refs, Theme, } from './types';
   9 | export declare const DEFAULT_OPTIONS: Options;    
  10 | /**

Oppdatert kodebase fra index.d.ts:

    import type { NewPlugin, Options, OptionsReceived } from './types';
    export type { Colors, Config, Options, OptionsReceived, OldPlugin, NewPlugin, Plugin, Plugins, Printer, Refs, Theme, } from './types';
    export declare const DEFAULT_OPTIONS: Options;
    /**
     * Returns a presentation string of your `val` object
     * @param val any potential JavaScript object
     * @param options Custom settings
     */
    export declare function format(val: unknown, options?: OptionsReceived): string;
    export declare const plugins: {
        AsymmetricMatcher: NewPlugin;
        ConvertAnsi: NewPlugin;
        DOMCollection: NewPlugin;
        DOMElement: NewPlugin;
        Immutable: NewPlugin;
        ReactElement: NewPlugin;
        ReactTestComponent: NewPlugin;
    };
    export default format;

Oppdatert og legg til tsconfig.json:

    {
      "compilerOptions": {
        "target": "es5",
        "lib": [
          "dom",
          "dom.iterable",
          "esnext"
        ],
        "allowJs": true,
        "skipLibCheck": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "noEmit": true,
        "jsx": "react"
      },
      "include": [
        "src"
      ]
    }

Er det noen som vet hvordan man fikser denne feilen? Tusen takk

Svar #1

fjern type-nøkkelordet :

import  { NewPlugin, Options, OptionsReceived } from './types';

export  { Colors, Config, Options, OptionsReceived, OldPlugin, NewPlugin, Plugin, Plugins, Printer, Refs, Theme, } from './types';

export declare const DEFAULT_OPTIONS: Options;

Svar #2

Etter litt leting løste jeg dette ved å oppgradere typescript til 3.8+

npm install typescript@^3.8

ref :

  • https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html
  • https://blog.51cto.com/u_15072920/4818871