Browse Source

Make sure that when doing a full compile, the latest tsConfig is used

Shaddock Heath 9 years ago
parent
commit
f59b2e384b

+ 1 - 1
Script/AtomicEditor/hostExtensions/languageExtensions/TypscriptLanguageExtension.ts

@@ -344,7 +344,7 @@ export default class TypescriptLanguageExtension implements Editor.HostExtension
         const editor = this.serviceRegistry.uiServices.getCurrentResourceEditor();
         if (editor && editor.typeName == "JSResourceEditor" && this.isValidFiletype(editor.fullPath)) {
             const jsEditor = <Editor.JSResourceEditor>editor;
-            jsEditor.webView.webClient.executeJavaScript(`TypeScript_DoFullCompile();`);
+            jsEditor.webView.webClient.executeJavaScript(`TypeScript_DoFullCompile('${JSON.stringify(this.buildTsConfig())}');`);
         } else {
             this.serviceRegistry.uiServices.showModalError("TypeScript Compilation", "Please open a TypeScript file in the editor before attempting to do a full compile.");
         }

+ 9 - 12
Script/AtomicWebViewEditor/clientExtensions/languageExtensions/typescript/TypescriptLanguageExtension.ts

@@ -125,14 +125,6 @@ export default class TypescriptLanguageExtension implements Editor.ClientExtensi
         });
     }
 
-    /**
-     * Grabs the TS Config file attached to the global window object
-     * @return {any}
-     */
-    private getTsConfig(): any {
-        return JSON.parse(window["TypeScriptLanguageExtension"]["tsConfig"]);
-    }
-
     /**
      * Called when the editor needs to be configured for a particular file
      * @param  {Editor.EditorEvents.EditorFileEvent} ev
@@ -144,7 +136,10 @@ export default class TypescriptLanguageExtension implements Editor.ClientExtensi
             this.overrideBuiltinServiceProviders();
 
             // Hook in the routine to allow the host to perform a full compile
-            this.serviceLocator.clientServices.getHostInterop().addCustomHostRoutine("TypeScript_DoFullCompile", this.doFullCompile.bind(this));
+            this.serviceLocator.clientServices.getHostInterop().addCustomHostRoutine("TypeScript_DoFullCompile", (jsonTsConfig: string) => {
+                let tsConfig = JSON.parse(jsonTsConfig);
+                this.doFullCompile(tsConfig);
+            });
 
             this.filename = ev.filename;
 
@@ -234,7 +229,9 @@ export default class TypescriptLanguageExtension implements Editor.ClientExtensi
             // Build our worker
             this.buildWorker();
 
-            let tsConfig = this.getTsConfig();
+            // Initial load, so the TSConfig on the window object should be the most current
+            let tsConfig = JSON.parse(window["TypeScriptLanguageExtension"]["tsConfig"]);
+
             let model = this.editor.getModel();
             let handle: number;
             model.onDidChangeContent(() => {
@@ -420,11 +417,11 @@ export default class TypescriptLanguageExtension implements Editor.ClientExtensi
     /**
      * Tell the language service to perform a full compile
      */
-    doFullCompile() {
+    doFullCompile(tsConfig: any) {
         if (this.active) {
             const message: WorkerProcessTypes.FullCompileMessageData = {
                 command: WorkerProcessTypes.DoFullCompile,
-                tsConfig: this.getTsConfig()
+                tsConfig: tsConfig
             };
             this.worker.port.postMessage(message);
         }

+ 1 - 1
Script/TypeScript/EditorWork.d.ts

@@ -511,6 +511,6 @@ declare module Editor.ClientExtensions {
          * @param  {string} routineName
          * @param  {(} callback
          */
-        addCustomHostRoutine(routineName: string, callback: () => void);
+        addCustomHostRoutine(routineName: string, callback: (...any) => void);
     }
 }