Ver Fonte

Add API to .d.ts

Alex Dima há 5 anos atrás
pai
commit
aee134f9c1
2 ficheiros alterados com 11 adições e 2 exclusões
  1. 5 0
      src/monaco.d.ts
  2. 6 2
      src/tsWorker.ts

+ 5 - 0
src/monaco.d.ts

@@ -275,6 +275,11 @@ declare module monaco.languages.typescript {
          */
         getSuggestionDiagnostics(fileName: string): Promise<Diagnostic[]>;
 
+        /**
+         * Get the content of a given file.
+         */
+        getScriptText(fileName: string): Promise<string | undefined>;
+
         /**
          * Get diagnostic messages related to the current compiler options.
          * @param fileName Not used

+ 6 - 2
src/tsWorker.ts

@@ -69,7 +69,11 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, monaco.language
 		return '';
 	}
 
-	getScriptText(fileName: string): string | undefined {
+	getScriptText(fileName: string): Promise<string | undefined> {
+		return Promise.resolve(this._getScriptText(fileName));
+	}
+
+	_getScriptText(fileName: string): string | undefined {
 		let text: string;
 		let model = this._getModel(fileName);
 		if (model) {
@@ -92,7 +96,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, monaco.language
 	}
 
 	getScriptSnapshot(fileName: string): ts.IScriptSnapshot | undefined {
-		const text = this.getScriptText(fileName);
+		const text = this._getScriptText(fileName);
 		if (!text) {
 			return;
 		}