Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Expose TypeScript version in public API #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/languageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,7 @@ export class FormatOnTypeAdapter extends FormatHelper implements monaco.language
});
}
}

export function getVersion() {
return ts.version;
}
4 changes: 3 additions & 1 deletion src/monaco.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as mode from './tsMode';
import Emitter = monaco.Emitter;
import IEvent = monaco.IEvent;
import IDisposable = monaco.IDisposable;
import { getVersion } from './languageFeatures';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ends up dragging the entire TS compiler to get loaded into the main thread.


// --- TypeScript configuration and defaults ---------

Expand Down Expand Up @@ -165,7 +166,8 @@ function createAPI(): typeof monaco.languages.typescript {
typescriptDefaults: typescriptDefaults,
javascriptDefaults: javascriptDefaults,
getTypeScriptWorker: getTypeScriptWorker,
getJavaScriptWorker: getJavaScriptWorker
getJavaScriptWorker: getJavaScriptWorker,
getVersion: getVersion
}
}
monaco.languages.typescript = createAPI();
Expand Down
2 changes: 2 additions & 0 deletions src/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,6 @@ declare module monaco.languages.typescript {

export var getTypeScriptWorker: () => Promise<any>;
export var getJavaScriptWorker: () => Promise<any>;

export function getVersion(): string;
}