MCPcopy Create free account
hub / github.com/arktypeio/arktype / getInstantiationsWithFile

Function getInstantiationsWithFile

ark/attest/cache/utils.ts:190–210  ·  view source on GitHub ↗
(
	fileText: string,
	fileName: string,
	displayResult = false
)

Source from the content-addressed store, hash-verified

188}
189
190const getInstantiationsWithFile = (
191 fileText: string,
192 fileName: string,
193 displayResult = false
194) => {
195 const env = getIsolatedEnv()
196 const file = createOrUpdateFile(env, fileName, fileText)
197 const program = getProgram(env)
198
199 // trigger type checking to generate instantiations
200 // (was previously program.emit(file), but that as of TS 5.6 that doesn't
201 // work, so this may need to change if instantiations is reported as 0 after
202 // a future TypeScript update)
203 program.getSemanticDiagnostics(file)
204 // this may lead to additional type checking per Jake Bailey from the TS
205 // team, although it doesn't currently affect any of our internal benchmarks
206 program.getDeclarationDiagnostics(file)
207 if (displayResult && file) displayBenchResult(program, file)
208 const count = program.getInstantiationCount()
209 return count
210}
211
212let virtualEnv: tsvfs.VirtualTypeScriptEnvironment | undefined = undefined
213

Callers 1

Calls 4

getProgramFunction · 0.90
getIsolatedEnvFunction · 0.85
createOrUpdateFileFunction · 0.85
displayBenchResultFunction · 0.85

Tested by

no test coverage detected