From d0b4ccdaeaefdfac7c5d4248692d3f1b7a66247e Mon Sep 17 00:00:00 2001 From: Nathan Mc Grath Date: Thu, 11 Jan 2024 17:40:39 +0100 Subject: [PATCH] fix: add missing typescript export for init args (#510) --- rust/candid_parser/src/bindings/typescript.rs | 4 +++- rust/candid_parser/tests/assets/ok/actor.d.ts | 1 + rust/candid_parser/tests/assets/ok/class.d.ts | 1 + rust/candid_parser/tests/assets/ok/cyclic.d.ts | 1 + rust/candid_parser/tests/assets/ok/empty.d.ts | 1 + rust/candid_parser/tests/assets/ok/escape.d.ts | 1 + rust/candid_parser/tests/assets/ok/example.d.ts | 1 + rust/candid_parser/tests/assets/ok/fieldnat.d.ts | 1 + rust/candid_parser/tests/assets/ok/keyword.d.ts | 1 + rust/candid_parser/tests/assets/ok/management.d.ts | 1 + rust/candid_parser/tests/assets/ok/recursion.d.ts | 1 + rust/candid_parser/tests/assets/ok/recursive_class.d.ts | 1 + rust/candid_parser/tests/assets/ok/service.d.ts | 1 + rust/candid_parser/tests/assets/ok/unicode.d.ts | 1 + 14 files changed, 16 insertions(+), 1 deletion(-) diff --git a/rust/candid_parser/src/bindings/typescript.rs b/rust/candid_parser/src/bindings/typescript.rs index 50a738ec..a93df74e 100644 --- a/rust/candid_parser/src/bindings/typescript.rs +++ b/rust/candid_parser/src/bindings/typescript.rs @@ -192,7 +192,9 @@ import type { IDL } from '@dfinity/candid'; None => RcDoc::nil(), Some(actor) => pp_actor(env, actor) .append(RcDoc::line()) - .append("export declare const idlFactory: IDL.InterfaceFactory;"), + .append("export declare const idlFactory: IDL.InterfaceFactory;") + .append(RcDoc::line()) + .append("export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[];"), }; let doc = RcDoc::text(header) .append(RcDoc::line()) diff --git a/rust/candid_parser/tests/assets/ok/actor.d.ts b/rust/candid_parser/tests/assets/ok/actor.d.ts index 98924db1..5d1664c8 100644 --- a/rust/candid_parser/tests/assets/ok/actor.d.ts +++ b/rust/candid_parser/tests/assets/ok/actor.d.ts @@ -13,3 +13,4 @@ export interface _SERVICE { 'o' : ActorMethod<[o], o>, } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/class.d.ts b/rust/candid_parser/tests/assets/ok/class.d.ts index c7e627cd..609a84e0 100644 --- a/rust/candid_parser/tests/assets/ok/class.d.ts +++ b/rust/candid_parser/tests/assets/ok/class.d.ts @@ -8,3 +8,4 @@ export interface _SERVICE { 'set' : ActorMethod<[List], List>, } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/cyclic.d.ts b/rust/candid_parser/tests/assets/ok/cyclic.d.ts index e17e0f84..ae0959f2 100644 --- a/rust/candid_parser/tests/assets/ok/cyclic.d.ts +++ b/rust/candid_parser/tests/assets/ok/cyclic.d.ts @@ -10,3 +10,4 @@ export type Y = Z; export type Z = A; export interface _SERVICE { 'f' : ActorMethod<[A, B, C, X, Y, Z], undefined> } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/empty.d.ts b/rust/candid_parser/tests/assets/ok/empty.d.ts index 4d42e33e..2a8b36a6 100644 --- a/rust/candid_parser/tests/assets/ok/empty.d.ts +++ b/rust/candid_parser/tests/assets/ok/empty.d.ts @@ -9,3 +9,4 @@ export interface _SERVICE { 'h' : ActorMethod<[[T, never]], { 'a' : T } | { 'b' : {} }>, } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/escape.d.ts b/rust/candid_parser/tests/assets/ok/escape.d.ts index 515334bf..06041ba2 100644 --- a/rust/candid_parser/tests/assets/ok/escape.d.ts +++ b/rust/candid_parser/tests/assets/ok/escape.d.ts @@ -10,3 +10,4 @@ export interface t { } export interface _SERVICE { '\n\'\"\'\'\"\"\r\t' : ActorMethod<[t], undefined> } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/example.d.ts b/rust/candid_parser/tests/assets/ok/example.d.ts index ffa8f55a..d04234de 100644 --- a/rust/candid_parser/tests/assets/ok/example.d.ts +++ b/rust/candid_parser/tests/assets/ok/example.d.ts @@ -51,3 +51,4 @@ export interface _SERVICE { 'x' : ActorMethod<[a, b], [[] | [a], [] | [b]]>, } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/fieldnat.d.ts b/rust/candid_parser/tests/assets/ok/fieldnat.d.ts index 5c8c2ab3..2f2074fa 100644 --- a/rust/candid_parser/tests/assets/ok/fieldnat.d.ts +++ b/rust/candid_parser/tests/assets/ok/fieldnat.d.ts @@ -14,3 +14,4 @@ export interface _SERVICE { 'foo' : ActorMethod<[{ _2_ : bigint }], { _2_ : bigint, '_2' : bigint }>, } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/keyword.d.ts b/rust/candid_parser/tests/assets/ok/keyword.d.ts index f1180c50..a2e5b060 100644 --- a/rust/candid_parser/tests/assets/ok/keyword.d.ts +++ b/rust/candid_parser/tests/assets/ok/keyword.d.ts @@ -32,3 +32,4 @@ export interface _SERVICE { >, } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/management.d.ts b/rust/candid_parser/tests/assets/ok/management.d.ts index 36cf95f8..1455fa09 100644 --- a/rust/candid_parser/tests/assets/ok/management.d.ts +++ b/rust/candid_parser/tests/assets/ok/management.d.ts @@ -172,3 +172,4 @@ export interface _SERVICE { >, } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/recursion.d.ts b/rust/candid_parser/tests/assets/ok/recursion.d.ts index 08a59192..7b8f1f5e 100644 --- a/rust/candid_parser/tests/assets/ok/recursion.d.ts +++ b/rust/candid_parser/tests/assets/ok/recursion.d.ts @@ -15,3 +15,4 @@ export type tree = { { 'leaf' : bigint }; export interface _SERVICE extends s {} export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/recursive_class.d.ts b/rust/candid_parser/tests/assets/ok/recursive_class.d.ts index 9439a801..8fa267da 100644 --- a/rust/candid_parser/tests/assets/ok/recursive_class.d.ts +++ b/rust/candid_parser/tests/assets/ok/recursive_class.d.ts @@ -5,3 +5,4 @@ import type { IDL } from '@dfinity/candid'; export interface s { 'next' : ActorMethod<[], Principal> } export interface _SERVICE extends s {} export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/service.d.ts b/rust/candid_parser/tests/assets/ok/service.d.ts index 7ed19b63..da5e1ad3 100644 --- a/rust/candid_parser/tests/assets/ok/service.d.ts +++ b/rust/candid_parser/tests/assets/ok/service.d.ts @@ -19,3 +19,4 @@ export interface _SERVICE { >, } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/rust/candid_parser/tests/assets/ok/unicode.d.ts b/rust/candid_parser/tests/assets/ok/unicode.d.ts index 69fe3d78..ed34dc13 100644 --- a/rust/candid_parser/tests/assets/ok/unicode.d.ts +++ b/rust/candid_parser/tests/assets/ok/unicode.d.ts @@ -19,3 +19,4 @@ export interface _SERVICE { '👀' : ActorMethod<[bigint], bigint>, } export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[];