我试图包装一个没有导出的纯js库,只是一个带有原型扩展的全局变量。 https://github.com/davidshimjs/qrcodejs
声明文件与npm库分开
declare class QRCode {
constructor (el: HTMLElement, vOption: string|Options): IQRCode;
public makeCode(sText: string): void
public clear(): void
}
declare module 'davidshimjs-qrcodejs' {
export enum CorrectLevel {
M = 0,
L = 1,
H = 2,
Q = 3
}
export interface Options {
text: string,
width: number = 256,
height: number = 256,
colorDark: string = '#000000',
colorLight: string = '#ffffff',
correctLevel: CorrectLevel
}
}