Skip to content

Commit

Permalink
fix a few things, change tsc check to have options
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Nov 2, 2023
1 parent edcee29 commit edb75c9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ jobs:
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }}
shell: bash -l {0}
working-directory: ${{ matrix.example_directories }}
run: $GITHUB_WORKSPACE/node_modules/.bin/tsc --noEmit --skipLibCheck # TODO can we just add all of the tsconfig.json stuff here?
run: $GITHUB_WORKSPACE/node_modules/.bin/tsc --noEmit --skipLibCheck --target es2020 --strict --moduleResolution node --allowJs

check-basic-integration-tests-success:
needs: basic-integration-tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
type rec_0 = record {desc:text; phone:text};
type rec_1 = record {desc:text; phone:text};
service: () -> {
insert: (text, rec_0) -> ();
lookup: (text) -> (opt rec_1) query;
insert: (text, record {desc:text; phone:text}) -> ();
lookup: (text) -> (opt record {desc:text; phone:text}) query;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import type { Principal } from '@dfinity/principal';
import type { ActorMethod } from '@dfinity/agent';

export interface rec_0 {
desc: string;
phone: string;
}
export interface rec_1 {
desc: string;
phone: string;
}
export interface _SERVICE {
insert: ActorMethod<[string, rec_0], undefined>;
lookup: ActorMethod<[string], [] | [rec_1]>;
insert: ActorMethod<[string, { desc: string; phone: string }], undefined>;
lookup: ActorMethod<[string], [] | [{ desc: string; phone: string }]>;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
export const idlFactory = ({ IDL }) => {
const rec_0 = IDL.Record({ desc: IDL.Text, phone: IDL.Text });
const rec_1 = IDL.Record({ desc: IDL.Text, phone: IDL.Text });
return IDL.Service({
insert: IDL.Func([IDL.Text, rec_0], [], []),
lookup: IDL.Func([IDL.Text], [IDL.Opt(rec_1)], ['query'])
insert: IDL.Func(
[IDL.Text, IDL.Record({ desc: IDL.Text, phone: IDL.Text })],
[],
[]
),
lookup: IDL.Func(
[IDL.Text],
[IDL.Opt(IDL.Record({ desc: IDL.Text, phone: IDL.Text }))],
['query']
)
});
};
export const init = ({ IDL }) => {
Expand Down
6 changes: 2 additions & 4 deletions examples/motoko_examples/phone-book/src/phone_book/index.did
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
type rec_0 = record {desc:text; phone:text};
type rec_1 = record {desc:text; phone:text};
service: () -> {
insert: (text, rec_0) -> ();
lookup: (text) -> (opt rec_1) query;
insert: (text, record {desc:text; phone:text}) -> ();
lookup: (text) -> (opt record {desc:text; phone:text}) query;
}
11 changes: 3 additions & 8 deletions examples/motoko_examples/phone-book/test/tests.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Test } from 'azle/test';
import {
_SERVICE,
rec_0 as Entry
} from '../src/declarations/phone_book/phone_book.did';
import { _SERVICE } from '../src/declarations/phone_book/phone_book.did';
import { ActorSubclass } from '@dfinity/agent';

const TEST_PHONE_BOOK_RECORD: Entry = {
const TEST_PHONE_BOOK_RECORD = {
desc: 'This is a test record',
phone: '555-555-5555'
};
Expand All @@ -27,9 +24,7 @@ export function getTests(phoneBookCanister: ActorSubclass<_SERVICE>): Test[] {
{
name: 'look up',
test: async () => {
const result: Entry | undefined = (
await phoneBookCanister.lookup('Test')
)[0];
const result = (await phoneBookCanister.lookup('Test'))[0];
return {
Ok:
result !== undefined &&
Expand Down
4 changes: 2 additions & 2 deletions examples/timers/test/tests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ActorSubclass } from '@dfinity/agent';
import { Test } from 'azle/test';
import { _SERVICE, rec_0 } from './dfx_generated/timers/timers.did';
import { _SERVICE } from './dfx_generated/timers/timers.did';

let timerIds: rec_0 = {
let timerIds = {
single: 0n,
inline: 0n,
capture: 0n,
Expand Down

0 comments on commit edb75c9

Please sign in to comment.