react-typescript 错误

@types/jsurl/index.d.ts' is not a module.

npm i jsurl 安装错误,

因为 typescript无法用此方法安装,卸载干净。

1. 增加types目录

新建jsurl.d.ts文件,写入:

declare module 'jsurl' {
  type Nullable<T> = T | null | undefined;
  export function stringify(input: any): string;
  export function parse(input?: Nullable<string>): Nullable<any>;
}

 

2)重新运行,成功!