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

feat!: add CIDVersion type #87

Merged
merged 1 commit into from
May 26, 2021
Merged

feat!: add CIDVersion type #87

merged 1 commit into from
May 26, 2021

Conversation

achingbrain
Copy link
Member

Enables us to constrain CID version to 0 | 1, similar to how we used to do with the cids module.

Enables us to constrain CID version to `0 | 1`, similar to how we
used to do with the `cids` module.
Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

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

Any reason to think this might be a breaking change for downstream users? Will it break TS compiles in any way (presuming they're only using 0 or 1 - outside of that it's their own fault).

@achingbrain
Copy link
Member Author

achingbrain commented May 25, 2021

I think it is breaking as the argument type for several functions has been constrained from number to 0|1 - it'll break anyone passing variable with the number type into CID.create (for example) but not if they are passing a literal 1 or 0.

This should be ok:

function foo (/* maybe some args here */) {
  const version = 1

  // other code here

  return CID.create(version, /* other args here */)
}

But this will not be:

function bar (version: number, /* maybe some args here */) {
  // other code here
 
  return CID.create(version, /* other args here */)
}

@achingbrain achingbrain changed the title feat: add CIDVersion type feat!: add CIDVersion type May 25, 2021
@rvagg rvagg merged commit 06ad092 into master May 26, 2021
@rvagg rvagg deleted the feat/add-cid-version-type branch May 26, 2021 03:38
@rvagg
Copy link
Member

rvagg commented May 26, 2021

ok then, let's do the semver dance again

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