Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Fix: wrong reference on TSQualifiedName (fixes #550) #551

Merged
merged 1 commit into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions analyze-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,15 @@ class Referencer extends OriginalReferencer {
}
}

/**
* Create reference objects for the object part. (This is `obj.prop`)
* @param {TSTypeQuery} node The TSTypeQuery node to visit.
* @returns {void}
*/
TSQualifiedName(node) {
this.visit(node.left);
}

/**
* Create reference objects for the references in computed keys.
* @param {TSPropertySignature} node The TSPropertySignature node to visit.
Expand Down
19 changes: 19 additions & 0 deletions tests/lib/scope-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,23 @@ export default class ListModalStore {

expect(messages).toStrictEqual([]);
});

test("https://github.com/eslint/typescript-eslint-parser/issues/550", () => {
const code = `
function test(file: Blob) {
const slice: typeof file.slice =
file.slice || (file as any).webkitSlice || (file as any).mozSlice
return slice
}
`;
const config = {
parser: "typescript-eslint-parser",
rules: {
"no-use-before-define": "error"
}
};
const messages = linter.verify(code, config, { filename: "issue.ts" });

expect(messages).toStrictEqual([]);
});
});