Skip to content

to typescript #89

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

Merged
merged 1 commit into from
Mar 5, 2019
Merged

to typescript #89

merged 1 commit into from
Mar 5, 2019

Conversation

stefanpenner
Copy link
Owner

@stefanpenner stefanpenner commented Feb 9, 2019

cc @mike-north / @krisselden r?

  • update readme
  • ensure TS stuff makes sense to others

Although from CJS this isn't a breaking change, Typescript consumers it will be as it this project (to maintain CJS compat) must be required with import FSTree = require('fs-tree-diff');

@stefanpenner stefanpenner force-pushed the typescript branch 5 times, most recently from b9d1eee to b9fd7cd Compare February 9, 2019 08:00
lib/index.ts Outdated
}
};

class FSTree {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider making FSTree and BasicEntry having relativePath and isDirectory, and have a DefaultEntry interface match what defaultIsEqual uses. calculatePatch can further narrow equal in a generic to make the IsEqual type or the default if no isEqual function is passed in.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks, I got your example. I'll work on it after my next meeting.

Copy link
Owner Author

Choose a reason for hiding this comment

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

updated

lib/index.ts Outdated
const inputPath = path.join(input, relativePath);
const outputPath = path.join(output, relativePath);

const delegateType = typeof delegate[methodName];

Choose a reason for hiding this comment

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

unused

Copy link
Owner Author

Choose a reason for hiding this comment

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

fixed

} else if (entryA.mtime === undefined || entryB.mtime === undefined) {
equal = false;
} else if (+entryA.mtime === +entryB.mtime) {
equal = true;

Choose a reason for hiding this comment

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

I'd think you'd want to early return in these equal = true; cases.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ya, i toyed with several variations. The current ends up with the one i enjoyed the most.

@stefanpenner stefanpenner force-pushed the typescript branch 4 times, most recently from aa12fec to 764a6d1 Compare February 12, 2019 03:31
j++;
additions.push(addOperation(y));
} else {
if (!isEqual(x, y)) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm actually not super sure how Typescript thinks this is valid yet. I'll have to do more investigation.

Basically, if T,K do not extend from or implement DefaultEntry, and isEqual is the defaultIsEqual. Then I think we should have a type mismatch...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Because defaultIsEqual satisfies the a: T, b: K but it requires a: K, b: K.

lib/index.ts Outdated
}
};

class FSTree<T extends BaseEntry> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might consider making the default entry type the default when you don't provide the generic type. class FSTree<T extends BaseEntry = DefaultEntry>

Copy link
Owner Author

Choose a reason for hiding this comment

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

I did not realize this was a thing. Cool!

@ef4
Copy link

ef4 commented Feb 27, 2019

I'm using this branch, because the currently released version doesn't play well with the latest walk-sync's types.

@stefanpenner
Copy link
Owner Author

@ef4 as a consumer any feedback?
I am tempted to release, the only Q is should this be a major version bump or minor? I'm worried the Typing changes may break typescript consumers...

@ef4
Copy link

ef4 commented Feb 28, 2019

I think it's a breaking change for people like me who had previously written their own local types for it. But it was a pretty painless update, our types differed only cosmetically.

Also, I found one significant bug. Though it's not really a bug in fs-tree-diff, it's a bug in ember-cli:

new FSTree.fromEntries([]);

That used to actually work, but now it's an exception.

@stefanpenner
Copy link
Owner Author

new FSTree.fromEntries([]); that usage is def not expected to work...

@stefanpenner
Copy link
Owner Author

@ef4 submitted a fix ember-cli/ember-cli#8479

I'll release this as a major bump, so we can move forward and not break folks

@stefanpenner stefanpenner merged commit a55126e into master Mar 5, 2019
@stefanpenner stefanpenner deleted the typescript branch March 5, 2019 21:24
@stefanpenner
Copy link
Owner Author

released as v2.0.0

@stefanpenner
Copy link
Owner Author

@Turbo87 i even added a changelog entry for you

@Turbo87
Copy link

Turbo87 commented Mar 5, 2019

😂 thanks!

I'm curious why it's a major version bump though. Did the APIs change?

nevermind, just saw the PR description

@krisselden
Copy link
Collaborator

Why is fromEntries([]) supposed to Error? What if you use walkSync on an empty directory?

@krisselden
Copy link
Collaborator

Nevermind I see it’s only with ‘new’

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.

6 participants