diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 74108fa9bf558..e34aef3532946 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -3117,8 +3117,9 @@ namespace ts.server { return; } - const info: OpenFileInfo = { checkJs: !!project.getSourceFile(scriptInfo.path)!.checkJsDirective }; - this.eventHandler({ eventName: OpenFileInfoTelemetryEvent, data: { info } }); + const sourceFile = project.getSourceFile(scriptInfo.path); + const checkJs = !!sourceFile && !!sourceFile.checkJsDirective; + this.eventHandler({ eventName: OpenFileInfoTelemetryEvent, data: { info: { checkJs } } }); } /**