Skip to content

Commit 946224d

Browse files
committed
fix: ignore optional dependencies in type definitions
relate sxzz/rolldown-plugin-dts#289
1 parent 62f01cd commit 946224d

6 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎__snapshots__/tsnapi/index.snapshot.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export type TsdownInputOption = Arrayable<string | Record<string, Arrayable<stri
250250
export type TsdownPluginOption<A = any> = Awaitable<TsdownPlugin<A> | RolldownPlugin<A> | {
251251
name: string;
252252
} | undefined | null | void | false | TsdownPluginOption<A>[]>;
253+
export type UnusedOptions = import("unplugin-unused").Options;
253254
export type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
254255
export type UserConfigFn = (_: InlineConfig, _: {
255256
ci: boolean;
@@ -282,5 +283,4 @@ export declare const version: string;
282283
export { DtsOptions }
283284
export { Rolldown }
284285
export { TreeshakingOptions }
285-
export { UnusedOptions }
286286
// #endregion

‎src/config/types.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import type {
3434
MarkPartial,
3535
Overwrite,
3636
} from '../utils/types.ts'
37-
import type { CssOptions } from '@tsdown/css'
3837
import type { Hookable } from 'hookable'
3938
import type {
4039
ChecksOptions,
@@ -48,7 +47,9 @@ import type {
4847
TreeshakingOptions,
4948
} from 'rolldown'
5049
import type { Options as DtsOptions } from 'rolldown-plugin-dts'
51-
import type { Options as UnusedOptions } from 'unplugin-unused'
50+
51+
/** @ts-ignore - optional dep */
52+
type UnusedOptions = import('unplugin-unused').Options
5253

5354
export type Sourcemap = boolean | 'inline' | 'hidden'
5455
export type Format = ModuleFormat
@@ -143,6 +144,9 @@ export type WithEnabled<T> =
143144
enabled?: boolean | CIOption
144145
})
145146

147+
/** @ts-ignore - optional dep */
148+
type CssOptions = import('@tsdown/css').CssOptions
149+
146150
/**
147151
* Options for tsdown.
148152
*/

‎src/features/devtools.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { importWithError } from '../utils/general.ts'
2-
import type { StartOptions } from '@vitejs/devtools/cli-commands'
32
import type { InputOptions } from 'rolldown'
43

4+
/** @ts-ignore - optional dep */
5+
type StartOptions = import('@vitejs/devtools/cli-commands').StartOptions
6+
57
export interface DevtoolsOptions extends NonNullable<InputOptions['devtools']> {
68
/**
79
* **[experimental]** Enable devtools integration. `@vitejs/devtools` must be installed as a dependency.

‎src/features/exe.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { fsRemove, fsStat } from '../utils/fs.ts'
1111
import { importWithError, typeAssert } from '../utils/general.ts'
1212
import { styleText } from '../utils/style.ts'
1313
import type { ResolvedConfig, RolldownChunk } from '../config/types.ts'
14-
import type { ExeExtensionOptions, ExeTarget } from '@tsdown/exe'
14+
import type { ExeTarget } from '@tsdown/exe'
1515

1616
export const NODE_SEA_MIN_VERSION: string = '25.7.0'
1717
export const NODE_SEA_MIN_VERSION_PARSED: SemVer = {
@@ -20,6 +20,8 @@ export const NODE_SEA_MIN_VERSION_PARSED: SemVer = {
2020
patch: 0,
2121
}
2222

23+
/** @ts-ignore - optional dep */
24+
type ExeExtensionOptions = import('@tsdown/exe').ExeExtensionOptions
2325
export interface ExeOptions extends ExeExtensionOptions {
2426
seaConfig?: Omit<SeaConfig, 'main' | 'output' | 'mainFormat'>
2527
/**

‎src/features/pkg/attw.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { createDebug } from 'obug'
33
import { importWithError, slash } from '../../utils/general.ts'
44
import { styleText } from '../../utils/style.ts'
55
import type { ResolvedConfig } from '../../config/index.ts'
6-
import type {
7-
CheckPackageOptions,
8-
Problem,
9-
ProblemKind,
10-
} from '@arethetypeswrong/core'
6+
import type { Problem, ProblemKind } from '@arethetypeswrong/core'
117
import type { Buffer } from 'node:buffer'
128

139
const debug = createDebug('tsdown:attw')
@@ -28,7 +24,10 @@ const problemFlags: Record<ProblemKind, string> = {
2824
InternalResolutionError: 'internal-resolution-error',
2925
}
3026

27+
/** @ts-ignore - optional dep */
28+
type CheckPackageOptions = import('@arethetypeswrong/core').CheckPackageOptions
3129
export interface AttwOptions extends CheckPackageOptions {
30+
/** @ts-ignore - optional dep */
3231
module?: typeof import('@arethetypeswrong/core')
3332

3433
/**

‎src/features/pkg/publint.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { importWithError } from '../../utils/general.ts'
33
import { styleText } from '../../utils/style.ts'
44
import type { ResolvedConfig } from '../../config/index.ts'
55
import type { Buffer } from 'node:buffer'
6-
import type { Options } from 'publint'
76

87
const debug = createDebug('tsdown:publint')
98
const label = styleText.dim(`[publint]`)
109

10+
/** @ts-ignore - optional dep */
11+
type Options = import('publint').Options
1112
export interface PublintOptions extends Omit<Options, 'pack' | 'pkgDir'> {
13+
/** @ts-ignore - optional dep */
1214
module?: [typeof import('publint'), typeof import('publint/utils')]
1315
}
1416

0 commit comments

Comments
 (0)