Skip to content

Commit 68fe461

Browse files
committed
Add better types for inferred function and constructor parameters
1 parent c3339ce commit 68fe461

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/cashscript/src/types/type-inference.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import type SignatureTemplate from '../SignatureTemplate.js';
22

3+
type BytesType = Uint8Array | string;
4+
type SignatureType = SignatureTemplate | BytesType;
5+
36
type TypeMap = {
4-
[k: `bytes${number}`]: Uint8Array | string; // Matches any "bytes<number>" pattern
7+
[k: `bytes${number}`]: BytesType; // Matches any "bytes<number>" pattern
58
} & {
6-
byte: Uint8Array | string;
7-
bytes: Uint8Array | string;
9+
byte: BytesType;
10+
bytes: BytesType;
811
bool: boolean;
912
int: bigint;
1013
string: string;
11-
pubkey: Uint8Array | string;
12-
sig: SignatureTemplate | Uint8Array | string;
13-
datasig: Uint8Array | string;
14+
pubkey: BytesType;
15+
sig: SignatureType;
16+
datasig: BytesType;
1417
};
1518

1619
// Helper type to process a single parameter by mapping its `type` to a value in `TypeMap`.

0 commit comments

Comments
 (0)