Skip to content

Commit 0f6e39d

Browse files
authored
Merge pull request #118 from Xvezda/feature/constructor-type-narrowing
Support type narrowing for constructor
2 parents afc4232 + 964ae13 commit 0f6e39d

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/rules/check-throws-tag-type.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ module.exports = createRule({
207207
if (!callerDeclaration) return;
208208

209209
const calleeDeclaration =
210-
node.type === AST_NODE_TYPES.CallExpression
210+
(node.type === AST_NODE_TYPES.CallExpression ||
211+
node.type === AST_NODE_TYPES.NewExpression)
211212
? getCallSignatureDeclaration(services, node)
212213
: node.parent?.type === AST_NODE_TYPES.CallExpression
213214
? getCallSignatureDeclaration(services, node.parent)

src/rules/no-undocumented-throws.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ module.exports = createRule({
130130
if (!callerDeclaration) return;
131131

132132
const calleeDeclaration =
133-
node.type === AST_NODE_TYPES.CallExpression
133+
(node.type === AST_NODE_TYPES.CallExpression ||
134+
node.type === AST_NODE_TYPES.NewExpression)
134135
? getCallSignatureDeclaration(services, node)
135136
: node.parent?.type === AST_NODE_TYPES.CallExpression
136137
? getCallSignatureDeclaration(services, node.parent)

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ const getDeclarationsByNode = (services, node) => {
252252
*
253253
* @public
254254
* @param {import('@typescript-eslint/utils').ParserServicesWithTypeInformation} services
255-
* @param {import('@typescript-eslint/utils').TSESTree.CallExpression} node
255+
* @param {import('@typescript-eslint/utils').TSESTree.CallExpression | import('@typescript-eslint/utils').TSESTree.NewExpression} node
256256
* @return {import('typescript').Declaration | null}
257257
*/
258258
const getCallSignatureDeclaration = (services, node) => {

0 commit comments

Comments
 (0)