Skip to content

Commit

Permalink
Restructure types export
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Apr 18, 2024
1 parent e47c91f commit d2a2b4f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 15 deletions.
8 changes: 6 additions & 2 deletions packages/types/src/allForks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";

// We have to use import->export because of the limitation in `@microsoft/api-extractor`
// which is used to bundle the package types
import * as ts from "./types.js";
import * as ssz from "./sszTypes.js";
export {ts, ssz};
5 changes: 3 additions & 2 deletions packages/types/src/altair/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
import * as ts from "./types.js";
import * as ssz from "./sszTypes.js";
export {ts, ssz};
5 changes: 3 additions & 2 deletions packages/types/src/bellatrix/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
import * as ts from "./types.js";
import * as ssz from "./sszTypes.js";
export {ts, ssz};
5 changes: 3 additions & 2 deletions packages/types/src/capella/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
import * as ts from "./types.js";
import * as ssz from "./sszTypes.js";
export {ts, ssz};
5 changes: 3 additions & 2 deletions packages/types/src/deneb/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
import * as ts from "./types.js";
import * as ssz from "./sszTypes.js";
export {ts, ssz};
3 changes: 2 additions & 1 deletion packages/types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./types.js";
export * as ssz from "./sszTypes.js";
import * as ssz from "./sszTypes.js";
export {ssz};
// Typeguards
export * from "./utils/typeguards.js";
// String type
Expand Down
5 changes: 3 additions & 2 deletions packages/types/src/phase0/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./types.js";
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
import * as ts from "./types.js";
import * as ssz from "./sszTypes.js";
export {ts, ssz};
5 changes: 3 additions & 2 deletions packages/types/src/primitive/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * as ts from "./types.js";
export * as ssz from "./sszTypes.js";
import * as ts from "./types.js";
import * as ssz from "./sszTypes.js";
export {ts, ssz};
10 changes: 10 additions & 0 deletions packages/types/src/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {Boolean, phase0} from "./sszTypes.js";

const b = Boolean.serialize(false);
console.log(typeof b, b, Boolean.deserialize(b));

const s = phase0.Balances.toViewDU([1, 2]);
console.log(typeof s, s);

const v = phase0.Balances.hashTreeRoot([1, 2]);
console.log(typeof v, v);

0 comments on commit d2a2b4f

Please sign in to comment.