Skip to content

Commit

Permalink
export: Handle function overloading in '*.d.ts'
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Jan 20, 2020
1 parent f84d457 commit d1d1ef6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rules/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ const tsTypePrefix = 'type:'
*/
function isTypescriptFunctionOverloads(nodes) {
const types = new Set(Array.from(nodes, node => node.parent.type))
return types.size === 2 && types.has('TSDeclareFunction') && types.has('FunctionDeclaration')
return (
types.has('TSDeclareFunction') &&
(types.size === 1 || types.size === 2 && types.has('FunctionDeclaration'))
)
}

module.exports = {
Expand Down
7 changes: 7 additions & 0 deletions tests/src/rules/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ context('TypeScript', function () {
`,
}, parserConfig)),

test(Object.assign({
code: `
export function fff(a: string);
export function fff(a: number);
`,
}, parserConfig)),

test(Object.assign({
code: `
export function fff(a: string);
Expand Down

0 comments on commit d1d1ef6

Please sign in to comment.