Skip to content

Commit 8d1bfa8

Browse files
committed
docs: avoid typedoc warnings
1 parent e90f7dd commit 8d1bfa8

6 files changed

Lines changed: 35 additions & 25 deletions

File tree

.config/typedoc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { readFileSync } from 'node:fs';
2+
import { OptionDefaults } from 'typedoc';
23

34
/**
45
* @import {TypeDocOptions} from "typedoc"
@@ -12,6 +13,7 @@ const customFooterHtml = readFileSync(
1213
/** @type {Partial<TypeDocOptions>} */
1314
export default {
1415
basePath: process.env.GITHUB_ACTIONS ? '/bargs/' : '/',
16+
blockTags: [...OptionDefaults.blockTags, '@knipignore'],
1517
customCss: '../site/media/bargs-theme.css',
1618
customFooterHtml,
1719
darkHighlightTheme: 'vitesse-dark',

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"scripts": {
4242
"build": "zshy",
4343
"commitlint": "commitlint",
44-
"docs": "typedoc",
44+
"docs": "typedoc --treatWarningsAsErrors",
45+
"docs:dev": "typedoc --watch",
4546
"fix": "run-s -sl fix:*",
4647
"fix:eslint": "eslint --fix .",
4748
"fix:markdown": "markdownlint-cli2 --fix \"**/*.md\"",

src/bargs.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ import { defaultTheme, getTheme, type Theme } from './theme.js';
2525
// INTERNAL TYPES
2626
// ═══════════════════════════════════════════════════════════════════════════════
2727

28+
/**
29+
* Transform fn type - can be sync or async.
30+
*
31+
* @knipignore
32+
*/
33+
export type TransformFn<
34+
V1,
35+
P1 extends readonly unknown[],
36+
V2,
37+
P2 extends readonly unknown[],
38+
> = (
39+
result: ParseResult<V1, P1>,
40+
) => ParseResult<V2, P2> | Promise<ParseResult<V2, P2>>;
2841
// Type for commands that may have transforms
2942
type CommandWithTransform<V, P extends readonly unknown[]> = Command<V, P> & {
3043
__transform?: (
@@ -48,17 +61,6 @@ type ParserWithTransform<V, P extends readonly unknown[]> = Parser<V, P> & {
4861
r: ParseResult<unknown, readonly unknown[]>,
4962
) => ParseResult<V, P>;
5063
};
51-
/**
52-
* Transform fn type - can be sync or async.
53-
*/
54-
type TransformFn<
55-
V1,
56-
P1 extends readonly unknown[],
57-
V2,
58-
P2 extends readonly unknown[],
59-
> = (
60-
result: ParseResult<V1, P1>,
61-
) => ParseResult<V2, P2> | Promise<ParseResult<V2, P2>>;
6264

6365
// ═══════════════════════════════════════════════════════════════════════════════
6466
// MERGE COMBINATOR

src/help.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ import { readPackageInfoSync } from './version.js';
2727

2828
/**
2929
* Minimal config shape for help generation.
30+
*
31+
* @knipignore
3032
*/
31-
interface HelpConfig {
33+
export interface HelpConfig {
3234
commands?: Record<
3335
string,
3436
{

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,21 @@
2525

2626
// Main API
2727
export { bargs, handle, map, merge } from './bargs.js';
28+
export type { TransformFn } from './bargs.js';
2829

2930
// Errors
3031
export { BargsError, HelpError, ValidationError } from './errors.js';
3132

3233
// Help generators
3334
export { generateCommandHelp, generateHelp } from './help.js';
35+
export type { HelpConfig } from './help.js';
3436

3537
// Option and positional builders
3638
export { opt, pos } from './opt.js';
39+
export type {
40+
CallableOptionsParser,
41+
CallablePositionalsParser,
42+
} from './opt.js';
3743

3844
// OSC utilities for terminal hyperlinks
3945
export { link, linkifyUrls, supportsHyperlinks } from './osc.js';

src/opt.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ const validateAliasConflicts = (schema: OptionsSchema): void => {
5959
*
6060
* - First arg in pipe: used directly as a Parser
6161
* - Later arg in pipe: called as function to merge with incoming Parser
62+
*
63+
* @knipignore
6264
*/
63-
type CallableOptionsParser<V> = (<V2, P2 extends readonly unknown[]>(
65+
export type CallableOptionsParser<V> = (<V2, P2 extends readonly unknown[]>(
6466
parser: Parser<V2, P2>,
6567
) => Parser<V & V2, P2>) &
6668
Parser<V, readonly []>;
@@ -290,21 +292,16 @@ export const opt = {
290292
* - Later arg in pipe: called as function to merge with incoming Parser
291293
*
292294
* For positionals, we DON'T intersect values - we just pass through V2.
295+
*
296+
* @knipignore
293297
*/
294-
type CallablePositionalsParser<P extends readonly unknown[]> = (<
298+
export type CallablePositionalsParser<P extends readonly unknown[]> = (<
295299
V2,
296300
P2 extends readonly unknown[],
297301
>(
298302
parser: Parser<V2, P2>,
299303
) => Parser<V2, readonly [...P2, ...P]>) &
300-
Parser<EmptyObject, P>;
301-
302-
/**
303-
* Empty object type that works better with intersections than Record<string,
304-
* never>. {} & T = T, but Record<string, never> & T can be problematic.
305-
*/
306-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
307-
type EmptyObject = {};
304+
Parser<object, P>;
308305

309306
/**
310307
* Create a Parser from positional definitions that can also merge with existing
@@ -341,12 +338,12 @@ const positionalsImpl = <T extends PositionalsSchema>(
341338

342339
// Add Parser properties to the function
343340
// Use empty object {} instead of Record<string, never> for better intersection behavior
344-
const parserProps: Parser<EmptyObject, InferPositionals<T>> = {
341+
const parserProps: Parser<object, InferPositionals<T>> = {
345342
__brand: 'Parser',
346343
__optionsSchema: {},
347344
__positionals: [] as unknown as InferPositionals<T>,
348345
__positionalsSchema: positionals,
349-
__values: {} as EmptyObject,
346+
__values: {},
350347
};
351348

352349
return Object.assign(merger, parserProps) as CallablePositionalsParser<

0 commit comments

Comments
 (0)