From dfcfbb0cba9418ad423aaf496d5e9c411861472b Mon Sep 17 00:00:00 2001 From: cool Date: Thu, 30 May 2024 17:43:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8F=92=E4=BB=B6=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/plugin/service/types.ts | 16 ++++++++++++++-- tsconfig.json | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/modules/plugin/service/types.ts b/src/modules/plugin/service/types.ts index bd75da2..3e8574c 100644 --- a/src/modules/plugin/service/types.ts +++ b/src/modules/plugin/service/types.ts @@ -60,7 +60,7 @@ export class PluginTypesService extends BaseService { useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames, writeFile: (fileName, content) => { if (fileName.includes('file.d.ts')) { - output = content; + output = content || output; } }, }; @@ -69,11 +69,23 @@ export class PluginTypesService extends BaseService { declaration: true, emitDeclarationOnly: true, outDir: './', + skipLibCheck: true, + skipDefaultLibCheck: true, + noEmitOnError: false, + target: ts.ScriptTarget.ES2018, + strict: false, + module: ts.ModuleKind.Node16, + moduleResolution: ts.ModuleResolutionKind.Node16, + types: ['node'], }; const program = ts.createProgram(['file.ts'], options, compilerHost); - program.emit(); + const emitResult = program.emit(); + if (!output) { + // Provide a default value if the output is still empty + output = '/* No declaration content generated */'; + } return output; } diff --git a/tsconfig.json b/tsconfig.json index f25c9ca..9e88494 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "moduleResolution": "node", "experimentalDecorators": true, "emitDecoratorMetadata": true, - "inlineSourceMap": false, + "inlineSourceMap": true, "noImplicitThis": true, "noUnusedLocals": false, "stripInternal": true,