Skip to content

Commit f5cfb09

Browse files
committed
method-snippets: don't activate in typeof
1 parent 6201eeb commit f5cfb09

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

typescript/src/constructMethodSnippet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { findChildContainingExactPosition } from './utils'
55

66
export default (languageService: ts.LanguageService, sourceFile: ts.SourceFile, position: number, c: GetConfig) => {
77
const node = findChildContainingExactPosition(sourceFile, position)
8-
if (!node || isTypeNode(node)) return
8+
if (!node || isTypeNode(node) || tsFull.isPartOfTypeQuery(node as any)) return
99

1010
const checker = languageService.getProgram()!.getTypeChecker()!
1111
const type = checker.getTypeAtLocation(node)

typescript/test/completions.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ describe('Method snippets', () => {
123123
124124
declare const a: A
125125
a/*2*/
126+
type B1 = typeof a/*7*/;
126127
127128
// overload
128129
function foo(this: {}, a)
@@ -169,6 +170,7 @@ describe('Method snippets', () => {
169170
compareMethodSnippetAgainstMarker(markers, 4, '($b)')
170171
compareMethodSnippetAgainstMarker(markers, 5, '(a, b, { d, e: {} }, ...c)')
171172
compareMethodSnippetAgainstMarker(markers, 6, '(a, b, c)')
173+
compareMethodSnippetAgainstMarker(markers, 7, null)
172174
})
173175

174176
test('Skip trailing void', () => {

0 commit comments

Comments
 (0)