mirror of
https://github.com/chenasraf/DefinitelyTyped-tools.git
synced 2026-05-18 01:49:03 +00:00
export-just-namespace supports TSDeclareFunction too (#534)
This commit is contained in:
committed by
GitHub
parent
9ff4fd36b6
commit
4e6f2cdbeb
@@ -58,6 +58,7 @@ function isJustNamespace(statements: TSESTree.ProgramStatement[], exportEqualsNa
|
||||
break;
|
||||
case AST_NODE_TYPES.ClassDeclaration:
|
||||
case AST_NODE_TYPES.FunctionDeclaration:
|
||||
case AST_NODE_TYPES.TSDeclareFunction:
|
||||
case AST_NODE_TYPES.TSTypeAliasDeclaration:
|
||||
case AST_NODE_TYPES.TSInterfaceDeclaration:
|
||||
if (nameMatches(statement.id)) {
|
||||
@@ -70,8 +71,8 @@ function isJustNamespace(statements: TSESTree.ProgramStatement[], exportEqualsNa
|
||||
|
||||
return anyNamespace;
|
||||
|
||||
function nameMatches(nameNode: TSESTree.Node | undefined): boolean {
|
||||
return nameNode !== undefined && nameNode.type === AST_NODE_TYPES.Identifier && nameNode.name === exportEqualsName;
|
||||
function nameMatches(nameNode: TSESTree.Node | undefined | null): boolean {
|
||||
return !!nameNode && nameNode.type === AST_NODE_TYPES.Identifier && nameNode.name === exportEqualsName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,5 +58,13 @@ class Stuff {}
|
||||
namespace Stuff {}
|
||||
export = Stuff;
|
||||
`,
|
||||
`export = First
|
||||
namespace First {}
|
||||
declare function First()
|
||||
`,
|
||||
`declare namespace Second {}
|
||||
export = Second
|
||||
declare function Second<U, S>(s: U): S
|
||||
`
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user