From 6284f6800297a51bbbbceb6642ba6a955f9d153e Mon Sep 17 00:00:00 2001 From: hyrious Date: Mon, 28 Oct 2024 18:00:51 +0800 Subject: [PATCH] fix: force emit types even when there's errors --- src/index.ts | 3 +++ tests/testcases/using-ts-files/common.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 80c7106f..90ea776f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -167,6 +167,9 @@ const plugin: PluginImpl = (options = {}) => { }, undefined, // cancellationToken true, // emitOnlyDtsFiles + undefined, // customTransformers + // @ts-ignore This is a private API for workers, should be safe to use as TypeScript Playground has used it for a long time. + true, // forceDtsEmit ); if (emitSkipped) { const errors = diagnostics.filter((diag) => diag.category === ts.DiagnosticCategory.Error); diff --git a/tests/testcases/using-ts-files/common.ts b/tests/testcases/using-ts-files/common.ts index ad6bc798..807dafc2 100644 --- a/tests/testcases/using-ts-files/common.ts +++ b/tests/testcases/using-ts-files/common.ts @@ -1,3 +1,6 @@ export interface A {} export interface B {} export interface unused {} +// The following code triggers `Unused '@ts-expect-error' directive` error, +// but it doesn't actually prevent the DTS from being emitted. +// @ts-expect-error