Skip to content

Commit

Permalink
Replace cast types with generic type params
Browse files Browse the repository at this point in the history
  • Loading branch information
dansteren committed Dec 18, 2023
1 parent 9cab790 commit ac362cc
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ type Mode = 'query' | 'update' | 'oneway';
export function FuncDefinitionArb(
candidDefArb: fc.Arbitrary<CandidDefinition>
): fc.Arbitrary<FuncCandidDefinition> {
return (fc.constantFrom('query', 'update', 'oneway') as fc.Arbitrary<Mode>)
return fc
.constantFrom<Mode>('query', 'update', 'oneway')
.chain((mode) => {
const returnType =
mode === 'oneway' ? VoidDefinitionArb() : candidDefArb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function ServiceMethodArb(
return fc
.tuple(
JsFunctionNameArb,
fc.constantFrom('query', 'update') as fc.Arbitrary<Mode>,
fc.constantFrom<Mode>('query', 'update'),
fc.array(candidDefArb),
fc.oneof(candidDefArb, VoidDefinitionArb())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export function InitMethodArb<
UniqueIdentifierArb('canisterMethod'),
paramTypeArrayArb,
VoidArb(),
fc.constantFrom(
'INLINE',
'STANDALONE'
) as fc.Arbitrary<CallbackLocation>,
fc.constantFrom<CallbackLocation>('INLINE', 'STANDALONE'),
UniqueIdentifierArb('typeDeclaration')
// TODO: This unique id would be better named globalScope or something
// But needs to match the same scope as typeDeclarations so I'm using
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export function PostUpgradeMethodArb<
UniqueIdentifierArb('canisterMethod'),
paramTypeArrayArb,
VoidArb(),
fc.constantFrom(
'INLINE',
'STANDALONE'
) as fc.Arbitrary<CallbackLocation>,
fc.constantFrom<CallbackLocation>('INLINE', 'STANDALONE'),
UniqueIdentifierArb('typeDeclaration')
// TODO: This unique id would be better named globalScope or something
// But needs to match the same scope as typeDeclarations so I'm using
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ export function QueryMethodArb<
UniqueIdentifierArb('canisterMethod'),
paramTypeArrayArb,
returnTypeArb,
fc.constantFrom(
'INLINE',
'STANDALONE'
) as fc.Arbitrary<CallbackLocation>,
fc.constantFrom<CallbackLocation>('INLINE', 'STANDALONE'),
UniqueIdentifierArb('typeDeclaration')
// TODO: This unique id would be better named globalScope or something
// But needs to match the same scope as typeDeclarations so I'm using
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ export function UpdateMethodArb<
UniqueIdentifierArb('canisterMethod'),
paramTypeArrayArb,
returnTypeArb,
fc.constantFrom(
'INLINE',
'STANDALONE'
) as fc.Arbitrary<CallbackLocation>,
fc.constantFrom<CallbackLocation>('INLINE', 'STANDALONE'),
UniqueIdentifierArb('typeDeclaration')
// TODO: This unique id would be better named globalScope or something
// But needs to match the same scope as typeDeclarations so I'm using
Expand Down

0 comments on commit ac362cc

Please sign in to comment.