Skip to content

Clean up amalgamatedDuplicates #27285

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
2 commits merged into from
Oct 1, 2018
Merged

Clean up amalgamatedDuplicates #27285

2 commits merged into from
Oct 1, 2018

Conversation

ghost
Copy link

@ghost ghost commented Sep 22, 2018

Fixes #27280

Cleans up the way amalgamatedDuplicates stores data, which happens to fix a bug where it reported the same location multiple times.

@ghost ghost force-pushed the duplicateDuplicates branch from e4a7b02 to 9c388fa Compare September 22, 2018 01:13
@ghost ghost requested review from DanielRosenwasser and sandersn September 22, 2018 01:13
@@ -8369,4 +8369,16 @@ namespace ts {
export function isJsonEqual(a: unknown, b: unknown): boolean {
return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && equalOwnProperties(a as MapLike<unknown>, b as MapLike<unknown>, isJsonEqual);
}

export function getOrUpdate<T>(map: Map<T>, key: string, getValue: () => T): T {
Copy link
Member

Choose a reason for hiding this comment

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

getValue should probably be named getDefault.

amalgamatedDuplicates.set(cacheKey, existing);
return target;
const filesDuplicates = getOrUpdate<DuplicateInfoForFiles>(amalgamatedDuplicates, `${firstFile.path}|${secondFile.path}`, () =>
({ firstFile, secondFile, conflictingSymbols: createMap() }));
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to see DuplicateInfoForFiles as an assertion on the object literal: { firstFile, secondFile, conflictingSymbols: createMap() } as DuplicateInfoForFiles

Copy link
Author

Choose a reason for hiding this comment

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

That would conflict with https://palantir.github.io/tslint/rules/no-object-literal-type-assertion/ -- it's unsafe to cast an object literal because that allows misspelled properties.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Some questions and suggestion.

@ghost ghost merged commit 8feddcd into master Oct 1, 2018
@ghost ghost deleted the duplicateDuplicates branch October 1, 2018 19:16
This pull request was closed.
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.

"'x' was also declared here. and here." repeats same location
1 participant