Skip to content

Commit

Permalink
优化插件类型生成
Browse files Browse the repository at this point in the history
  • Loading branch information
cool-team-official committed May 30, 2024
1 parent dba0331 commit dfcfbb0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/modules/plugin/service/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
},
};
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"inlineSourceMap": false,
"inlineSourceMap": true,
"noImplicitThis": true,
"noUnusedLocals": false,
"stripInternal": true,
Expand Down

0 comments on commit dfcfbb0

Please sign in to comment.