Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(codec): avoid repeating type declare #359

Merged
merged 1 commit into from
Jun 23, 2022
Merged

docs(codec): avoid repeating type declare #359

merged 1 commit into from
Jun 23, 2022

Conversation

homura
Copy link
Collaborator

@homura homura commented Jun 23, 2022

This PR guides users on how to define TS types in a simple way when using the @ckb-lumos/codec

import { molecule } from "@ckb-lumos/codec";
import type { UnpackResult } from "@ckb-lumos/codec";
const { struct } = molecule;

const RGB = struct(
  { r: Uint8, g: Uint8, b: Uint8 },
  ["r", "g", "b"] 
);

// We don't need to repeat the definition like this
// type UnpackedRGB = { r: number; g: number; b: number };
type UnpackedRGB = UnpackResult<typeof RGB>;

@vercel
Copy link

vercel bot commented Jun 23, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
lumos-website ✅ Ready (Inspect) Visit Preview Jun 23, 2022 at 6:45AM (UTC)

@codecov
Copy link

codecov bot commented Jun 23, 2022

Codecov Report

Merging #359 (1de99e3) into develop (0c57197) will increase coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #359      +/-   ##
===========================================
+ Coverage    78.40%   78.48%   +0.07%     
===========================================
  Files           83       83              
  Lines        20224    20248      +24     
  Branches      1827     1847      +20     
===========================================
+ Hits         15856    15891      +35     
+ Misses        4347     4336      -11     
  Partials        21       21              
Impacted Files Coverage Δ
packages/debugger/src/types.ts 100.00% <0.00%> (ø)
packages/debugger/src/executor.ts 100.00% <0.00%> (ø)
packages/debugger/src/context.ts 89.39% <0.00%> (+0.75%) ⬆️
packages/debugger/src/parse.ts 100.00% <0.00%> (+3.29%) ⬆️
packages/debugger/src/download.ts 96.55% <0.00%> (+12.91%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c57197...1de99e3. Read the comment docs.

Copy link
Contributor

@zhangyouxin zhangyouxin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@homura homura merged commit b2e9f66 into develop Jun 23, 2022
@homura homura deleted the codec-ts branch June 23, 2022 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants