Skip to content

Clean up amalgamatedDuplicates#27285

Merged
2 commits merged intomasterfrom
duplicateDuplicates
Oct 1, 2018
Merged

Clean up amalgamatedDuplicates#27285
2 commits merged intomasterfrom
duplicateDuplicates

Conversation

@ghost
Copy link
Copy Markdown

@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
Comment thread src/compiler/utilities.ts Outdated
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
Copy Markdown
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.

Comment thread src/compiler/checker.ts Outdated
Comment thread src/compiler/checker.ts Outdated
Comment thread src/compiler/checker.ts
amalgamatedDuplicates.set(cacheKey, existing);
return target;
const filesDuplicates = getOrUpdate<DuplicateInfoForFiles>(amalgamatedDuplicates, `${firstFile.path}|${secondFile.path}`, () =>
({ firstFile, secondFile, conflictingSymbols: createMap() }));
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/compiler/checker.ts Outdated
Comment thread src/compiler/checker.ts Outdated
Copy link
Copy Markdown
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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
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.

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

1 participant