Skip to content

Commit eed450e

Browse files
authored
fix(dts): error log of set declarationDir when dts.build is true (#1120)
1 parent adbd46c commit eed450e

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.1.1/schema.json",
33
"assist": {
44
"actions": {
55
"source": {

packages/plugin-dts/src/dts.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,8 @@ export async function generateDts(data: DtsGenOptions): Promise<void> {
167167
(!rawCompilerOptions.declarationDir ||
168168
normalize(rawCompilerOptions.declarationDir) !== resolvedDtsEmitPath)
169169
) {
170-
const info =
171-
rawCompilerOptions.outDir && !rawCompilerOptions.declarationDir
172-
? 'outDir'
173-
: 'declarationDir';
174170
throw Error(
175-
`Please set ${info}: "${dtsEmitPath}" in ${color.underline(
171+
`Please set "declarationDir": "${dtsEmitPath}" in ${color.underline(
176172
tsconfigPath,
177173
)} to keep it same as "dts.distPath" or "output.distPath.root" field in lib config.`,
178174
);

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/dts/build/tsconfig/rslib.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default defineConfig({
88
dts: {
99
bundle: false,
1010
build: true,
11+
distPath: './dist/types',
1112
},
1213
}),
1314
],

tests/integration/dts/build/tsconfig/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"compilerOptions": {
44
"baseUrl": "./",
55
"rootDir": "src",
6-
"declaration": true
6+
"declaration": true,
7+
"outDir": "./dist/esm"
78
},
89
"include": ["src"],
910
"references": [

tests/integration/dts/index.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,9 @@ describe('dts when build: true', () => {
533533
const stdoutOutput = result.stdout ? result.stdout.toString() : '';
534534

535535
expect(result.status).toBe(1);
536-
expect(stdoutOutput).toContain('Please set declarationDir: "./dist/esm"');
536+
expect(stdoutOutput).toContain(
537+
'Please set "declarationDir": "./dist/types"',
538+
);
537539
});
538540

539541
test('should clean dts dist files', async () => {

0 commit comments

Comments
 (0)