From 40e7e591473f7cd6415170aba99c0e2cddef0051 Mon Sep 17 00:00:00 2001 From: Micah Zoltu Date: Mon, 19 Nov 2018 08:00:53 +0800 Subject: [PATCH 1/4] Adds TypeScript definition for the package's supported public surface area. --- index.d.ts | 5 +++++ package.json | 1 + 2 files changed, 6 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..1ad34063 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,5 @@ +declare module "solc" { + export type ReadCallbackResult = { contents: string } | { error: string }; + export type ReadCallback = (path: string) => ReadCallbackResult; + export function compile(input: string, readCallback?: ReadCallback): string; +} diff --git a/package.json b/package.json index e5749aba..133870e3 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.5.14", "description": "Solidity compiler", "main": "index.js", + "types": "index.d.ts", "bin": { "solcjs": "solcjs" }, From 8019e930b2d684c6cea2cb29207dea33ee971e67 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 3 Dec 2018 15:29:32 +0000 Subject: [PATCH 2/4] Add more of the public functions to the TypeScript definition --- index.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.d.ts b/index.d.ts index 1ad34063..f8d54286 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,15 @@ declare module "solc" { + export function version(): string; + export function semver(): string; + export function license(): string; + + export let features: { + legacySingleInput: boolean, + multipleInputs: boolean, + importCallback: boolean, + nativeStandardJSON: boolean, + }; + export type ReadCallbackResult = { contents: string } | { error: string }; export type ReadCallback = (path: string) => ReadCallbackResult; export function compile(input: string, readCallback?: ReadCallback): string; From 904385ecc890e3b8cbeadb0a7a1ebfc73f04265e Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 25 Sep 2019 22:37:46 +0100 Subject: [PATCH 3/4] Add missing types --- index.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index f8d54286..0e70a9bf 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,6 +3,13 @@ declare module "solc" { export function semver(): string; export function license(): string; + export let lowlevel: { + compileSingle: function(input: string): string; + compileMulti: function(input: string): string; + compileCallback: function(input: string): string; + compileStandard: function(input: string): string; + }; + export let features: { legacySingleInput: boolean, multipleInputs: boolean, @@ -12,5 +19,6 @@ declare module "solc" { export type ReadCallbackResult = { contents: string } | { error: string }; export type ReadCallback = (path: string) => ReadCallbackResult; - export function compile(input: string, readCallback?: ReadCallback): string; + export type Callbacks = { import: ReadCallback }; + export function compile(input: string, readCallback?: Callbacks | ReadCallback): string; } From 31b540319aa994cc00c08616ae8273142feadabc Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 12 Dec 2019 00:01:43 +0000 Subject: [PATCH 4/4] 0.6.0 update --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 0e70a9bf..69e7d588 100644 --- a/index.d.ts +++ b/index.d.ts @@ -20,5 +20,5 @@ declare module "solc" { export type ReadCallbackResult = { contents: string } | { error: string }; export type ReadCallback = (path: string) => ReadCallbackResult; export type Callbacks = { import: ReadCallback }; - export function compile(input: string, readCallback?: Callbacks | ReadCallback): string; + export function compile(input: string, readCallback?: Callbacks): string; }