Skip to content

Commit 3d6bf31

Browse files
authored
TS bugfix, export top-level indexer
`export default` will export like `module.exports["default"] = cptable`
1 parent 62fd61e commit 3d6bf31

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

Diff for: types/index.d.ts

+30-26
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
11
/* codepage.js (C) 2013-present SheetJS -- http://sheetjs.com */
22
// TypeScript Version: 2.2
33

4-
/** Codepage index type (integer or string representation) */
5-
export type CP$Index = number | string;
4+
declare namespace cptable {
5+
/** Codepage index type (integer or string representation) */
6+
export type CP$Index = number | string;
7+
8+
/* Individual codepage converter */
9+
export interface CP$Conv {
10+
enc: {[n: string]: number; };
11+
dec: {[n: number]: string; };
12+
}
13+
14+
/** Encode input type (string, array of characters, Buffer) */
15+
export type CP$String = string | string[] | Uint8Array;
16+
17+
/** Encode output / decode input type */
18+
export type CP$Data = string | number[] | Uint8Array;
19+
20+
/** General utilities */
21+
export interface CP$Utils {
22+
decode(cp: CP$Index, data: CP$Data): string;
23+
encode(cp: CP$Index, data: CP$String, opts?: any): CP$Data;
24+
hascp(n: number): boolean;
25+
magic: {[cp: string]: string};
26+
}
627

7-
/* Individual codepage converter */
8-
export interface CP$Conv {
9-
enc: {[n: string]: number; };
10-
dec: {[n: number]: string; };
1128
}
1229

13-
/** Encode input type (string, array of characters, Buffer) */
14-
export type CP$String = string | string[] | Uint8Array;
15-
16-
/** Encode output / decode input type */
17-
export type CP$Data = string | number[] | Uint8Array;
18-
19-
/** General utilities */
20-
export interface CP$Utils {
21-
decode(cp: CP$Index, data: CP$Data): string;
22-
encode(cp: CP$Index, data: CP$String, opts?: any): CP$Data;
23-
hascp(n: number): boolean;
24-
magic: {[cp: string]: string};
25-
}
26-
27-
/* note: TS cannot export top-level indexer, hence default workaround */
28-
export interface CP$Module {
30+
interface CP$Module {
2931
/** Version string */
3032
version: string;
3133

3234
/** Utility Functions */
33-
utils: CP$Utils;
35+
utils: cptable.CP$Utils;
3436

3537
/** Codepage Converters */
36-
[cp: number]: CP$Conv;
38+
[cp: number]: cptable.CP$Conv;
3739
}
38-
export const cptable: CP$Module;
39-
export default cptable;
40+
41+
declare const cptable:CP$Module;
42+
43+
export = cptable;

0 commit comments

Comments
 (0)