Skip to content

Commit 00fb078

Browse files
committed
Mark TypeDocOptions members as optional
Resolves #2901
1 parent dfd3c27 commit 00fb078

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ title: Changelog
44

55
## Unreleased
66

7+
### Features
8+
9+
- The `TypeDocOptions` interface now marks options as optional so it no longer has to be wrapped in `Partial`
10+
for use in config files, #2901.
11+
712
### Bug Fixes
813

914
- `--watch` can now infer entry points from `package.json` as supported in non-watch mode, #2899.

src/lib/application.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class Application extends AbstractComponent<
219219
* Initialize TypeDoc, loading plugins if applicable.
220220
*/
221221
static async bootstrapWithPlugins(
222-
options: Partial<TypeDocOptions> = {},
222+
options: TypeDocOptions = {},
223223
readers: readonly OptionsReader[] = DEFAULT_READERS,
224224
): Promise<Application> {
225225
const app = new Application(DETECTOR);
@@ -250,7 +250,7 @@ export class Application extends AbstractComponent<
250250
* @param readers Option readers to use to discover options from config files.
251251
*/
252252
static async bootstrap(
253-
options: Partial<TypeDocOptions> = {},
253+
options: TypeDocOptions = {},
254254
readers: readonly OptionsReader[] = DEFAULT_READERS,
255255
): Promise<Application> {
256256
const app = new Application(DETECTOR);
@@ -259,7 +259,7 @@ export class Application extends AbstractComponent<
259259
return app;
260260
}
261261

262-
private async _bootstrap(options: Partial<TypeDocOptions>) {
262+
private async _bootstrap(options: TypeDocOptions) {
263263
this.options.reset();
264264
this.setOptions(options, /* reportErrors */ false);
265265
this.internationalization.setLocale(this.lang);
@@ -319,7 +319,7 @@ export class Application extends AbstractComponent<
319319
}
320320

321321
/** @internal */
322-
setOptions(options: Partial<TypeDocOptions>, reportErrors = true) {
322+
setOptions(options: TypeDocOptions, reportErrors = true) {
323323
let success = true;
324324
for (const [key, val] of Object.entries(options)) {
325325
try {

src/lib/utils/options/declaration.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type CommentStyle = (typeof CommentStyle)[keyof typeof CommentStyle];
3939
export type OutputSpecification = {
4040
name: string;
4141
path: string;
42-
options?: Partial<TypeDocOptions>;
42+
options?: TypeDocOptions;
4343
};
4444

4545
/**
@@ -118,7 +118,7 @@ export const rootPackageOptions = [
118118
* @interface
119119
*/
120120
export type TypeDocOptions = {
121-
[K in keyof TypeDocOptionMap]: unknown extends TypeDocOptionMap[K] ? unknown :
121+
[K in keyof TypeDocOptionMap]?: unknown extends TypeDocOptionMap[K] ? unknown :
122122
TypeDocOptionMap[K] extends ManuallyValidatedOption<
123123
infer ManuallyValidated
124124
> ? ManuallyValidated :
@@ -138,6 +138,7 @@ export type TypeDocOptions = {
138138
* Describes all TypeDoc specific options as returned by {@link Options.getValue}, this is
139139
* slightly more restrictive than the {@link TypeDocOptions} since it does not allow both
140140
* keys and values for mapped option types, and does not allow partials of flag values.
141+
* It also does not mark keys as optional.
141142
* @interface
142143
*/
143144
export type TypeDocOptionValues = {
@@ -186,7 +187,7 @@ export interface TypeDocOptionMap {
186187
lang: string;
187188
locales: ManuallyValidatedOption<Record<string, Record<string, string>>>;
188189
packageOptions: ManuallyValidatedOption<
189-
Partial<TypeDocPackageOptions>
190+
TypeDocPackageOptions
190191
>;
191192

192193
// Input

src/lib/utils/options/options.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export class Options {
270270
/**
271271
* Gets all of the TypeDoc option values defined in this option container.
272272
*/
273-
getRawValues(): Readonly<Partial<TypeDocOptions>> {
273+
getRawValues(): Readonly<Partial<TypeDocOptionValues>> {
274274
return this._values;
275275
}
276276

@@ -303,7 +303,7 @@ export class Options {
303303
*/
304304
setValue<K extends keyof TypeDocOptions>(
305305
name: K,
306-
value: TypeDocOptions[K],
306+
value: Exclude<TypeDocOptions[K], undefined>,
307307
configPath?: string,
308308
): void;
309309
setValue(

src/test/programs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function getConverterApp() {
4242
gitRevision: "fake",
4343
readme: "none",
4444
skipErrorChecking: true,
45-
} satisfies Partial<TypeDocOptions>,
45+
} satisfies TypeDocOptions,
4646
)
4747
) {
4848
converterApp.options.setValue(name as never, value as never);
@@ -119,7 +119,7 @@ export function getConverter2App() {
119119
tsconfig: join(getConverter2Base(), "tsconfig.json"),
120120
validation: true,
121121
skipErrorChecking: true,
122-
} satisfies Partial<TypeDocOptions>,
122+
} satisfies TypeDocOptions,
123123
)
124124
) {
125125
converter2App.options.setValue(name as never, value as never);

0 commit comments

Comments
 (0)