Skip to content

Commit 5838ca4

Browse files
committed
fix: dont disable method snippets when function has __promisify__ property
1 parent 205aa50 commit 5838ca4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

typescript/src/constructMethodSnippet.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default (
2828
const isNewExpression =
2929
ts.isNewExpression(containerNode) &&
3030
ts.textSpanIntersectsWithPosition(ts.createTextSpanFromBounds(containerNode.expression.pos, containerNode.expression.end), position)
31-
if (!isNewExpression && (type.getProperties().length > 0 || type.getStringIndexType() || type.getNumberIndexType())) {
31+
if (!isNewExpression && (getNonFunctionProperties(type).length > 0 || type.getStringIndexType() || type.getNumberIndexType())) {
3232
resolveData.isAmbiguous = true
3333
}
3434

@@ -152,3 +152,8 @@ function getPromiseLikeTypeArgument(type: ts.Type | undefined, checker: ts.TypeC
152152
function hasPrivateOrProtectedModifier(modifiers: ts.NodeArray<ts.ModifierLike> | ts.NodeArray<ts.Modifier> | undefined) {
153153
return modifiers?.some(modifier => oneOf(modifier.kind, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ProtectedKeyword))
154154
}
155+
156+
function getNonFunctionProperties(type: ts.Type) {
157+
const customSpecialFunctionProperties = ['__promisify__']
158+
return type.getProperties().filter(x => !customSpecialFunctionProperties.includes(x.name))
159+
}

0 commit comments

Comments
 (0)