Skip to content

Commit

Permalink
Add support for TypeScript 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Apr 29, 2024
1 parent 96b4ae8 commit ea2e3d0
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 71 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -17,6 +17,7 @@

### Features

- Added support for TypeScript 5.5.
- TypeDoc now has the architecture in place to support localization. No languages besides English
are currently shipped in the package, but it is now possible to add support for additional languages, #2475.
- `--hostedBaseUrl` will now be used to generate a `<link rel="canonical">` element in the project root page, #2550.
Expand Down
58 changes: 41 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -30,7 +30,7 @@
"shiki": "^1.3.0"
},
"peerDependencies": {
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x"
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x"
},
"devDependencies": {
"@types/lunr": "^2.3.7",
Expand All @@ -47,7 +47,7 @@
"prettier": "3.2.5",
"puppeteer": "^13.5.2",
"ts-node": "^10.9.2",
"typescript": "5.4.5"
"typescript": "5.5.0-beta"
},
"files": [
"/bin",
Expand Down
101 changes: 49 additions & 52 deletions src/test/behavior.c2.test.ts
Expand Up @@ -272,10 +272,11 @@ describe("Behavior Tests", () => {
["Variable class", "Stat docs", "Inst docs"],
);

equal(
project.children?.map((c) => c.name),
["BadClass", "CallableClass", "VariableClass"],
);
equal(project.children?.map((c) => c.name), [
"BadClass",
"CallableClass",
"VariableClass",
]);
});

it("Handles const type parameters", () => {
Expand All @@ -288,10 +289,7 @@ describe("Behavior Tests", () => {

it("Handles declare global 'modules'", () => {
const project = convert("declareGlobal");
equal(
project.children?.map((c) => c.name),
["DeclareGlobal"],
);
equal(project.children?.map((c) => c.name), ["DeclareGlobal"]);
});

it("Handles duplicate heritage clauses", () => {
Expand Down Expand Up @@ -440,10 +438,7 @@ describe("Behavior Tests", () => {
app.options.setValue("excludeCategories", ["A", "Default"]);
app.options.setValue("defaultCategory", "Default");
const project = convert("excludeCategories");
equal(
project.children?.map((c) => c.name),
["c"],
);
equal(project.children?.map((c) => c.name), ["c"]);
});

it("Handles excludeNotDocumentedKinds", () => {
Expand Down Expand Up @@ -520,10 +515,12 @@ describe("Behavior Tests", () => {
const C = query(project, "C");
const D = query(project, "D");

equal(
project.groups?.map((g) => g.title),
["Variables", "A", "B", "With Spaces"],
);
equal(project.groups?.map((g) => g.title), [
"Variables",
"A",
"B",
"With Spaces",
]);

equal(
project.groups?.map((g) =>
Expand All @@ -541,10 +538,7 @@ describe("Behavior Tests", () => {
it("Inherits @group tag if comment is not redefined", () => {
const project = convert("groupInheritance");
const cls = query(project, "Cls");
equal(
cls.groups?.map((g) => g.title),
["Constructors", "Group"],
);
equal(cls.groups?.map((g) => g.title), ["Constructors", "Group"]);
equal(
cls.groups.map((g) => g.children),
[[query(project, "Cls.constructor")], [query(project, "Cls.prop")]],
Expand All @@ -555,10 +549,7 @@ describe("Behavior Tests", () => {
app.options.setValue("categorizeByGroup", false);
const project = convert("categoryInheritance");
const cls = query(project, "Cls");
equal(
cls.categories?.map((g) => g.title),
["Cat", "Other"],
);
equal(cls.categories?.map((g) => g.title), ["Cat", "Other"]);
equal(
cls.categories?.map((g) =>
Comment.combineDisplayParts(g.description),
Expand All @@ -574,10 +565,12 @@ describe("Behavior Tests", () => {
it("Handles hidden accessors", () => {
const project = convert("hiddenAccessor");
const test = query(project, "Test");
equal(
test.children?.map((c) => c.name),
["constructor", "auto", "x", "y"],
);
equal(test.children?.map((c) => c.name), [
"constructor",
"auto",
"x",
"y",
]);
});

it("Handles simple @inheritDoc cases", () => {
Expand Down Expand Up @@ -948,10 +941,10 @@ describe("Behavior Tests", () => {
equal(fooComments, ["No arg comment\n", "No arg comment\n"]);
equal(foo.comment, undefined);

equal(
foo.signatures?.map((s) => s.comment?.label),
["NO_ARGS", "WITH_X"],
);
equal(foo.signatures?.map((s) => s.comment?.label), [
"NO_ARGS",
"WITH_X",
]);

const bar = query(project, "bar");
const barComments = bar.signatures?.map((sig) =>
Expand Down Expand Up @@ -1069,10 +1062,7 @@ describe("Behavior Tests", () => {
const project = convert("typeAliasInterface");
const bar = query(project, "Bar");
equal(bar.kind, ReflectionKind.Interface);
equal(
bar.children?.map((c) => c.name),
["a", "b"],
);
equal(bar.children?.map((c) => c.name), ["a", "b"]);

const comments = [bar, bar.children[0], bar.children[1]].map((r) =>
Comment.combineDisplayParts(r.comment?.summary),
Expand All @@ -1084,35 +1074,34 @@ describe("Behavior Tests", () => {
it("Allows specifying group sort order #2251", () => {
app.options.setValue("groupOrder", ["B", "Variables", "A"]);
const project = convert("groupTag");
equal(
project.groups?.map((g) => g.title),
["B", "Variables", "A", "With Spaces"],
);
equal(project.groups?.map((g) => g.title), [
"B",
"Variables",
"A",
"With Spaces",
]);
});

it("Supports disabling sorting of entry points #2393", () => {
app.options.setValue("sort", ["alphabetical"]);
const project = convert("blockComment", "asConstEnum");
equal(
project.children?.map((c) => c.name),
["asConstEnum", "blockComment"],
);
equal(project.children?.map((c) => c.name), [
"asConstEnum",
"blockComment",
]);

app.options.setValue("sortEntryPoints", false);
const project2 = convert("blockComment", "asConstEnum");
equal(
project2.children?.map((c) => c.name),
["blockComment", "asConstEnum"],
);
equal(project2.children?.map((c) => c.name), [
"blockComment",
"asConstEnum",
]);
});

it("Respects resolution-mode when resolving types", () => {
app.options.setValue("excludeExternals", false);
const MergedType = query(convert("resolutionMode"), "MergedType");
equal(
MergedType.children?.map((child) => child.name),
["cjs", "esm"],
);
equal(MergedType.children?.map((child) => child.name), ["cjs", "esm"]);
});

it("Special cases some `this` type occurrences", () => {
Expand Down Expand Up @@ -1194,4 +1183,12 @@ describe("Behavior Tests", () => {
equal(sig.parameters[0].type?.toString(), "C[]");
equal(sig.parameters[1].type?.toString(), "NoInfer");
});

it("Handles inferred predicate functions from TS 5.5", () => {
const project = convert("inferredPredicates");
const sig = querySig(project, "isNumber");
equal(sig.type?.toString(), "x is number");
const sig2 = querySig(project, "isNonNullish");
equal(sig2.type?.toString(), "x is NonNullable<T>");
});
});
3 changes: 3 additions & 0 deletions src/test/converter2/behavior/inferredPredicates.ts
@@ -0,0 +1,3 @@
export const isNumber = (x: unknown) => typeof x === "number";

export const isNonNullish = <T>(x: T) => x != null;

0 comments on commit ea2e3d0

Please sign in to comment.