-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(typescript): add index.d.ts file for type safety when importing g…
…enerated declarations (#2597) * fix(typescript): add index.d.ts file for type safety when importing generated declarations * Update e2e/tests-dfx/generate.bash * fixes #2537 Co-authored-by: Eric Swanson <64809312+ericswanson-dfinity@users.noreply.github.com>
- Loading branch information
1 parent
6fb3f91
commit c398533
Showing
5 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bats | ||
|
||
load ../utils/_ | ||
|
||
setup() { | ||
standard_setup | ||
|
||
dfx_new hello | ||
} | ||
|
||
teardown() { | ||
dfx_stop | ||
|
||
standard_teardown | ||
} | ||
|
||
@test "dfx generate creates files" { | ||
dfx_start | ||
dfx canister create --all | ||
dfx build | ||
dfx canister install --all | ||
|
||
dfx --version | ||
dfx generate | ||
|
||
assert_file_exists "src/declarations/hello_backend/hello_backend.did" | ||
assert_file_exists "src/declarations/hello_backend/hello_backend.did.js" | ||
assert_file_exists "src/declarations/hello_backend/hello_backend.did.d.ts" | ||
assert_file_exists "src/declarations/hello_backend/index.js" | ||
assert_file_exists "src/declarations/hello_backend/index.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ActorSubclass, HttpAgentOptions, ActorConfig } from '@dfinity/agent'; | ||
import { Principal } from '@dfinity/principal'; | ||
|
||
import { _SERVICE } from './{{canister_name}}.did'; | ||
|
||
export declare interface CreateActorOptions { | ||
agentOptions?: HttpAgentOptions; | ||
actorOptions?: ActorConfig; | ||
} | ||
|
||
export declare const createActor: ( | ||
canisterId: string | Principal, | ||
options: CreateActorOptions | ||
) => ActorSubclass<_SERVICE>; | ||
|
||
export declare const {{canister_name}}: ActorSubclass<_SERVICE>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters