Skip to content

Commit

Permalink
Fix validation for requiredToBeDocumented
Browse files Browse the repository at this point in the history
Closes #1872
  • Loading branch information
Gerrit0 committed Mar 6, 2022
1 parent eab5dd4 commit 4350d47
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- Add support for TypeScript 4.6, #1877.
- Support copying `@param` comments for nested members that target union and intersection types, #1876.

### Bug Fixes

- Fixed validation for `--requiredToBeDocumented` option, #1872.

## v0.22.12 (2022-02-20)

### Features
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/options/sources/typedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
);

for (const kind of values) {
if (validValues.includes(kind)) {
if (!validValues.includes(kind)) {
throw new Error(
`'${kind}' is an invalid value for 'requiredToBeDocumented'. Must be one of: ${validValues.join(
", "
Expand Down
16 changes: 15 additions & 1 deletion src/test/utils/options/default-options.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ok, throws, strictEqual } from "assert";
import { ok, throws, strictEqual, doesNotThrow } from "assert";
import { BUNDLED_THEMES } from "shiki";
import { Logger, Options } from "../../../lib/utils";

Expand Down Expand Up @@ -54,4 +54,18 @@ describe("Default Options", () => {
throws(() => opts.setValue("markedOptions", []));
});
});

describe("requiredToBeDocumented", () => {
it("Works with valid values", () => {
doesNotThrow(() =>
opts.setValue("requiredToBeDocumented", ["Enum"])
);
});

it("Throws on invalid values", () => {
throws(() =>
opts.setValue("requiredToBeDocumented", ["Enum2" as never])
);
});
});
});

0 comments on commit 4350d47

Please sign in to comment.