|
const version = memoryCache.files.get(normalizedFileName)!.version |
If the file is not in the MemoryCache this will throw. I'm not sure if this is the intended behavior, but it is causing issues for me.
|
// We need to return `undefined` and not a string here because TypeScript will use |
|
// `getScriptVersion` and compare against their own version - which can be `undefined`. |
|
// If we don't return `undefined` it results in `undefined === "undefined"` and run |
|
// `createProgram` again (which is very slow). Using a `string` assertion here to avoid |
|
// TypeScript errors from the function signature (expects `(x: string) => string`). |
|
return version === undefined ? ((undefined as any) as string) : String(version) |
The return statement, and the lengthy comment above it, already expects as much is a possibility and will return undefined.
Changing to const version = memoryCache.files.get(normalizedFileName)?.version; will allow a cache miss and return undefined.
ts-jest/src/compiler/language-service.ts
Line 85 in b5dc7cb
If the file is not in the MemoryCache this will throw. I'm not sure if this is the intended behavior, but it is causing issues for me.
ts-jest/src/compiler/language-service.ts
Lines 87 to 92 in b5dc7cb
The return statement, and the lengthy comment above it, already expects as much is a possibility and will return undefined.
Changing to
const version = memoryCache.files.get(normalizedFileName)?.version;will allow a cache miss and returnundefined.