diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..52ab9ee --- /dev/null +++ b/index.d.ts @@ -0,0 +1,36 @@ +declare const stringify: typeof JSON.stringify; +declare const parse: typeof JSON.parse; + +declare function JSONBig(options?: Options): { parse: typeof parse; stringify: typeof stringify }; + +interface Options { + /** + * @default false + */ + strict?: boolean | undefined; + /** + * @default false + */ + storeAsString?: boolean | undefined; + /** + * @default false + */ + alwaysParseAsBig?: boolean | undefined; + /** + * @default false + */ + useNativeBigInt?: boolean | undefined; + /** + * @default 'error' + */ + protoAction?: "error" | "ignore" | "preserve" | undefined; + /** + * @default 'error' + */ + constructorAction?: "error" | "ignore" | "preserve" | undefined; +} + +type JSONBigExport = typeof JSONBig & { parse: typeof parse; stringify: typeof stringify }; + +declare const _: JSONBigExport; +export = _; diff --git a/package.json b/package.json index 5193854..86f03c5 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.2", "description": "JSON.parse with bigint support and correct handling of scientific notation", "main": "index.js", + "types": "index.d.ts", "files": [ "index.js", "lib/parse.js",