Skip to content

Commit a5c9c01

Browse files
authored
Force dts emit (microsoft#3084)
1 parent ef64e46 commit a5c9c01

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/sandbox/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,13 @@ export const createTypeScriptSandbox = (
296296
}
297297

298298
/** Gets the results of compiling your editor's code */
299-
const getEmitResult = async () => {
299+
const getEmitResult = async (
300+
emitOnlyDtsFiles?: boolean,
301+
forceDtsEmit?: boolean
302+
) => {
300303
const model = editor.getModel()!
301304
const client = await getWorkerProcess()
302-
return await client.getEmitOutput(model.uri.toString())
305+
return await client.getEmitOutput(model.uri.toString(), emitOnlyDtsFiles, forceDtsEmit)
303306
}
304307

305308
/** Gets the JS of compiling your editor's code */
@@ -318,7 +321,7 @@ export const createTypeScriptSandbox = (
318321

319322
/** Gets the DTS for the JS/TS of compiling your editor's code */
320323
const getDTSForCode = async () => {
321-
const result = await getEmitResult()
324+
const result = await getEmitResult(/*emitOnlyDtsFiles*/ undefined, /*forceDtsEmit*/ true)
322325
return result.outputFiles.find((o: any) => o.name.endsWith(".d.ts"))?.text || ""
323326
}
324327

packages/sandbox/src/tsWorker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export declare class TypeScriptWorker implements ts.LanguageServiceHost {
5353
providePrefixAndSuffixTextForRename: boolean
5454
): Promise<readonly ts.RenameLocation[] | undefined>
5555
getRenameInfo(fileName: string, position: number, options: ts.RenameInfoOptions): Promise<ts.RenameInfo>
56-
getEmitOutput(fileName: string): Promise<ts.EmitOutput>
56+
getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): Promise<ts.EmitOutput>
5757
getCodeFixesAtPosition(
5858
fileName: string,
5959
start: number,

0 commit comments

Comments
 (0)