Skip to content

Commit 62eeeed

Browse files
ocavuesxzz
andauthored
fix!: rename option isolatedDeclaration to isolatedDeclarations (#15)
Co-authored-by: 三咲智子 Kevin Deng <[email protected]>
1 parent 07cf8b5 commit 62eeeed

5 files changed

Lines changed: 24 additions & 20 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ interface Options {
6868
*
6969
* This option is enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
7070
*/
71-
isolatedDeclaration?: boolean | Omit<IsolatedDeclarationsOptions, 'sourcemap'>
71+
isolatedDeclarations?:
72+
| boolean
73+
| Omit<IsolatedDeclarationsOptions, 'sourcemap'>
7274

7375
/** Resolve external types used in dts files from `node_modules` */
7476
resolve?: boolean | (string | RegExp)[]
@@ -79,7 +81,7 @@ interface Options {
7981

8082
### Isolated Declarations
8183

82-
The plugin leverages Oxc's `isolatedDeclarations` to generate `.d.ts` files when `isolatedDeclaration` is enabled,
84+
The plugin leverages Oxc's `isolatedDeclarations` to generate `.d.ts` files when `isolatedDeclarations` is enabled,
8385
offering significantly faster performance compared to the `typescript` compiler.
8486

8587
### Single Build for ESM

src/generate.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ export type DtsMap = Map<string, TsModule>
3131
export function createGeneratePlugin({
3232
tsconfig,
3333
compilerOptions,
34-
isolatedDeclaration,
34+
isolatedDeclarations,
3535
resolve = false,
3636
emitDtsOnly = false,
3737
}: Pick<
3838
Options,
39-
| 'isolatedDeclaration'
39+
| 'isolatedDeclarations'
4040
| 'resolve'
4141
| 'emitDtsOnly'
4242
| 'tsconfig'
@@ -60,14 +60,14 @@ export function createGeneratePlugin({
6060
}
6161
}
6262

63-
if (isolatedDeclaration == null) {
64-
isolatedDeclaration = !!compilerOptions?.isolatedDeclarations
63+
if (isolatedDeclarations == null) {
64+
isolatedDeclarations = !!compilerOptions?.isolatedDeclarations
6565
}
66-
if (isolatedDeclaration === true) {
67-
isolatedDeclaration = {}
66+
if (isolatedDeclarations === true) {
67+
isolatedDeclarations = {}
6868
}
69-
if (isolatedDeclaration && isolatedDeclaration.stripInternal == null) {
70-
isolatedDeclaration.stripInternal = !!compilerOptions?.stripInternal
69+
if (isolatedDeclarations && isolatedDeclarations.stripInternal == null) {
70+
isolatedDeclarations.stripInternal = !!compilerOptions?.stripInternal
7171
}
7272
}
7373

@@ -93,7 +93,7 @@ export function createGeneratePlugin({
9393
tsconfig: tsconfig ? (tsconfig as string) : undefined,
9494
})
9595

96-
if (!isolatedDeclaration) {
96+
if (!isolatedDeclarations) {
9797
initTs()
9898
}
9999

@@ -245,11 +245,11 @@ export function createGeneratePlugin({
245245
const { code, id, isEntry } = dtsMap.get(dtsId)!
246246
let dtsCode: string | undefined
247247

248-
if (isolatedDeclaration) {
248+
if (isolatedDeclarations) {
249249
const result = oxcIsolatedDeclaration(
250250
id,
251251
code,
252-
isolatedDeclaration === true ? {} : isolatedDeclaration,
252+
isolatedDeclarations === true ? {} : isolatedDeclarations,
253253
)
254254
if (result.errors.length) {
255255
const [error] = result.errors

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export interface Options {
4242
*
4343
* This option is enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
4444
*/
45-
isolatedDeclaration?: boolean | Omit<IsolatedDeclarationsOptions, 'sourcemap'>
45+
isolatedDeclarations?:
46+
| boolean
47+
| Omit<IsolatedDeclarationsOptions, 'sourcemap'>
4648

4749
/** Resolve external types used in dts files from `node_modules` */
4850
resolve?: boolean | (string | RegExp)[]

tests/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test('typescript compiler', async () => {
4242
skipLibCheck: true,
4343
isolatedDeclarations: false,
4444
},
45-
isolatedDeclaration: false,
45+
isolatedDeclarations: false,
4646
}),
4747
],
4848
)
@@ -55,7 +55,7 @@ test('resolve dependencies', async () => {
5555
[
5656
dts({
5757
resolve: ['magic-string-ast'],
58-
isolatedDeclaration: true,
58+
isolatedDeclarations: true,
5959
emitDtsOnly: true,
6060
}),
6161
],
@@ -73,7 +73,7 @@ test('input alias', async () => {
7373
dts({
7474
emitDtsOnly: false, // Generate both JS and DTS files
7575
compilerOptions: {},
76-
isolatedDeclaration: false,
76+
isolatedDeclarations: false,
7777
}),
7878
],
7979
{
@@ -103,7 +103,7 @@ test('isolated declaration error', async () => {
103103
[
104104
dts({
105105
emitDtsOnly: true,
106-
isolatedDeclaration: true,
106+
isolatedDeclarations: true,
107107
}),
108108
],
109109
).catch((error: any) => error)
@@ -119,7 +119,7 @@ test('paths', async () => {
119119
path.resolve(root, 'index.ts'),
120120
[
121121
dts({
122-
isolatedDeclaration: true,
122+
isolatedDeclarations: true,
123123
emitDtsOnly: true,
124124
}),
125125
],

tsdown.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default defineConfig({
88
platform: 'node',
99
plugins: [
1010
dts({
11-
isolatedDeclaration: true,
11+
isolatedDeclarations: true,
1212
}),
1313
],
1414
})

0 commit comments

Comments
 (0)