Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

feat: add ts types with aegir #131

Merged
merged 1 commit into from
Dec 11, 2020
Merged

feat: add ts types with aegir #131

merged 1 commit into from
Dec 11, 2020

Conversation

hugomrdias
Copy link
Member

this is a best effort approach since multiformats/multiformats will probably superseed this repo soon.

@hugomrdias hugomrdias requested review from vmx, Gozala and achingbrain and removed request for vmx and Gozala November 24, 2020 11:39
Copy link
Member

@vmx vmx left a comment

Choose a reason for hiding this comment

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

Can you please remove the unrelated things like adding a GitHub issue template from this PR?

It also removes the withIs, which is a (potentially) huge breaking change. I'd prefer if we keep that in for compatibility. I don't think it makes sense to remove it as it will be replaced by multiformats/cid anyway.

@Gozala
Copy link
Contributor

Gozala commented Dec 10, 2020

It also removes the withIs, which is a (potentially) huge breaking change. I'd prefer if we keep that in for compatibility. I don't think it makes sense to remove it as it will be replaced by multiformats/cid anyway.

@vmx withIs unfortunately triggers various different bugs in TS & I'm guessing that is also why it end up been part of this PR. Switch to multiformats/cid might be larger effort but probably worth considering. I'd be interested in helping with that effort.

@hugomrdias
Copy link
Member Author

@vmx im just trying to keep these repos consistent with each other and has you said we might move to the new multiformats soon, so theres no point in spending too much time in this and thats why i just added everything in.

@vmx
Copy link
Member

vmx commented Dec 11, 2020

@Gozala @achingbrain @hugomrdias So we do a new major release of js-cid for adding TypeScript types? If there's agreement that's fine with me.

@hugomrdias Though next time I'd prefer having things like adding issue templates in a separate commit as it's totally unrelated.

@hugomrdias
Copy link
Member Author

@vmx nothing is actually a breaking change it behaves exactly as before, just a little bit safer now

@vmx
Copy link
Member

vmx commented Dec 11, 2020

@Gozala @achingbrain @hugomrdias: oh sorry I missed that line: https://github.com/multiformats/js-cid/pull/131/files#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556R17

Which add the symbol which withIs() is adding. So it's not a breaking change.

this is a best effort approach since multiformats/multiformats will probably superseed this repo soon.
@vmx
Copy link
Member

vmx commented Dec 11, 2020

I've removed the issue templates, I don't want them in this repo, I think it increases the burden of reporting a bug without having too much benefit (we also don't get that many bug reports here).

Copy link
Member

@vmx vmx left a comment

Choose a reason for hiding this comment

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

Thanks for the change and also updating the CI to GitHub actions (I should've done that a long time ago myself).

@vmx vmx merged commit 0e11f03 into master Dec 11, 2020
@vmx vmx deleted the feat/ts-types branch December 11, 2020 11:19
achingbrain added a commit that referenced this pull request Dec 11, 2020
The changes in #131 broke the tests of IPFS and probably quite a few
other modules.

This sort of thing used to work, now does not:

```js
expect(ipfs.bitswap.unwant.calledWith(new CID(cidStr), defaultOptions)).to.be.true()
```

The reason it breaks is because internally `calledWith` does a `deepEqual`
on the args which compares (among other things) the properties of the passed
objects.

We used to use `Object.defineProperty` to create cached versions of
expensive to calculate fields which makes fields non-enumerable by
default so they are skipped during the `deepEqual` check.

different fields depending on how which constructor branch was hit or
worse, if the instances properties have been accessed.
achingbrain added a commit that referenced this pull request Dec 11, 2020
The changes in #131 broke the tests of IPFS and probably quite a few
other modules.

This sort of thing used to work, now does not:

```js
expect(ipfs.bitswap.unwant.calledWith(new CID(cidStr), defaultOptions)).to.be.true()
```

The reason it breaks is because internally `calledWith` does a `deepEqual`
on the args which compares (among other things) the properties of the passed
objects.

We used to use `Object.defineProperty` to create cached versions of
expensive to calculate fields which makes fields non-enumerable by
default so they are skipped during the `deepEqual` check.

Now we just set the fields on the object which means instances have
different fields depending on which constructor branch was hit or worse,
if the instances properties have been accessed.
vmx pushed a commit that referenced this pull request Dec 11, 2020
The changes in #131 broke the tests of IPFS and probably quite a few
other modules.

This sort of thing used to work, now does not:

```js
expect(ipfs.bitswap.unwant.calledWith(new CID(cidStr), defaultOptions)).to.be.true()
```

The reason it breaks is because internally `calledWith` does a `deepEqual`
on the args which compares (among other things) the properties of the passed
objects.

We used to use `Object.defineProperty` to create cached versions of
expensive to calculate fields which makes fields non-enumerable by
default so they are skipped during the `deepEqual` check.

Now we just set the fields on the object which means instances have
different fields depending on which constructor branch was hit or worse,
if the instances properties have been accessed.
Gozala added a commit that referenced this pull request Dec 12, 2020
Fixes regression introduced by #131 due to incorrect type mappings
@Gozala Gozala mentioned this pull request Dec 12, 2020
vmx pushed a commit that referenced this pull request Dec 12, 2020
Fixes regression introduced by #131 due to incorrect type mappings
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants