Skip to content

Commit

Permalink
refactor(wasm-api-bindgen): update type usage
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Apr 19, 2024
1 parent ab27740 commit 1c4a3c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/wasm-api-bindgen/src/internal/classify.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Maybe } from "@thi.ng/api";
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
import type { Field, TypeColl } from "../api.js";
import {
Expand Down Expand Up @@ -114,14 +115,14 @@ const __classifyType = (

/** @internal */
const __selectForLength = (
len: number | undefined,
len: Maybe<number>,
single: FieldClass,
fixed: FieldClass,
multi: FieldClass
) => (len != null ? (len > 0 ? fixed : multi) : single);

/** @internal */
const __ensureLength = (len: number | undefined) => {
const __ensureLength = (len: Maybe<number>) => {
if (len == null || len < 1)
illegalArgs("missing or invalid array/vec length");
};
4 changes: 2 additions & 2 deletions packages/wasm-api-bindgen/src/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Nullable, NumOrString } from "@thi.ng/api";
import type { Maybe, Nullable, NumOrString } from "@thi.ng/api";
import {
BIGINT_ARRAY_CTORS,
BIT_SHIFTS,
Expand Down Expand Up @@ -319,7 +319,7 @@ const generateField = (
field: Field,
coll: TypeColl,
opts: CodeGenOpts
): AugmentedField | undefined => {
): Maybe<AugmentedField> => {
if (field.skip) return;
if (isFuncPointer(field.type, coll) || isOpaque(field.type)) {
field = { ...field, type: opts.target.usize };
Expand Down

0 comments on commit 1c4a3c3

Please sign in to comment.