Skip to content

Commit ab51894

Browse files
committed
Clean up some unnecessary any
1 parent 85d32d2 commit ab51894

File tree

6 files changed

+44
-18
lines changed

6 files changed

+44
-18
lines changed

src/lib/converter/comments/discovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const wantedKinds: Record<ReflectionKind, ts.SyntaxKind[]> = {
5252
ts.SyntaxKind.PropertySignature,
5353
ts.SyntaxKind.BinaryExpression,
5454
ts.SyntaxKind.PropertyAssignment,
55-
// class X { constructor(/** Comment */ readonly z: any) }
55+
// class X { constructor(/** Comment */ readonly z: string) }
5656
ts.SyntaxKind.Parameter,
5757
],
5858
[ReflectionKind.Method]: [

src/lib/converter/plugins/CommentPlugin.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ const NEVER_RENDERED = [
4848
/**
4949
* Handles most behavior triggered by comments. `@group` and `@category` are handled by their respective plugins, but everything else is here.
5050
*
51+
* How it works today
52+
* ==================
5153
* During conversion:
5254
* - Handle visibility flags (`@private`, `@protected`. `@public`)
5355
* - Handle module renames (`@module`)
@@ -68,6 +70,36 @@ const NEVER_RENDERED = [
6870
* - Copy auto inherited comments from heritage clauses
6971
* - Handle `@inheritDoc`
7072
* - Resolve `@link` tags to point to target reflections
73+
*
74+
* How it should work
75+
* ==================
76+
* During conversion:
77+
* - Handle visibility flags (`@private`, `@protected`. `@public`)
78+
* - Handle module renames (`@module`)
79+
* - Remove excluded tags & comment discovery tags (`@module`, `@packageDocumentation`)
80+
*
81+
* Resolve begin (100):
82+
* - Copy auto inherited comments from heritage clauses
83+
* - Apply `@label` tag
84+
*
85+
* Resolve begin (75)
86+
* - Handle `@inheritDoc`
87+
*
88+
* Resolve begin (50)
89+
* - Copy comments on signature containers to the signature if signatures don't already have a comment
90+
* and then remove the comment on the container.
91+
* - Copy comments for type parameters from the parent container (for classes/interfaces)
92+
*
93+
* Resolve begin (25)
94+
* - Remove hidden reflections
95+
*
96+
* Resolve:
97+
* - Copy comments to parameters and type parameters (for signatures)
98+
* - Apply `@group` and `@category` tags
99+
*
100+
* Resolve end:
101+
* - Resolve `@link` tags to point to target reflections
102+
*
71103
*/
72104
@Component({ name: "comment" })
73105
export class CommentPlugin extends ConverterComponent {

src/lib/models/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ export class OptionalType extends Type {
652652
* Represents a type predicate.
653653
*
654654
* ```ts
655-
* function isString(anything: any): anything is string {}
655+
* function isString(x: unknown): x is string {}
656656
* function assert(condition: boolean): asserts condition {}
657657
* ```
658658
*/

src/lib/output/themes/MarkedPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ output file :
196196
) ?? {}) as Marked.marked.MarkedOptions;
197197

198198
// Set some default values if they are not specified via the TypeDoc option
199-
markedOptions.highlight ??= (text: any, lang: any) =>
199+
markedOptions.highlight ??= (text, lang) =>
200200
this.getHighlighted(text, lang);
201201
markedOptions.renderer ??= customMarkedRenderer;
202202
markedOptions.mangle ??= false; // See https://github.com/TypeStrong/typedoc/issues/1395
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export const debounce = (fn: Function, wait: number = 100) => {
1+
export const debounce = (fn: () => void, wait: number = 100) => {
22
let timeout: ReturnType<typeof setTimeout>;
3-
return (...args: any[]) => {
3+
return () => {
44
clearTimeout(timeout);
5-
timeout = setTimeout(() => fn(args), wait);
5+
timeout = setTimeout(() => fn(), wait);
66
};
77
};

src/lib/utils/plugins.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as Path from "path";
44
import type { Application } from "../application";
55
import type { Logger } from "./loggers";
66
import { nicePath } from "./paths";
7+
import { validate } from "./validation";
78

89
export function loadPlugins(app: Application, plugins: readonly string[]) {
910
if (plugins.includes("none")) {
@@ -97,7 +98,7 @@ export function discoverPlugins(app: Application): string[] {
9798
/**
9899
* Load and parse the given `package.json`.
99100
*/
100-
function loadPackageInfo(logger: Logger, fileName: string): any {
101+
function loadPackageInfo(logger: Logger, fileName: string): unknown {
101102
try {
102103
return require(fileName);
103104
} catch {
@@ -111,20 +112,13 @@ const PLUGIN_KEYWORDS = ["typedocplugin", "typedoc-plugin", "typedoc-theme"];
111112
/**
112113
* Test whether the given package info describes a TypeDoc plugin.
113114
*/
114-
function isPlugin(info: any): boolean {
115-
if (typeof info !== "object" || !info) {
115+
function isPlugin(info: unknown): boolean {
116+
if (!validate({ keywords: [Array, String] }, info)) {
116117
return false;
117118
}
118119

119-
const keywords: unknown[] = info.keywords;
120-
if (!keywords || !Array.isArray(keywords)) {
121-
return false;
122-
}
123-
124-
return keywords.some(
125-
(keyword) =>
126-
typeof keyword === "string" &&
127-
PLUGIN_KEYWORDS.includes(keyword.toLocaleLowerCase())
120+
return info.keywords.some((keyword) =>
121+
PLUGIN_KEYWORDS.includes(keyword.toLocaleLowerCase())
128122
);
129123
}
130124

0 commit comments

Comments
 (0)