Skip to content

Commit bde2173

Browse files
committed
up playground code
1 parent 240f2e1 commit bde2173

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

playground.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
import ts from 'typescript/lib/tsserverlibrary'
33
import { createLanguageService } from './typescript/src/dummyLanguageService'
44

5-
let testString = 'const a: {/** @default test */a: 5} | {b: 6, /** yes */a: 9} = null as any;\nif ("||" in a) {}'
5+
globalThis.ts = ts
6+
7+
let testString = /* ts */ `
8+
const b = () => 5
9+
const a = b()|| as
10+
new Promise()
11+
`
612
const replacement = '||'
713
const pos = testString.indexOf(replacement)
814
testString = testString.slice(0, pos) + testString.slice(pos + replacement.length)
@@ -16,7 +22,7 @@ const sourceFile = program?.getSourceFile(filePath)
1622
if (!program || !sourceFile) throw new Error('No source file')
1723

1824
const typeChecker = program.getTypeChecker()
19-
const node = findChildContainingPosition(ts, sourceFile, pos)
25+
let node = findChildContainingPosition(ts, sourceFile, pos)
2026
if (!node) throw new Error('No node')
2127
const type = typeChecker.getTypeAtLocation(node)
2228

0 commit comments

Comments
 (0)