Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force dts emit #3084

Merged
merged 2 commits into from
Apr 25, 2024
Merged
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
9 changes: 6 additions & 3 deletions packages/sandbox/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,13 @@ export const createTypeScriptSandbox = (
}

/** Gets the results of compiling your editor's code */
const getEmitResult = async () => {
const getEmitResult = async (
emitOnlyDtsFiles?: boolean,
forceDtsEmit?: boolean
) => {
const model = editor.getModel()!
const client = await getWorkerProcess()
return await client.getEmitOutput(model.uri.toString())
return await client.getEmitOutput(model.uri.toString(), emitOnlyDtsFiles, forceDtsEmit)
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion packages/sandbox/src/tsWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export declare class TypeScriptWorker implements ts.LanguageServiceHost {
providePrefixAndSuffixTextForRename: boolean
): Promise<readonly ts.RenameLocation[] | undefined>
getRenameInfo(fileName: string, position: number, options: ts.RenameInfoOptions): Promise<ts.RenameInfo>
getEmitOutput(fileName: string): Promise<ts.EmitOutput>
getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): Promise<ts.EmitOutput>
getCodeFixesAtPosition(
fileName: string,
start: number,
Expand Down
Loading